43 const a2dCommandId a2dCommand_SplitAtPin::Id( wxT(
"SplitAtPin" ) );
45 a2dCommand_SplitAtPin::a2dCommand_SplitAtPin(
a2dCanvasObject* parent,
a2dPin* splitPin,
double hitMargin )
48 m_splitPin = splitPin;
51 m_hitMargin = hitMargin;
54 a2dCommand_SplitAtPin::~a2dCommand_SplitAtPin()
60 m_splitPinClone = m_wire->
SplitAtPin( m_parent, m_splitPin, NULL, NULL, m_hitMargin );
63 if ( m_splitPinClone )
71 bool done = wire->
JoinAtPin( m_parent, m_splitPin, m_splitPinClone );
78 m_wire->
SplitAtPin( m_parent, m_splitPin, m_splitPinClone, m_clone, m_hitMargin );
86 const a2dCommandId a2dCommand_JoinAtPin::Id( wxT(
"JoinAtPin" ) );
92 m_joinPin2 = joinPin2;
95 m_secondRedirect =
false;
99 a2dCommand_JoinAtPin::~a2dCommand_JoinAtPin()
105 a2dPin* beginConnected = m_wirePin2->FindBeginPin();
106 a2dPin* endConnected = m_wirePin2->FindEndPin();
109 bool done = m_wire->
MergAtPin( m_parent, m_joinPin, m_joinPin2, m_inFront, m_secondRedirect );
111 if ( m_secondRedirect )
114 m_renamedPin = endConnected;
116 m_renamedPin = beginConnected;
126 m_wirePin2->SetRelease(
false );
156 iterpins = m_wirePin2->GetChildObjectList()->begin();
157 while( iterpins != m_wirePin2->GetChildObjectList()->end() )
168 m_parent->
Append( m_wirePin2 );
170 if ( m_secondRedirect && m_renamedPin )
173 m_renamedPin->
SetName( wxT(
"end" ) );
175 m_renamedPin->
SetName( wxT(
"begin" ) );
186 bool done = m_wire->
MergAtPin( m_parent, m_joinPin, m_joinPin2, m_inFront, m_secondRedirect );
195 const a2dCommandId a2dCommand_EliminateMatrix::Id( wxT(
"EliminateMatrix" ) );
197 a2dCommand_EliminateMatrix::a2dCommand_EliminateMatrix(
a2dWirePolylineL* wire )
202 a2dCommand_EliminateMatrix::~a2dCommand_EliminateMatrix()
245 const a2dCommandId a2dCommand_RemoveZeroWire::Id( wxT(
"RemoveZeroWire" ) );
255 a2dCommand_RemoveZeroWire::~a2dCommand_RemoveZeroWire()
264 wxASSERT_MSG( begin->
GetConnectedPinsNr() == 1,
"Can only be used with one connected pin" );
265 wxASSERT_MSG( end->
GetConnectedPinsNr() == 1,
"Can only be used with one connected pin" );
273 if ( m_joinPin != m_joinPin2 )
274 m_joinPin->ConnectTo( m_joinPin2 );
282 if ( obj && obj == m_wire )
297 m_parent->
Append( m_wire );
302 if ( m_joinPin != m_joinPin2 )
323 EVT_CHAR( a2dWirePolylineL::OnChar )
326 a2dWirePolylineL::a2dWirePolylineL()
333 m_wasVertical =
false;
336 m_rerouteAdd =
false;
338 m_flags.m_generatePins =
true;
341 a2dWirePolylineL::a2dWirePolylineL(
a2dVertexList* points,
bool spline )
349 m_wasVertical =
false;
352 m_rerouteAdd =
false;
354 m_flags.m_generatePins =
true;
369 m_oneLine = poly.m_oneLine;
371 m_rerouteAdd =
false;
376 a2dWirePolylineL::~a2dWirePolylineL()
408 if ( m_lsegments->size() < 2 )
420 if( pin->
GetName() == wxT(
"begin" ) )
427 double angle =
wxRadToDeg( atan2( yb-ybp, xb-xbp ) );
431 else if( pin->
GetName() == wxT(
"end" ) )
438 double angle =
wxRadToDeg( atan2( ye-yep, xe-xep ) );
448 bool changed =
false;
466 else if( pin->
GetName() == wxT(
"begin" ) )
471 if( xNew != xOld || yNew != yOld )
481 else if( pin->
GetName() == wxT(
"end" ) )
486 if( xNew != xOld || yNew != yOld )
503 wxASSERT_MSG( splitPin->
GetParent() ==
this,
"splitPin not part of wire" );
505 if ( splitPin->
GetName() == wxT(
"end" ) || splitPin->
GetName() == wxT(
"begin" ) )
512 a2dVertexList::iterator iter = m_lsegments->item( hit.
m_index );
516 clone->m_lsegments->clear();
518 a2dVertexList::iterator iterc = clone->m_lsegments->begin();
519 clone->m_lsegments->splice( iterc, *m_lsegments, ++iter, m_lsegments->end() );
534 a2dPin* thisPinToPart2 = begin;
540 thisPinToPart2 = end;
542 bool foundSplitPin =
false;
553 if ( pin == splitPin )
554 foundSplitPin =
true;
560 if ( pin != thisPinToPart2 )
580 if ( !foundSplitPin )
583 if ( !splitPinClone )
588 splitPinClone->
SetName( wxT(
"begin" ) );
589 splitPin->
SetName( wxT(
"end" ) );
593 splitPin->
SetName( wxT(
"begin" ) );
594 splitPinClone->
SetName( wxT(
"end" ) );
597 clone->
Append( splitPinClone );
602 return splitPinClone;
609 wxASSERT_MSG( joinPin->
GetParent() ==
this,
"splitPin not part of wire" );
611 if ( joinPin->
GetName() != wxT(
"end" ) && joinPin->
GetName() != wxT(
"begin" ) )
614 if ( joinPinOther->
GetName() != wxT(
"end" ) && joinPinOther->
GetName() != wxT(
"begin" ) )
619 a2dVertexList::iterator iter = m_lsegments->end();
620 m_lsegments->pop_back();
621 clone->m_lsegments->pop_front();
623 m_lsegments->insert ( iter, clone->m_lsegments->begin(), clone->m_lsegments->end() );
630 a2dCanvasObjectList::iterator iterpins = clone->
m_childobjects->begin();
646 if ( pin != joinPinOther )
652 joinPin->
SetName( wxT(
"dynamic" ) );
660 if ( obj && obj == clone )
670 wxASSERT_MSG( joinPin->
GetParent() ==
this,
"splitPin not part of wire" );
672 if ( joinPin->
GetName() != wxT(
"end" ) && joinPin->
GetName() != wxT(
"begin" ) )
675 if ( joinPinOther->
GetName() != wxT(
"end" ) && joinPinOther->
GetName() != wxT(
"begin" ) )
687 if ( begin == joinPin && joinPinOther == endConnected )
690 a2dVertexList::reverse_iterator iwireConnected = wireConnected->
GetSegments()->rbegin();
692 for( iwireConnected; iwireConnected != wireConnected->
GetSegments()->rend(); ++iwireConnected )
693 m_lsegments->push_front( *iwireConnected );
695 else if ( end == joinPin && joinPinOther == endConnected )
697 secondRedirect =
true;
698 if ( beginConnected )
699 beginConnected->
SetName(
"end" );
700 a2dVertexList::reverse_iterator iwireConnected = wireConnected->
GetSegments()->rbegin();
702 for( iwireConnected; iwireConnected != wireConnected->
GetSegments()->rend(); ++iwireConnected )
703 m_lsegments->push_back( *iwireConnected );
705 else if ( end == joinPin && joinPinOther == beginConnected )
707 a2dVertexList::iterator iwireConnected = wireConnected->
GetSegments()->begin();
709 for( iwireConnected; iwireConnected != wireConnected->
GetSegments()->end(); ++iwireConnected )
710 m_lsegments->push_back( *iwireConnected );
712 else if ( begin == joinPin && joinPinOther == beginConnected )
715 secondRedirect =
true;
717 endConnected->
SetName(
"begin" );
718 a2dVertexList::iterator iwireConnected = wireConnected->
GetSegments()->begin();
720 for( iwireConnected; iwireConnected != wireConnected->
GetSegments()->end(); ++iwireConnected )
721 m_lsegments->push_front( *iwireConnected );
738 if ( pin == joinPin )
761 if ( pin != joinPinOther )
776 if ( obj && obj == wireConnected )
795 m_lsegments->reverse();
798 void a2dWirePolylineL::OnChar( wxKeyEvent& event )
802 switch( event.GetKeyCode() )
811 if ( m_lsegments->size() <= 2 )
813 wxLogWarning( _(
"stopped removing segment or vertexes, object should keep at least one segment" ) );
819 if ( m_lsegments->size() <= 2 )
821 wxLogWarning( _(
"stopped removing segment or vertexes, object should keep at least one segment" ) );
830 a2dVertexList::iterator iterpoly = handle->GetNode();
832 if ( segment->GetBin() )
834 if ( handle->
GetPin() == begin || handle->
GetPin() == end )
836 wxLogWarning( _(
"end or begin pins maybe not be deleted this way, select and remove whole wire instead" ) );
843 if ( handle2->
GetPin() == begin || handle2->
GetPin() == end )
845 wxLogWarning( _(
"end or begin pins maybe not be deleted this way, select and remove whole wire instead" ) );
858 iterpoly = m_lsegments->erase( iterpoly );
859 (*iterpoly)->m_x = xn; (*iterpoly)->m_y = yn;
876 if ( handle->
GetPin() == begin || handle->
GetPin() == end )
878 wxLogWarning( _(
"end or begin pins maybe not be deleted this way, select and remove whole wire instead" ) );
882 a2dVertexList::iterator iterpoly = handle->GetNode();
884 a2dVertexList::iterator iterorg = handle->GetNodeOrg();
887 if ( m_lsegments->size() <= 2 )
889 wxLogWarning( _(
"stopped removing segment or vertexes, object should keep at least one segment" ) );
895 m_lsegments->erase( iterpoly );
929 a2dVertexList::iterator iter = m_lsegments->begin();
930 a2dVertexList::iterator iterorg = original->
GetSegments()->begin();
995 #if wxART2D_USE_CVGIO
999 if ( xmlparts == a2dXmlSer_attrib )
1001 out.WriteAttribute( wxT(
"invert" ),
m_inverted );
1002 out.WriteAttribute( wxT(
"pcobjbegin" ),
m_objBegin->GetName() );
1003 out.WriteAttribute( wxT(
"pcwirebegin" ),
m_wireBegin->GetName() );
1004 out.WriteAttribute( wxT(
"pcwireend" ),
m_wireEnd->GetName() );
1013 if ( xmlparts == a2dXmlSer_attrib )
1024 wxString reference_name =
GetName();
1025 a2dGeneralGlobals->ReportErrorF(
a2dError_NoPinClass, _(
"a2dWirePolylineL with name %s \n Pin class %s not found (replaced with Standard)" ), reference_name.c_str(), pinclass.c_str() );
1033 wxString reference_name =
GetName();
1034 a2dGeneralGlobals->ReportErrorF(
a2dError_NoPinClass, _(
"a2dWirePolylineL with name %s \n Pin class %s not found (replaced with Standard)" ), reference_name.c_str(), pinclass.c_str() );
1042 wxString reference_name =
GetName();
1043 a2dGeneralGlobals->ReportErrorF(
a2dError_NoPinClass, _(
"a2dWirePolylineL with name %s \n Pin class %s not found (replaced with Standard)" ), reference_name.c_str(), pinclass.c_str() );
1050 #endif //wxART2D_USE_CVGIO
1060 double xNext, yNext;
1062 bool isHor = fabs( yPre - yNext ) <= 1e-10 * wxMax( fabs( yPre ), fabs( yNext ) );
1063 bool isVert = fabs( xPre - xNext ) <= 1e-10 * wxMax( fabs( xPre ), fabs( xNext ) );
1066 if( isHor && ! isVert || isHor && isVert && !
m_wasVertical )
1089 , wxT(
"pinclass connection generator not set" ) );
1110 a2dPinClass* toCreate = toConnectTo->GetPinClassForTask( task,
this );
1118 a2dVertexList::iterator iter = m_lsegments->begin();
1119 assert( m_lsegments->size() );
1127 a2dVertexList::iterator iter = m_lsegments->end();
1128 assert( m_lsegments->size() );
1135 if ( m_lsegments->size() > 0 )
1138 double xNear, yNear;
1142 if ( hit.
IsHit() && ( hit.m_stroke2 == a2dHit::stroke2_edgevert || hit.m_stroke2 == a2dHit::stroke2_edgehor ) )
1151 a2dRestrictionEngine::snapToGridPos |
1161 double xNearLocal, yNearLocal;
1163 double dx = fabs( xNear - x );
1164 double dy = fabs( yNear - y );
1165 if ( margin && ( dx > margin || dy > margin ) )
1168 bool reuseTempPin =
false;
1175 pin->
SetPosXY( xNearLocal, yNearLocal );
1177 reuseTempPin =
true;
1182 if ( !reuseTempPin )
1187 pin->SetMouseInObject(
true );
1219 if ( begin != pin && end != pin )
1256 savepins.push_back( pin );
1260 for( a2dCanvasObjectList::iterator iterpins = savepins.begin(); iterpins != savepins.end(); ++iterpins )
1263 a2dPinList::const_iterator iterconp;
1269 for ( iterconp = savepinsother.begin( ) ; iterconp != savepinsother.end( ) ; iterconp++ )
1271 a2dPin* otherpin = *iterconp;
1282 if ( wireConnected &&
1283 ( wireConnected !=
this ) &&
1298 if ( begin == pin && otherpin == endConnected )
1302 else if ( allowredirect && end == pin && otherpin == endConnected )
1306 else if ( end == pin && otherpin == beginConnected )
1310 else if ( allowredirect && begin == pin && otherpin == beginConnected )
1325 a2dWireEnd::a2dWireEnd(
double x ,
double y )
1337 return new a2dWireEnd( *
this, options, refs );
1361 wxString m_VirtWireName;
1364 const a2dCommandId a2dCommand_VirtWire::Id(
"a2dVirtWire" );
1366 a2dCommand_VirtWire::a2dCommand_VirtWire(
a2dVirtWire* target,
const wxString& VirtWireName )
1370 m_VirtWireName = VirtWireName;
1373 a2dCommand_VirtWire::~a2dCommand_VirtWire(
void )
1379 wxString VirtWireName = m_target->GetVirtWireName();
1380 m_target->SetVirtWireName( m_VirtWireName );
1382 m_VirtWireName = VirtWireName;
1400 m_VirtWireName( VirtWireName ),
1403 m_flags.m_generatePins =
false;
1404 m_text =
" " + VirtWireName;
1412 : a2dText( other, options, refs ),
1413 m_parent( other.m_parent )
1415 m_VirtWireName = other.m_VirtWireName;
1416 m_text =
" " + m_VirtWireName;
1426 bool hasConnectedPins =
false;
1435 if ( virtConnect && !virtConnect->
GetBin() && virtConnect !=
this && !virtConnect->
GetRelease() && virtConnect->m_VirtWireName == m_VirtWireName )
1437 for( a2dCanvasObjectList::iterator iterpinssignal = virtConnect->
m_childobjects->begin(); iterpinssignal != virtConnect->
m_childobjects->end(); ++iterpinssignal )
1443 if ( pinOtherSignal && !pinOtherSignal->
GetRelease( ) && !pinOtherSignal->
GetBin() )
1445 hasConnectedPins |= virtConnect->
FindConnectedPins( result, NULL, walkWires, searchPinClass, isConnectedTo );
1450 return hasConnectedPins;
1461 int result = dlg.ShowModal();
1462 if (result == wxID_OK)
1467 original->SetEditing(
false );
1476 if ( xmlparts == a2dXmlSer_attrib )
1478 out.WriteAttribute( wxT(
"virtName" ), m_VirtWireName );
1488 if ( xmlparts == a2dXmlSer_attrib )
1497 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
1525 wxDialog::Create( parent, -1, _(
"Wire-Name"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSYSTEM_MENU|
wxCLOSE_BOX|wxTAB_TRAVERSAL );
1526 m_virtWire = virtWire;
1528 GetSizer()->SetSizeHints(
this);
1532 void a2dVirtWireDlg::CreateControls()
1536 bs =
new wxBoxSizer(wxVERTICAL);
1540 bsN =
new wxBoxSizer(wxHORIZONTAL);
1541 bs->Add(bsN, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1542 st =
new wxStaticText(
this, wxID_ANY, _(
"Wire-Name") +
":");
1543 bsN->Add(st, 0, wxALIGN_CENTER_VERTICAL);
1546 wxArrayString names;
1551 if ( virtConnect && !virtConnect->
GetRelease() )
1552 if (names.Index( virtConnect->GetVirtWireName() ) == wxNOT_FOUND)
1553 names.Add( virtConnect->GetVirtWireName() );
1555 m_CBName =
new wxComboBox(
this, wxID_ANY, m_virtWire->GetVirtWireName(), wxDefaultPosition, wxSize(130, -1), names, wxCB_DROPDOWN );
1556 bsN->Add(m_CBName, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1559 wxStdDialogButtonSizer *sdbs =
new wxStdDialogButtonSizer();
1560 bs->Add(sdbs, 0, wxGROW|wxALL, 5);
1561 wxButton *bOk =
new wxButton(
this, wxID_OK, _(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
1562 sdbs->AddButton(bOk);
1563 wxButton *bCancel =
new wxButton(
this, wxID_CANCEL, _(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
1564 sdbs->AddButton(bCancel);
1565 wxButton *bHelp =
new wxButton(
this, wxID_HELP, _(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
1566 sdbs->AddButton(bHelp);
1570 m_CBName->Set(names);
1571 m_CBName->SetStringSelection( m_virtWire->GetVirtWireName() );
1585 #define EQSIGN(x1, x2, x3, x4) ( ( x2 - x1 ) * ( x3 - x4 ) > 0 )
1587 #define CODE(x, y, w, h, px, py, c) { \
1589 if ( px < x ) c = 0x01; \
1590 else if ( px >= x + w ) c = 0x02; \
1591 if ( py < y ) c |= 0x04; \
1592 else if ( py >= y + h ) c |= 0x08; \
1596 a2dSingleRoute::a2dSingleRoute(
double offset,
double smax )
1606 if ( cos( anglerad ) > 0 )
1608 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1610 else if ( sin( anglerad ) > 0 )
1617 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1619 else if ( sin( anglerad ) > 0 )
1626 if ( cos( anglerad ) > 0 )
1628 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1630 else if ( sin( anglerad ) > 0 )
1637 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1639 else if ( sin( anglerad ) > 0 )
1685 if ( cos( anglerad ) > 0 )
1687 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1689 else if ( sin( anglerad ) > 0 )
1696 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1698 else if ( sin( anglerad ) > 0 )
1705 if ( cos( anglerad ) > 0 )
1707 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1709 else if ( sin( anglerad ) > 0 )
1716 if ( fabs( cos( anglerad ) ) > fabs( sin( anglerad )) )
1718 else if ( sin( anglerad ) > 0 )
1746 static int directs[4][4] = {
1747 { TOP, BOTTOM, LEFT, RIGHT },
1748 { BOTTOM, TOP, RIGHT, LEFT },
1749 { RIGHT, LEFT, TOP, BOTTOM },
1750 { LEFT, RIGHT, BOTTOM, TOP }
1755 Transform(DIRECT, diro, xo, yo, xi, yi, &txi, &tyi);
1756 switch ( directs[diro][diri] ) {
1763 Shape5PB(txi, tyi, -1);
1767 Shape5PB(txi, tyi, -1);
1773 Shape5PB(txi, tyi, 1);
1780 Shape5PB(txi, tyi, 1);
1788 Shape6P(txi, tyi, -1);
1792 if ( txi < - m_smax || txi >
m_smax ) {
1796 Shape6P(txi, tyi, 1);
1802 for ( i = 0 ; i < m_pnr ; i++ )
1803 Transform(INVERSE, diro, xo, yo, m_p[i][0], m_p[i][1], &m_p[i][0], &m_p[i][1]);
1820 void a2dSingleRoute::Transform (
int mode,
int dout,
double xout,
double yout,
double x,
double y,
double* tx,
double* ty )
1884 void a2dSingleRoute::Correct (
double x,
double y,
double w,
double h )
1887 double op[2], od[2];
1905 for ( j = 1, i = 2 ; i < m_pnr - 1 ; i++, j++ )
1907 if ( Overcross(x, y, w, h, m_p[j][0], m_p[j][1], m_p[i][0], m_p[i][1]) )
1909 c = ( m_p[j][0] == m_p[i][0] ) ? 0 : 1;
1920 if ( EQSIGN(m_p[j-1][c], m_p[j][c], m_p[i][c], m_p[i+1][c]) )
1922 if ( m_p[j][c] < m_p[j-1][c] )
1923 m_p[j][c] = m_p[i][c] = op[c] -
m_offset + 2;
1925 m_p[j][c] = m_p[i][c] = op[c] + od[c] - 1 + m_offset - 2;
1929 if ( m_p[i][c] < m_p[i+1][c] )
1930 m_p[j][c] = m_p[i][c] = op[c] -
m_offset + 2;
1932 m_p[j][c] = m_p[i][c] = op[c] + od[c] - 1 + m_offset - 2;
1964 int a2dSingleRoute::Overcross (
double x,
double y,
double w,
double h,
double x1,
double y1,
double x2,
double y2 )
1968 CODE(x, y, w, h, x1, y1, c1);
1969 CODE(x, y, w, h, x2, y2, c2);
1970 return(! ( c1 & c2));
1984 void a2dSingleRoute::Shape3P (
double xi,
double yi )
1996 void a2dSingleRoute::Shape4PD (
double xi,
double yi )
2005 m_p[2][1] = m_p[1][1];
2021 void a2dSingleRoute::Shape4PU (
double xi,
double yi )
2028 m_p[1][1] = ( ( yi <= 0 ) ? 0 : yi ) +
m_offset;
2030 m_p[2][1] = m_p[1][1];
2038 m_p[1][1] = ( yi <= 0 ) ? 0 : yi;
2040 m_p[2][1] = m_p[1][1];
2048 void a2dSingleRoute::Shape5PB (
double xi,
double yi,
int sign )
2056 if ( sign * xi < -
m_smax )
2059 m_p[2][0] = ( ( sign * xi < 0 ) ? 0 : xi ) + sign *
m_offset;
2060 m_p[2][1] = m_p[1][1];
2061 m_p[3][0] = m_p[2][0];
2069 if ( sign * xi < -
m_smax )
2072 m_p[1][0] = ( ( sign * xi < 0 ) ? 0 : xi );
2073 m_p[1][1] = m_p[0][1];
2074 m_p[2][0] = m_p[1][0];
2083 void a2dSingleRoute::Shape5PT (
double xi,
double yi,
int sign )
2092 m_p[2][1] = m_p[1][1];
2093 m_p[3][0] = m_p[2][0];
2110 void a2dSingleRoute::Shape6P (
double xi,
double yi,
int sign )
2135 m_p[2][1] = m_p[1][1];
2136 m_p[3][0] = m_p[2][0];
2139 m_p[4][1] = m_p[3][1];
2161 m_p[2][0] = m_p[1][0];
2170 void a2dSingleRoute::Optimize ()
2202 for ( i = 1 ; i < m_pnr ; i++ )
2204 if ( m_p[i][0] == m_p[j][0] && m_p[i][1] == m_p[j][1] )
2209 m_p[j][0] = m_p[i][0];
2210 m_p[j][1] = m_p[i][1];
2218 for ( i = 1 ; i < m_pnr-1 ; i++ )
2220 if ( m_p[i][0] == m_p[j][0] && m_p[i][0] == m_p[i+1][0] ||
2221 m_p[i][1] == m_p[j][1] && m_p[i][1] == m_p[i+1][1] )
2226 m_p[j][0] = m_p[i][0];
2227 m_p[j][1] = m_p[i][1];
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
used to move points in polygon objects
double GetHeight() const
returns height of the boundingbox
virtual bool Undo()=0
Override this to undo a command.
a2dPin * IsDislocated() const
double GetAbsY() const
get absolute Y position of the pin ( after applying the parent's matrix and its own matrix ) ...
specialized command using the Assign method of Taco to transfer changes in editcopy to original...
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.
unsigned int m_index
For edge/vertex hits the index of the edge / vertex.
bool GetGeneratePins() const
get the GeneratePins flag
void Connect(double xo, double yo, int diro, double xi, double yi, int diri)
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
bool FindNearPoint(const a2dAffineMatrix *cworld, double xIn, double yIn, double *xOut, double *yOut)
Find the point on the polyline closest to the given world point.
void SetRotation(double rotation)
Sets a rotation of this object.
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
#define a2dACCUR
accuracy used to have some limit to calculation like hittesting
a2dPinClass * m_objEnd
The pin class in the pin of the object at the end of the wire.
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
void SetRelease(bool value)
set release flag
bool RequireAttributeValueBool(const wxString &attrib)
Forces an attribute and returns its boolean value.
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.
a2dDrawing * m_root
root group for rendering and accessing the canvas's also contains layer settings
a2dCanvasOFlags m_flags
holds flags for objects
virtual bool Do()=0
Override this to perform a command.
static const long sm_PinCanConnectToPinClass
Pin can connect to supplied a2dPinClass.
static const a2dCanvasObjectFlagsMask BIN2
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
a2dPin is used in a2dCanvasObject to add pins to it.
This is a class/type description for a2dPin's.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
double wxDegToRad(double deg)
conversion from degrees to radians
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
bool Do()
Override this to perform a command.
generate pins, given Connect/wire pinclass
bool IsHit() const
true if this is a hit
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
bool MergAtPin(a2dCanvasObject *parent, a2dPin *joinPin, a2dPin *joinPinOther, bool &inFront, bool &secondRedirect)
join two wires at joinPin and joinPinOther will be removed.
bool IsIdentity(void) const
Is the matrix the identity matrix?
a2dBoundingBox GetCalculatedBoundingBox(int nChildLevels)
Like GetBbox, but it always calculcates the bounding box from scratch.
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Input and output handler for the XmlSer format.
double m_x2
x2 x of arc midpoint
void SetSnapSourceFeature(a2dSnapToWhat snapSourceFeature, bool value=true)
set one of the snapping features for the source to true or false, leaf others as is ...
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
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
bool m_visiblechilds
child objects are visible or not
bool IsDislocated()
Check if the begin or end pin of the wire is dislocated.
bool m_wasVertical
This is used temporarily during editing and need not be saved.
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 Reverse()
make the direction of vertexes the oposite
bool Do()
Override this to perform a command.
Arc Segment in a2dVertexList.
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
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.
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
wxUint32 GetConnectedPinsNr() const
Get the number of connected pins.
bool Do()
Override this to perform a command.
virtual bool GeneratePossibleConnections(a2dCanvasObject *object, a2dPinClass *pinClass, a2dConnectTask task, double x, double y, double margin) const
generate temporary pins to which objects can connect
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
a2dCanvas uses a2dCanvasView for displaying a view on a a2dCanvasDocument.
vertex list of line and arc segments.
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
handle holds a pointer to a polygon/polyline segment
bool GetSelected() const
is the object selected flag set
void SetSelected(bool selected)
Set the object selected flag if allowed.
void SetBin(bool bin)
general flag use at will.
double m_smax
object min half size
void Transform(const a2dAffineMatrix &world)
transform all segments with given matrix
int ReleaseChild(a2dCanvasObject *obj, bool backwards=false, bool all=false, bool now=false, bool undoCommands=false)
remove the given object from the childobjects
int FindPinSegmentIndex(a2dPin *pinToFind, double margin=a2dACCUR)
find the index of the segment where the pin is on.
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
bool m_generatePins
generate pins if true
bool MoveDynamicPinCloseTo(a2dPin *pin, const a2dPoint2D &point, bool final)
Move the given dynamic pin close to the given absolute point.
void RemoveDuplicateConnectedPins(a2dPin *other)
pins connected to given other pin, will be removed on this pin.
a2dWirePolylineL is a polyline that adjusts itself when the objects it connects move ...
If no other snap point was closer, force to grid, even if not within threshold.
bool Disconnect(a2dPin *pin=a2dAnyPin, bool forceErase=false)
bool m_draggable
can be dragged
a2dText is an abstract base class.
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
used to change a property on objects
void ConnectTo(a2dPin *connectto)
connect this pin to the given pin
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
double GetMinX() const
get minimum X of the boundingbox
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
Render derived object.
bool Undo()
Override this to undo a command.
a2dCanvasObjectList * m_childobjects
holds child objects
virtual bool GeneratePinsPossibleConnections(a2dPinClass *pinClass, a2dConnectTask task, double x, double y, double margin=0)
generates pins on all possible locations where the wire can be connected.
void Transform(const a2dAffineMatrix &tworld)
transform the object using the given matrix
#define forEachIn(listtype, list)
easy iteration for a2dlist
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
void SetMode(int mode)
default used to modify rendering
polyline defined with list of points.
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.
used to remove points from polygon objects
double GetPosX() const
get x position from affine matrix
bool JoinAtPin(a2dCanvasObject *parent, a2dPin *joinPin, a2dPin *joinPinOther)
Join two pins making one pin, and merge the this wire with the parent wire of the other pin...
void ComputeCon(a2dPin *outPad, a2dPin *inPad)
void SetSegments(a2dVertexList *points)
Set the list of points ( the old list is NOT DELETED !!! )
bool Undo()
Override this to undo a command.
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
#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! )
Drawing context abstraction.
bool m_editable
object can be edited
double wxRadToDeg(double rad)
conversion from radians to degrees
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 bool IsConnect() const
return true, if this object is used to connect other object's using rubberband like structures...
void SetSnapSourceFeatures(wxUint32 snapSourceFeatures)
void SetEndPoint(int iEnd, int iNext, double x, double y, bool final)
Set position of an end point and possibly one adjacent point.
static a2dPinClass * GetClassByName(const wxString &name)
return the name of this pinclass.
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Restriction engine for editing restrictions like snapping.
a2dLineSegment * FindPinSegment(a2dPin *pinToFind, double margin=a2dACCUR)
find the segment where the pin is on.
bool m_childrenOnSameLayer
bool HasPins(bool realcheck=false)
are there a2dPin derived children
a2dHit HitTestPolyline(const a2dPoint2D &ptest, double margin)
extensive hittesting on vertex list seen as polyline.
Input and output handler for the XmlSer format.
bool GetBin() const
general flag use at will.
a2dPin * AddPin(const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass *pinClass, bool undo=false)
add a a2dPin as child
double m_offset
first & last segment min size
a2dPin * FindBeginPin()
Get the begin pin from the childs.
void ComputeConToWireVertex(a2dPin *outPad, double xw, double yw, double angle)
bool Undo()
Override this to undo a command.
void CleanUpNonConnected()
wxString RequireAttributeValue(const wxString &attrib)
Forces an attribute and returns its string value.
Each a2dCommand is given a command id at construction.
editing is completely controlled by tools. No handles are added
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
virtual bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
bool IsTemporaryPin() const
return true if this pin is a temporary pin
A 2x3 affine matrix class for 2D transformations.
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
a2dPoint2D GetPosXY() const
get position of object
bool IsDynamicPin() const
return true if this pin is a dynamic pin
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
a2dPin * HasPinNamed(const wxString pinName, bool NotConnected=false)
are there a2dPin derived children which matches the given pin name?
double m_y2
y2 y of arc midpoint
double GetPosY() const
get y position from affine matrix
a2dBoundingBox m_untransbbox
Untransformed bounding box.
while iterating a a2dCanvasDocument, this holds the context.
const a2dError a2dError_NoPinClass
struct for how a single object on one layer was hit
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
bool Do()
Override this to perform a command.
a2dlist< a2dDumbPtr< a2dPin > > & GetConnectedPins()
Return list fo connected pins.
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
bool Undo()
Override this to undo a command.
virtual bool Submit(a2dCommand *command, bool storeIt=true)
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
Render derived object.
virtual bool FindConnectedPins(a2dCanvasObjectList &result, a2dPin *pin=NULL, bool walkWires=true, a2dPinClass *searchPinClass=NULL, a2dCanvasObject *isConnectedTo=NULL)
Find pins in other object which are connected to this object.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
virtual bool NeedsUpdateWhenConnected() const
used in case of flexible canvas objects (wires).
used to release object from a a2dCanvasDocument in the current parent
void DuplicateConnectedPins(a2dPin *other, bool undo=false)
pins connected to given other pin, will become part of this pin.
wxString GetName() const
get the name given to the pin.
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
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 ) ...
bool GetRelease() const
get release flag
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
wire classes for connecting objects.
bool Undo()
Override this to undo a command.
double GetWidth() const
returns width of the boundingbox
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
if set, clone properties (e.g. fill style), otherwise ref-copy them
void SetPin(a2dPin *pin)
if handle is at the position of a pin, it can be set here, to make it easy moving it in sync with the...
bool m_editingCopy
true if the object needs to be rendered in edit mode.
void SetPinClass(a2dPinClass *pinClass)
Set the pin class.
if set, clone members (e.g. line end styles), otherwise ref-copy them
a2dPin * GetPin()
see SetPin()
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
bool Invert(void)
Invert matrix.
virtual bool FindConnectedPins(a2dCanvasObjectList &result, a2dPin *pin=NULL, bool walkWires=true, a2dPinClass *searchPinClass=NULL, a2dCanvasObject *isConnectedTo=NULL)
Find pins in other object which are connected to this object.
void SetDynamicPin(bool dynamicPin)
set when pin is a dynamic pin
a2dCanvasObject * GetParent() const
a2dPinClass * m_wireBegin
The pin class in the pin of the wire at the start of the wire.
all polygon and polyline a2dCanvasObject are here.
double GetMinY() const
get minimum Y of the boundingbox
double Length()
calculate length of path
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.
a2dPinClass * m_wireEnd
The pin class in the pin of the wire at the end of the wire.
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
virtual bool AdjustAfterChange(bool final)
a2dPinClass * m_objBegin
The pin class in the pin of the object at the start of the wire.
size_t GetNumberOfSegments()
get the number of points in the pointlist
a2dSnapToWhatMask GetSnapSourceFeatures() const
void GetPosXYSegment(int index, double &x, double &y, bool transform=true) const
get point x and y at index
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
void SetName(const wxString &name)
set the name of the pin (must be unique)
a2dCanvasObject * GetParent() const
get parent object of the pin
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
virtual bool IsConnect() const
return true, if this object is used to connect other object's using rubberband like structures...
#define BBOX2XYWH(bbox)
expand a2dBoundingBox to x,y,w,h
void SetConnectionInfo(bool inverted, a2dPinClass *objBegin, a2dPinClass *objEnd)
bool m_inverted
The wire is inverted (drawn from end to begin)
CloneOptions
options for cloning
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
snap to pins in other objects
bool EliminateMatrix()
reduce matrix to identity without replacing object
a2dPin * SplitAtPin(a2dCanvasObject *parent, a2dPin *splitPin, a2dPin *splitPinClone=NULL, a2dWirePolylineL *clone=NULL, double hitMargin=a2dACCUR)
Split wire at pin given, and add the new split off wire part to parent, creates a new pin at split...
static const a2dCanvasObjectFlagsMask PRERENDERASCHILD
general canvas module declarations and classes
void SetArcHandle(bool arcHandle)
set handle on segment as arc modifier
bool Do()
Override this to perform a command.
a base command for the a2dCommandProcessor