21 #include "a2dprivate.h" 
   49 a2dBooleanWalkerHandler::~a2dBooleanWalkerHandler()
 
   61     m_resultOnSameLayer = 
false;
 
   63     m_firstLevelChild = 
false;
 
   77     double CORRECTIONFACTOR = 500.0;  
 
   78     double CORRECTIONABER   = 1.0;    
 
   79     double ROUNDFACTOR      = 1.5;    
 
   80     double SMOOTHABER       = 0.001;   
 
   81     double MAXLINEMERGE     = 1000.0; 
 
  109     m_booleng->SetCorrectionFactor( CORRECTIONFACTOR );
 
  110     m_booleng->SetCorrectionAber( CORRECTIONABER );
 
  112     m_booleng->SetMaxlinemerge( MAXLINEMERGE );
 
  113     m_booleng->SetRoundfactor( ROUNDFACTOR );
 
  114     m_booleng->SetOrientationEntryMode( 
false );
 
  122     setp.
Start( 
object );
 
  124     setflags.SetSkipNotRenderedInDrawing( 
true );
 
  125     setflags.
Start( 
object, 
false );
 
  129         object->Walker( NULL, *
this );
 
  131     catch ( Bool_Engine_Error& error )
 
  133         wxString str( error.GetErrorMessage().data(), wxConvUTF8, error.GetErrorMessage().size() );
 
  158                 m_firstLevelChild = 
true;
 
  160                 m_firstLevelChild = 
true;
 
  175         if ( canobj && parent && !canobj->
GetBin() && !canobj->GetIgnoreLayer() && m_firstLevelChild )
 
  178             bool hasLayer = 
false;
 
  181                 wxUint16 layer = *iter;
 
  183                 if ( wxLAYER_ALL == layer )
 
  200                     wxUint16 layer = *iter;
 
  202                     if ( wxLAYER_ALL == layer )
 
  222             CallEngine( canobjToAddTo );
 
  232             wxString name = canobj->
GetName();
 
  235             CallEngine( canobj );
 
  243                     if ( !obj->GetBin2() && obj->
GetLayer() == 
m_target && !obj->GetIgnoreLayer() )
 
  258                 if ( !obj->GetBin2() && obj->
GetLayer() == 
m_target && !obj->GetIgnoreLayer() )
 
  277             m_firstLevelChild = 
false;
 
  339         obj->SetBin2( 
true );
 
  360         booleanobject->
SetBin( 
true );
 
  361         booleanobject->SetBin2( 
true );
 
  362         booleanobject->
SetLayer( !m_resultOnSameLayer ? 
m_target : m_useFirstChildLayer );
 
  390             for( a2dVertexList::const_iterator iter = poly->
GetSegments()->begin(); iter != poly->
GetSegments()->end(); ++iter )
 
  399         for( a2dListOfa2dVertexList::iterator iterp = holes.begin(); iterp != holes.end(); iterp++ )
 
  404             if ( vlist->size() > 2 && 
m_booleng->StartHolePolygonAdd( A_or_B ) )
 
  406                 for( a2dVertexList::iterator iter = vlist->begin(); iter != vlist->end(); ++iter )
 
  488             for( a2dVertexList::const_iterator iter = poly->
GetSegments()->begin(); iter != poly->
GetSegments()->end(); ++iter )
 
  497         for( a2dListOfa2dVertexList::iterator iterp = holes.begin(); iterp != holes.end(); iterp++ )
 
  502             if ( vlist->size() > 2 && 
m_booleng->StartHolePolygonAdd( A_or_B ) )
 
  504                 for( a2dVertexList::iterator iter = vlist->begin(); iter != vlist->end(); ++iter )
 
  546         a2dCanvasObjectList::iterator iter = vpath->begin();
 
  547         while ( iter != vpath->end() )
 
  553             for( a2dCanvasObjectList::iterator iterp = polylist->begin(); iterp != polylist->end(); ++iterp )
 
  558                     bool returnIsPolygon;
 
  567                             for( a2dVertexList::const_iterator iter = poly->
GetSegments()->begin(); iter != poly->
GetSegments()->end(); ++iter )
 
  584                         for( a2dVertexList::const_iterator iter = poly->
GetSegments()->begin(); iter != poly->
GetSegments()->end(); ++iter )
 
  595             iter = vpath->erase( iter );
 
  596             iter = vpath->begin();
 
  603 bool a2dBooleanWalkerHandler::CallEngine( 
a2dCanvasObject* canobjToAddChildren )
 
  605     bool foundfirst = 
false;
 
  612             bool foundObjects = 
false;
 
  623                     m_useFirstChildStyleStroke = obj->GetStroke();
 
  624                     m_useFirstChildStyleFill = obj->GetFill();
 
  625                     m_useFirstChildLayer = obj->
GetLayer();
 
  631                 wxString classname = obj->GetClassInfo()->GetClassName();
 
  637                     canobjToAddChildren->
Prepend( holdChildRes );
 
  652                 bool foundObjects = 
false;
 
  659                         m_useFirstChildStyleStroke = obj->GetStroke();
 
  660                         m_useFirstChildStyleFill = obj->GetFill();
 
  661                         m_useFirstChildLayer = obj->
GetLayer();
 
  667                     wxString classname = obj->GetClassInfo()->GetClassName();
 
  673                         canobjToAddChildren->
Prepend( holdChildRes );
 
  686         BOOL_OP boolOp = BOOL_NON;
 
  697             boolOp = BOOL_A_SUB_B;
 
  699             boolOp = BOOL_B_SUB_A;
 
  701             boolOp = BOOL_CORRECTION;
 
  703             boolOp = BOOL_SMOOTHEN;
 
  705             boolOp = BOOL_MAKERING;
 
  725                 while ( 
m_booleng->PolygonHasMorePoints() )
 
  728                     points->push_back( seg );
 
  729                     if ( 
m_booleng->GetHoleConnectionSegment() )
 
  741                 polygon->
SetLayer( !m_resultOnSameLayer ? 
m_target : m_useFirstChildLayer );
 
  745                     polygon->
SetStroke( m_useFirstChildStyleStroke );
 
  750                     polygon->
SetFill( m_useFirstChildStyleFill );
 
  752                 polygon->SetBin2( 
true );
 
  755                 canobjToAddChildren->
Prepend( polygon );
 
  770                 while ( 
m_booleng->PolygonHasMorePoints() )
 
  772                     if ( 
m_booleng->GetHoleConnectionSegment() )
 
  774                         wxFAIL_MSG( wxT( 
"this type should not be here" ) );
 
  785                         holepoints->push_back( seg );
 
  795                         points->push_back( seg );
 
  802                     surface->
SetLayer( !m_resultOnSameLayer ? 
m_target : m_useFirstChildLayer );
 
  806                         surface->
SetStroke( m_useFirstChildStyleStroke );
 
  811                         surface->
SetFill( m_useFirstChildStyleFill );
 
  813                     surface->SetBin2( 
true );
 
  816                     canobjToAddChildren->
Prepend( surface );
 
  820                     wxASSERT_MSG( surface, wxT( 
"need surface first to place holes within" ) );
 
  821                     surface->AddHole( holepoints );
 
  829         canobjToAddChildren->
SetBin( 
true );
 
  833 #endif //wxART2D_USE_KBOOL 
bool GetObjectsSurface(a2dCanvasObject *booleanobject, GroupType A_or_B)
search objects that are Surface and add them to m_foundA 
set check on a2dObject flag false or true 
a2dCircle at x,y, and with radius 
static const a2dCanvasObjectFlagsMask BIN
A2DGENERALDLLEXP long wxGenNewId()
This function is like wxNewId, but it has its own ID set. 
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types. 
a2dCanvasObjectList * CreateChildObjectList()
create and get the list where the child objects are stored in. 
void SetSegType(a2dSegType type)
Set the type of the segment. 
const a2dError a2dError_CommandError
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
virtual wxString GetName() const 
Returns the name of this object, if no name is given the internal id will be returned. 
const a2dAffineMatrix & GetTransformMatrix() const 
get the matrix used to position the object 
void SetRelease(bool value)
set release flag 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
void ConvertToLines(double aberation=0)
Convert complex segments to line segments. 
unsigned int GetChildObjectsCount() const 
get number of child objects 
static const a2dCanvasObjectFlagsMask BIN2
static const long Boolean_Surface2Polygon
Bool_Engine * m_booleng
the boolean engine 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
polygon defined with list of points. 
virtual bool Start(a2dCanvasObject *object)
called for boolean operation 
a2dCanvasObjectList * GetAsPolygons()
convert to a list of a2dPolygonL and a2dPolylineL 
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object. 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const 
create an exact copy of this property 
bool m_releaseOrignals
when an object takes part in operation, and this flag is true, the original is removed. 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
return the arrow converted to a vector path. 
a2dRectC is a centered rectangle 
a2dCanvasObjectList m_foundB
objects found for groupB 
static const long Boolean_MAKERING
void Initialize()
used from constructors 
a2dCanvasObjectList m_foundA
objects found for groupA 
wxUint16 m_lastdepth
to keep track of levels to do boolean operations 
a2dLayerGroup m_groupB
group B layers operand 
a2dCanvasObject is the base class for Canvas Objects. 
this segmnet is part of a hole 
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in. 
vertex list of line and arc segments. 
void TransformPoint(double x, double y, double &tx, double &ty) const 
Transform a point. 
bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument 
bool GetSelected() const 
is the object selected flag set 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
static const long Boolean_NON
virtual a2dVertexList * GetAsVertexList(bool &returnIsPolygon) const 
convert to a polygon. 
void SetBin(bool bin)
general flag use at will. 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectPostChild
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject 
bool GetCheck() const 
general flag use at will. 
a2dText is an abstract base class. 
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList 
bool HasArcs() const 
return true if there are a2dArcSegment segments. 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
#define forEachIn(listtype, list)
easy iteration for a2dlist 
a2dEllipse centered at x,y. 
polyline defined with list of points. 
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! ) 
Normal straight line segment in a2dVertexList and a2dVertexArray. 
static const long Boolean_AND
Operation m_operation
id for operation 
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes. 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
return text as a vector path, where text outline is converted to polyline or polygons. 
wxUint16 GetLayer() const 
Returns the layer index where this object is drawn upon. 
void Prepend(a2dCanvasObject *obj)
prepend a a2dCanvasObject to the childobjects 
bool GetBin() const 
general flag use at will. 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
const a2dFill * a2dNullFILL
global a2dFill stock object for defining NO filling 
bool GetObjectsForSurface(a2dCanvasObject *booleanobject, GroupType A_or_B)
search objects that are convertable to Surface and add them to m_foundA 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
a2dArrow is used for having line begin and ends on specific objects. 
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
void SetCheck(bool check)
general flag use at will. 
bool ConvertToPolygons(a2dCanvasObject *booleanobject, GroupType A_or_B)
convert obj to polygons and add to m_foundA and m_foundB 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
void Initialize()
used from constructor 
boolean operation on primitives in a a2dDocument. 
const a2dStroke * a2dNullSTROKE
global a2dStroke stock object for NO stroking 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
int m_currentDepth
contour to be used by algorithm, to decide on how deep recursing is to be. 
virtual double GetContourWidth() const 
get the Contour width of the shape 
double m_x
x endpoint of line 
polygon defined with list of points for outer contour plus a list of hole polygons ...
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! ) 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
double m_y
y endpoint of line 
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke. 
int TakeOverFrom(a2dCanvasObjectList *total, const wxString &type=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=NULL)
Move objects fitting the given filter from the total list to this list. 
static const long Boolean_B_SUB_A
static const long Boolean_A_SUB_B
bool VectorPathPolygonsToEngine(a2dCanvasObjectList *vpath, GroupType A_or_B)
vector path split ino polygons, and added to engine 
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler 
static const long Boolean_CORRECTION
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
a2dEndsLine with begin and/or end object. 
a2dLayerGroup m_groupA
group A layers operand 
bool Start(a2dCanvasObject *object, bool setTo)
start removing properties from the object given, and down. 
size_t GetNumberOfSegments()
get the number of points in the pointlist 
bool m_useCheck
if set a2dObject are only walked if not m_check is set 
bool m_useFirstChildStyle
use first child style or not. 
holds a list of layers numbers 
static const long Boolean_OR
bool ObjectOke(a2dCanvasObject *obj)
return true if object fits the filter 
all headers of the canvas module 
a2dCanvasObject for a Vector Path 
size_t GetNumberOfSegments()
get the number of points in the pointlist 
algorithm to delete a2dCanvasObjects on layers or to move, copy to other layers 
links an outside contour with a hole 
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon. 
bool m_clearTarget
clear the target layer before adding result. 
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const 
when implemented the object without its children, is converted to 
wxUint16 m_target
result into this layer 
static const long Boolean_Polygon2Surface
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease. 
void SetStopWalking(bool stopWalking)
to further recursion, e.g. in a2dObject::Walker() 
bool Start(a2dObject *object)
start removing properties from the object given, and down. 
static const long Boolean_EXOR
bool m_selectedOnlyB
work only on selected object in group B 
bool m_selectedOnlyA
work only on selected object in group A 
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill. 
a2dEllipticArc centered at x,y 
static const long Boolean_SMOOTHEN