34 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
35 #include <wx/msw/msvcrt.h>
47 m_returnPinClass = NULL;
48 m_returnConnect = NULL;
56 m_routeWhenDrag =
true;
60 m_allowredirect =
true;
61 m_generatePins =
true;
70 delete m_wiresEditCopies;
96 wxString a2dConnectionGenerator::GetRouteMethodAsString()
99 return "StraightEndSegment";
101 return "StraightEndSegmentUnlessPins";
103 return "StraightSegment";
105 return "StraightSegmentUnlessPins";
107 return "ManhattanSegments";
109 return "ManhattanEndSegments";
111 return "ManhattanEndSegmentsStay";
113 return "ManhattanEndSegmentsConvertAndStay";
115 return "GridRouting";
120 bool onlyNonSelected =
true;
125 if ( CreateExtraWires )
130 setflags.SetSkipNotRenderedInDrawing(
true );
131 setflags.Start( m_parent,
false );
135 a2dCanvasObjectList::iterator iter;
136 for( iter = dragList.begin(); iter != dragList.end(); ++iter )
140 original->
FindConnectedWires( connectedwires, NULL, walkWires, selected, stopAtSelectedWire );
143 iter = connectedwires.begin();
144 while( iter != connectedwires.end() )
146 a2dCanvasObjectList::value_type wire = *iter;
147 if ( std::find( dragList.begin(), dragList.end(), wire ) != dragList.end() )
148 iter = connectedwires.erase( iter );
151 wire->SetBin(
false );
152 wire->EliminateMatrix();
157 AddRerouteWires( &connectedwires, m_parent );
158 OptimizeRerouteWires();
160 setflags.Start( m_parent,
false );
167 for( a2dCanvasObjectList::const_iterator iterdrags = objectsToDrag.begin(); iterdrags != objectsToDrag.end(); ++iterdrags )
183 a2dPinList::const_iterator iterconp;
186 a2dPin* other = *iterconp;
195 if ( !pinConnectGen )
196 pinConnectGen =
this;
201 switch ( m_routeMethod )
254 if( other->
GetName() == wxT(
"begin" ) )
258 else if( other->
GetName() == wxT(
"end" ) )
277 if( pin->
GetName() != wxT(
"begin" ) && pin->
GetName() != wxT(
"end" ) )
280 if ( index == 0 && other->
GetName() == wxT(
"begin" ) )
330 void a2dConnectionGenerator::OptimizeRerouteWires(
bool removeZero )
332 wxASSERT_MSG( m_parent, wxT(
"parent object must be set" ) );
337 a2dCanvasObjectList::iterator iter;
338 for( iter = m_wires->begin(); iter != m_wires->end(); ++iter )
353 if ( begin != pin && end != pin )
368 for( iter = m_wires->begin(); iter != m_wires->end(); ++iter )
387 for( iter = m_wires->begin(); iter != m_wires->end(); ++iter )
401 iter = m_wires->begin();
402 while( iter != m_wires->end() )
411 iter = m_wires->erase( iter );
416 iter = m_wires->begin();
417 while( iter != m_wires->end() )
453 m_parent = parentOfWires;
459 m_parent = parentOfWires;
461 m_wires->push_back( wire );
470 int pb = bw? bw->GetPriority() : 0;
478 a2dPinList::const_iterator iterconp;
481 a2dPin* connectedPin = *iterconp;
484 if ( connectedPin != notThis )
497 wxASSERT_MSG( m_parent, wxT(
"parent object must be set" ) );
501 for( a2dCanvasObjectList::iterator iter = m_wires->begin(); iter != m_wires->end(); ++iter )
507 m_wiresEditCopies->push_back( wirecopy );
520 for( a2dCanvasObjectList::iterator iter = m_wires->begin(); iter != m_wires->end(); ++iter )
527 m_wiresEditCopies->push_back( wirecopy );
540 a2dPinList::const_iterator iterconp;
543 a2dPin* otherpin = *iterconp;
557 endpin->SetInternal(
true );
558 endpin->SetPosXY( 0, 0 );
559 endWire->
Append( endpin );
562 RemoveRefsNotThis( refs, otherpin, pin );
567 m_wiresEditCopies->push_back( endWire );
576 if ( !m_noEditCopy && m_routeWhenDrag && tool )
578 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
581 ( *iter )->SetVisible(
true );
589 switch ( m_routeMethod )
650 void a2dConnectionGenerator::ResetPositionsToOrignals()
652 wxASSERT_MSG( m_parent, wxT(
"parent object must be set" ) );
654 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
656 if ( !(*iter)->IsConnect() )
698 void a2dConnectionGenerator::PrepareGridRoute()
700 wxASSERT_MSG( m_parent, wxT(
"parent object must be set" ) );
702 s_a2dCanvasObjectSorter = &PrioritySorter;
703 m_wiresEditCopies->sort();
713 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
715 if ( !(*iter)->IsConnect() )
741 if( pin->
GetName() != wxT(
"begin" ) && pin->
GetName() != wxT(
"end" ) )
744 a2dPinList::const_iterator iterconp;
747 a2dPin* otherpin = *iterconp;
755 if( otherpin->
GetName() == wxT(
"begin" ) || otherpin->
GetName() == wxT(
"end" ) )
759 int minpriority = 1 + (wireconnected? wireconnected->
GetPriority() : 0);
760 if( minpriority > priority && minpriority < 255 )
761 priority = minpriority;
768 if( oldpriority != priority )
774 s_a2dCanvasObjectSorter = &PrioritySorter;
775 m_wiresEditCopies->sort();
778 if ( !m_wiresEditCopies->empty() )
785 void a2dConnectionGenerator::RerouteWire(
a2dWirePolylineL* wire,
bool& again )
816 if( pin->
GetName() == wxT(
"begin" ) )
841 else if( pin->
GetName() == wxT(
"end" ) )
868 wxASSERT_MSG( 0, wxT(
"Unknown pin type in wire" ) );
933 void a2dConnectionGenerator::AutoConnect(
a2dWirePolylineL* wire,
bool allowreconnectbegin,
bool allowreconnectend )
941 if( pin->
GetName() == wxT(
"begin" ) )
943 if( allowreconnectbegin )
948 else if( pin->
GetName() == wxT(
"end" ) )
950 if( allowreconnectend )
958 void a2dConnectionGenerator::RerouteWires(
bool final,
bool fromOriginal )
960 wxASSERT_MSG( m_parent, wxT(
"parent object must be set" ) );
961 double offset = m_offset;
963 if ( m_routeWhenDrag || ( !m_routeWhenDrag &&
final ) )
965 switch ( m_routeMethod )
971 bool displaced =
true;
973 while ( displaced && i < 1000 )
977 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
979 if ( !(*iter)->IsConnect() )
1006 if( pin->
GetName() == wxT(
"begin" ) )
1012 else if( pin->
GetName() == wxT(
"end" ) )
1025 if( pin->
GetName() == wxT(
"begin" ) )
1028 seg->SetPoint( otherPin->
GetAbsXY() );
1030 else if( pin->
GetName() == wxT(
"end" ) )
1033 seg->SetPoint( otherPin->
GetAbsXY() );
1058 bool displaced =
true;
1060 while ( displaced && i < 1000 )
1064 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1066 if ( !(*iter)->IsConnect() )
1091 if( pin->
GetName() == wxT(
"begin" ) )
1099 routeWire.ComputeConToWireVertex( otherPin, otherEndpin->
GetAbsX(), otherEndpin->
GetAbsY(), otherEndpin->
GetAbsAngle() - 180 );
1102 routeWire.ComputeCon ( otherPin, otherEndpin );
1104 for (
int v = 0; v < routeWire.m_pnr; v++ )
1106 newpoints->push_back(
new a2dLineSegment( routeWire.m_p[v][0], routeWire.m_p[v][1] ) );
1110 else if( pin->
GetName() == wxT(
"end" ) )
1118 routeWire.ComputeConToWireVertex( otherPin, otherEndpin->
GetAbsX(), otherEndpin->
GetAbsY(), otherEndpin->
GetAbsAngle() - 180 );
1121 routeWire.ComputeCon ( otherPin, otherEndpin );
1123 for (
int v = 0; v < routeWire.m_pnr; v++ )
1125 newpoints->push_front(
new a2dLineSegment( routeWire.m_p[v][0], routeWire.m_p[v][1] ) );
1146 bool displaced =
true;
1147 unsigned int trials = 0;
1148 while ( displaced && trials < 10 )
1152 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1169 bool hasbins =
false;
1171 a2dVertexList::iterator iter = newpoints->begin();
1172 while ( iter != newpoints->end() )
1174 if ( (*iter)->GetBin() && newpoints->size() > 1 )
1176 iter = newpoints->erase( iter );
1194 if( pin->
GetName() == wxT(
"begin" ) )
1198 if ( newpoints->size() > 1 )
1199 newpoints->pop_front();
1200 if ( newpoints->size() > 1 )
1201 newpoints->pop_front();
1206 if ( newpoints->size() <= 2 )
1214 routeWire.ComputeConToWireVertex( otherPin, otherEndpin->
GetAbsX(), otherEndpin->
GetAbsY(), otherEndpin->
GetAbsAngle() - 180 );
1217 routeWire.ComputeCon ( otherPin, otherEndpin );
1219 for (
int v = 0; v < routeWire.m_pnr; v++ )
1222 seg->SetBin(
true );
1223 newpoints->push_front( seg );
1229 routeWire.ComputeCon ( pin, otherPin );
1231 for (
int v = 1; v < routeWire.m_pnr; v++ )
1234 seg->SetBin(
true );
1235 newpoints->push_front( seg );
1240 else if( pin->
GetName() == wxT(
"end" ) )
1244 if ( newpoints->size() > 1 )
1245 newpoints->pop_back();
1246 if ( newpoints->size() > 1 )
1247 newpoints->pop_back();
1252 if ( newpoints->size() <= 2 )
1260 routeWire.ComputeConToWireVertex( otherPin, otherEndpin->
GetAbsX(), otherEndpin->
GetAbsY(), otherEndpin->
GetAbsAngle() - 180 );
1263 routeWire.ComputeCon ( otherPin, otherEndpin );
1265 for (
int v = 0; v < routeWire.m_pnr; v++ )
1268 seg->SetBin(
true );
1269 newpoints->push_front( seg );
1275 routeWire.ComputeCon ( pin, otherPin );
1277 for (
int v = 1; v < routeWire.m_pnr; v++ )
1280 seg->SetBin(
true );
1281 newpoints->push_back( seg );
1304 bool displaced =
true;
1305 unsigned int trials = 0;
1306 while ( displaced && trials < 10 )
1310 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1339 if( pin->
GetName() == wxT(
"begin" ) )
1345 seg->SetPoint( otherPin->
GetAbsXY() );
1347 else if ( newpoints->size() > 2 )
1349 a2dVertexList::iterator iter = newpoints->begin();
1351 if ( iter != newpoints->end() )
1354 if ( iter != newpoints->end() )
1357 if ( iter != newpoints->end() )
1360 EndManhattanRoute( otherPin, seg, seg2, seg3, newpoints,
false );
1364 a2dVertexList::iterator iter = newpoints->begin();
1367 if ( iter != newpoints->end() )
1370 if ( iter != newpoints->end() )
1379 seg->SetPoint( otherPin->
GetAbsXY() );
1383 else if( pin->
GetName() == wxT(
"end" ) )
1389 seg->SetPoint( otherPin->
GetAbsXY() );
1391 else if ( newpoints->size() > 2 )
1393 a2dVertexList::reverse_iterator iter = newpoints->rbegin();
1395 if ( iter != newpoints->rend() )
1398 if ( iter != newpoints->rend() )
1401 if ( iter != newpoints->rend() )
1404 EndManhattanRoute( otherPin, seg, seg2, seg3, newpoints,
true );
1408 a2dVertexList::reverse_iterator iter = newpoints->rbegin();
1411 if ( iter != newpoints->rend() )
1414 if ( iter != newpoints->rend() )
1423 seg->SetPoint( otherPin->
GetAbsXY() );
1446 ResetPositionsToOrignals();
1453 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1455 if ( !(*iter)->IsConnect() )
1471 RerouteWire( wire, again );
1482 bool displaced =
true;
1483 unsigned int trials = 0;
1484 while ( displaced && trials < 10000 )
1488 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1517 if( pin->
GetName() == wxT(
"begin" ) )
1520 seg->SetPoint( otherPin->
GetAbsXY() );
1522 else if( pin->
GetName() == wxT(
"end" ) )
1525 seg->SetPoint( otherPin->
GetAbsXY() );
1573 for( a2dCanvasObjectList::iterator iter = m_wiresEditCopies->begin(); iter != m_wiresEditCopies->end(); ++iter )
1582 if ( !m_noEditCopy )
1583 target = wxStaticCastNull( a2dCanvasObject::PROPID_Original->GetPropertyValue( wire ).Get(),
a2dWirePolylineL );
1592 if( !pin )
continue;
1596 if ( !m_noEditCopy )
1597 targetPin = wxStaticCastNull( a2dCanvasObject::PROPID_Original->GetPropertyValue( pin ).Get(),
a2dPin );
1626 m_wiresEditCopies->clear();
1627 for( a2dCanvasObjectList::iterator iter = m_wires->begin(); iter != m_wires->end(); ++iter )
1630 setp.SetSkipNotRenderedInDrawing(
true );
1631 setp.Start( *iter );
1637 OptimizeRerouteWires(
true );
1644 double seg1seg2Slope = 0;
1645 double seg2seg3Slope = 0;
1646 bool seg1seg2Same =
false;
1647 bool seg2seg3Same =
false;
1649 if ( seg1->
m_x == seg2->
m_x )
1651 if ( seg1->
m_y == seg2->
m_y )
1653 seg1seg2Same =
true;
1656 if ( pinangle == 0 || pinangle == 180 )
1659 seg1seg2Slope = DBL_MAX;
1662 seg1seg2Slope = DBL_MAX;
1665 seg1seg2Slope = ( seg1->
m_y - seg2->
m_y ) / ( seg1->
m_x - seg2->
m_x );
1667 if ( seg2->
m_x == seg3->
m_x )
1669 if ( seg2->
m_y == seg3->
m_y )
1671 seg2seg3Same =
true;
1674 seg2seg3Slope = seg1seg2Slope;
1677 seg2seg3Slope = DBL_MAX;
1680 seg2seg3Slope = ( seg2->
m_y - seg3->
m_y ) / ( seg2->
m_x - seg3->
m_x );
1685 if ( !seg1->GetBin() &&
1687 ( seg1seg2Slope == 0 && seg2seg3Slope == 0 )||
1688 ( seg1seg2Slope == DBL_MAX && seg2seg3Slope == DBL_MAX ) ||
1689 ( seg1seg2Slope == 0 && seg2seg3Slope == DBL_MAX ) ||
1690 ( seg1seg2Slope == DBL_MAX && seg2seg3Slope == 0 )
1698 if ( seg1seg2Slope == 0 && seg2seg3Slope == 0 )
1700 if ( seg1seg2Same && seg2seg3Same )
1702 else if ( seg2seg3Same )
1713 else if ( seg1seg2Slope == DBL_MAX && seg2seg3Slope == DBL_MAX )
1715 if ( seg1seg2Same && seg2seg3Same )
1717 else if ( seg2seg3Same )
1728 else if ( seg1seg2Slope == 0 && seg2seg3Slope == DBL_MAX )
1730 else if ( seg1seg2Slope == DBL_MAX && seg2seg3Slope == 0 )
1738 seg1->SetBin(
true );
1779 wirePinClassThis = wire->GetStartPinClass();
1780 wirePinClassOther = wire->GetEndPinClass();
1781 if ( pinThis && pinOther )
1786 if ( thisPinClass->
CanConnectTo( wire->GetStartPinClass() ) && otherPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1790 else if ( otherPinClass->
CanConnectTo( wire->GetStartPinClass() ) && thisPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1802 if ( thisPinClass->
CanConnectTo( wire->GetStartPinClass() ) )
1806 else if ( thisPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1815 else if ( pinOther )
1818 if ( otherPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1822 else if ( otherPinClass->
CanConnectTo( wire->GetStartPinClass() ) )
1850 thisPinClass = otherPinClass;
1851 otherPinClass = swapPinClass;
1861 parent->
Append( connect );
1865 wire->AddPoint( pinThis->
GetAbsX(), pinThis->
GetAbsY(), -1 , true );
1868 connect->
ConnectPins( parent, pinThis, begin, undo );
1877 wire->AddPoint( pinOther->
GetAbsX(), pinOther->
GetAbsY(), -1 , true );
1879 wirePinClassOther );
1880 connect->
ConnectPins( parent, pinOther, end, undo );
1884 wirePinClassOther );
1895 wirePinClassThis, true );
1902 wirePinClassThis, true );
1909 wirePinClassOther, true );
1916 wirePinClassOther, true );
1920 wire->SetConnectionInfo(
true, thisPinClass, otherPinClass );
1933 if ( thisPinClass && otherPinClass )
1935 if ( thisPinClass->
CanConnectTo( wire->GetStartPinClass() ) && otherPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1939 else if ( otherPinClass->
CanConnectTo( wire->GetStartPinClass() ) && thisPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1948 else if ( thisPinClass )
1950 if ( thisPinClass->
CanConnectTo( wire->GetStartPinClass() ) )
1954 else if ( thisPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1963 else if ( otherPinClass )
1965 if ( otherPinClass->
CanConnectTo( wire->GetEndPinClass() ) )
1969 else if ( otherPinClass->
CanConnectTo( wire->GetStartPinClass() ) )
1991 if ( !m_generatePins )
1998 bool found =
object->GeneratePins( pinClass, task, x, y, margin );
2004 wxASSERT_MSG( pinClass, wxT(
"pinClass cannot be NULL, maybe use a2dPinClass::Any?" ) );
2076 ic.SetHitMarginWorld( 0 );
2078 ic.SetHitMarginDevice( 0 );
2090 ic.SetLayer( wxLAYER_ALL );
2092 generateconnectpins.SetBoundingBoxCondition(
_ON |
_IN );
2093 generateconnectpins.SetBoundingBox(
a2dBoundingBox( x - m , y - m , x + m , y + m ) );
2099 return generateconnectpins.Start( ic, root );
2103 ic.SetLayer( wxLAYER_ALL );
2105 return generateconnectpins.Start( ic, root,
false );
2111 double x = pinToConnectTo->
GetAbsX();
2112 double y = pinToConnectTo->
GetAbsY();
2119 findconnectpins.StopAtFirst(
true );
2120 findconnectpins.
Start( root );
2122 if ( findconnectpins.
m_found.size() )
2178 findconnectpins.StopAtFirst(
true );
2179 findconnectpins.
Start( root );
2181 m_returnPinClass = findconnectpins.m_returnPinclass;
2182 m_returnConnect = NULL;
2184 if ( findconnectpins.
m_found.size() )
2199 resetpins.
Start( root );
2205 endstate.
Start( root );
2210 if ( !m_generatePins )
2225 feedbconnections.Start( ic, root );
2232 connectWherePossible.Start( root,
true );
2265 wireio->SetStartPinClass(
Input );
2266 wireio->SetEndPinClass(
Output );
2269 wireio->
SetEnd( arrow2 );
2283 if ( pinClass ==
Input )
2286 if ( pinClass ==
Output )
2292 if ( pinClass ==
Input )
2295 if ( pinClass ==
Output )
2359 wireio->SetStartPinClass(
Wire );
2360 wireio->SetEndPinClass(
Wire );
2366 wireio->
SetEnd( arrow2 );
2380 if ( pinClass ==
Object )
2383 if ( pinClass ==
Wire )
2389 if ( pinClass ==
Object )
2392 if ( pinClass ==
Wire )
2477 wireio->
SetEnd( arrow2 );
2623 wireio->
SetEnd( arrow2 );
2668 wireiob->
SetEnd( arrow2b );
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
a2dPin * IsDislocated() const
void SetConnectionGenerator(a2dConnectionGenerator *connectionGenerator)
Set class for generating new connection objects between object and pins.
static const a2dCanvasObjectFlagsMask BIN
double GetAbsY() const
get absolute Y position of the pin ( after applying the parent's matrix and its own matrix ) ...
bool SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask whichobjects=a2dCanvasOFlags::ALL, const a2dBoundingBox &bbox=wxNonValidBbox, const a2dAffineMatrix &tworld=a2dIDENTITY_MATRIX)
set all given bit flags at once recursive for all objects in given boundingbox
Temporary object used in editing connected objects.
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Base class for all types of strokes, understood by a2dDrawer2D classes.
virtual bool GeneratePinsToConnectObject(a2dDrawingPart *part, a2dCanvasObject *root, a2dCanvasObject *connectObject, a2dPinClass *pinClassToConnectTo=NULL, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
Generate pins on objects, and test which can connect to the given object.
a2dConnectionGeneratorInOut()
constructor
Generate pins on objects, which can connect to the given pinclass.
a2dCanvasObject * GetConnectObjectFlowB() const
return connect object.
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
static a2dPinClass * WireOutput
Pins of this class can only connect to ObjectOutput pins.
virtual a2dCanvasObject * CreateConnectObject(a2dCanvasObject *parent, a2dPin *pinThis, a2dPin *pinOther, bool undo=false) const
create connection object based on two pins which need to be connected.
#define a2dACCUR
accuracy used to have some limit to calculation like hittesting
~a2dConnectionGeneratorTwoFlow()
destructor
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
if set, set in the clone the PROPID_Original property to the copied object
a2dCanvasObjectPtr m_tmplObjectFlowB
Template for created object which represents a connection. e.g a2dWirePolylineL.
Remove original and replace with one straight segment, dynamic pins move with segment.
generate pins, given Connect/wire pinclass
class to map references to objects stored in XML, in order to make the connection later on...
a2dPin * FindEndPin()
Get the end pin from the childs.
virtual a2dPin * SearchPinForFinishWire(a2dCanvasObject *root, a2dPin *pinToConnectTo, a2dPinClass *pinClassToConnectTo, double margin, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
static a2dPinClass * Output
Pins of this class can only connect to Input pins.
unsigned int GetChildObjectsCount() const
get number of child objects
~a2dConnectionGeneratorInOut()
destructor
a2dCanvasObjectList m_found
pins found
Add manhattan lines to end.
Find pins in view, which can connect to the given pinclass.
void SetAnyPinClass(a2dPinClass *pinClass)
see GetAnyPinClass()
a2dPin is used in a2dCanvasObject to add pins to it.
This is a class/type description for a2dPin's.
used to add points to polygon objects
virtual a2dPinClass * GetPinClassForTask(a2dPinClass *pinClass, a2dConnectTask task, a2dCanvasObject *obj=NULL, a2dPinClass *pinClassTo=NULL, a2dPin *pinFrom=NULL) const
return a a2dPinClass which should be used to connect to the input a2dPinClass.
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
a2dConnectionGeneratorObjectWire()
constructor
void AddConnect(a2dPinClass *pinClass)
add a connection pinclass, to which this pin can connect
virtual a2dPinClass * GetPinClassForTask(a2dPinClass *pinClass, a2dConnectTask task, a2dCanvasObject *obj=NULL, a2dPinClass *pinClassTo=NULL, a2dPin *pinFrom=NULL) const
return a a2dPinClass which should be used to connect to the input a2dPinClass.
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
~a2dConnectionGeneratorDirectedFlow()
destructor
static a2dPinClass * Input
Pins of this class can only connect to Output pins.
generate pins, given Connect/wire pinclass
static a2dPinClass * Object
Pins of this class can only connect to Wire pins.
if set, clone childs, otherwise ref-copy them
void OptimizeRerouteWires(a2dCanvasObject *parent, bool removeZero=true, bool allowredirect=true)
a command processor specially designed to work with a a2dCanvasDocument
virtual void SetPending(bool pending)
set this object pending for update
a2dPin * IsConnectedTo(a2dPin *pin=a2dAnyPin) const
Return the pin to which this pin is connected.
The base class for all drawable objects in a a2dCanvasDocument.
void SetReroute(bool onOff)
indicated if the wire still needs to be rerouted, used in routing algorithms of wire between objects...
static a2dPinClass * FlowAWireInput
Pins of this class can only connect to FlowAWireOutput and FlowAOutput pins.
Remove original and replace with manhattan lines.
a2dPoint2D GetAbsXY() const
get absolute position of the pin ( after applying the parent's matrix and its own matrix ) ...
a2dCanvasObject is the base class for Canvas Objects.
~a2dConnectionGenerator()
destructor
wxUint32 GetConnectedPinsNr() const
Get the number of connected pins.
bool RemoveReference(const wxString &idToRemove)
remove given reference if from reference map.
virtual a2dPinClass * GetPinClassForTask(a2dPinClass *pinClass, a2dConnectTask task, a2dCanvasObject *obj=NULL, a2dPinClass *pinClassTo=NULL, a2dPin *pinFrom=NULL) const
return a a2dPinClass which should be used to connect to the input a2dPinClass.
virtual bool GeneratePossibleConnections(a2dCanvasObject *object, a2dPinClass *pinClass, a2dConnectTask task, double x, double y, double margin) const
generate temporary pins to which objects can connect
a2dCanvasObjectList m_found
pins found
a2dPinClass * CanConnectTo(a2dPinClass *other=NULL) const
searches in the connection list for a given pin class
void SetEditable(bool editable)
Sets if this object may be edited.
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
vertex list of line and arc segments.
virtual void SetPinsToEndState(a2dCanvasObject *root, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
set end state of pins after tool is finsihed
a2dCanvasObject * GetConnectObject() const
return connect object.
void SetHitMarginWorld(double world)
used to extend a hittest with the given margin in world coordinates.
static a2dPinClass * ObjectInput
Pins of this class can only connect to WireInput pins.
static a2dPinClass * FlowBWireInput
Pins of this class can only connect to FlowBWireOutput and FlowBOutput pins.
a2dConnectionGenerator()
constructor
void SetBin(bool bin)
general flag use at will.
static a2dPinClass * FlowBWireOutput
Pins of this class can only connect to FlowBInput and FlowBWireInput pins.
void RotateRouteMethod()
cycle through routing methods
int FindPinSegmentIndex(a2dPin *pinToFind, double margin=a2dACCUR)
find the index of the segment where the pin is on.
~a2dConnectionGeneratorObjectWire()
destructor
find wire/connect pinclass, given start pinclass of start pin
void CreateWiresOnPins(a2dCanvasObject *parent, const a2dCanvasObjectList &objectsToDrag, bool undo, bool onlyNonSelected=false)
create wires on pins which do not have wires, but directly are connected to other objects...
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
bool MoveDynamicPinCloseTo(a2dPin *pin, const a2dPoint2D &point, bool final)
Move the given dynamic pin close to the given absolute point.
a2dWirePolylineL is a polyline that adjusts itself when the objects it connects move ...
bool Disconnect(a2dPin *pin=a2dAnyPin, bool forceErase=false)
void ConnectPins(a2dCanvasObject *parent, a2dPin *pinc, a2dPin *pinother, bool undo=false)
connect two pins which must be unconnected and at the same position
used to change a property on objects
a2dConnectionGeneratorTwoFlow()
constructor
void SetConnectObject(a2dCanvasObject *tmplObject)
the template object is used as a template for creating new wires between pins.
void SetPriority(wxUint8 priority)
used to set order of rerouting in a set of lines.
#define forEachIn(listtype, list)
easy iteration for a2dlist
a2dCanvasObjectPtr m_tmplObject
Template for created object which represents a connection. e.g a2dWirePolylineL.
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
void AdjustBeginEndPinAngle()
adjust pin angles to the last segment at end and begin of wire.
double GetPosX() const
get x position from affine matrix
void SetHitMarginDevice(int pixels)
used to extend a hittest with the number of pixels.
void SetSegments(a2dVertexList *points)
Set the list of points ( the old list is NOT DELETED !!! )
bool GetRouteOneLine() const
see SetRouteOneLine()
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
bool Start(a2dCanvasObject *object)
Start traversing at object, returns true.
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Normal straight line segment in a2dVertexList and a2dVertexArray.
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
virtual a2dPin * SearchPinForStartWire(a2dCanvasObject *root, double xpin, double ypin, a2dPinClass *pinClassToConnectTo, double margin, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
Class for rerouting wires.
used to disconnect two pins
static std::list< a2dPinClass * > m_allPinClasses
a linked lists of all a2dPinClass'es, so that one can get a class by name
bool FindConnectedWires(a2dCanvasObjectList &result, a2dPin *pin, bool walkWires=true, bool selectedEnds=false, bool stopAtSelectedWire=false, bool addToResult=false)
find wires on pins of this objects.
bool HasPins(bool realcheck=false)
are there a2dPin derived children
static a2dPinClass * FlowAInput
Pins of this class can only connect to FlowAWireOutput and FlowAOutput pins.
bool IsSelected() const
Is the object selected flag set.
bool GetBin() const
general flag use at will.
static const a2dCanvasObjectFlagsMask EditingCopy
void SetBoundingBoxCondition(wxUint16 intersectionCondition)
if boundingbox is set, the object is testen against this condition, default _IN
a2dPin * AddPin(const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass *pinClass, bool undo=false)
add a a2dPin as child
virtual a2dCanvasObject * GetConnectTemplate(const a2dCanvasObject *object, a2dPinClass *thisPinClass, const a2dCanvasObject *other, a2dPinClass *otherPinClass) const
create connection object based on two pin classes, which (may) need to be connected.
a2dPin * FindBeginPin()
Get the begin pin from the childs.
Remove from property in a hierarchy of a canvas document.
Contains a2dDrawing Class to hold a drawing.
used to set the complete Segment list/array of polygons
static a2dPinClass * FlowBOutput
Pins of this class can only connect to FlowBWireInput and FlowBInput pins.
a2dArrow is used for having line begin and ends on specific objects.
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
used to add object to a a2dCanvasDocument in the current parent
Keep manhattan lines at end intact.
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
virtual a2dPinClass * GetPinClassForTask(a2dPinClass *pinClass, a2dConnectTask task, a2dCanvasObject *obj=NULL, a2dPinClass *pinClassTo=NULL, a2dPin *pinFrom=NULL) const
return a a2dPinClass which should be used to connect to the input a2dPinClass.
A 2x3 affine matrix class for 2D transformations.
a2dPoint2D GetPosXY() const
get position of object
Same as StraightSegment, unless there are dynamic pins on segment.
int GetPinCount()
How many a2dPin derived children are there.
static a2dPinClass * FlowAWireOutput
Pins of this class can only connect to FlowAInput and FlowAWireInput pins.
bool IsDynamicPin() const
return true if this pin is a dynamic pin
a2dPinClass * GetPinClass() const
return the pin class of this pin
void AutoConnect(a2dCanvasObject *root, double margin)
Try to connect this pin to another pin at the same location.
bool m_reverseCreate
how to create a connection
if set, set in the clone the PROPID_editcopy property to the original object
double GetPosY() const
get y position from affine matrix
while iterating a a2dCanvasDocument, this holds the context.
double m_x
x endpoint of line
a2dWalker based algorithms
void Remove180DegPoints(a2dCanvasObject *sendCommandsTo=NULL, bool removeZeroFirst=true)
remove segments which are opposite direction overlapping.
a2dlist< a2dDumbPtr< a2dPin > > & GetConnectedPins()
Return list fo connected pins.
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
a2dBoundingBox GetMappedBbox(a2dIterC &ic, bool withExtend=true)
first translate boundingbox with cworld and recalculate at new position
double m_y
y endpoint of line
virtual bool Submit(a2dCommand *command, bool storeIt=true)
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.
Reuse last straight segment at begin or end of line, dynamic pins move with segment.
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.
used to release object from a a2dCanvasDocument in the current parent
void SetBoundingBox(const a2dBoundingBox &bbox)
if valid, objects must fit in this boundingbox
static const a2dCanvasObjectFlagsMask VISIBLE
wxString GetName() const
get the name given to the pin.
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
double GetAbsAngle() const
get absolute angle of the pin ( after applying the parent its matrix and it own matrix ) ...
a2dPinClass * m_anypinclass
template pinclass
Generate pins on objects, and test which can connect to the given object.
bool GetRelease() const
get release flag
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
wire classes for connecting objects.
double GetHitMarginWorld()
Get HitMargin in World units.
bool Start(a2dCanvasObject *object)
Start traversing at object, returns true.
An object of this class will update a a2dIterC with the required information.
a2dConnectionGeneratorDirectedFlow()
constructor
virtual a2dCanvasObject * CreateConnectObject(a2dCanvasObject *parent, a2dPin *pinThis, a2dPin *pinOther, bool undo=false) const
create connection object based on two pins which need to be connected.
Set pins in begin state after wiring up some pins.
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
Same as StraightEndSegment, unless there are dynamic pins on segment.
bool GetRouteOneLine()
see SetRouteOneLine()
bool RerouteWire(a2dWirePolylineL *wire, a2dPin *dispin, a2dPin *startpin, bool startisbegin, bool final)
Reroute a wire.
void PrepareForRerouteWires(a2dBaseTool *tool=NULL, a2dRefMap *refs=NULL)
static a2dPinClass * FlowAOutput
Pins of this class can only connect to FlowAWireInput and FlowAInput pins.
bool Start(a2dCanvasObject *object)
called from within a2dCanvasDocument
Convert straight segments to manhattan lines and keep manhattan lines at end intact.
static a2dPinClass * ObjectOutput
Pins of this class can only connect to WireOutput pins.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
bool Invert(void)
Invert matrix.
virtual void SetPinsToBeginState(a2dCanvasObject *root, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::VISIBLE)
set begin state of pins, before a tools starts asking feedback or after tool is finsihed ...
void SetRerouteAdded(bool onOff)
indicated if the wire is added recently to be rerouted, used in routing algorithms of wire between ob...
Classes for generating connection between pins in canvas objects.
double Length()
calculate length of path
static bool GetWorldBased()
get if pin sizes are in world coordinates, else it is in pixels.
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
void SetPosXyPoint(const a2dPoint2D &pos)
set position to x,y
bool Start(a2dCanvasObject *object)
called from within a2dCanvasDocument
void SetConnectObjectFlowB(a2dCanvasObject *tmplObject)
the template object is used as a template for creating new wires between pins.
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
virtual bool AdjustAfterChange(bool final)
virtual a2dPinClass * GetPinClassForTask(a2dPinClass *pinClass, a2dConnectTask task, a2dCanvasObject *obj=NULL, a2dPinClass *pinClassTo=NULL, a2dPin *pinFrom=NULL) const
return a a2dPinClass which should be used to connect to the input a2dPinClass.
size_t GetNumberOfSegments()
get the number of points in the pointlist
Reroute using Lee routing.
static a2dPinClass * Wire
Pins of this class can only connect to Object pins.
Connect objects, which can connect to the given object.
wxUint8 GetPriority() const
See SetPriority()
double GetAbsX() const
get absolute X position of the pin ( after applying the parent's matrix and its own matrix ) ...
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
a2dCanvasObject * GetParent() const
get parent object of the pin
void SetEnd(a2dCanvasObject *end)
set object to draw as end point
void SetAngleLine(bool value)
is there an angle line on the pin
Set pins in end state after wiring up some pins.
virtual bool IsConnect() const
return true, if this object is used to connect other object's using rubberband like structures...
static a2dPinClass * FlowBInput
Pins of this class can only connect to FlowBWireOutput and FlowBOutput pins.
find normal object pinclass, given Connect/wire pinclass
when a new wire or other connection object needs to be created,
bool GetReroute() const
see SetReroute()
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
bool EliminateMatrix()
reduce matrix to identity without replacing object
general canvas module declarations and classes
static a2dPinClass * WireInput
Pins of this class can only connect to ObjectInput pins.