DGtal  0.9.3beta
Public Member Functions | Static Private Attributes
LibBoard::QuadraticBezierCurve Struct Reference

#include <Board/Shapes.h>

Inheritance diagram for LibBoard::QuadraticBezierCurve:
[legend]
Collaboration diagram for LibBoard::QuadraticBezierCurve:
[legend]

Public Member Functions

 QuadraticBezierCurve (double x1, double y1, double x2, double y2, double x3, double y3, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depthValue=-1)
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
 
void flushSVG (std::ostream &stream, const TransformSVG &transform) const
 
void flushCairo (cairo_t *cr, const TransformCairo &transform) const
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
 
const std::string & name () const
 
- Public Member Functions inherited from LibBoard::Triangle
 Triangle (const Point &p1, const Point &p2, const Point &p3, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depthValue=-1)
 
 Triangle (const double x1, const double y1, const double x2, const double y2, const double x3, const double y3, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depthValue=-1)
 
Triangle rotated (double angle) const
 
Triangle translated (double dx, double dy) const
 
Triangle scaled (double sx, double sy) const
 
Triangle scaled (double s) const
 
Triangleclone () const
 
- Public Member Functions inherited from LibBoard::Polyline
 Polyline (const std::vector< Point > &points, bool closed, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
 Polyline (const Path &path, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
 Polyline (bool closed, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
Point center () const
 
Polylineoperator<< (const Point &p)
 
Pointoperator[] (const unsigned int n)
 
Polylinerotate (double angle, const Point &center)
 
Polyline rotated (double angle, const Point &center) const
 
Polylinerotate (double angle)
 
Polyline rotated (double angle) const
 
Polylinetranslate (double dx, double dy)
 
Polyline translated (double dx, double dy) const
 
Shapescale (double sx, double sy)
 
Shapescale (double s)
 
Polyline scaled (double sx, double sy) const
 
Polyline scaled (double s) const
 
void scaleAll (double s)
 
Rect boundingBox () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape (DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth)
 
virtual ~Shape ()
 
bool filled () const
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
Rect bbox ()
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const DGtal::ColorpenColor () const
 
const DGtal::ColorfillColor () const
 

Static Private Attributes

static const std::string _name
 

Additional Inherited Members

- Public Types inherited from LibBoard::Shape
enum  LineCap { ButtCap = 0, RoundCap, SquareCap }
 
enum  LineJoin { MiterJoin = 0, RoundJoin, BevelJoin }
 
enum  LineStyle {
  SolidStyle = 0, DashStyle, DotStyle, DashDotStyle,
  DashDotDotStyle, DashDotDotDotStyle
}
 
- Protected Member Functions inherited from LibBoard::Shape
std::string svgProperties (const TransformSVG &transform) const
 
std::string postscriptProperties () const
 
void setCairoDashStyle (cairo_t *cr, LineStyle type) const
 
std::string tikzProperties (const TransformTikZ &transform) const
 
- Protected Attributes inherited from LibBoard::Polyline
Path _path
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
DGtal::Color _penColor
 
DGtal::Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Detailed Description

A quadratic Bezier curve having 3 control points. NB. It is also a parabola arc.

Definition at line 1160 of file Board/Shapes.h.

Constructor & Destructor Documentation

LibBoard::QuadraticBezierCurve::QuadraticBezierCurve ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
DGtal::Color  pen,
DGtal::Color  fill,
double  lineWidth,
const LineStyle  style = SolidStyle,
const LineCap  cap = ButtCap,
const LineJoin  join = MiterJoin,
int  depthValue = -1 
)
inline

Constructs a curve.

Parameters
x1First coordinate of the start point.
y1Second coordinate of the start point.
x2First coordinate of the middle point.
y2Second coordinate of the middle point.
x3First coordinate of the end point.
y3Second coordinate of the end point.
penColor of the curve.
fillColor of the interior.
lineWidthThe line thickness.
styleCurve style
capCurve cap
joinCurve join
depthValueThe depth of the line.

Definition at line 1179 of file Board/Shapes.h.

1187  : Triangle(x1, y1, x2, y2, x3, y3, pen, fill, lineWidth, style, cap, join, depthValue) {}
Triangle(const Point &p1, const Point &p2, const Point &p3, DGtal::Color pen, DGtal::Color fill, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depthValue=-1)

Member Function Documentation

void LibBoard::QuadraticBezierCurve::flushCairo ( cairo_t *  cr,
const TransformCairo transform 
) const
virtual

Writes the cairo code of the shape in a cairo drawing context according to a transform.

Parameters
crThe cairo drawing context.
transformA 2D transform to be applied.

Reimplemented from LibBoard::Polyline.

Definition at line 2473 of file Shapes.cpp.

References LibBoard::Shape::_fillColor, LibBoard::Shape::_lineCap, LibBoard::Shape::_lineJoin, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Polyline::_path, LibBoard::Shape::_penColor, DGtal::Color::blue(), LibBoard::Shape::filled(), DGtal::Color::green(), LibBoard::Transform::mapX(), LibBoard::TransformCairo::mapY(), DGtal::Color::None, DGtal::Color::red(), and LibBoard::Shape::setCairoDashStyle().

2475 {
2476  double x1, y1, x2, y2, x3, y3, x4, y4; //coordinates of the control points
2477  _path[ 0 ].get(x1, y1);
2478  _path[ 1 ].get(x3, y3);
2479  _path[ 2 ].get(x4, y4);
2480  //we compute the two middle control points of a cubic Bezier curve
2481  //from the three control points of the quadratic Bezier curve
2482  x2 = x1 + 2/3.0*(x3-x1);
2483  y2 = y1 + 2/3.0*(y3-y1);
2484  x3 = x2 + 1/3.0*(x4-x1);
2485  y3 = y2 + 1/3.0*(y4-y1);
2486 
2487  cairo_save (cr);
2488 
2489  cairo_set_source_rgba (cr, _fillColor.red()/255.0, _fillColor.green()/255.0, _fillColor.blue()/255.0, 1.);
2490 
2491  cairo_move_to( cr, transform.mapX( x1 ), transform.mapY( y1 ) );
2492  cairo_curve_to( cr, transform.mapX( x2 ), transform.mapY( y2 ),
2493  transform.mapX( x3 ), transform.mapY( y3 ),
2494  transform.mapX( x4 ), transform.mapY( y4 ) );
2495 
2496  if ( filled() )
2497  {
2498  if ( _penColor != DGtal::Color::None )
2499  cairo_fill_preserve (cr);
2500  else
2501  cairo_fill (cr);
2502  }
2503 
2504  if ( _penColor != DGtal::Color::None )
2505  {
2506  cairo_set_source_rgba (cr, _penColor.red()/255.0, _penColor.green()/255.0, _penColor.blue()/255.0, 1.);
2507 
2508  cairo_set_line_width (cr, _lineWidth);
2509  cairo_set_line_cap (cr, cairoLineCap[_lineCap]);
2510  cairo_set_line_join (cr, cairoLineJoin[_lineJoin]);
2512 
2513  cairo_stroke (cr);
2514  }
2515 
2516  cairo_restore (cr);
2517 }
static const Color None
Definition: Color.h:387
LineJoin _lineJoin
Definition: Board/Shapes.h:301
bool filled() const
Definition: Board/Shapes.h:111
void green(const unsigned char aGreenValue)
DGtal::Color _penColor
Definition: Board/Shapes.h:296
void red(const unsigned char aRedValue)
void setCairoDashStyle(cairo_t *cr, LineStyle type) const
Definition: Shapes.cpp:154
LineStyle _lineStyle
Definition: Board/Shapes.h:299
DGtal::Color _fillColor
Definition: Board/Shapes.h:297
void blue(const unsigned char aBlueValue)
void LibBoard::QuadraticBezierCurve::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< DGtal::Color, int > &  colormap 
) const
virtual

Writes the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.
colormapA colormap.

Reimplemented from LibBoard::Polyline.

Definition at line 2441 of file Shapes.cpp.

References LibBoard::Polyline::flushFIG().

2444 {
2445  stream << "#FIXME: quadratic Bezier curve unimplemented" << std::endl;
2446  Triangle::flushFIG(stream, transform, colormap);
2447 }
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
Definition: Shapes.cpp:1761
void LibBoard::QuadraticBezierCurve::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
virtual

Writes the EPS code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Reimplemented from LibBoard::Polyline.

Definition at line 2391 of file Shapes.cpp.

References LibBoard::Shape::_fillColor, LibBoard::Polyline::_path, LibBoard::Shape::_penColor, DGtal::Color::flushPostscript(), LibBoard::Transform::mapX(), LibBoard::TransformEPS::mapY(), DGtal::Color::None, and LibBoard::Shape::postscriptProperties().

2393 {
2394  double x1, y1, x2, y2, x3, y3, x4, y4; //coordinates of the control points
2395  _path[ 0 ].get(x1, y1);
2396  _path[ 1 ].get(x3, y3);
2397  _path[ 2 ].get(x4, y4);
2398  //we compute the two middle control points of a cubic Bezier curve
2399  //from the three control points of the quadratic Bezier curve
2400  x2 = x1 + 2/3.0*(x3-x1);
2401  y2 = y1 + 2/3.0*(y3-y1);
2402  x3 = x2 + 1/3.0*(x4-x1);
2403  y3 = y2 + 1/3.0*(y4-y1);
2404 
2405  stream << std::endl << "% Bezier curve" << std::endl;
2406  if ( _fillColor != DGtal::Color::None ) {
2407  stream << "n "
2408  << transform.mapX( x1 ) << " "
2409  << transform.mapY( y1 ) << " "
2410  << "m "
2411  << transform.mapX( x2 ) << " "
2412  << transform.mapY( y2 ) << " "
2413  << transform.mapX( x3 ) << " "
2414  << transform.mapY( y3 ) << " "
2415  << transform.mapX( x4 ) << " "
2416  << transform.mapY( y4 ) << " "
2417  << "curveto ";
2418  _fillColor.flushPostscript( stream );
2419  stream << " " << postscriptProperties();
2420  stream << " fill" << std::endl;
2421  }
2422  if ( _penColor != DGtal::Color::None ) {
2423  stream << " " << postscriptProperties() << " ";
2424  stream << "n "
2425  << transform.mapX( x1 ) << " "
2426  << transform.mapY( y1 ) << " "
2427  << "m "
2428  << transform.mapX( x2 ) << " "
2429  << transform.mapY( y2 ) << " "
2430  << transform.mapX( x3 ) << " "
2431  << transform.mapY( y3 ) << " "
2432  << transform.mapX( x4 ) << " "
2433  << transform.mapY( y4 ) << " "
2434  << "curveto ";
2435  _penColor.flushPostscript( stream );
2436  stream << " stroke" << std::endl;
2437  }
2438 }
std::string postscriptProperties() const
Definition: Shapes.cpp:141
static const Color None
Definition: Color.h:387
void flushPostscript(std::ostream &) const
Definition: Color.cpp:124
DGtal::Color _penColor
Definition: Board/Shapes.h:296
DGtal::Color _fillColor
Definition: Board/Shapes.h:297
void LibBoard::QuadraticBezierCurve::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
virtual

Writes the SVG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Reimplemented from LibBoard::Polyline.

Definition at line 2450 of file Shapes.cpp.

References LibBoard::Polyline::_path, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Shape::svgProperties().

2452 {
2453  double x1, y1, x2, y2, x3, y3; //coordinates of the control points
2454  _path[ 0 ].get(x1, y1);
2455  _path[ 1 ].get(x2, y2);
2456  _path[ 2 ].get(x3, y3);
2457 
2458  stream << "<path ";
2459  stream << svgProperties( transform ) << " ";
2460  //first point
2461  stream << "d='M " << transform.mapX( x1 );
2462  stream << "," << transform.mapY( y1 );
2463  //arc
2464  stream << " Q " << transform.mapX( x2 ) << "," << transform.mapY( y2 );
2465  //last point
2466  stream << " " << transform.mapX( x3 );
2467  stream << "," << transform.mapY( y3 );
2468  stream << "' />";
2469 }
std::string svgProperties(const TransformSVG &transform) const
Definition: Shapes.cpp:110
void LibBoard::QuadraticBezierCurve::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
virtual

Writes the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Reimplemented from LibBoard::Polyline.

Definition at line 2521 of file Shapes.cpp.

References LibBoard::Polyline::_path, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Shape::tikzProperties().

2523 {
2524  double x1, y1, x2, y2, x3, y3, x4, y4; //coordinates of the control points
2525  _path[ 0 ].get(x1, y1);
2526  _path[ 1 ].get(x3, y3);
2527  _path[ 2 ].get(x4, y4);
2528  //we compute the two middle control points of a cubic Bezier curve
2529  //from the three control points of the quadratic Bezier curve
2530  x2 = x1 + 2/3.0*(x3-x1);
2531  y2 = y1 + 2/3.0*(y3-y1);
2532  x3 = x2 + 1/3.0*(x4-x1);
2533  y3 = y2 + 1/3.0*(y4-y1);
2534 
2535  stream << "\\draw[" << tikzProperties(transform) << "] ("
2536  << transform.mapX( x1 ) << ',' << transform.mapY( y1 )
2537  << ") .. controls ("
2538  << transform.mapX( x2 ) << ',' << transform.mapY( y2 )
2539  << ") and ("
2540  << transform.mapX( x3 ) << ',' << transform.mapY( y3 )
2541  << ") .. ("
2542  << transform.mapX( x4 ) << ',' << transform.mapY( y4 )
2543  << ");" << std::endl;
2544 }
std::string tikzProperties(const TransformTikZ &transform) const
Definition: Shapes.cpp:178
const std::string & LibBoard::QuadraticBezierCurve::name ( ) const
virtual

Returns the name of the shape (QuadraticBezierCurve)

Returns
object name

Reimplemented from LibBoard::Triangle.

Definition at line 2385 of file Shapes.cpp.

References _name.

2386 {
2387  return _name;
2388 }
static const std::string _name

Field Documentation

const std::string LibBoard::QuadraticBezierCurve::_name
staticprivate

name of the shape.

Definition at line 1215 of file Board/Shapes.h.

Referenced by name().


The documentation for this struct was generated from the following files: