📄 drawable.h
字号:
// This may look like C code, but it is really -*- C++ -*-//// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002//// Definition of Drawable (Graphic objects)//// The technique used for instantiating classes which derive from STL// templates is described in Microsoft MSDN Article ID: Q168958// "HOWTO: Exporting STL Components Inside & Outside of a Class".//#if !defined(Magick_Drawable_header)#define Magick_Drawable_header#include "Magick++/Include.h"#include <functional>#include <string>#include <list>#include <utility>#include "Magick++/Color.h"#include "Magick++/Geometry.h"#if defined(MagickDLLBuild)# if defined(MAGICK_DRAWABLE_IMPLEMENTATION)# define MagickDrawableExtern# else# pragma warning( disable: 4231 ) // Disable warning regarding using extern# define MagickDrawableExtern extern# endif // MAGICK_DRAWABLE_IMPLEMENTATION#else# define MagickDrawableExtern#endif // MagickDLLBuildnamespace Magick{ // // Representation of an x,y coordinate // class MagickDLLDecl Coordinate { public: Coordinate ( void ) : _x(0), _y(0) { } Coordinate ( double x_, double y_ ) : _x(x_), _y(y_) { } virtual ~Coordinate () { } void x ( double x_ ) { _x = x_; } double x ( void ) const { return _x; } void y ( double y_ ) { _y = y_; } double y ( void ) const { return _y; } private: double _x; double _y; }; typedef std::list<Magick::Coordinate> CoordinateList;#if defined(MagickDLLBuild) MagickDrawableExtern template class MagickDLLDecl std::allocator<Magick::Coordinate>; MagickDrawableExtern template class MagickDLLDecl std::list<Magick::Coordinate, std::allocator<Magick::Coordinate> >;#endif // MagickDLLBuild // Compare two Coordinate objects regardless of LHS/RHS MagickDLLDeclExtern int operator == ( const Coordinate& left_, const Coordinate& right_ ); MagickDLLDeclExtern int operator != ( const Coordinate& left_, const Coordinate& right_ ); MagickDLLDeclExtern int operator > ( const Coordinate& left_, const Coordinate& right_ ); MagickDLLDeclExtern int operator < ( const Coordinate& left_, const Coordinate& right_ ); MagickDLLDeclExtern int operator >= ( const Coordinate& left_, const Coordinate& right_ ); MagickDLLDeclExtern int operator <= ( const Coordinate& left_, const Coordinate& right_ ); // // Base class for all drawable objects // //struct MagickDLLDecl std::unary_function<MagickLib::DrawContext,void>; class MagickDLLDecl DrawableBase: public std::unary_function<MagickLib::DrawContext,void> { public: // Constructor DrawableBase ( void ) { } // Destructor virtual ~DrawableBase ( void ); // Operator to invoke equivalent draw API call virtual void operator()( MagickLib::DrawContext ) const = 0; // Return polymorphic copy of object virtual DrawableBase* copy() const = 0; private: }; // // Representation of a drawable surrogate object to manage drawable objects //#undef Drawable // Conflict with <X11/Xproto.h> class MagickDLLDecl Drawable { public: // Constructor Drawable ( void ); // Construct from DrawableBase Drawable ( const DrawableBase& original_ ); // Destructor ~Drawable ( void ); // Copy constructor Drawable ( const Drawable& original_ ); // Assignment operator Drawable& operator= (const Drawable& original_ ); // Operator to invoke contained object void operator()( MagickLib::DrawContext context_ ) const; private: DrawableBase* dp; }; // Compare two Drawable objects regardless of LHS/RHS MagickDLLDeclExtern int operator == ( const Drawable& left_, const Drawable& right_ ); MagickDLLDeclExtern int operator != ( const Drawable& left_, const Drawable& right_ ); MagickDLLDeclExtern int operator > ( const Drawable& left_, const Drawable& right_ ); MagickDLLDeclExtern int operator < ( const Drawable& left_, const Drawable& right_ ); MagickDLLDeclExtern int operator >= ( const Drawable& left_, const Drawable& right_ ); MagickDLLDeclExtern int operator <= ( const Drawable& left_, const Drawable& right_ ); typedef std::list<Magick::Drawable> DrawableList;#if defined(MagickDLLBuild) MagickDrawableExtern template class MagickDLLDecl std::allocator<Magick::Drawable>; MagickDrawableExtern template class MagickDLLDecl std::list<Magick::Drawable, std::allocator<Magick::Drawable> >;#endif // MagickDLLBuild//// Base class for all drawable path elements for use with// DrawablePath//class MagickDLLDecl VPathBase{public: // Constructor VPathBase ( void ) { } // Destructor virtual ~VPathBase ( void ); // Assignment operator // const VPathBase& operator= (const VPathBase& original_ ); // Operator to invoke equivalent draw API call virtual void operator()( MagickLib::DrawContext context_ ) const = 0; // Return polymorphic copy of object virtual VPathBase* copy() const = 0;};//// Representation of a drawable path element surrogate object to// manage drawable path elements so they may be passed as a list to// DrawablePath.//class MagickDLLDecl VPath{public: // Constructor VPath ( void ); // Construct from VPathBase VPath ( const VPathBase& original_ ); // Destructor virtual ~VPath ( void ); // Copy constructor VPath ( const VPath& original_ ); // Assignment operator VPath& operator= (const VPath& original_ ); // Operator to invoke contained object void operator()( MagickLib::DrawContext context_ ) const;private: VPathBase* dp;};// Compare two VPath objects regardless of LHS/RHSMagickDLLDeclExtern int operator == ( const VPath& left_, const VPath& right_ );MagickDLLDeclExtern int operator != ( const VPath& left_, const VPath& right_ );MagickDLLDeclExtern int operator > ( const VPath& left_, const VPath& right_ );MagickDLLDeclExtern int operator < ( const VPath& left_, const VPath& right_ );MagickDLLDeclExtern int operator >= ( const VPath& left_, const VPath& right_ );MagickDLLDeclExtern int operator <= ( const VPath& left_, const VPath& right_ );typedef std::list<Magick::VPath> VPathList;#if defined(MagickDLLBuild)MagickDrawableExtern template class MagickDLLDeclstd::allocator<Magick::VPath>;MagickDrawableExtern template class MagickDLLDeclstd::list<Magick::VPath, std::allocator<Magick::VPath> >;#endif // MagickDLLBuild//// Drawable Objects//// Affine (scaling, rotation, and translation)class MagickDLLDecl DrawableAffine : public DrawableBase{public: DrawableAffine ( double sx_, double sy_, double rx_, double ry_, double tx_, double ty_ ); DrawableAffine ( void ); /*virtual*/ ~DrawableAffine( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const; void sx( const double sx_ ) { _affine.sx = sx_; } double sx( void ) const { return _affine.sx; } void sy( const double sy_ ) { _affine.sy = sy_; } double sy( void ) const { return _affine.sy; } void rx( const double rx_ ) { _affine.rx = rx_; } double rx( void ) const { return _affine.rx; } void ry( const double ry_ ) { _affine.ry = ry_; } double ry( void ) const { return _affine.ry; } void tx( const double tx_ ) { _affine.tx = tx_; } double tx( void ) const { return _affine.tx; } void ty( const double ty_ ) { _affine.ty = ty_; } double ty( void ) const { return _affine.ty; } private: MagickLib::AffineMatrix _affine;};// Arcclass MagickDLLDecl DrawableArc : public DrawableBase{public: DrawableArc ( double startX_, double startY_, double endX_, double endY_, double startDegrees_, double endDegrees_ ) : _startX(startX_), _startY(startY_), _endX(endX_), _endY(endY_), _startDegrees(startDegrees_), _endDegrees(endDegrees_) { } /*virtual*/ ~DrawableArc( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const; void startX( double startX_ ) { _startX = startX_; } double startX( void ) const { return _startX; } void startY( double startY_ ) { _startY = startY_; } double startY( void ) const { return _startY; } void endX( double endX_ ) { _endX = endX_; } double endX( void ) const { return _endX; } void endY( double endY_ ) { _endY = endY_; } double endY( void ) const { return _endY; } void startDegrees( double startDegrees_ ) { _startDegrees = startDegrees_; } double startDegrees( void ) const { return _startDegrees; } void endDegrees( double endDegrees_ ) { _endDegrees = endDegrees_; } double endDegrees( void ) const { return _endDegrees; } private: double _startX; double _startY; double _endX; double _endY; double _startDegrees; double _endDegrees;};// Bezier curve (Coordinate list must contain at least three members)class MagickDLLDecl DrawableBezier : public DrawableBase{public: // Construct from coordinates DrawableBezier ( const CoordinateList &coordinates_ ); // Copy constructor DrawableBezier ( const DrawableBezier& original_ ); // Destructor /*virtual*/ ~DrawableBezier ( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const; private: CoordinateList _coordinates;};// Pop (terminate) clip path definitionclass MagickDLLDecl DrawablePopClipPath : public DrawableBase{public: DrawablePopClipPath ( void ) : _dummy(0) { } /*virtual*/ ~DrawablePopClipPath ( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const;private: int _dummy;};// Push (create) Clip path definitionclass MagickDLLDecl DrawablePushClipPath : public DrawableBase{public: DrawablePushClipPath ( const std::string &id_); DrawablePushClipPath ( const DrawablePushClipPath& original_ ); /*virtual*/ ~DrawablePushClipPath ( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const;private: std::string _id;};// Named Clip Pathclass MagickDLLDecl DrawableClipPath : public DrawableBase{public: DrawableClipPath ( const std::string &id_ ); DrawableClipPath ( const DrawableClipPath& original_ ); /*virtual*/ ~DrawableClipPath ( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const; void clip_path( const std::string &id_ ) { _id = id_.c_str(); //multithread safe } std::string clip_path( void ) const { return _id; }private: std::string _id;};// Circleclass MagickDLLDecl DrawableCircle : public DrawableBase{public: DrawableCircle ( double originX_, double originY_, double perimX_, double perimY_ ) : _originX(originX_), _originY(originY_), _perimX(perimX_), _perimY(perimY_) { } /*virtual*/ ~DrawableCircle ( void ); // Operator to invoke equivalent draw API call /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const; // Return polymorphic copy of object /*virtual*/ DrawableBase* copy() const; void originX( double originX_ ) { _originX = originX_; } double originX( void ) const { return _originX; } void originY( double originY_ ) { _originY = originY_; } double originY( void ) const { return _originY; } void perimX( double perimX_ ) { _perimX = perimX_; } double perimX( void ) const { return _perimX; } void perimY( double perimY_ ) { _perimY = perimY_; } double perimY( void ) const { return _perimY; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -