00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "a2dprec.h"
00012
00013 #ifdef __BORLANDC__
00014 #pragma hdrstop
00015 #endif
00016
00017 #ifndef WX_PRECOMP
00018 #include "wx/wx.h"
00019 #endif
00020
00021 #include "wx/module.h"
00022
00023 #include <wx/wfstream.h>
00024 #include <wx/tokenzr.h>
00025
00026 #include <math.h>
00027
00028 #include "wx/canvas/canobj.h"
00029 #include "wx/canvas/candoc.h"
00030 #include "wx/canvas/cancom.h"
00031 #include "wx/canvas/drawer.h"
00032 #include "wx/canvas/canvas.h"
00033 #include "wx/canvas/tools.h"
00034 #include "wx/canvas/wire.h"
00035 #include "wx/canvas/canglob.h"
00036 #include "wx/canvas/algos.h"
00037
00038 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00039 #include <wx/msw/msvcrt.h>
00040 #endif
00041
00042
00043
00044 #include "wx/general/smrtptr.inl"
00045
00046
00047
00048
00049
00050
00051
00052 #define CIRCLE_STEPS 128
00053
00054 #if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00055
00056
00057
00058 #ifdef _MSC_VER
00059 #pragma warning(disable: 4660)
00060 #endif
00061
00062 template class a2dPropertyIdTyped<a2dCanvasObjectPtr, class a2dCanvasObjectPtrProperty>;
00063 template class a2dPropertyIdTyped<a2dBoundingBox, a2dBoudingBoxProperty>;
00064
00065
00066 #ifdef _MSC_VER
00067 #pragma warning(default: 4660)
00068 #endif
00069
00070 #endif // (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00071
00072 #ifdef _DEBUG
00073
00074 a2dCanvasObject *_dbco1 = 0;
00075 a2dCanvasObject *_dbco2 = 0;
00076 #endif
00077
00078
00079
00080
00081 bool a2dCanvasObjectFilterLayerMask::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00082 {
00083 if ( canvasObject->m_layer != m_layer && m_layer != wxLAYER_ALL && !canvasObject->GetIgnoreLayer() )
00084 {
00085
00086
00087
00088 if ( canvasObject->m_childobjects == wxNullCanvasObjectList ||
00089 !canvasObject->m_flags.m_visiblechilds || canvasObject->m_flags.m_childrenOnSameLayer )
00090 return false;
00091 }
00092
00093 if ( m_layer != wxLAYER_ALL && !canvasObject->GetIgnoreLayer() &&
00094
00095 ( !ic.GetCanvasView()->GetLayerRenderArray()[ m_layer ].DoRenderLayer() ||
00096 canvasObject->m_root && canvasObject->m_root->GetLayerSetup() &&
00097 !canvasObject->m_root->GetLayerSetup()->GetVisible(m_layer)
00098
00099 )
00100
00101 )
00102 return false;
00103
00104 if ( !( canvasObject->CheckMask(m_mask) || ic.GetLevel() == 0 ) )
00105 return false;
00106
00107 if ( !( m_antimask == a2dCanvasOFlags::NON || !canvasObject->CheckMask(m_antimask) || ic.GetLevel() == 0 ) )
00108 return false;
00109
00110 return true;
00111 }
00112
00113
00114
00115
00116
00117
00118 bool a2dCanvasObjectFilterLayerMaskNoToolNoEdit::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00119 {
00120 if ( a2dCanvasObjectFilterLayerMask::Filter( ic, canvasObject ) )
00121 return !canvasObject->m_flags.m_editingCopy && ! a2dCanvasObject::PROPID_ToolObject->GetPropertyValue( canvasObject );
00122 return false;
00123 }
00124
00125 void a2dCanvasObjectFilterLayerMaskNoToolNoEdit::EndFilter( a2dIterC& WXUNUSED(ic), a2dCanvasObject* WXUNUSED(canvasObject) )
00126 {
00127 }
00128
00129
00130
00131
00132
00133 bool a2dCanvasObjectFilterOnlyNoMaskBlind::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00134 {
00135 if ( canvasObject->CheckMask(m_mask) )
00136 {
00137 m_maskedCanvasObject = canvasObject;
00138 ic.GetDrawer2D()->SetDisableDrawing( false );
00139 return true;
00140 }
00141
00142 if ( !m_maskedCanvasObject )
00143 ic.GetDrawer2D()->SetDisableDrawing( true );
00144 return true;
00145 }
00146
00147 void a2dCanvasObjectFilterOnlyNoMaskBlind::EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00148 {
00149 if ( canvasObject == m_maskedCanvasObject )
00150 ic.GetDrawer2D()->SetDisableDrawing( true );
00151 }
00152
00153
00154
00155
00156 bool a2dCanvasObjectFilterPropertyNoMaskBlind::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00157 {
00158 if ( m_maskedCanvasObject )
00159 {
00160
00161 return canvasObject->CheckMask(m_mask);
00162 }
00163 else if ( canvasObject->HasProperty( m_id ) )
00164 {
00165 m_maskedCanvasObject = canvasObject;
00166 ic.GetDrawer2D()->SetDisableDrawing( false );
00167 return canvasObject->CheckMask(m_mask);
00168 }
00169
00170
00171
00172 ic.GetDrawer2D()->SetDisableDrawing( true );
00173 return true;
00174 }
00175
00176 void a2dCanvasObjectFilterPropertyNoMaskBlind::EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00177 {
00178
00179
00180 if ( canvasObject == m_maskedCanvasObject )
00181 {
00182 m_maskedCanvasObject = NULL;
00183 ic.GetDrawer2D()->SetDisableDrawing( true );
00184 }
00185 }
00186
00187
00188
00189
00190 bool a2dCanvasObjectFilterSelected::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00191 {
00192 if ( m_maskedCanvasObject )
00193
00194 return canvasObject->CheckMask(m_mask);
00195 else
00196 {
00197 if ( canvasObject->GetSelected() )
00198 {
00199 m_maskedCanvasObject = canvasObject;
00200 ic.GetDrawer2D()->SetDisableDrawing( false );
00201 return canvasObject->CheckMask(m_mask);
00202 }
00203 else
00204 {
00205
00206 return ic.GetCanvasView()->GetShowObject() == canvasObject;
00207
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 }
00232 }
00233
00234 void a2dCanvasObjectFilterSelected::EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00235 {
00236
00237
00238 if ( canvasObject == m_maskedCanvasObject )
00239 {
00240 m_maskedCanvasObject = NULL;
00241 ic.GetDrawer2D()->SetDisableDrawing( true );
00242 }
00243 }
00244
00245
00246
00247
00248 bool a2dCanvasObjectFilterHighLighted::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00249 {
00250 if ( m_maskedCanvasObject )
00251
00252 return canvasObject->CheckMask(m_mask);
00253 else
00254 {
00255 if ( canvasObject->GetHighLight() )
00256 {
00257 m_maskedCanvasObject = canvasObject;
00258 ic.GetDrawer2D()->SetDisableDrawing( false );
00259 return canvasObject->CheckMask(m_mask);
00260 }
00261 else
00262 {
00263
00264 return ic.GetCanvasView()->GetShowObject() == canvasObject;
00265
00266 }
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 }
00290 }
00291
00292 void a2dCanvasObjectFilterHighLighted::EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00293 {
00294
00295
00296 if ( canvasObject == m_maskedCanvasObject )
00297 {
00298 m_maskedCanvasObject = NULL;
00299 ic.GetDrawer2D()->SetDisableDrawing( true );
00300 }
00301 }
00302
00303
00304
00305
00306 bool a2dCanvasObjectFilterToolObjects::Filter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00307 {
00308 if ( m_maskedCanvasObject )
00309 return canvasObject->CheckMask(m_mask);
00310 else
00311 {
00312 if ( canvasObject->GetHasToolObjectsBelow() )
00313 {
00314 if ( canvasObject->HasProperty( m_id ) )
00315 {
00316 m_maskedCanvasObject = canvasObject;
00317 ic.GetDrawer2D()->SetDisableDrawing( false );
00318 return canvasObject->CheckMask(m_mask);
00319 }
00320 else
00321 {
00322 return canvasObject->CheckMask(m_mask);
00323 }
00324 }
00325 else
00326 {
00327
00328
00329 ic.GetDrawer2D()->SetDisableDrawing( true );
00330 return false;
00331 }
00332 }
00333 }
00334
00335 void a2dCanvasObjectFilterToolObjects::EndFilter( a2dIterC& ic, a2dCanvasObject* canvasObject )
00336 {
00337
00338
00339 if ( canvasObject == m_maskedCanvasObject )
00340 {
00341 m_maskedCanvasObject = NULL;
00342 ic.GetDrawer2D()->SetDisableDrawing( true );
00343 }
00344 }
00345
00346
00347
00348
00349 a2dIterCU::a2dIterCU( a2dIterC &ic, const a2dAffineMatrix& matrix, OVERLAP clip )
00350 {
00351 m_iterC = ⁣
00352 m_objectLevel = false;
00353 m_clip = clip;
00354
00355 m_iterC->m_drawer->GetDrawer2D()->PushTransform( matrix );
00356 if( ic.m_bottom )
00357 {
00358 m_parent = ic.m_bottom;
00359 m_object = ic.m_bottom->m_object;
00360 m_previous = NULL;
00361
00362 m_relativetransform = ic.m_bottom->m_relativetransform;
00363 m_relativetransform *= matrix;
00364
00365
00366 ic.m_bottom = this;
00367 }
00368 else
00369 {
00370 m_parent = NULL;
00371 m_object = NULL;
00372 m_previous = NULL;
00373
00374
00375 ic.m_bottom = this;
00376 ic.m_top = this;
00377 m_relativetransform = matrix;
00378 }
00379
00380 if ( !ic.m_disableInvert )
00381 {
00382 m_inverseRelativetransform = m_relativetransform;
00383 m_inverseRelativetransform.Invert();
00384 }
00385 }
00386
00387 a2dIterCU::a2dIterCU( a2dIterC &ic, a2dCanvasObject *object, OVERLAP clip )
00388 {
00389 m_objectLevel = true;
00390 m_clip = clip;
00391
00392
00393 assert( !ic.m_bottom || ic.m_bottom->m_object!=object );
00394
00395
00396
00397
00398 m_iterC = ⁣
00399 m_parent = ic.m_bottom;
00400 m_object = object;
00401 m_previous = NULL;
00402 ic.m_levels++;
00403 m_iterC->m_drawer->GetDrawer2D()->PushTransform( object->GetTransformMatrix() );
00404
00405 if( ic.m_bottom )
00406 {
00407 m_relativetransform = ic.m_bottom->m_relativetransform;
00408 m_relativetransform *= object->GetTransformMatrix();
00409
00410
00411 ic.m_bottom = this;
00412 }
00413 else
00414 {
00415
00416 ic.m_bottom = this;
00417 ic.m_top = this;
00418
00419 m_relativetransform *= object->GetTransformMatrix();
00420 }
00421 if ( !ic.m_disableInvert )
00422 {
00423 m_inverseRelativetransform = m_relativetransform;
00424 m_inverseRelativetransform.Invert();
00425 }
00426 }
00427
00428 a2dIterCU::~a2dIterCU()
00429 {
00430 m_iterC->m_bottom = m_parent;
00431 m_iterC->m_previous = m_object;
00432 if ( m_objectLevel )
00433 m_iterC->m_levels--;
00434
00435 if( m_parent )
00436 m_parent->m_previous = m_object;
00437
00438 m_iterC->m_drawer->GetDrawer2D()->PopTransform();
00439 }
00440
00441 a2dIterCU::a2dIterCU( const a2dIterCU& cu )
00442 {
00443 m_objectLevel = cu.m_objectLevel;
00444 m_iterC = NULL;
00445 m_parent = NULL;
00446 m_object = cu.m_object;
00447 m_previous = NULL;
00448 m_relativetransform = cu.m_relativetransform;
00449 m_inverseRelativetransform = cu.m_inverseRelativetransform;
00450 }
00451
00452
00453
00454
00455
00456 a2dIterC::a2dIterC()
00457 {
00458 m_disableInvert = false;
00459 m_bottom = 0;
00460 m_top = 0;
00461 m_previous = 0;
00462 m_levels = 0;
00463 m_foundCorridorEnd = false;
00464
00465 m_hitmargin_world = a2dCanvasGlobals->GetHitMarginWorld();
00466 m_worldStrokeExtend = 0;
00467
00468 m_drawer = new a2dCanvasView( 100, 100, new a2dBlindDrawer2D() );
00469 m_ownDrawer = true;
00470 m_drawstyle = RenderLAYERED;
00471 m_layer = wxLAYER_ALL;
00472 m_perLayerMode = true;
00473 m_generateCommands = false;
00474 m_renderChildDerived = true;
00475 }
00476
00477 a2dIterC::a2dIterC( a2dCanvasView* drawer, int level )
00478 {
00479
00480 m_disableInvert = false;
00481 m_bottom = 0;
00482 m_top = 0;
00483 m_previous = 0;
00484 m_levels = level;
00485 m_foundCorridorEnd = false;
00486
00487 m_drawer = drawer;
00488 m_drawstyle = RenderLAYERED;
00489
00490 m_usertodevice = drawer->GetDrawer2D()->GetUserToDeviceTransform();
00491
00492 m_mapping = drawer->GetDrawer2D()->GetMappingMatrix();
00493
00494 m_hitmargin_world = drawer->GetHitMarginWorld();
00495 m_worldStrokeExtend = 0;
00496 m_layer = 0;
00497 m_generateCommands = false;
00498 m_ownDrawer = false;
00499 m_perLayerMode = true;
00500 m_renderChildDerived = true;
00501 }
00502
00503 a2dIterC::~a2dIterC()
00504 {
00505 if ( m_ownDrawer )
00506 m_drawer->SetClosed();
00507 }
00508
00509 void a2dIterC::Reset()
00510 {
00511 m_bottom = 0;
00512 m_top = 0;
00513 m_previous = 0;
00514 m_worldStrokeExtend = 0;
00515 m_perLayerMode = true;
00516 m_renderChildDerived = true;
00517 }
00518
00519 void a2dIterC::SetHitMarginDevice( int pixels )
00520 {
00521 m_hitmargin_world = GetDrawer2D()->DeviceToWorldXRel( pixels );
00522 }
00523
00524 void a2dIterC::SetHitMarginWorld( double world )
00525 {
00526 m_hitmargin_world = world;
00527 }
00528
00529 double a2dIterC::GetHitMarginWorld()
00530 {
00531 return m_hitmargin_world;
00532 }
00533
00534 double a2dIterC::ExtendDeviceToWorld( int extend )
00535 {
00536 return GetDrawer2D()->DeviceToWorldXRel( extend );
00537 }
00538
00539 double a2dIterC::GetTransformedHitMargin()
00540 {
00541 return GetInverseParentTransform().TransformDistance( m_hitmargin_world );
00542 }
00543
00544 const a2dAffineMatrix& a2dIterC::GetMappingTransform() const
00545 {
00546 return m_drawer->GetDrawer2D()->GetMappingMatrix();
00547 }
00548
00549 const a2dAffineMatrix& a2dIterC::GetUserToDeviceTransform() const
00550 {
00551 return m_drawer->GetDrawer2D()->GetUserToDeviceTransform();
00552 }
00553
00554 a2dCanvasView* a2dIterC::GetCanvasView() const
00555 {
00556 return m_drawer;
00557 }
00558
00559 a2dDrawer2D* a2dIterC::GetDrawer2D() const
00560 {
00561 return m_drawer->GetDrawer2D();
00562 }
00563
00564 a2dCanvasObject* a2dIterC::GetParent()
00565 {
00566
00567 assert ( m_bottom );
00568 return m_bottom->m_parent ? m_bottom->m_parent->m_object : 0;
00569 }
00570
00571 a2dCanvasObject* a2dIterC::GetObject()
00572 {
00573
00574 assert ( m_bottom );
00575 return m_bottom ? m_bottom->m_object : 0;
00576 }
00577
00578 a2dCanvasObject* a2dIterC::GetPreviousDeep()
00579 {
00580 return m_previous;
00581 }
00582
00583 a2dCanvasObject* a2dIterC::GetPreviousSibling()
00584 {
00585
00586 assert ( m_bottom );
00587 if( m_bottom->m_parent )
00588 return m_bottom->m_parent->m_previous;
00589 else
00590 return NULL;
00591 }
00592
00593 a2dCanvasObject* a2dIterC::GetPreviousOrParent()
00594 {
00595
00596 assert ( m_bottom );
00597 a2dCanvasObject *rslt = GetPreviousSibling();
00598
00599 if( rslt )
00600 return rslt;
00601 else
00602 return GetParent();
00603 }
00604
00605 const a2dAffineMatrix &a2dIterC::GetTransform() const
00606 {
00607 if( m_bottom )
00608 return m_bottom->m_relativetransform;
00609 else
00610 return a2dAffineMatrix::GetIdentityMatrix();
00611 }
00612
00613 OVERLAP a2dIterC::GetClipStatus() const
00614 {
00615 if( m_bottom )
00616 return m_bottom->m_clip;
00617 else
00618 return _IN;
00619 }
00620
00621 OVERLAP a2dIterC::GetParentClipStatus() const
00622 {
00623
00624 assert ( m_bottom );
00625 if( m_bottom->m_parent )
00626 return m_bottom->m_parent->m_clip;
00627 else
00628 return _ON;
00629 }
00630
00631 void a2dIterC::SetClipStatus( OVERLAP status )
00632 {
00633 if( m_bottom )
00634 m_bottom->m_clip = status;
00635 }
00636
00637 const a2dAffineMatrix &a2dIterC::GetInverseTransform() const
00638 {
00639 assert( !m_disableInvert );
00640
00641 if( m_bottom )
00642 return m_bottom->m_inverseRelativetransform;
00643 else
00644 return a2dAffineMatrix::GetIdentityMatrix();
00645 }
00646
00647 const a2dAffineMatrix &a2dIterC::GetParentTransform() const
00648 {
00649
00650 assert ( m_bottom );
00651 if( m_bottom->m_parent )
00652 return m_bottom->m_parent->m_relativetransform;
00653 else
00654 return a2dAffineMatrix::GetIdentityMatrix();
00655 }
00656
00657 const a2dAffineMatrix &a2dIterC::GetInverseParentTransform() const
00658 {
00659 assert( !m_disableInvert );
00660
00661 assert ( m_bottom );
00662 if( m_bottom->m_parent )
00663 return m_bottom->m_parent->m_inverseRelativetransform;
00664 else
00665 return a2dAffineMatrix::GetIdentityMatrix();
00666 }
00667
00668 void a2dIterC::SetCorridorPath( bool OnOff, a2dCanvasObject* captureObject )
00669 {
00670 GetCanvasView()->ClearCorridorPath( true );
00671
00672 m_foundCorridorEnd = false;
00673 a2dIterCU* iter = m_bottom;
00674 while ( iter )
00675 {
00676 if ( iter->m_object )
00677 {
00678 iter->m_object->SetIsOnCorridorPath( OnOff );
00679
00680 }
00681 iter = iter->m_parent;
00682 }
00683 if ( OnOff )
00684 {
00685
00686 if ( m_bottom->m_object )
00687 GetCanvasView()->SetEndCorridorObject( m_bottom->m_object );
00688 else
00689 GetCanvasView()->SetEndCorridorObject( GetCanvasView()->GetShowObject() );
00690
00691 GetCanvasView()->SetCaptured( captureObject );
00692 }
00693 else
00694 {
00695
00696 GetCanvasView()->SetEndCorridorObject( NULL );
00697 GetCanvasView()->SetCaptured( NULL );
00698 }
00699 }
00700
00701 void a2dIterC::SetCorridorPathToParent()
00702 {
00703 m_foundCorridorEnd = false;
00704 a2dIterCU* iter = m_bottom;
00705 if ( iter->m_object )
00706 iter->m_object->SetIsOnCorridorPath( false );
00707 iter = iter->m_parent;
00708 while ( iter )
00709 {
00710 if ( iter->m_object )
00711 {
00712 iter->m_object->SetIsOnCorridorPath( true );
00713
00714 }
00715 iter = iter->m_parent;
00716 }
00717
00718 if ( m_bottom->m_parent->m_object )
00719 GetCanvasView()->SetEndCorridorObject( m_bottom->m_parent->m_object );
00720 else
00721 GetCanvasView()->SetEndCorridorObject( GetCanvasView()->GetShowObject() );
00722 GetCanvasView()->SetCaptured( NULL );
00723 }
00724
00725 void a2dIterC::SetCorridorPathCaptureObject( a2dCanvasObject* captureObject )
00726 {
00727 m_foundCorridorEnd = false;
00728 if ( m_bottom->m_object )
00729 GetCanvasView()->SetEndCorridorObject( m_bottom->m_object );
00730 else
00731 GetCanvasView()->SetEndCorridorObject( GetCanvasView()->GetShowObject() );
00732 GetCanvasView()->SetCaptured( captureObject );
00733 }
00734
00735 bool a2dIterC::FilterObject( a2dCanvasObject* canvasObject )
00736 {
00737 if ( m_objectFilter )
00738 return m_objectFilter->Filter( *this, canvasObject );
00739 else
00740 return true;
00741 }
00742
00743 void a2dIterC::EndFilterObject( a2dCanvasObject* canvasObject )
00744 {
00745 if ( m_objectFilter )
00746 m_objectFilter->EndFilter( *this, canvasObject );
00747 }
00748
00749
00750
00751
00752
00753
00754 a2dExtendedResult::a2dExtendedResult()
00755 {
00756 }
00757
00758 a2dExtendedResult::~a2dExtendedResult()
00759 {
00760 }
00761
00762
00763
00764
00765
00766 a2dConnectionGenerator::a2dConnectionGenerator()
00767 {
00768 m_anypinclass = NULL;
00769 }
00770
00771 a2dConnectionGenerator::~a2dConnectionGenerator()
00772 {
00773 }
00774
00775 a2dCanvasObject* a2dConnectionGenerator::CreateConnectObject( a2dCanvasObject* parent, a2dPin* pinThis, a2dPin* pinOther, bool undo ) const
00776 {
00777 a2dPinClass* thisPinClass = NULL;
00778 a2dPinClass* otherPinClass = NULL;
00779 a2dPinClass* wirePinClassThis = NULL;
00780 a2dPinClass* wirePinClassOther = NULL;
00781 a2dWirePolylineL* wireThis = NULL;
00782 a2dWirePolylineL* wireOther = NULL;
00783 a2dWirePolylineL* wire = NULL;
00784 m_reverseCreate = false;
00785
00786 if ( pinThis && pinOther )
00787 {
00788 thisPinClass = pinThis->GetPinClass();
00789 otherPinClass = pinOther->GetPinClass();
00790 wirePinClassThis = thisPinClass->CanConnectToAsWire();
00791 wirePinClassOther = otherPinClass->CanConnectToAsWire();
00792
00793 if ( wirePinClassThis )
00794 wireThis = wxStaticCast( wirePinClassThis->GetConnectObject(), a2dWirePolylineL );
00795 if ( wirePinClassOther )
00796 wireOther = wxStaticCast( wirePinClassOther->GetConnectObject(), a2dWirePolylineL );
00797
00798 if ( !wireThis && !wireOther )
00799 return false;
00800
00801 wxASSERT_MSG( wireThis == wireOther, wxT("connecting wire must be the same for both pins") );
00802
00803 wire = wireThis;
00804
00805 if ( wirePinClassThis != wire->GetStartPinClass() )
00806 {
00807 wxASSERT_MSG( wirePinClassOther == wire->GetStartPinClass(),
00808 wxT("wire created from PinClass pinOther, does not fit wire StartPin") );
00809 wxASSERT_MSG( wirePinClassThis == wire->GetEndPinClass(),
00810 wxT("wire created from PinClass pinThis, does not fit wire EndPin") );
00811
00812 m_reverseCreate = true;
00813 }
00814 else
00815 {
00816 wxASSERT_MSG( wirePinClassOther == wire->GetEndPinClass(),
00817 wxT("wire created from PinClass pinOther, does not fit wire EndPinClass") );
00818 wxASSERT_MSG( wirePinClassThis == wire->GetStartPinClass(),
00819 wxT("wire created from PinClass pinThis, does not fit wire StartPinClass") );
00820
00821 m_reverseCreate = false;
00822 }
00823 }
00824 else if ( pinThis )
00825 {
00826 thisPinClass = pinThis->GetPinClass();
00827 wirePinClassThis = thisPinClass->CanConnectToAsWire();
00828 if ( wirePinClassThis )
00829 wireThis = wxStaticCast( wirePinClassThis->GetConnectObject(), a2dWirePolylineL );
00830
00831 if ( !wireThis )
00832 return false;
00833
00834 if ( wirePinClassThis != wireThis->GetStartPinClass() )
00835 {
00836 wxASSERT_MSG( wirePinClassThis == wireThis->GetEndPinClass(),
00837 wxT("wire created from PinClass pinThis, does not fit wire EndPin") );
00838 wirePinClassOther = wireThis->GetStartPinClass();
00839 m_reverseCreate = true;
00840 }
00841 else
00842 {
00843 wirePinClassOther = wireThis->GetEndPinClass();
00844 m_reverseCreate = false;
00845 }
00846 }
00847 else if ( pinOther )
00848 {
00849 otherPinClass = pinOther->GetPinClass();
00850 wirePinClassOther = otherPinClass->CanConnectToAsWire();
00851 if ( wirePinClassOther )
00852 wireOther = wxStaticCast( wirePinClassOther->GetConnectObject(), a2dWirePolylineL );
00853
00854 if ( !wireOther )
00855 return false;
00856
00857 if ( wirePinClassOther != wireOther->GetEndPinClass() )
00858 {
00859 wxASSERT_MSG( wirePinClassOther == wireOther->GetStartPinClass(),
00860 wxT("wire created from PinClass pinThis, does not fit wire StartPin") );
00861 wirePinClassThis = wireOther->GetStartPinClass();
00862 m_reverseCreate = true;
00863 }
00864 else
00865 {
00866 wirePinClassThis = wireOther->GetStartPinClass();
00867 m_reverseCreate = false;
00868 }
00869 }
00870
00871
00872 if ( m_reverseCreate )
00873 {
00874 a2dPinPtr swappin = pinThis;
00875 pinThis = pinOther;
00876 pinOther = swappin;
00877 a2dPinClass* swapPinClass = thisPinClass;
00878 thisPinClass = otherPinClass;
00879 otherPinClass = swapPinClass;
00880
00881 swapPinClass = wirePinClassThis;
00882 wirePinClassThis = wirePinClassOther;
00883 wirePinClassOther = swapPinClass;
00884 }
00885
00886 if ( wireThis || wireOther )
00887 {
00888 wire = wxStaticCast( wirePinClassThis->GetConnectObject()->Clone( clone_deep ), a2dWirePolylineL );
00889
00890 if ( !undo )
00891 {
00892 parent->Append( wire );
00893 if ( pinThis )
00894 {
00895 wire->AddPoint( pinThis->GetAbsX(), pinThis->GetAbsY(), -1 , true );
00896 a2dPin* begin = wire->AddPin( wxT("begin"), pinThis->GetAbsX(), pinThis->GetAbsY(), a2dPin::NON,
00897 wirePinClassThis );
00898 wire->ConnectPins( parent, pinThis, begin, undo );
00899 }
00900 else
00901 wire->AddPin( wxT("begin"), pinOther->GetAbsX(), pinOther->GetAbsY(), a2dPin::NON,
00902 wirePinClassThis );
00903
00904 if ( pinOther )
00905 {
00906 wire->AddPoint( pinOther->GetAbsX(), pinOther->GetAbsY(), -1 , true );
00907 a2dPin* end = wire->AddPin( wxT("end"), pinOther->GetAbsX(), pinOther->GetAbsY(), a2dPin::NON,
00908 wirePinClassOther );
00909 wire->ConnectPins( parent, pinOther, end, undo );
00910 }
00911 else
00912 wire->AddPin( wxT("end"), pinThis->GetAbsX(), pinThis->GetAbsY(), a2dPin::NON,
00913 wirePinClassOther );
00914 }
00915 else
00916 {
00917 a2dCanvasCommandProcessor* cmp = parent->GetCanvasDocument()->GetCanvasCommandProcessor();
00918 cmp->Submit( new a2dCommand_AddObject( parent, wire ) );
00919 if ( pinThis )
00920 {
00921 cmp->Submit( new a2dCommand_AddPoint( wire, pinThis->GetAbsX(), pinThis->GetAbsY(), -1 ) );
00922 a2dPin* begin = wire->AddPin( wxT("begin"), pinThis->GetAbsX(), pinThis->GetAbsY(), a2dPin::NON,
00923 wirePinClassThis );
00924
00925
00926 cmp->Submit( new a2dCommand_ConnectPins( pinThis, begin ), true );
00927 }
00928 else
00929 wire->AddPin( wxT("begin"), pinOther->GetAbsX(), pinOther->GetAbsY(), a2dPin::NON,
00930 wirePinClassThis );
00931
00932 if ( pinOther )
00933 {
00934 cmp->Submit( new a2dCommand_AddPoint( wire, pinOther->GetAbsX(), pinOther->GetAbsY(), -1 ) );
00935 a2dPin* end = wire->AddPin( wxT("end"), pinOther->GetAbsX(), pinOther->GetAbsY(), a2dPin::NON,
00936 wirePinClassOther );
00937
00938
00939 cmp->Submit( new a2dCommand_ConnectPins( pinOther, end ), true );
00940 }
00941 else
00942 wire->AddPin( wxT("end"), pinThis->GetAbsX(), pinThis->GetAbsY(), a2dPin::NON,
00943 wirePinClassOther );
00944 }
00945
00946 wire->SetConnectionInfo( true, thisPinClass, otherPinClass );
00947 return wire;
00948 }
00949 return NULL;
00950 }
00951
00952 a2dCanvasObject* a2dConnectionGenerator::GetConnectTemplate( const a2dCanvasObject* WXUNUSED(object), a2dPinClass* mapThis, const a2dCanvasObject* WXUNUSED(other), a2dPinClass* mapOther ) const
00953 {
00954 a2dPinClass* wirePinClassStart = mapThis->CanConnectToAsWire();
00955 a2dPinClass* wirePinClassEnd = mapOther->CanConnectToAsWire( wirePinClassStart );
00956
00957 if ( wirePinClassStart && wirePinClassEnd )
00958 {
00959
00960 assert( wirePinClassStart->GetConnectObject() == wirePinClassEnd->GetConnectObject() );
00961 return wirePinClassStart->GetConnectObject();
00962 }
00963 return NULL;
00964 }
00965
00966
00967 bool a2dConnectionGenerator::GeneratePossibleConnections( a2dCanvasObject* object, a2dPinClass* pinClass, a2dConnectTask task, double x, double y ) const
00968 {
00969 assert( pinClass );
00970 bool found = object->GeneratePins( pinClass, task, x, y );
00971 return found;
00972 }
00973
00974 a2dPinClass* a2dConnectionGenerator::GetPinClassForTask( a2dPinClass* pinClass, a2dConnectTask task, a2dCanvasObject* obj ) const
00975 {
00976 wxASSERT_MSG( pinClass, wxT("pinClass cannot be NULL, maybe use a2dPinClass::Any?") );
00977
00978
00979 if ( pinClass == a2dPinClass::Any )
00980 {
00981 if ( obj && obj->GetCanvasDocument() && obj->GetCanvasDocument()->GetLayerSetup() )
00982 {
00983 a2dLayerInfo* info = obj->GetCanvasDocument()->GetLayerSetup()->GetLayerIndex()[ obj->GetLayer() ];
00984 if ( info != wxNullLayerInfo )
00985 return info->GetPinClass();
00986
00987 }
00988
00989 a2dPinClass* objectPinClassStart = pinClass->CanConnectToAsObject();
00990 if ( objectPinClassStart )
00991 return objectPinClassStart;
00992
00993 if ( obj->IsConnect() )
00994 return m_anypinclass;
00995 else
00996 return m_anypinclass;
00997 }
00998
00999 switch ( task )
01000 {
01001
01002 case a2d_ToConnectPinClassWire_ObjectPinClass_In:
01003 {
01004 assert( pinClass->IsInputPin() );
01005 a2dPinClass* wirePinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_output );
01006 return wirePinClassInOut;
01007 }
01008 break;
01009 case a2d_ToConnectPinClassWire_ObjectPinClass_Out:
01010 {
01011 assert( pinClass->IsOutputPin() );
01012 a2dPinClass* wirePinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_input );
01013 return wirePinClassInOut;
01014 }
01015 break;
01016 case a2d_ToConnectPinClassWire_ObjectPinClass_InOut:
01017 {
01018 a2dPinClass* wirePinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_input | a2dPinClass::PC_output );
01019 return wirePinClassInOut;
01020 }
01021 break;
01022
01023
01024 case a2d_ObjectPinClass_ToConnectPinClassWire_In:
01025 {
01026 assert( pinClass->IsInputPin() );
01027 assert( pinClass->GetConnectObject() );
01028 a2dPinClass* objectPinClassInOut = NULL;
01029
01030 if ( obj->IsConnect() )
01031 objectPinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_output );
01032 else
01033 objectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_output );
01034 }
01035 break;
01036 case a2d_ObjectPinClass_ToConnectPinClassWire_Out:
01037 {
01038 assert( pinClass->IsOutputPin() );
01039 assert( pinClass->GetConnectObject() );
01040 a2dPinClass* objectPinClassInOut = NULL;
01041
01042 if ( obj->IsConnect() )
01043 objectPinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_input );
01044 else
01045 objectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_input );
01046 return objectPinClassInOut;
01047 }
01048 break;
01049 case a2d_ObjectPinClass_ToConnectPinClassWire_InOut:
01050 {
01051 assert( pinClass->GetConnectObject() );
01052 a2dPinClass* objectPinClassInOut = NULL;
01053
01054 if ( obj->IsConnect() )
01055 objectPinClassInOut = pinClass->CanConnectToAsWire( NULL, a2dPinClass::PC_input | a2dPinClass::PC_output );
01056 else
01057 objectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_input | a2dPinClass::PC_output );
01058 return objectPinClassInOut;
01059 }
01060 break;
01061
01062
01063 case a2d_ToConnectPinClassObject_ObjectPinClass_In:
01064 {
01065 assert( pinClass->IsInputPin() );
01066 a2dPinClass* toConnectobjectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_output );
01067 return toConnectobjectPinClassInOut;
01068 }
01069 break;
01070 case a2d_ToConnectPinClassObject_ObjectPinClass_Out:
01071 {
01072 assert( pinClass->IsOutputPin() );
01073 a2dPinClass* toConnectobjectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_input );
01074 return toConnectobjectPinClassInOut;
01075 }
01076 break;
01077 case a2d_ToConnectPinClassObject_ObjectPinClass_InOut:
01078 {
01079 a2dPinClass* toConnectobjectPinClassInOut = pinClass->CanConnectToAsObject( NULL, a2dPinClass::PC_input | a2dPinClass::PC_output );
01080 return toConnectobjectPinClassInOut;
01081 }
01082 break;
01083
01084
01085 case a2d_ObjectPinClass_ToConnectPinClassObject_In:
01086 {
01087 assert( pinClass->IsInputPin() );
01088 a2dPinClass* objectPinClassInOut = pinClass->CanConnectTo( NULL, a2dPinClass::PC_output );
01089 return objectPinClassInOut;
01090 }
01091 break;
01092 case a2d_ObjectPinClass_ToConnectPinClassObject_Out:
01093 {
01094 assert( pinClass->IsOutputPin() );
01095 a2dPinClass* objectPinClassInOut = pinClass->CanConnectTo( NULL, a2dPinClass::PC_input );
01096 return objectPinClassInOut;
01097 }
01098 break;
01099 case a2d_ObjectPinClass_ToConnectPinClassObject_InOut:
01100 {
01101 a2dPinClass* objectPinClassInOut = pinClass->CanConnectTo( NULL, a2dPinClass::PC_input | a2dPinClass::PC_output );
01102 return objectPinClassInOut;
01103 }
01104 break;
01105
01106 default:
01107
01108 break;
01109 }
01110
01111 return NULL;
01112 }
01113
01114
01115
01116
01117
01118 bool operator < (const a2dSmrtPtr<a2dCanvasObject>& a, const a2dSmrtPtr<a2dCanvasObject>& b)
01119 {
01120 return (*(s_a2dCanvasObjectSorter)) ( a, b );
01121 }
01122
01123 a2dCanvasObjectSorter s_a2dCanvasObjectSorter = NULL;
01124
01125 bool a2dCanvasObject::m_ignoreAllSetpending = false;
01126
01127 a2dPropertyIdMatrix* a2dCanvasObject::PROPID_TransformMatrix = NULL;
01128 a2dPropertyIdPoint2D* a2dCanvasObject::PROPID_Position = NULL;
01129 a2dPropertyIdUint16* a2dCanvasObject::PROPID_Layer = NULL;
01130 a2dPropertyIdBool* a2dCanvasObject::PROPID_Selected = NULL;
01131 a2dPropertyIdBool* a2dCanvasObject::PROPID_Selectable = NULL;
01132 a2dPropertyIdBool* a2dCanvasObject::PROPID_SubEdit = NULL;
01133 a2dPropertyIdBool* a2dCanvasObject::PROPID_SubEditAsChild = NULL;
01134 a2dPropertyIdBool* a2dCanvasObject::PROPID_Visible = NULL;
01135 a2dPropertyIdBool* a2dCanvasObject::PROPID_Draggable = NULL;
01136 a2dPropertyIdBool* a2dCanvasObject::PROPID_Showshadow = NULL;
01137 a2dPropertyIdBool* a2dCanvasObject::PROPID_Filled = NULL;
01138 a2dPropertyIdBool* a2dCanvasObject::PROPID_GroupA = NULL;
01139 a2dPropertyIdBool* a2dCanvasObject::PROPID_GroupB = NULL;
01140 a2dPropertyIdBool* a2dCanvasObject::PROPID_GeneratePins = NULL;
01141 a2dPropertyIdBool* a2dCanvasObject::PROPID_Bin = NULL;
01142 a2dPropertyIdBool* a2dCanvasObject::PROPID_Bin2 = NULL;
01143 a2dPropertyIdBool* a2dCanvasObject::PROPID_Pending = NULL;
01144 a2dPropertyIdBool* a2dCanvasObject::PROPID_Snap = NULL;
01145 a2dPropertyIdBool* a2dCanvasObject::PROPID_SnapTo = NULL;
01146 a2dPropertyIdBool* a2dCanvasObject::PROPID_Pushin = NULL;
01147 a2dPropertyIdBool* a2dCanvasObject::PROPID_Prerenderaschild = NULL;
01148 a2dPropertyIdBool* a2dCanvasObject::PROPID_Visiblechilds = NULL;
01149 a2dPropertyIdBool* a2dCanvasObject::PROPID_Editable = NULL;
01150 a2dPropertyIdBool* a2dCanvasObject::PROPID_Editing = NULL;
01151 a2dPropertyIdBool* a2dCanvasObject::PROPID_EditingRender = NULL;
01152 a2dPropertyIdBool* a2dCanvasObject::PROPID_ChildrenOnSameLayer = NULL;
01153 a2dPropertyIdBool* a2dCanvasObject::PROPID_DoConnect = NULL;
01154 a2dPropertyIdBool* a2dCanvasObject::PROPID_IsOnCorridorPath = NULL;
01155 a2dPropertyIdBool* a2dCanvasObject::PROPID_HasPins = NULL;
01156 a2dPropertyIdBool* a2dCanvasObject::PROPID_IsProperty = NULL;
01157 a2dPropertyIdBool* a2dCanvasObject::PROPID_MouseInObject = NULL;
01158 a2dPropertyIdBool* a2dCanvasObject::PROPID_HighLight = NULL;
01159 a2dPropertyIdBool* a2dCanvasObject::PROPID_Template = NULL;
01160 a2dPropertyIdBool* a2dCanvasObject::PROPID_External = NULL;
01161 a2dPropertyIdBool* a2dCanvasObject::PROPID_Used = NULL;
01162 a2dPropertyIdBool* a2dCanvasObject::PROPID_Release = NULL;
01163 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_Begin = NULL;
01164 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_End = NULL;
01165 a2dPropertyIdDouble* a2dCanvasObject::PROPID_EndScaleX = NULL;
01166 a2dPropertyIdDouble* a2dCanvasObject::PROPID_EndScaleY = NULL;
01167 a2dPropertyIdBool* a2dCanvasObject::PROPID_Spline = NULL;
01168 a2dPropertyIdDouble* a2dCanvasObject::PROPID_ContourWidth = NULL;
01169 a2dPropertyIdBool* a2dCanvasObject::PROPID_Allowrotation = NULL;
01170 a2dPropertyIdBool* a2dCanvasObject::PROPID_Allowsizing = NULL;
01171 a2dPropertyIdBool* a2dCanvasObject::PROPID_Allowskew = NULL;
01172 a2dPropertyIdBool* a2dCanvasObject::PROPID_IncludeChildren = NULL;
01173 a2dPropertyIdRefObjectAutoZero* a2dCanvasObject::PROPID_Controller = NULL;
01174 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_Original = NULL;
01175 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_Editcopy = NULL;
01176 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_Parent = NULL;
01177 a2dPropertyIdCanvasObject* a2dCanvasObject::PROPID_Objecttip = NULL;
01178 a2dPropertyIdUint16* a2dCanvasObject::PROPID_Editmode = NULL;
01179 a2dPropertyIdUint16* a2dCanvasObject::PROPID_Editstyle = NULL;
01180 a2dPropertyIdUint16* a2dCanvasObject::PROPID_Index = NULL;
01181 a2dPropertyIdCanvasShadowStyle* a2dCanvasObject::PROPID_Shadowstyle = NULL;
01182 a2dPropertyIdFill* a2dCanvasObject::PROPID_Fill = NULL;
01183 a2dPropertyIdStroke* a2dCanvasObject::PROPID_Stroke = NULL;
01184 a2dPropertyIdInt32* a2dCanvasObject::PROPID_UpdateImmediatePriority = NULL;
01185 a2dPropertyIdUint32* a2dCanvasObject::PROPID_RefDesCount = NULL;
01186 a2dPropertyIdUint32* a2dCanvasObject::PROPID_RefDesNr = NULL;
01187 a2dPropertyIdBool* a2dCanvasObject::PROPID_ToolDecoration = NULL;
01188 a2dPropertyIdVoidPtr* a2dCanvasObject::PROPID_ToolObject = NULL;
01189 a2dPropertyIdBool* a2dCanvasObject::PROPID_TemporaryObject = NULL;
01190 a2dPropertyIdBoundingBox* a2dCanvasObject::PROPID_BoundingBox = NULL;
01191 a2dPropertyIdColour* a2dCanvasObject::PROPID_StrokeColour = NULL;
01192 a2dPropertyIdColour* a2dCanvasObject::PROPID_FillColour = NULL;
01193 a2dPropertyIdRefObject* a2dCanvasObject::PROPID_ViewSpecific = NULL;
01194 a2dPropertyIdBool* a2dCanvasObject::PROPID_FirstEventInObject = NULL;
01195 a2dPropertyIdUint16* a2dCanvasObject::PROPID_Datatype = NULL;
01196 a2dPropertyIdRefObject* a2dCanvasObject::PROPID_ViewDependent = NULL;
01197 a2dPropertyIdMatrix* a2dCanvasObject::PROPID_IntViewDependTransform = NULL;
01198 a2dPropertyIdDateTime* a2dCanvasObject::PROPID_DateTime = NULL;
01199 a2dPropertyIdDateTime* a2dCanvasObject::PROPID_ModificationDateTime = NULL;
01200 a2dPropertyIdDateTime* a2dCanvasObject::PROPID_AccessDateTime = NULL;
01201 a2dPropertyIdMenu* a2dCanvasObject::PROPID_PopupMenu = NULL;
01202 a2dPropertyIdWindow* a2dCanvasObject::PROPID_TipWindow = NULL;
01203
01204 DEFINE_EVENT_TYPE( sm_changedLayer )
01205
01206
01207 a2dDynamicIdMap& a2dCanvasObject::GetPropertyIdMap()
01208 {
01209 return sm_dymPropIds;
01210 }
01211 bool a2dCanvasObject::AddPropertyId( a2dPropertyId *dynproperty )
01212 {
01213 if ( sm_dymPropIds.find( dynproperty->GetName() ) == sm_dymPropIds.end() )
01214 sm_dymPropIds[ dynproperty->GetName() ]= dynproperty;
01215 else
01216 wxASSERT_MSG( 0, _("The property id name '") + dynproperty->GetName() + _("' already exists in #a2dCanvasObject") );
01217 return true;
01218 }
01219 bool a2dCanvasObject::HasPropertyId( const a2dPropertyId* id ) const
01220 {
01221 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
01222 {
01223 wxString name = (*i).first;
01224 a2dPropertyIdPtr propId = (*i).second;
01225 if ( propId == id )
01226 return true;
01227 }
01228 return a2dPropObject::HasPropertyId( id );
01229 }
01230 a2dPropertyId* a2dCanvasObject::HasPropertyId( const wxString& name )
01231 {
01232 if ( sm_dymPropIds.find( name ) != sm_dymPropIds.end() )
01233 return sm_dymPropIds[ name ];
01234 return a2dPropObject::HasPropertyId( name );
01235 }
01236 const a2dNamedProperty *a2dCanvasObject::FindProperty( const wxString &idName ) const
01237 {
01238 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
01239 {
01240 wxString name = (*i).first;
01241 a2dPropertyIdPtr propId = (*i).second;
01242 if ( propId->GetName() == idName )
01243 return GetProperty( propId );
01244 }
01245 return a2dPropObject::FindProperty( idName );
01246 }
01247 void a2dCanvasObject::CollectProperties2( a2dNamedPropertyList *total, const a2dPropertyId *id, a2dPropertyId::Flags flags ) const
01248 {
01249 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
01250 {
01251 wxString name = (*i).first;
01252 a2dPropertyIdPtr p = (*i).second;
01253 if( p->CheckCollect( id, flags ) )
01254 {
01255 a2dNamedProperty* dprop = p->GetPropertyAsNamedProperty( this );
01256 if ( dprop )
01257 total->push_back( dprop );
01258 }
01259 }
01260 return a2dPropObject::CollectProperties2( total, id, flags );
01261 }
01262 a2dDynamicIdMap a2dCanvasObject::sm_dymPropIds;
01263 static bool initPropa2dCanvasObject = a2dCanvasObject::InitializePropertyIds();
01264 bool a2dCanvasObject::InitializePropertyIds()
01265 {
01266 PROPID_TransformMatrix = new a2dPropertyIdMatrix( wxT("TransformMatrix"),
01267 a2dPropertyId::flag_none, a2dIDENTITY_MATRIX,
01268 a2dPropertyIdMatrix::Get( &a2dCanvasObject::GetTransform ),
01269 a2dPropertyIdMatrix::Set( &a2dCanvasObject::SetTransform ) );
01270 AddPropertyId( PROPID_TransformMatrix );
01271
01272 PROPID_Position = new a2dPropertyIdPoint2D( wxT("Position"),
01273 a2dPropertyId::flag_none, a2dPoint2D( 0, 0 ),
01274 a2dPropertyIdPoint2D::Get( &a2dCanvasObject::GetPosXY ),
01275 a2dPropertyIdPoint2D::ConstSet( &a2dCanvasObject::SetPosXyPoint ) );
01276 AddPropertyId( PROPID_Position );
01277
01278 PROPID_Layer = new a2dPropertyIdUint16( wxT("Layer"),
01279 a2dPropertyId::flag_none, 0,
01280 a2dPropertyIdUint16::Get( &a2dCanvasObject::GetLayer ),
01281 a2dPropertyIdUint16::Set( &a2dCanvasObject::SetLayer ) );
01282 AddPropertyId( PROPID_Layer );
01283
01284 PROPID_Selected = new a2dPropertyIdBool( wxT("Selected"),
01285 a2dPropertyId::flag_none, false,
01286 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSelected ),
01287 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSelected ) );
01288 AddPropertyId( PROPID_Selected );
01289
01290 PROPID_Selectable = new a2dPropertyIdBool( wxT("Selectable"),
01291 a2dPropertyId::flag_none, false,
01292 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSelectable ),
01293 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSelectable ) );
01294 AddPropertyId( PROPID_Selectable );
01295
01296 PROPID_SubEdit = new a2dPropertyIdBool( wxT("SubEdit"),
01297 a2dPropertyId::flag_none, false,
01298 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSubEdit ),
01299 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSubEdit ) );
01300 AddPropertyId( PROPID_SubEdit );
01301
01302 PROPID_SubEditAsChild = new a2dPropertyIdBool( wxT("SubEditAsChild"),
01303 a2dPropertyId::flag_none, false,
01304 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSubEditAsChild ),
01305 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSubEditAsChild ) );
01306 AddPropertyId( PROPID_SubEditAsChild );
01307
01308 PROPID_Visible = new a2dPropertyIdBool( wxT("Visible"),
01309 a2dPropertyId::flag_none, false,
01310 a2dPropertyIdBool::Get( &a2dCanvasObject::GetVisible ),
01311 a2dPropertyIdBool::Set( &a2dCanvasObject::SetVisible ) );
01312 AddPropertyId( PROPID_Visible );
01313
01314 PROPID_Draggable = new a2dPropertyIdBool( wxT("Draggable"),
01315 a2dPropertyId::flag_none, false,
01316 a2dPropertyIdBool::Get( &a2dCanvasObject::GetDraggable ),
01317 a2dPropertyIdBool::Set( &a2dCanvasObject::SetDraggable ) );
01318 AddPropertyId( PROPID_Draggable );
01319
01320 PROPID_Showshadow = new a2dPropertyIdBool( wxT("Showshadow"),
01321 a2dPropertyId::flag_none, false,
01322 a2dPropertyIdBool::Get( &a2dCanvasObject::GetShowshadow ),
01323 a2dPropertyIdBool::Set( &a2dCanvasObject::SetShowshadow ) );
01324 AddPropertyId( PROPID_Showshadow );
01325
01326 PROPID_Filled = new a2dPropertyIdBool( wxT("Filled"),
01327 a2dPropertyId::flag_none, false,
01328 a2dPropertyIdBool::Get( &a2dCanvasObject::GetFilled ),
01329 a2dPropertyIdBool::Set( &a2dCanvasObject::SetFilled ) );
01330 AddPropertyId( PROPID_Filled );
01331
01332 PROPID_GroupA = new a2dPropertyIdBool( wxT("GroupA"),
01333 a2dPropertyId::flag_none, false,
01334 a2dPropertyIdBool::Get( &a2dCanvasObject::GetGroupA ),
01335 a2dPropertyIdBool::Set( &a2dCanvasObject::SetGroupA ) );
01336 AddPropertyId( PROPID_GroupA );
01337
01338 PROPID_GroupB = new a2dPropertyIdBool( wxT("GroupB"),
01339 a2dPropertyId::flag_none, false,
01340 a2dPropertyIdBool::Get( &a2dCanvasObject::GetGroupB ),
01341 a2dPropertyIdBool::Set( &a2dCanvasObject::SetGroupB ) );
01342 AddPropertyId( PROPID_GroupB );
01343
01344 PROPID_GeneratePins = new a2dPropertyIdBool( wxT("GeneratePins"),
01345 a2dPropertyId::flag_none, false,
01346 a2dPropertyIdBool::Get( &a2dCanvasObject::GetGeneratePins ),
01347 a2dPropertyIdBool::Set( &a2dCanvasObject::SetGeneratePins ) );
01348 AddPropertyId( PROPID_GeneratePins );
01349
01350 PROPID_Bin = new a2dPropertyIdBool( wxT("Bin"),
01351 a2dPropertyId::flag_none, false,
01352 a2dPropertyIdBool::Get( &a2dCanvasObject::GetBin ),
01353 a2dPropertyIdBool::Set( &a2dCanvasObject::SetBin ) );
01354 AddPropertyId( PROPID_Bin );
01355
01356 PROPID_Bin2 = new a2dPropertyIdBool( wxT("Bin2"),
01357 a2dPropertyId::flag_none, false,
01358 a2dPropertyIdBool::Get( &a2dCanvasObject::GetBin2 ),
01359 a2dPropertyIdBool::Set( &a2dCanvasObject::SetBin2 ) );
01360 AddPropertyId( PROPID_Bin2 );
01361
01362 PROPID_Pending = new a2dPropertyIdBool( wxT("Pending"),
01363 a2dPropertyId::flag_none, false,
01364 a2dPropertyIdBool::Get( &a2dCanvasObject::GetPending ),
01365 a2dPropertyIdBool::Set( &a2dCanvasObject::SetPending ) );
01366 AddPropertyId( PROPID_Pending );
01367
01368 PROPID_Snap = new a2dPropertyIdBool( wxT("Snap"),
01369 a2dPropertyId::flag_none, false,
01370 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSnap ),
01371 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSnap ) );
01372 AddPropertyId( PROPID_Snap );
01373
01374 PROPID_SnapTo = new a2dPropertyIdBool( wxT("SnapTo"),
01375 a2dPropertyId::flag_none, false,
01376 a2dPropertyIdBool::Get( &a2dCanvasObject::GetSnapTo ),
01377 a2dPropertyIdBool::Set( &a2dCanvasObject::SetSnapTo ) );
01378 AddPropertyId( PROPID_SnapTo );
01379
01380 PROPID_Pushin = new a2dPropertyIdBool( wxT("Pushin"),
01381 a2dPropertyId::flag_none, false,
01382 a2dPropertyIdBool::Get( &a2dCanvasObject::GetPushin ),
01383 a2dPropertyIdBool::Set( &a2dCanvasObject::SetPushin ) );
01384 AddPropertyId( PROPID_Pushin );
01385
01386 PROPID_Prerenderaschild = new a2dPropertyIdBool( wxT("Prerenderaschild"),
01387 a2dPropertyId::flag_none, false,
01388 a2dPropertyIdBool::Get( &a2dCanvasObject::GetPrerenderaschild ),
01389 a2dPropertyIdBool::Set( &a2dCanvasObject::SetPrerenderaschild ) );
01390 AddPropertyId( PROPID_Prerenderaschild );
01391
01392 PROPID_Visiblechilds = new a2dPropertyIdBool( wxT("Visiblechilds"),
01393 a2dPropertyId::flag_none, false,
01394 a2dPropertyIdBool::Get( &a2dCanvasObject::GetVisiblechilds ),
01395 a2dPropertyIdBool::Set( &a2dCanvasObject::SetVisiblechilds ) );
01396 AddPropertyId( PROPID_Visiblechilds );
01397
01398 PROPID_Editable = new a2dPropertyIdBool( wxT("Editable"),
01399 a2dPropertyId::flag_none, false,
01400 a2dPropertyIdBool::Get( &a2dCanvasObject::GetEditable ),
01401 a2dPropertyIdBool::Set( &a2dCanvasObject::SetEditable ) );
01402 AddPropertyId( PROPID_Editable );
01403
01404 PROPID_Editing = new a2dPropertyIdBool( wxT("Editing"),
01405 a2dPropertyId::flag_none, false,
01406 a2dPropertyIdBool::Get( &a2dCanvasObject::GetEditing ),
01407 a2dPropertyIdBool::Set( &a2dCanvasObject::SetEditing ) );
01408 AddPropertyId( PROPID_Editing );
01409
01410 PROPID_EditingRender = new a2dPropertyIdBool( wxT("EditingRender"),
01411 a2dPropertyId::flag_none, false,
01412 a2dPropertyIdBool::Get( &a2dCanvasObject::GetEditingRender ),
01413 a2dPropertyIdBool::Set( &a2dCanvasObject::SetEditingRender ) );
01414 AddPropertyId( PROPID_EditingRender );
01415
01416 PROPID_ChildrenOnSameLayer = new a2dPropertyIdBool( wxT("ChildrenOnSameLayer"),
01417 a2dPropertyId::flag_none, false,
01418 a2dPropertyIdBool::Get( &a2dCanvasObject::GetChildrenOnSameLayer ),
01419 a2dPropertyIdBool::Set( &a2dCanvasObject::SetChildrenOnSameLayer ) );
01420 AddPropertyId( PROPID_ChildrenOnSameLayer );
01421
01422 PROPID_DoConnect = new a2dPropertyIdBool( wxT("DoConnect"),
01423 a2dPropertyId::flag_none, false,
01424 a2dPropertyIdBool::Get( &a2dCanvasObject::GetDoConnect ),
01425 a2dPropertyIdBool::Set( &a2dCanvasObject::SetDoConnect ) );
01426 AddPropertyId( PROPID_DoConnect );
01427
01428 PROPID_IsOnCorridorPath = new a2dPropertyIdBool( wxT("IsOnCorridorPath"),
01429 a2dPropertyId::flag_none, false,
01430 a2dPropertyIdBool::Get( &a2dCanvasObject::GetIsOnCorridorPath ),
01431 a2dPropertyIdBool::Set( &a2dCanvasObject::SetIsOnCorridorPath ) );
01432 AddPropertyId( PROPID_IsOnCorridorPath );
01433
01434 PROPID_HasPins = new a2dPropertyIdBool( wxT("HasPins"),
01435 a2dPropertyId::flag_none, false,
01436 a2dPropertyIdBool::Get( &a2dCanvasObject::GetHasPins ),
01437 a2dPropertyIdBool::Set( &a2dCanvasObject::SetHasPins ) );
01438 AddPropertyId( PROPID_HasPins );
01439
01440 PROPID_IsProperty = new a2dPropertyIdBool( wxT("IsProperty"),
01441 a2dPropertyId::flag_none, false,
01442 a2dPropertyIdBool::Get( &a2dCanvasObject::GetIsProperty ),
01443 a2dPropertyIdBool::Set( &a2dCanvasObject::SetIsProperty ) );
01444 AddPropertyId( PROPID_IsProperty );
01445
01446 PROPID_MouseInObject = new a2dPropertyIdBool( wxT("MouseInObject"),
01447 a2dPropertyId::flag_none, false,
01448 a2dPropertyIdBool::Get( &a2dCanvasObject::GetMouseInObject ),
01449 a2dPropertyIdBool::Set( &a2dCanvasObject::SetMouseInObject ) );
01450 AddPropertyId( PROPID_MouseInObject );
01451
01452 PROPID_HighLight = new a2dPropertyIdBool( wxT("HighLight"),
01453 a2dPropertyId::flag_none, false,
01454 a2dPropertyIdBool::Get( &a2dCanvasObject::GetHighLight ),
01455 a2dPropertyIdBool::Set( &a2dCanvasObject::SetHighLight ) );
01456 AddPropertyId( PROPID_HighLight );
01457
01458 PROPID_Template = new a2dPropertyIdBool( wxT("Template"),
01459 a2dPropertyId::flag_none, false,
01460 a2dPropertyIdBool::Get( &a2dCanvasObject::GetTemplate ),
01461 a2dPropertyIdBool::Set( &a2dCanvasObject::SetTemplate ) );
01462 AddPropertyId( PROPID_Template );
01463
01464 PROPID_External = new a2dPropertyIdBool( wxT("External"),
01465 a2dPropertyId::flag_none, false,
01466 a2dPropertyIdBool::Get( &a2dCanvasObject::GetExternal ),
01467 a2dPropertyIdBool::Set( &a2dCanvasObject::SetExternal ) );
01468 AddPropertyId( PROPID_External );
01469
01470 PROPID_Used = new a2dPropertyIdBool( wxT("Used"),
01471 a2dPropertyId::flag_none, false,
01472 a2dPropertyIdBool::Get( &a2dCanvasObject::GetUsed ),
01473 a2dPropertyIdBool::Set( &a2dCanvasObject::SetUsed ) );
01474 AddPropertyId( PROPID_Used );
01475
01476 PROPID_Release = new a2dPropertyIdBool( wxT("Release"),
01477 a2dPropertyId::flag_none, false,
01478 a2dPropertyIdBool::Get( &a2dCanvasObject::GetRelease ),
01479 a2dPropertyIdBool::Set( &a2dCanvasObject::SetRelease ) );
01480 AddPropertyId( PROPID_Release );
01481
01482 PROPID_Allowrotation = new a2dPropertyIdBool( wxT("Allowrotation"),
01483 a2dPropertyId::flag_none, false );
01484 AddPropertyId( PROPID_Allowrotation );
01485
01486 PROPID_Allowsizing = new a2dPropertyIdBool( wxT("Allowsizing"),
01487 a2dPropertyId::flag_none, false );
01488 AddPropertyId( PROPID_Allowsizing );
01489
01490 PROPID_Allowskew = new a2dPropertyIdBool( wxT("Allowskew"),
01491 a2dPropertyId::flag_none, false );
01492 AddPropertyId( PROPID_Allowskew );
01493
01494 PROPID_IncludeChildren = new a2dPropertyIdBool( wxT("IncludeChildren"),
01495 a2dPropertyId::flag_none, false );
01496 AddPropertyId( PROPID_IncludeChildren );
01497
01498
01499 PROPID_ToolDecoration = new a2dPropertyIdBool( wxT("ToolDecoration"),
01500 a2dPropertyId::flag_none, false );
01501 AddPropertyId( PROPID_ToolDecoration );
01502
01503
01504 PROPID_TemporaryObject = new a2dPropertyIdBool( wxT("TemporaryObject"),
01505 a2dPropertyId::flag_none, false );
01506 AddPropertyId( PROPID_TemporaryObject );
01507
01508
01509 PROPID_FirstEventInObject = new a2dPropertyIdBool( wxT("FirstEventInObject"),
01510 a2dPropertyId::flag_none, false );
01511 AddPropertyId( PROPID_FirstEventInObject );
01512
01513 PROPID_Begin = new a2dPropertyIdCanvasObject( wxT("Begin"),
01514 a2dPropertyId::flag_transfer|a2dPropertyId::flag_onlymemberhint, 0 );
01515 AddPropertyId( PROPID_Begin );
01516
01517 PROPID_End = new a2dPropertyIdCanvasObject( wxT("End"),
01518 a2dPropertyId::flag_transfer|a2dPropertyId::flag_onlymemberhint, 0 );
01519 AddPropertyId( PROPID_End );
01520
01521 PROPID_EndScaleX = new a2dPropertyIdDouble( wxT("EndScaleX"),
01522 a2dPropertyId::flag_transfer|a2dPropertyId::flag_onlymemberhint, 0 );
01523 AddPropertyId( PROPID_EndScaleX );
01524
01525 PROPID_EndScaleY = new a2dPropertyIdDouble( wxT("EndScaleY"),
01526 a2dPropertyId::flag_transfer|a2dPropertyId::flag_onlymemberhint, 0 );
01527 AddPropertyId( PROPID_EndScaleY );
01528
01529 PROPID_Spline = new a2dPropertyIdBool( wxT("Spline"),
01530 a2dPropertyId::flag_transfer|a2dPropertyId::flag_onlymemberhint, false );
01531 AddPropertyId( PROPID_Spline );
01532
01533 PROPID_ContourWidth = new a2dPropertyIdDouble( wxT("ContourWidth"),
01534 a2dPropertyId::flag_none, 0,
01535 a2dPropertyIdDouble::Get( &a2dCanvasObject::GetContourWidth ),
01536 a2dPropertyIdDouble::Set( &a2dCanvasObject::SetContourWidth ) );
01537 AddPropertyId( PROPID_ContourWidth );
01538
01539 PROPID_Original = new a2dPropertyIdCanvasObject( wxT("Original"),
01540 a2dPropertyId::flag_temporary, 0 );
01541 AddPropertyId( PROPID_Original );
01542
01543 PROPID_Editcopy = new a2dPropertyIdCanvasObject( wxT("Editcopy"),
01544 a2dPropertyId::flag_temporary, 0 );
01545 AddPropertyId( PROPID_Editcopy );
01546
01547 PROPID_Parent = new a2dPropertyIdCanvasObject( wxT("Parent"),
01548 a2dPropertyId::flag_temporary, 0 );
01549 AddPropertyId( PROPID_Parent );
01550
01551 PROPID_Objecttip = new a2dPropertyIdCanvasObject( wxT("Objecttip"),
01552 a2dPropertyId::flag_temporary, 0 );
01553 AddPropertyId( PROPID_Objecttip );
01554
01555 PROPID_Controller = new a2dPropertyIdRefObjectAutoZero( wxT("Controller"),
01556 a2dPropertyId::flag_temporary, 0 );
01557 AddPropertyId( PROPID_Controller );
01558
01559 PROPID_Editmode = new a2dPropertyIdUint16( wxT("Editmode"),
01560 a2dPropertyId::flag_none, 0 );
01561 AddPropertyId( PROPID_Editmode );
01562
01563 PROPID_Editstyle = new a2dPropertyIdUint16( wxT("Editstyle"),
01564 a2dPropertyId::flag_none, 0 );
01565 AddPropertyId( PROPID_Editstyle );
01566
01567 PROPID_Index = new a2dPropertyIdUint16( wxT("Index"),
01568 a2dPropertyId::flag_none, 0 );
01569 AddPropertyId( PROPID_Index );
01570 PROPID_Index = PROPID_Index;
01571
01572 PROPID_RefDesCount = new a2dPropertyIdUint32( wxT("RefDesCount"),
01573 a2dPropertyId::flag_none, 0 );
01574 AddPropertyId( PROPID_RefDesCount );
01575
01576 PROPID_RefDesNr = new a2dPropertyIdUint32( wxT("RefDesNr"),
01577 a2dPropertyId::flag_none, 0 );
01578 AddPropertyId( PROPID_RefDesNr );
01579
01580 PROPID_UpdateImmediatePriority = new a2dPropertyIdInt32( wxT("UpdateImmediatePriority"),
01581 a2dPropertyId::flag_none, 0 );
01582 AddPropertyId( PROPID_UpdateImmediatePriority );
01583
01584 PROPID_Shadowstyle = new a2dPropertyIdCanvasShadowStyle( wxT("Shadowstyle"),
01585 a2dPropertyId::flag_none );
01586 AddPropertyId( PROPID_Shadowstyle );
01587
01588 PROPID_Fill = new a2dPropertyIdFill( wxT("Fill"),
01589 a2dPropertyId::flag_transfer|a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep,
01590 *a2dNullFILL, static_cast < a2dPropertyIdFill::ConstGet >(&a2dCanvasObject::MX_GetFill), static_cast < a2dPropertyIdFill::ConstSet >(&a2dCanvasObject::MX_SetFill) );
01591 AddPropertyId( PROPID_Fill );
01592
01593 PROPID_Stroke = new a2dPropertyIdStroke( wxT("Stroke"),
01594 a2dPropertyId::flag_transfer|a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep,
01595 *a2dNullSTROKE, static_cast < a2dPropertyIdStroke::ConstGet >(&a2dCanvasObject::MX_GetStroke), static_cast < a2dPropertyIdStroke::ConstSet >(&a2dCanvasObject::MX_SetStroke) );
01596 AddPropertyId( PROPID_Stroke );
01597
01598 PROPID_ToolObject = new a2dPropertyIdVoidPtr( wxT("ToolObject"),
01599 a2dPropertyId::flag_none|a2dPropertyId::flag_temporary, 0 );
01600 AddPropertyId( PROPID_ToolObject );
01601
01602 PROPID_BoundingBox = new a2dPropertyIdBoundingBox( wxT("BoundingBox"),
01603 a2dPropertyId::flag_temporary|a2dPropertyId::flag_multiple, a2dBoundingBox() );
01604 AddPropertyId( PROPID_BoundingBox );
01605
01606 PROPID_FillColour = new a2dPropertyIdColour( wxT("FillColour"), a2dPropertyId::flag_none, wxColour(),
01607 static_cast < a2dPropertyIdColour::Get >( &a2dCanvasObject::GetFillColour ), static_cast < a2dPropertyIdColour::ConstSet >( &a2dCanvasObject::SetFillColour ) );
01608 AddPropertyId( PROPID_FillColour );
01609
01610 PROPID_StrokeColour = new a2dPropertyIdColour( wxT("StrokeColour"), a2dPropertyId::flag_none, wxColour(),
01611 static_cast < a2dPropertyIdColour::Get >( &a2dCanvasObject::GetStrokeColour ), static_cast < a2dPropertyIdColour::ConstSet >( &a2dCanvasObject::SetStrokeColour ) );
01612 AddPropertyId( PROPID_StrokeColour );
01613
01614 PROPID_ViewSpecific = new a2dPropertyIdRefObject( wxT("ViewSpecific"), a2dPropertyId::flag_temporary|a2dPropertyId::flag_listonly, 0 );
01615 AddPropertyId( PROPID_ViewSpecific );
01616
01617 PROPID_ViewDependent = new a2dPropertyIdRefObject( wxT("ViewDependent"), a2dPropertyId::flag_temporary|a2dPropertyId::flag_listonly, 0 );
01618 AddPropertyId( PROPID_ViewDependent );
01619
01620 PROPID_IntViewDependTransform = new a2dPropertyIdMatrix( wxT("IntViewDependTransform"), a2dPropertyId::flag_none, a2dIDENTITY_MATRIX );
01621 AddPropertyId( PROPID_IntViewDependTransform );
01622
01623 PROPID_Datatype = new a2dPropertyIdUint16( wxT("Datatype"), a2dPropertyId::flag_none, 0 );
01624 AddPropertyId( PROPID_Datatype );
01625
01626 PROPID_DateTime = new a2dPropertyIdDateTime( wxT("DateTime"),
01627 a2dPropertyId::flag_norender|a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep, wxDefaultDateTime );
01628 AddPropertyId( PROPID_DateTime );
01629
01630 PROPID_ModificationDateTime = new a2dPropertyIdDateTime( wxT("ModificationDateTime"),
01631 a2dPropertyId::flag_norender|a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep, wxDefaultDateTime );
01632 AddPropertyId( PROPID_ModificationDateTime );
01633
01634 PROPID_AccessDateTime = new a2dPropertyIdDateTime( wxT("AccessDateTime"),
01635 a2dPropertyId::flag_norender|a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep, wxDefaultDateTime );
01636 AddPropertyId( PROPID_AccessDateTime );
01637
01638 PROPID_PopupMenu = new a2dPropertyIdMenu( wxT("PopupMenu"), a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep, NULL );
01639 AddPropertyId( PROPID_PopupMenu );
01640
01641 PROPID_TipWindow = new a2dPropertyIdWindow( wxT("TipWindow"), a2dPropertyId::flag_listfirst|a2dPropertyId::flag_clonedeep, NULL );
01642 AddPropertyId( PROPID_TipWindow );
01643
01644 return true;
01645 }
01646
01647
01648 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::NON = 0x00000000;
01649 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SELECTED = 0x00000001;
01650 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SELECTABLE = 0x00000002;
01651 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::HasSelectedObjectsBelow = 0x00000004;
01652 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SubEdit = 0x00000008;
01653 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SubEditAsChild = 0x00000010;
01654 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::VISIBLE = 0x00000020;
01655 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::DRAGGABLE = 0x00000040;
01656 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SHOWSHADOW = 0x00000080;
01657 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::FILLED = 0x00000100;
01658 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::A = 0x00000200;
01659 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::B = 0x00000400;
01660 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::generatePins = 0x00000800;
01661 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::BIN = 0x00001000;
01662 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::BIN2 = 0x00002000;
01663 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::PENDING = 0x00004000;
01664 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SNAP = 0x00008000;
01665 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::PUSHIN = 0x00010000;
01666 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::PRERENDERASCHILD = 0x00020000;
01667 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::VISIBLECHILDS = 0x00040000;
01668 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::EDITABLE = 0x00080000;
01669 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ChildrenOnSameLayer= 0x00100000;
01670
01671 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::DoConnect = 0x00200000;
01672 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::IsOnCorridorPath = 0x00400000;
01673 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::HasPins = 0x00800000;
01674 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::Editing = 0x01000000;
01675 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::EditingCopy = 0x02000000;
01676 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::IsProperty = 0x04000000;
01677 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::MouseInObject = 0x08000000;
01678 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::HighLight = 0x10000000;
01679 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::Notused = 0x20000000;
01680 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ignoreSetpending = 0x40000000;
01681 #if defined(__UNIX__) || defined(__GNUG__)
01682 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::HasToolObjectsBelow = 0x080000000LL;
01683 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ChildOnlyTranslate = 0x100000000LL;
01684 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ignoreLayer = 0x200000000LL;
01685 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SNAP_TO = 0x400000000LL;
01686 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::normalized = 0x800000000LL;
01687 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::NoRenderCanvasObject = 0x1000000000LL;
01688
01689 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ALL = 0xFFFFFFFFFFFFFFFFLL;
01690 #else
01691 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::HasToolObjectsBelow = 0x080000000;
01692 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ChildOnlyTranslate = 0x100000000;
01693 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ignoreLayer = 0x200000000;
01694 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::SNAP_TO = 0x400000000;
01695 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::normalized = 0x800000000;
01696 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::NoRenderCanvasObject = 0x1000000000;
01697 const a2dCanvasObjectFlagsMask a2dCanvasOFlags::ALL = 0xFFFFFFFFFFFFFFFF;
01698 #endif
01699
01700 a2dCanvasOFlags::a2dCanvasOFlags( a2dCanvasObjectFlagsMask which )
01701 {
01702 SetFlags( which );
01703 }
01704
01705 void a2dCanvasOFlags::SetSpecificFlags( bool setOrClear, a2dCanvasObjectFlagsMask which )
01706 {
01707 if ( which ==a2dCanvasOFlags::ALL )
01708 {
01709 m_selected = setOrClear;
01710 m_selectable = setOrClear;
01711 m_HasSelectedObjectsBelow = setOrClear;
01712 m_subEdit = setOrClear;
01713 m_subEditAsChild = setOrClear;
01714 m_visible = setOrClear;
01715 m_draggable = setOrClear;
01716 m_showshadow = setOrClear;
01717 m_filled = setOrClear;
01718 m_a = setOrClear;
01719 m_b = setOrClear;
01720 m_generatePins = setOrClear;
01721 m_bin = setOrClear;
01722 m_bin2 = setOrClear;
01723 m_pending = setOrClear;
01724 m_snap = setOrClear;
01725 m_snap_to = setOrClear;
01726 m_pushin = setOrClear;
01727 m_prerenderaschild = setOrClear;
01728 m_visiblechilds = setOrClear;
01729 m_editable = setOrClear;
01730 m_childrenOnSameLayer = setOrClear;
01731 m_doConnect = setOrClear;
01732 m_isOnCorridorPath = setOrClear;
01733 m_hasPins = setOrClear;
01734 m_editing = setOrClear;
01735 m_IsProperty = setOrClear;
01736 m_MouseInObject =
01737 m_HighLight = setOrClear;
01738 m_editingCopy = setOrClear;
01739 m_ignoreSetpending = setOrClear;
01740 m_template = setOrClear;
01741 m_external = setOrClear;
01742 m_resizeToChilds = setOrClear;
01743 m_normalized = setOrClear;
01744 }
01745 else if(which == a2dCanvasOFlags::PENDING)
01746 m_pending = setOrClear;
01747 else
01748 {
01749 if ( 0 < (which & a2dCanvasOFlags::SELECTABLE)) m_selectable = setOrClear;
01750 if ( 0 < (which & a2dCanvasOFlags::SELECTED)) m_selected = setOrClear;
01751 if ( 0 < (which & a2dCanvasOFlags::HasSelectedObjectsBelow)) m_HasSelectedObjectsBelow = setOrClear;
01752 if ( 0 < (which & a2dCanvasOFlags::SubEdit)) m_subEdit = setOrClear;
01753 if ( 0 < (which & a2dCanvasOFlags::SubEditAsChild)) m_subEditAsChild = setOrClear;
01754 if ( 0 < (which & a2dCanvasOFlags::VISIBLE)) m_visible = setOrClear;
01755 if ( 0 < (which & a2dCanvasOFlags::DRAGGABLE)) m_draggable = setOrClear;
01756 if ( 0 < (which & a2dCanvasOFlags::SHOWSHADOW)) m_showshadow = setOrClear;
01757 if ( 0 < (which & a2dCanvasOFlags::FILLED)) m_filled = setOrClear;
01758 if ( 0 < (which & a2dCanvasOFlags::A)) m_a = setOrClear;
01759 if ( 0 < (which & a2dCanvasOFlags::B)) m_b = setOrClear;
01760 if ( 0 < (which & a2dCanvasOFlags::generatePins)) m_generatePins = setOrClear;
01761 if ( 0 < (which & a2dCanvasOFlags::BIN)) m_bin = setOrClear;
01762 if ( 0 < (which & a2dCanvasOFlags::BIN2)) m_bin2 = setOrClear;
01763 if ( 0 < (which & a2dCanvasOFlags::PENDING)) m_pending = setOrClear;
01764 if ( 0 < (which & a2dCanvasOFlags::SNAP)) m_snap = setOrClear;
01765 if ( 0 < (which & a2dCanvasOFlags::SNAP_TO)) m_snap_to = setOrClear;
01766 if ( 0 < (which & a2dCanvasOFlags::PUSHIN)) m_pushin = setOrClear;
01767 if ( 0 < (which & a2dCanvasOFlags::PRERENDERASCHILD)) m_prerenderaschild = setOrClear;
01768 if ( 0 < (which & a2dCanvasOFlags::VISIBLECHILDS)) m_visiblechilds = setOrClear;
01769 if ( 0 < (which & a2dCanvasOFlags::EDITABLE)) m_editable = setOrClear;
01770 if ( 0 < (which & a2dCanvasOFlags::ChildrenOnSameLayer)) m_childrenOnSameLayer = setOrClear;
01771 if ( 0 < (which & a2dCanvasOFlags::DoConnect)) m_doConnect = setOrClear;
01772 if ( 0 < (which & a2dCanvasOFlags::IsOnCorridorPath)) m_isOnCorridorPath = setOrClear;
01773 if ( 0 < (which & a2dCanvasOFlags::HasPins)) m_hasPins = setOrClear;
01774 if ( 0 < (which & a2dCanvasOFlags::Editing)) m_editing = setOrClear;
01775 if ( 0 < (which & a2dCanvasOFlags::EditingCopy)) m_editingCopy = setOrClear;
01776 if ( 0 < (which & a2dCanvasOFlags::IsProperty)) m_IsProperty = setOrClear;
01777 if ( 0 < (which & a2dCanvasOFlags::MouseInObject)) m_MouseInObject = setOrClear;
01778 if ( 0 < (which & a2dCanvasOFlags::HighLight)) m_HighLight = setOrClear;
01779 if ( 0 < (which & a2dCanvasOFlags::ignoreSetpending)) m_ignoreSetpending = setOrClear;
01780 if ( 0 < (which & a2dCanvasOFlags::normalized)) m_normalized = setOrClear;
01781 }
01782 }
01783
01784 void a2dCanvasOFlags::SetFlags( a2dCanvasObjectFlagsMask which )
01785 {
01786 if ( which ==a2dCanvasOFlags::ALL )
01787 {
01788 m_selected = true;
01789 m_selectable = true;
01790 m_HasSelectedObjectsBelow = true;
01791 m_subEdit = true;
01792 m_subEditAsChild = true;
01793 m_visible = true;
01794 m_draggable = true;
01795 m_showshadow = true;
01796 m_filled = true;
01797 m_a = true;
01798 m_b = true;
01799 m_generatePins = true;
01800 m_bin = true;
01801 m_pending = true;
01802 m_snap = true;
01803 m_snap_to = true;
01804 m_pushin = true;
01805 m_prerenderaschild = true;
01806 m_visiblechilds = true;
01807 m_editable = true;
01808 m_childrenOnSameLayer = true;
01809 m_doConnect = true;
01810 m_isOnCorridorPath = true;
01811 m_hasPins = true;
01812 m_editing = true;
01813 m_editingCopy = true;
01814 m_IsProperty = true;
01815 m_MouseInObject = true;
01816 m_HighLight = true;
01817 m_ignoreSetpending = true;
01818 m_template = true;
01819 m_external = true;
01820 m_resizeToChilds = true;
01821 m_normalized = true;
01822 }
01823 else
01824 {
01825 m_selectable = 0 < (which & a2dCanvasOFlags::SELECTABLE);
01826 m_selected = ( 0 < (which & a2dCanvasOFlags::SELECTED)) && m_selectable;
01827 m_HasSelectedObjectsBelow = 0 < (which & a2dCanvasOFlags::HasSelectedObjectsBelow);
01828 m_subEdit = 0 < (which & a2dCanvasOFlags::SubEdit);
01829 m_subEditAsChild = 0 < (which & a2dCanvasOFlags::SubEditAsChild);
01830 m_visible = 0 < (which & a2dCanvasOFlags::VISIBLE);
01831 m_draggable = 0 < (which & a2dCanvasOFlags::DRAGGABLE) ;
01832 m_showshadow = 0 < (which & a2dCanvasOFlags::SHOWSHADOW);
01833 m_filled = 0 < (which & a2dCanvasOFlags::FILLED);
01834 m_a = 0 < (which & a2dCanvasOFlags::A);
01835 m_b = 0 < (which & a2dCanvasOFlags::B);
01836 m_generatePins = 0 < (which & a2dCanvasOFlags::generatePins);
01837 m_bin = 0 < (which & a2dCanvasOFlags::BIN);
01838 m_bin2 = 0 < (which & a2dCanvasOFlags::BIN2);
01839 m_pending = 0 < (which & a2dCanvasOFlags::PENDING);
01840 m_snap = 0 < (which & a2dCanvasOFlags::SNAP);
01841 m_snap_to = 0 < (which & a2dCanvasOFlags::SNAP_TO);
01842 m_pushin = 0 < (which & a2dCanvasOFlags::PUSHIN);
01843 m_prerenderaschild = 0 < (which & a2dCanvasOFlags::PRERENDERASCHILD);
01844 m_visiblechilds = 0 < (which & a2dCanvasOFlags::VISIBLECHILDS);
01845 m_editable = 0 < (which & a2dCanvasOFlags::EDITABLE) ;
01846 m_childrenOnSameLayer = 0 < (which & a2dCanvasOFlags::ChildrenOnSameLayer);
01847 m_doConnect = 0 < (which & a2dCanvasOFlags::DoConnect);
01848 m_isOnCorridorPath = 0 < (which & a2dCanvasOFlags::IsOnCorridorPath);
01849 m_hasPins = 0 < (which & a2dCanvasOFlags::HasPins);
01850 m_editing = 0 < (which & a2dCanvasOFlags::Editing);
01851 m_editingCopy = 0 < (which & a2dCanvasOFlags::EditingCopy);
01852 m_IsProperty = 0 < (which & a2dCanvasOFlags::IsProperty);
01853 m_MouseInObject = 0 < (which & a2dCanvasOFlags::MouseInObject);
01854 m_HighLight = 0 < (which & a2dCanvasOFlags::HighLight);
01855 m_ignoreSetpending = 0 < (which & a2dCanvasOFlags::ignoreSetpending);
01856 m_ChildOnlyTranslate = 0 < (which & ChildOnlyTranslate);
01857 m_ignoreLayer = 0 < (which & ignoreLayer);
01858 m_normalized = 0 < (which & a2dCanvasOFlags::normalized);
01859 }
01860 }
01861
01862 bool a2dCanvasOFlags::GetFlag( a2dCanvasObjectFlagsMask which ) const
01863 {
01864 switch ( which )
01865 {
01866 case a2dCanvasOFlags::SELECTED: return m_selected;
01867 case a2dCanvasOFlags::SELECTABLE: return m_selectable;
01868 case a2dCanvasOFlags::HasSelectedObjectsBelow: return m_HasSelectedObjectsBelow;
01869 case a2dCanvasOFlags::SubEdit: return m_subEdit;
01870 case a2dCanvasOFlags::SubEditAsChild: return m_subEditAsChild;
01871 case a2dCanvasOFlags::VISIBLE: return m_visible;
01872 case a2dCanvasOFlags::DRAGGABLE: return m_draggable;
01873 case a2dCanvasOFlags::SHOWSHADOW: return m_showshadow;
01874 case a2dCanvasOFlags::FILLED: return m_filled;
01875 case a2dCanvasOFlags::A: return m_a;
01876 case a2dCanvasOFlags::B: return m_b;
01877 case a2dCanvasOFlags::generatePins: return m_generatePins;
01878 case a2dCanvasOFlags::BIN: return m_bin;
01879 case a2dCanvasOFlags::BIN2: return m_bin2;
01880 case a2dCanvasOFlags::PENDING: return m_pending;
01881 case a2dCanvasOFlags::SNAP: return m_snap;
01882 case a2dCanvasOFlags::SNAP_TO: return m_snap_to;
01883 case a2dCanvasOFlags::PUSHIN: return m_pushin;
01884 case a2dCanvasOFlags::PRERENDERASCHILD: return m_prerenderaschild;
01885 case a2dCanvasOFlags::VISIBLECHILDS: return m_visiblechilds;
01886 case a2dCanvasOFlags::EDITABLE: return m_editable;
01887 case a2dCanvasOFlags::ChildrenOnSameLayer: return m_childrenOnSameLayer;
01888 case a2dCanvasOFlags::DoConnect: return m_doConnect;
01889 case a2dCanvasOFlags::IsOnCorridorPath: return m_isOnCorridorPath;
01890 case a2dCanvasOFlags::HasPins: return m_hasPins;
01891 case a2dCanvasOFlags::Editing: return m_editing;
01892 case a2dCanvasOFlags::EditingCopy: return m_editingCopy;
01893 case a2dCanvasOFlags::IsProperty: return m_IsProperty;
01894 case a2dCanvasOFlags::MouseInObject: return m_MouseInObject;
01895 case a2dCanvasOFlags::HighLight: return m_HighLight;
01896 case a2dCanvasOFlags::ignoreSetpending: return m_ignoreSetpending;
01897 case a2dCanvasOFlags::normalized: return m_normalized;
01898 case a2dCanvasOFlags::NoRenderCanvasObject: return m_NoRenderCanvasObject;
01899 default:
01900 wxFAIL_MSG( wxT("This Flag not implemented") );
01901 return false;
01902 }
01903 }
01904
01905 a2dCanvasObjectFlagsMask a2dCanvasOFlags::GetFlags() const
01906 {
01907 a2dCanvasObjectFlagsMask oflags = a2dCanvasOFlags::NON;
01908
01909 if (m_selected) oflags = oflags | a2dCanvasOFlags::SELECTED;
01910 if (m_selectable) oflags = oflags | a2dCanvasOFlags::SELECTABLE;
01911 if (m_HasSelectedObjectsBelow) oflags = oflags | a2dCanvasOFlags::HasSelectedObjectsBelow;
01912 if (m_subEdit) oflags = oflags | a2dCanvasOFlags::SubEdit;
01913 if (m_subEditAsChild) oflags = oflags | a2dCanvasOFlags::SubEditAsChild;
01914 if (m_visible) oflags = oflags | a2dCanvasOFlags::VISIBLE;
01915 if (m_editable) oflags = oflags | a2dCanvasOFlags::EDITABLE;
01916 if (m_showshadow) oflags = oflags | a2dCanvasOFlags::SHOWSHADOW;
01917 if (m_filled) oflags = oflags | a2dCanvasOFlags::FILLED;
01918 if (m_a) oflags = oflags | a2dCanvasOFlags::A;
01919 if (m_b) oflags = oflags | a2dCanvasOFlags::B;
01920 if (m_generatePins) oflags = oflags | a2dCanvasOFlags::generatePins;
01921 if (m_bin) oflags = oflags | a2dCanvasOFlags::BIN;
01922 if (m_bin2) oflags = oflags | a2dCanvasOFlags::BIN2;
01923 if (m_pending) oflags = oflags | a2dCanvasOFlags::PENDING;
01924 if (m_snap) oflags = oflags | a2dCanvasOFlags::SNAP;
01925 if (m_snap_to) oflags = oflags | a2dCanvasOFlags::SNAP_TO;
01926 if (m_pushin) oflags = oflags | a2dCanvasOFlags::PUSHIN;
01927 if (m_prerenderaschild) oflags = oflags | a2dCanvasOFlags::PRERENDERASCHILD;
01928 if (m_visiblechilds) oflags = oflags | a2dCanvasOFlags::VISIBLECHILDS;
01929 if (m_editable) oflags = oflags | a2dCanvasOFlags::EDITABLE;
01930 if (m_childrenOnSameLayer) oflags = oflags | a2dCanvasOFlags::ChildrenOnSameLayer;
01931 if (m_doConnect) oflags = oflags | a2dCanvasOFlags::DoConnect;
01932 if (m_isOnCorridorPath) oflags = oflags | a2dCanvasOFlags::IsOnCorridorPath;
01933 if (m_hasPins) oflags = oflags | a2dCanvasOFlags::HasPins;
01934 if (m_editing) oflags = oflags | a2dCanvasOFlags::Editing;
01935 if (m_editingCopy) oflags = oflags | a2dCanvasOFlags::EditingCopy;
01936 if (m_IsProperty) oflags = oflags | a2dCanvasOFlags::IsProperty;
01937 if (m_MouseInObject) oflags = oflags | a2dCanvasOFlags::MouseInObject;
01938 if (m_HighLight) oflags = oflags | a2dCanvasOFlags::HighLight;
01939 if (m_ignoreSetpending) oflags = oflags | a2dCanvasOFlags::ignoreSetpending;
01940 if (m_normalized) oflags = oflags | a2dCanvasOFlags::normalized;
01941 if (m_NoRenderCanvasObject) oflags = oflags | a2dCanvasOFlags::NoRenderCanvasObject;
01942
01943 return oflags;
01944 }
01945
01946 bool a2dCanvasOFlags::CheckMask( a2dCanvasObjectFlagsMask mask) const
01947 {
01948 if ( mask == a2dCanvasOFlags::NON )
01949 return true;
01950 if ( mask ==a2dCanvasOFlags::ALL )
01951 return true;
01952
01953
01954 if ( 0 < (mask & a2dCanvasOFlags::VISIBLE) && !m_visible ) return false;
01955 if ( 0 < (mask & a2dCanvasOFlags::SELECTABLE) && !m_selectable ) return false;
01956 if ( 0 < (mask & a2dCanvasOFlags::SELECTED) && !m_selected ) return false;
01957 if ( 0 < (mask & a2dCanvasOFlags::HasSelectedObjectsBelow) && !m_HasSelectedObjectsBelow ) return false;
01958 if ( 0 < (mask & a2dCanvasOFlags::SubEdit) && !m_subEdit ) return false;
01959 if ( 0 < (mask & a2dCanvasOFlags::SubEditAsChild) && !m_subEditAsChild ) return false;
01960 if ( 0 < (mask & a2dCanvasOFlags::DRAGGABLE) && !m_draggable ) return false;
01961 if ( 0 < (mask & a2dCanvasOFlags::SHOWSHADOW) && !m_showshadow ) return false;
01962 if ( 0 < (mask & a2dCanvasOFlags::FILLED) && !m_filled ) return false;
01963 if ( 0 < (mask & a2dCanvasOFlags::A) && !m_a ) return false;
01964 if ( 0 < (mask & a2dCanvasOFlags::B) && !m_b ) return false;
01965 if ( 0 < (mask & a2dCanvasOFlags::generatePins) && !m_generatePins ) return false;
01966 if ( 0 < (mask & a2dCanvasOFlags::BIN) && !m_bin ) return false;
01967 if ( 0 < (mask & a2dCanvasOFlags::BIN2) && !m_bin2 ) return false;
01968 if ( 0 < (mask & a2dCanvasOFlags::PENDING) && !m_pending ) return false;
01969 if ( 0 < (mask & a2dCanvasOFlags::SNAP) && !m_snap ) return false;
01970 if ( 0 < (mask & a2dCanvasOFlags::SNAP_TO) && !m_snap_to ) return false;
01971 if ( 0 < (mask & a2dCanvasOFlags::PUSHIN) && !m_pushin ) return false;
01972 if ( 0 < (mask & a2dCanvasOFlags::PRERENDERASCHILD) && !m_prerenderaschild ) return false;
01973 if ( 0 < (mask & a2dCanvasOFlags::VISIBLECHILDS) && !m_visiblechilds ) return false;
01974 if ( 0 < (mask & a2dCanvasOFlags::EDITABLE) && !m_editable ) return false;
01975 if ( 0 < (mask & a2dCanvasOFlags::ChildrenOnSameLayer) && !m_childrenOnSameLayer ) return false;
01976 if ( 0 < (mask & a2dCanvasOFlags::DoConnect) && !m_doConnect ) return false;
01977 if ( 0 < (mask & a2dCanvasOFlags::IsOnCorridorPath) && !m_isOnCorridorPath ) return false;
01978 if ( 0 < (mask & a2dCanvasOFlags::HasPins) && !m_hasPins ) return false;
01979 if ( 0 < (mask & a2dCanvasOFlags::Editing) && !m_editing ) return false;
01980 if ( 0 < (mask & a2dCanvasOFlags::EditingCopy) && !m_editingCopy ) return false;
01981 if ( 0 < (mask & a2dCanvasOFlags::IsProperty) && !m_IsProperty ) return false;
01982 if ( 0 < (mask & a2dCanvasOFlags::MouseInObject) && !m_MouseInObject ) return false;
01983 if ( 0 < (mask & a2dCanvasOFlags::HighLight) && !m_HighLight ) return false;
01984 if ( 0 < (mask & a2dCanvasOFlags::ignoreSetpending) && !m_ignoreSetpending ) return false;
01985 if ( 0 < (mask & a2dCanvasOFlags::normalized) && !m_normalized ) return false;
01986 if ( 0 < (mask & a2dCanvasOFlags::NoRenderCanvasObject) && !m_NoRenderCanvasObject ) return false;
01987
01988 return true;
01989 }
01990
01991
01992 a2dCanvasOFlags a2dCanvasObject::m_flagsInit =
01993 a2dCanvasOFlags
01994 (
01995 a2dCanvasOFlags::VISIBLE | a2dCanvasOFlags::DRAGGABLE | a2dCanvasOFlags::EDITABLE | a2dCanvasOFlags::FILLED | a2dCanvasOFlags::SELECTABLE |
01996 a2dCanvasOFlags::SHOWSHADOW |a2dCanvasOFlags::VISIBLECHILDS |
01997 a2dCanvasOFlags::DoConnect | a2dCanvasOFlags::SNAP | a2dCanvasOFlags::SNAP_TO | a2dCanvasOFlags::generatePins
01998
01999 );
02000
02001 DEFINE_EVENT_TYPE( a2dCanvasObject::sm_changedLayer )
02002
02003 IMPLEMENT_DYNAMIC_CLASS(a2dCanvasObject, a2dEvtHandler)
02004
02005 IMPLEMENT_CLASS( a2dCanvasObject::a2dDoUpdateImmediateData, a2dPropObject );
02006
02007 A2D_BEGIN_EVENT_TABLE(a2dCanvasObject,a2dEvtHandler)
02008 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dCanvasObject::OnCanvasObjectMouseEvent )
02009 A2D_EVT_CANVASHANDLE_MOUSE_EVENT( a2dCanvasObject::OnHandleEvent )
02010 A2D_EVT_CANVASOBJECT_ENTER_EVENT( a2dCanvasObject::OnEnterObject )
02011 A2D_EVT_CANVASOBJECT_LEAVE_EVENT( a2dCanvasObject::OnLeaveObject )
02012 A2D_EVT_CANVASOBJECT_POPUPMENU_EVENT( a2dCanvasObject::OnPopUpEvent )
02013 A2D_EVT_CHAR( a2dCanvasObject::OnChar )
02014 A2D_END_EVENT_TABLE()
02015
02016 a2dCanvasObject::a2dCanvasObject( double x, double y )
02017 {
02018 m_lworld.Translate( x, y );
02019
02020 m_childobjects = wxNullCanvasObjectList;
02021
02022
02023 SetHitFlags( a2dCANOBJ_EVENT_VISIBLE );
02024
02025 m_root = NULL;
02026
02027 m_flags = m_flagsInit;
02028
02029 m_layer = wxLAYER_DEFAULT;
02030
02031
02032 SetPending(true);
02033
02034 m_worldExtend = 0;
02035 m_pixelExtend = 0;
02036 }
02037
02038 a2dCanvasObject::~a2dCanvasObject()
02039 {
02040 if ( m_childobjects != wxNullCanvasObjectList )
02041 {
02042 delete m_childobjects;
02043 m_childobjects = wxNullCanvasObjectList;
02044 }
02045 }
02046
02047 a2dObject* a2dCanvasObject::Clone( CloneOptions options ) const
02048 {
02049 return new a2dCanvasObject( *this, options );
02050 }
02051
02052 a2dCanvasObject::a2dCanvasObject( const a2dCanvasObject &other, CloneOptions options )
02053 :a2dEvtHandler( other, options )
02054 {
02055 m_root = other.m_root;
02056
02057 m_flags = other.m_flags;
02058
02059 m_hitflags = other.m_hitflags;
02060
02061 m_flags.m_showshadow = true;
02062
02063 m_layer = other.m_layer;
02064
02065 m_lworld = other.m_lworld;
02066
02067 m_childobjects = wxNullCanvasObjectList;
02068 if ( other.m_childobjects != wxNullCanvasObjectList )
02069 {
02070 m_childobjects = new a2dCanvasObjectList();
02071
02072 forEachIn( a2dCanvasObjectList, other.m_childobjects )
02073 {
02074 a2dCanvasObject *obj = *iter;
02075
02076 if ( obj && !obj->GetRelease() )
02077 {
02078 if( options & clone_childs )
02079 {
02080 a2dCanvasObject* objn = obj->TClone( CloneOptions( options & ~ clone_seteditcopy ) );
02081
02082
02083 objn->SetParent( this );
02084 m_childobjects->push_back( objn );
02085 }
02086 else
02087 {
02088 m_childobjects->push_back( obj );
02089 }
02090 }
02091 }
02092 }
02093
02094 if( options & clone_seteditcopy )
02095 {
02096
02097
02098 PROPID_Editcopy->SetPropertyToObject( const_cast<a2dCanvasObject*>( &other ), this );
02099 }
02100
02101 if( options & clone_setoriginal )
02102 {
02103
02104 PROPID_Original->SetPropertyToObject( this, const_cast<a2dCanvasObject*>( &other ) );
02105 }
02106
02107 m_bbox = other.m_bbox;
02108 m_bbox.SetValid( false );
02109 m_worldExtend = other.m_worldExtend;
02110 m_pixelExtend = other.m_pixelExtend;
02111 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
02112
02113 CurrentSmartPointerOwner = this;
02114 #endif
02115 }
02116
02117 void a2dCanvasObject::SentChangeLayerEvent( wxUint16 layer )
02118 {
02119
02120
02121
02122
02123 if ( layer == wxLAYER_DEFAULT )
02124 return;
02125
02126 a2dComEvent changedlayer( this, PROPID_Layer, layer, &sm_changedLayer );
02127 a2dDocviewGlobals->GetEventDistributer()->ProcessEvent( changedlayer );
02128 }
02129
02130 a2dCanvasObjectList* a2dCanvasObject::GetAsCanvasVpaths( bool WXUNUSED(transform) )
02131 {
02132 return wxNullCanvasObjectList;
02133 }
02134
02135 bool a2dCanvasObject::SetPosXYRestrict( double& x, double& y )
02136 {
02137 double xold = m_lworld.GetValue(2,0);
02138 double yold = m_lworld.GetValue(2,1);
02139 if( m_flags.m_snap )
02140 {
02141 a2dRestrictionEngine *restrictEngine = a2dCanvasGlobals->GetRestrictionEngine();
02142 if (restrictEngine )
02143 restrictEngine->RestrictPoint( x, y );
02144 }
02145 if(xold != x || yold != y)
02146 {
02147 m_lworld.SetValue(2,0,x); m_lworld.SetValue(2,1,y); SetPending(true);
02148 return true;
02149 }
02150 return false;
02151 }
02152
02153 void a2dCanvasObject::SetPosXY( double x, double y, bool restrict )
02154 {
02155 double xold = m_lworld.GetValue(2,0);
02156 double yold = m_lworld.GetValue(2,1);
02157
02158 if( restrict )
02159 {
02160 SetPosXYRestrict( x, y );
02161 }
02162
02163 if(xold != x || yold != y)
02164 {
02165 m_lworld.SetValue(2,0,x); m_lworld.SetValue(2,1,y); SetPending(true);
02166 }
02167 }
02168
02169 a2dCanvasObject* a2dCanvasObject::StartEdit( a2dBaseTool* tool, wxUint16 editmode, wxEditStyle editstyle )
02170 {
02171 if ( m_flags.m_editable )
02172 {
02173 a2dCanvasObjectPtr editcopy;
02174
02175 if( editstyle & wxEDITSTYLE_CONNECTED )
02176 editcopy = TClone( clone_members | clone_childs | clone_seteditcopy | clone_setoriginal | clone_reconnectable );
02177 else
02178 editcopy = TClone( clone_members | clone_childs | clone_seteditcopy | clone_setoriginal );
02179
02180 editcopy->DoConnect( false );
02181 SetSnapTo( false );
02182 editcopy->SetSnapTo( false );
02183 SetSelected( false );
02184 editcopy->SetSelected( false );
02185
02186 if ( ! PROPID_Allowrotation->GetPropertyValue( this ))
02187 PROPID_Allowrotation->SetPropertyToObject( editcopy, true );
02188 if ( ! PROPID_Allowsizing->GetPropertyValue( this ) )
02189 PROPID_Allowsizing->SetPropertyToObject( editcopy, true );
02190 if ( ! PROPID_Allowskew->GetPropertyValue( this ) )
02191 PROPID_Allowskew->SetPropertyToObject( editcopy, true );
02192 PROPID_Parent->SetPropertyToObject( editcopy, tool->GetParentObject() );
02193 editcopy->m_flags.m_editingCopy = true;
02194
02195 editcopy->Update( updatemask_force );
02196
02197 m_flags.m_editing = true;
02198
02199 PROPID_Editmode->SetPropertyToObject( editcopy, editmode );
02200 PROPID_Editstyle->SetPropertyToObject( editcopy, (wxUint16) editstyle );
02201
02202
02203 PROPID_IncludeChildren->SetPropertyToObject( editcopy, true );
02204 PROPID_Controller->SetPropertyToObject( editcopy, tool->GetToolController() );
02205 PROPID_ViewSpecific->SetPropertyToObject( editcopy, tool->GetCanvasView() );
02206
02207 PROPID_FirstEventInObject->SetPropertyToObject( editcopy, true );
02208
02209 if ( !editcopy->DoStartEdit( editmode, editstyle ) )
02210 {
02211 EndEdit();
02212 return NULL;
02213 }
02214
02215
02216 tool->AddEditobject( editcopy );
02217
02218 return editcopy;
02219 }
02220
02221 return NULL;
02222 }
02223
02224 void a2dCanvasObject::ReStartEdit( wxUint16 editmode )
02225 {
02226
02227 a2dCanvasObjectPtr editcopy = this;
02228
02229
02230 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
02231 a2dCanvasObject* parent = PROPID_Parent->GetPropertyValue( this );
02232 a2dToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dToolContr );
02233 wxUint16 editstyle = PROPID_Editstyle->GetPropertyValue( this );
02234
02235
02236 EndEdit();
02237
02238
02239 m_release = false;
02240 SetVisible( true );
02241 SetIgnoreSetpending( false );
02242 SetSelected( false );
02243 PROPID_Allowrotation->SetPropertyToObject( editcopy, true );
02244 PROPID_Allowsizing->SetPropertyToObject( editcopy, true );
02245 PROPID_Allowskew->SetPropertyToObject( editcopy, true );
02246 PROPID_Original->SetPropertyToObject( editcopy, original );
02247 PROPID_Parent->SetPropertyToObject( editcopy, parent );
02248
02249 PROPID_Editstyle->SetPropertyToObject( editcopy, editstyle );
02250
02251 PROPID_Editcopy->SetPropertyToObject( original, editcopy );
02252
02253 m_flags.m_editingCopy = true;
02254
02255 Update( updatemask_force );
02256
02257 original->m_flags.m_editing = true;
02258
02259 PROPID_Editmode->SetPropertyToObject( editcopy, editmode );
02260
02261 PROPID_IncludeChildren->SetPropertyToObject( editcopy, true );
02262 PROPID_Controller->SetPropertyToObject( editcopy, controller );
02263
02264
02265 DoStartEdit( editmode , (wxEditStyle) editstyle );
02266
02267 parent->Append( this );
02268 }
02269
02270 bool a2dCanvasObject::DoStartEdit( wxUint16 WXUNUSED(editmode), wxEditStyle WXUNUSED(editstyle) )
02271 {
02272 if ( m_flags.m_editable )
02273 {
02274 bool allowrotation = PROPID_Allowrotation->GetPropertyValue( this );
02275 bool allowsizing = PROPID_Allowsizing->GetPropertyValue( this );
02276 bool allowskew = PROPID_Allowskew->GetPropertyValue( this );
02277
02278 m_flags.m_visiblechilds = true;
02279 m_flags.m_childrenOnSameLayer = true;
02280
02281
02282
02283
02284 a2dBoundingBox untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_EDIT );
02285 if ( untrans.GetWidth() == 0 || untrans.GetWidth() == 0 )
02286 untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_CHILDREN | a2dCANOBJ_BBOX_EDIT );
02287
02288 double x,y,w,h;
02289 x = untrans.GetMinX();
02290 y = untrans.GetMinY();
02291 w = untrans.GetWidth();
02292 h = untrans.GetHeight();
02293
02294
02295 a2dRect* around = new a2dRect( x, y, w, h );
02296 around->SetStroke( *wxRED, 0, a2dSTROKE_DOT_DASH );
02297 around->SetFill( *a2dTRANSPARENT_FILL );
02298 around->SetPreRenderAsChild( false );
02299 around->SetSpecificFlags( true, a2dCanvasOFlags::BIN2 );
02300 around->SetHitFlags( a2dCANOBJ_EVENT_NON );
02301 around->SetLayer( m_layer );
02302 Append( around );
02303
02304 a2dHandle* handle = NULL;
02305 if ( allowsizing )
02306 {
02307 Append( handle = new a2dHandle( this, x, y, wxT("handle1") ));
02308 handle->SetLayer( m_layer );
02309 Append( handle = new a2dHandle( this, x, y+h, wxT("handle2") ));
02310 handle->SetLayer( m_layer );
02311 Append( handle = new a2dHandle( this, x+w, y+h , wxT("handle3") ));
02312 handle->SetLayer( m_layer );
02313 Append( handle = new a2dHandle( this, x+w, y, wxT("handle4") ));
02314 handle->SetLayer( m_layer );
02315 Append( handle = new a2dHandle( this, x, y+h/2 , wxT("handle12") ));
02316 handle->SetLayer( m_layer );
02317 Append( handle = new a2dHandle( this, x+w/2, y+h, wxT("handle23") ));
02318 handle->SetLayer( m_layer );
02319 Append( handle = new a2dHandle( this, x+w, y+h/2 , wxT("handle34") ));
02320 handle->SetLayer( m_layer );
02321 Append( handle = new a2dHandle( this, x+w/2, y, wxT("handle41") ));
02322 }
02323
02324 if ( allowrotation )
02325 {
02326 a2dSLine* rotline = new a2dSLine( x + w/2, y + h/2, x + w*3/4, y + h/2 );
02327 rotline->SetStroke( *wxRED, 0 );
02328 rotline->SetPreRenderAsChild( false );
02329 rotline->SetHitFlags( a2dCANOBJ_EVENT_NON );
02330 Append( rotline );
02331 rotline->SetLayer( m_layer );
02332
02333 Append( handle = new a2dHandle( this, x+w*3/4, y+h/2, wxT("rotate") ));
02334 handle->SetLayer( m_layer );
02335 rotline->SetBin2( true );
02336 }
02337 if ( allowskew )
02338 {
02339 Append( handle = new a2dHandle( this, x+w*3/4, y+h, wxT("skewx") ));
02340 handle->SetLayer( m_layer );
02341 Append( handle = new a2dHandle( this, x+w, y+h*3/4, wxT("skewy") ));
02342 handle->SetLayer( m_layer );
02343 }
02344
02345 m_childobjects->SetSpecificFlags( false, a2dCanvasOFlags::PRERENDERASCHILD, wxT("a2dHandle") );
02346 m_childobjects->SetSpecificFlags( true, a2dCanvasOFlags::BIN2, wxT("a2dHandle") );
02347
02348
02349
02350 Update( updatemask_force );
02351
02352 SetPending( true );
02353 return true;
02354 }
02355
02356 return false;
02357 }
02358
02359 void a2dCanvasObject::EndEdit()
02360 {
02361
02362 DoEndEdit();
02363
02364 SetSnapTo( true );
02365 m_flags.m_editingCopy = false;
02366
02367
02368 if ( m_childobjects != wxNullCanvasObjectList )
02369 m_childobjects->Release( a2dCanvasOFlags::BIN2 );
02370
02371
02372
02373
02374 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
02375
02376
02377 RemoveProperty( PROPID_Original );
02378
02379 RemoveProperty( PROPID_Allowrotation );
02380 RemoveProperty( PROPID_Allowsizing );
02381 RemoveProperty( PROPID_Allowskew );
02382
02383 RemoveProperty( PROPID_Editmode );
02384 RemoveProperty( PROPID_Editstyle );
02385 RemoveProperty( PROPID_Controller );
02386 RemoveProperty( PROPID_IncludeChildren );
02387
02388 a2dCanvasObject* parent = PROPID_Parent->GetPropertyValue( this );
02389 RemoveProperty( PROPID_Parent );
02390
02391 SetPending( true );
02392
02393 original->m_flags.m_editing = false;
02394
02395
02396
02397 original->RemoveProperty( PROPID_Editcopy );
02398
02399
02400 SetVisible( false );
02401 SetIgnoreSetpending( true );
02402
02403 if ( parent )
02404 parent->ReleaseChild( this );
02405 }
02406
02407 a2dCanvasObject* a2dCanvasObject::GetOriginal()
02408 {
02409 return PROPID_Original->GetPropertyValue( this ).Get();
02410 }
02411
02412 a2dHandle* a2dCanvasObject::SetHandlePos( wxString name, double x, double y )
02413 {
02414 a2dHandle* handle = NULL;
02415
02416 if ( m_childobjects != wxNullCanvasObjectList )
02417 {
02418 forEachIn( a2dCanvasObjectList, m_childobjects )
02419 {
02420 handle = wxDynamicCast( (*iter).Get(), a2dHandle );
02421 if ( handle && handle->GetName() == name )
02422 {
02423 handle->SetPosXY( x, y );
02424 return handle;
02425 }
02426 }
02427 }
02428 return NULL;
02429 }
02430
02431 void a2dCanvasObject::OnChar(wxKeyEvent& event)
02432 {
02433 if ( m_flags.m_editingCopy && m_flags.m_editable )
02434 {
02435 switch(event.GetKeyCode())
02436 {
02437 case WXK_SPACE:
02438 {
02439 EndEdit();
02440 event.Skip();
02441 }
02442 break;
02443 default:
02444 event.Skip();
02445 }
02446 }
02447 else
02448 event.Skip();
02449 }
02450
02451 void a2dCanvasObject::OnPopUpEvent( a2dCanvasObjectMouseEvent &event)
02452 {
02453 a2dIterC* ic = event.GetIterC();
02454
02455 if ( HasDynamicProperties() )
02456 {
02457 const a2dMenuProperty* prop = PROPID_PopupMenu->GetPropertyListOnly( this );
02458 if ( prop )
02459 {
02460 wxWindow* win = ic->GetCanvasView()->GetDisplayWindow();
02461 win->PopupMenu( prop->GetValue(), event.GetMouseEvent().GetX(), event.GetMouseEvent().GetY() );
02462
02463 }
02464 else
02465 event.Skip();
02466 }
02467 else
02468 event.Skip();
02469 }
02470
02471 void a2dCanvasObject::OnEnterObject(a2dCanvasObjectMouseEvent &event)
02472 {
02473 a2dIterC* ic = event.GetIterC();
02474
02475 if ( HasDynamicProperties() )
02476 {
02477 a2dCanvasObjectPtrProperty* prop = PROPID_Objecttip->GetPropertyListOnly( this );
02478 if ( prop )
02479 {
02480 prop->SetVisible( true );
02481 SetPending( true );
02482 }
02483
02484 a2dTipWindowProperty * tipProp = wxDynamicCast( a2dPropObject::FindProperty( PROPID_TipWindow ), a2dTipWindowProperty );
02485 if ( tipProp )
02486 {
02487 wxTipWindow* tipWindow = wxDynamicCast(tipProp->GetValue(),wxTipWindow);
02488 wxWindow* win = ic->GetCanvasView()->GetDisplayWindow();
02489 if(tipWindow)
02490 {
02491
02492 tipWindow->SetTipWindowPtr(NULL);
02493 tipWindow->Close();
02494 }
02495
02496 wxRect tipRect = tipProp->GetRect();
02497 wxPoint aWinPos(0,0);
02498 aWinPos = win->ClientToScreen(aWinPos);
02499 wxRect aRect( aWinPos.x + event.GetMouseEvent().GetX() - tipRect.GetX(),
02500 aWinPos.y + event.GetMouseEvent().GetY() - tipRect.GetY(), tipRect.GetWidth(), tipRect.GetHeight() );
02501 if ( tipProp->GetUseObjRect() )
02502 {
02503 aRect = GetAbsoluteArea( *ic );
02504 wxPoint aWinPos1 = win->ClientToScreen( aRect.GetTopLeft() );
02505 wxPoint aWinPos2 = win->ClientToScreen( aRect.GetBottomRight() );
02506 aRect = wxRect( aWinPos1, aWinPos2 );
02507 }
02508 tipWindow = new wxTipWindow(win,tipProp->GetString(), 200 , (wxTipWindow**)tipProp->GetValuePtr(), &aRect);
02509 tipProp->SetValue(tipWindow);
02510 }
02511 }
02512
02513
02514 if ( m_flags.m_editingCopy && m_flags.m_editable )
02515 {
02516 if( ic->GetCanvasView()->GetCaptured() == this )
02517 ic->GetCanvasView()->PushCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
02518 else
02519 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
02520 }
02521 }
02522
02523 void a2dCanvasObject::OnLeaveObject(a2dCanvasObjectMouseEvent &event)
02524 {
02525 a2dIterC* ic = event.GetIterC();
02526
02527 if ( HasDynamicProperties() )
02528 {
02529 a2dCanvasObjectPtrProperty* prop = PROPID_Objecttip->GetPropertyListOnly( this );
02530 if ( prop )
02531 {
02532 prop->SetVisible( false );
02533 SetPending( true );
02534 }
02535 const a2dWindowProperty * tipProp = PROPID_TipWindow->GetPropertyListOnly( this );;
02536 if ( tipProp )
02537 {
02538 wxTipWindow* tipWindow = wxDynamicCast(tipProp->GetValue(),wxTipWindow);
02539 if(tipWindow)
02540 {
02541
02542
02543
02544
02545
02546 }
02547
02548 }
02549 }
02550
02551
02552 if ( m_flags.m_editingCopy && m_flags.m_editable )
02553 {
02554 if( ic->GetCanvasView()->GetCaptured() == this )
02555 ic->GetCanvasView()->PopCursor();
02556 else
02557 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL ) );
02558 }
02559 }
02560
02561 void a2dCanvasObject::LeaveInObjects( a2dIterC& ic, a2dHitEvent& hitEvent )
02562 {
02563 a2dCanvasObjectList::reverse_iterator iter = m_childobjects->rbegin();
02564 while( iter != m_childobjects->rend() )
02565 {
02566 a2dCanvasObject *obj = *iter;
02567
02568 obj->LeaveInObjects( ic, hitEvent );
02569 if ( obj->m_flags.m_MouseInObject )
02570 {
02571
02572
02573 obj->m_flags.m_MouseInObject = false;
02574 wxMouseEvent* mouse = wxDynamicCast( hitEvent.m_event, wxMouseEvent );
02575 a2dCanvasObjectMouseEvent leave( &ic, obj, wxEVT_CANVASOBJECT_LEAVE_EVENT, hitEvent.m_x, hitEvent.m_y, *mouse );
02576 hitEvent.SetProcessed( obj->ProcessEvent( leave ) );
02577 }
02578 iter++;
02579 }
02580 }
02581
02582 void a2dCanvasObject::OnHandleEvent(a2dHandleMouseEvent &event)
02583 {
02584 a2dIterC* ic = event.GetIterC();
02585
02586 if ( m_flags.m_editingCopy && m_flags.m_editable )
02587 {
02588 a2dRestrictionEngine *restrictEngine = a2dCanvasGlobals->GetRestrictionEngine();
02589
02590 a2dHandle* draghandle = event.GetCanvasHandle();
02591
02592
02593 double xw,yw;
02594 xw = event.GetX();
02595 yw = event.GetY();
02596
02597
02598
02599 double xwi;
02600 double ywi;
02601 ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
02602
02603 bool __includeChildren__ = PROPID_IncludeChildren->GetPropertyValue( this );
02604 a2dBoundingBox untrans;
02605 if ( __includeChildren__ )
02606 untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_CHILDREN | a2dCANOBJ_BBOX_EDIT );
02607 else
02608 untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_EDIT );
02609
02610 double xmin,ymin,xmax,ymax,w,h;
02611 xmin = untrans.GetMinX();
02612 ymin = untrans.GetMinY();
02613 xmax = untrans.GetMaxX();
02614 ymax = untrans.GetMaxY();
02615 w = untrans.GetWidth();
02616 h = untrans.GetHeight();
02617
02618 a2dAffineMatrix origworld = m_lworld;
02619 double x1,y1,x2,y2;
02620
02621 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
02622
02623 if ( event.GetMouseEvent().LeftDown() )
02624 {
02625 if (restrictEngine )
02626 restrictEngine->SetRestrictPoint( xw, yw );
02627 }
02628 else if (event.GetMouseEvent().LeftUp() )
02629 {
02630 if ( m_lworld != original->GetTransformMatrix() )
02631 {
02632 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_TransformMatrix, m_lworld ) );
02633
02634 a2dDocviewGlobals->RecordF( this, wxT("setproperty __M_Transform { matrix ( %g %g %g %g %g %g ) } transform"),
02635 m_lworld.GetValue(0,0), m_lworld.GetValue(0,1),
02636 m_lworld.GetValue(1,0), m_lworld.GetValue(1,1),
02637 m_lworld.GetValue(2,0), m_lworld.GetValue(2,1) );
02638 }
02639 }
02640 else if ( event.GetMouseEvent().Dragging() )
02641 {
02642 if (restrictEngine )
02643 restrictEngine->RestrictPoint( xw, yw );
02644 ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
02645
02646 if ( draghandle->GetName() == wxT("handle1") )
02647 {
02648
02649 double dx,dy;
02650 dx = xwi-xmin;
02651 dy = ywi-ymin;
02652
02653 double sx;
02654 double sy;
02655 if ( w )
02656 sx = (w-dx/2)/w;
02657 else
02658 sx = 0;
02659 if ( h )
02660 sy = (h-dy/2)/h;
02661 else
02662 sy = 0;
02663
02664 origworld.TransformPoint( xmax,ymax, x2, y2 );
02665
02666
02667 SetTransformMatrix();
02668 Scale(sx,sy);
02669 Transform( origworld );
02670 m_lworld.TransformPoint( xmax, ymax, x1, y1 );
02671 Translate(x2-x1, y2-y1);
02672 }
02673 else if ( draghandle->GetName() == wxT("handle2") )
02674 {
02675
02676 double dx,dy;
02677 dx = xwi-xmin;
02678 dy = ywi-ymax;
02679
02680 double sx;
02681 double sy;
02682 if ( w )
02683 sx = (w-dx/2)/w;
02684 else
02685 sx = 0;
02686 if ( h )
02687 sy = (h+dy/2)/h;
02688 else
02689 sy = 0;
02690
02691 origworld.TransformPoint( xmax, ymin, x2, y2 );
02692
02693
02694 SetTransformMatrix();
02695 Scale(sx,sy);
02696 Transform( origworld );
02697 m_lworld.TransformPoint( xmax, ymin, x1, y1 );
02698 Translate(x2-x1, y2-y1);
02699 }
02700 else if ( draghandle->GetName() == wxT("handle3") )
02701 {
02702
02703 double dx,dy;
02704 dx = xwi-xmax;
02705 dy = ywi-ymax;
02706
02707 double sx;
02708 double sy;
02709 if ( w )
02710 sx = (w+dx/2)/w;
02711 else
02712 sx = 0;
02713 if ( h )
02714 sy = (h+dy/2)/h;
02715 else
02716 sy = 0;
02717
02718 origworld.TransformPoint( xmin, ymin, x2, y2 );
02719
02720
02721 SetTransformMatrix();
02722 Scale(sx,sy);
02723 Transform( origworld );
02724 m_lworld.TransformPoint( xmin, ymin, x1, y1 );
02725 Translate(x2-x1, y2-y1);
02726 }
02727 else if ( draghandle->GetName() == wxT("handle4") )
02728 {
02729
02730 double dx,dy;
02731 dx = xwi-xmax;
02732 dy = ywi-ymin;
02733
02734 double sx;
02735 double sy;
02736 if ( w )
02737 sx = (w+dx/2)/w;
02738 else
02739 sx = 0;
02740 if ( h )
02741 sy = (h-dy/2)/h;
02742 else
02743 sy = 0;
02744
02745 origworld.TransformPoint( xmin, ymax, x2, y2 );
02746
02747
02748 SetTransformMatrix();
02749 Scale(sx,sy);
02750 Transform( origworld );
02751 m_lworld.TransformPoint( xmin, ymax, x1, y1 );
02752 Translate(x2-x1, y2-y1);
02753 }
02754 else if ( draghandle->GetName() == wxT("rotate") )
02755 {
02756 double xr, yr;
02757 m_lworld.TransformPoint( xmin + w/2, ymin + h/2, xr, yr );
02758
02759
02760 double dx,dy;
02761
02762 dx = xw - xr;
02763 dy = yw - yr;
02764 double angn;
02765 if (!dx && !dy)
02766 angn=0;
02767 else
02768 angn= wxRadToDeg(atan2(dy,dx));
02769
02770 m_lworld = m_lworld.Rotate(angn-m_lworld.GetRotation(), xr, yr );
02771
02772
02773
02774
02775
02776 }
02777 else if ( draghandle->GetName() == wxT("skewx") )
02778 {
02779
02780 double dx,dy;
02781
02782 dx = xwi-(xmin + w*3/4);
02783 dy = ywi-(ymin + h/2);
02784
02785 origworld.TransformPoint( xmin + w/2, ymin + h/2, x2, y2 );
02786
02787
02788 SetTransformMatrix();
02789 SkewX( wxRadToDeg(atan2(dx,dy)) );
02790 Transform( origworld );
02791 m_lworld.TransformPoint( xmin + w/2, ymin + h/2, x1, y1 );
02792 Translate(x2-x1, y2-y1);
02793 }
02794 else if ( draghandle->GetName() == wxT("skewy") )
02795 {
02796
02797 double dx,dy;
02798
02799 dx = xwi-(xmin + w/2);
02800 dy = ywi-(ymin + h*3/4);
02801
02802 origworld.TransformPoint( xmin + w/2, ymin + h/2, x2, y2 );
02803
02804
02805 SetTransformMatrix();
02806 SkewY( wxRadToDeg(atan2(dy,dx)) );
02807 Transform( origworld );
02808 m_lworld.TransformPoint( xmin + w/2, ymin + h/2, x1, y1 );
02809 Translate(x2-x1, y2-y1);
02810 }
02811 else if ( draghandle->GetName() == wxT("handle12") )
02812 {
02813
02814 double dx;
02815
02816 dx = xwi-xmin;
02817
02818 double sx;
02819 if ( w )
02820 sx = (w-dx/2)/w;
02821 else
02822 sx = 0;
02823
02824 origworld.TransformPoint( xmax, ymax, x2, y2 );
02825
02826
02827 SetTransformMatrix();
02828 Scale( sx, 1 );
02829 Transform( origworld );
02830 m_lworld.TransformPoint( xmax, ymax, x1, y1 );
02831 Translate(x2-x1, y2-y1);
02832 }
02833 else if ( draghandle->GetName() == wxT("handle23") )
02834 {
02835
02836 double dy;
02837
02838 dy = ywi-ymax;
02839
02840 double sy;
02841 if ( h )
02842 sy = (h+dy/2)/h;
02843 else
02844 sy = 0;
02845
02846 origworld.TransformPoint( xmax, ymin, x2, y2 );
02847
02848
02849 SetTransformMatrix();
02850 Scale( 1, sy );
02851 Transform( origworld );
02852 m_lworld.TransformPoint( xmax, ymin, x1, y1 );
02853 Translate(x2-x1, y2-y1);
02854 }
02855 else if ( draghandle->GetName() == wxT("handle34") )
02856 {
02857
02858 double dx;
02859
02860 dx = xwi-xmax;
02861
02862 double sx;
02863 if ( w )
02864 sx = (w+dx/2)/w;
02865 else
02866 sx = 0;
02867
02868 origworld.TransformPoint( xmin, ymin, x2, y2 );
02869
02870
02871 SetTransformMatrix();
02872 Scale( sx, 1 );
02873 Transform( origworld );
02874 m_lworld.TransformPoint( xmin, ymin, x1, y1 );
02875 Translate(x2-x1, y2-y1);
02876 }
02877 else if ( draghandle->GetName() == wxT("handle41") )
02878 {
02879
02880 double dy;
02881
02882 dy = ywi - ymin;
02883
02884 double sy;
02885 if ( h )
02886 sy = (h-dy/2)/h;
02887 else
02888 sy = 0;
02889
02890 origworld.TransformPoint( xmin, ymax, x2, y2 );
02891
02892
02893 SetTransformMatrix();
02894 Scale( 1, sy );
02895 Transform( origworld );
02896 m_lworld.TransformPoint( xmin, ymax, x1, y1 );
02897 Translate(x2-x1, y2-y1);
02898 }
02899 else
02900 event.Skip();
02901 SetPending( true );
02902 }
02903 }
02904 }
02905
02906 void a2dCanvasObject::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
02907 {
02908 a2dIterC* ic = event.GetIterC();
02909 ic->SetPerLayerMode( false );
02910
02911 if ( m_flags.m_editingCopy )
02912 ic->SetPerLayerMode( false );
02913
02914 if ( event.GetMouseEvent().RightDown() )
02915 {
02916
02917
02918
02919 a2dCanvasObjectMouseEvent popup( ic, this, wxEVT_CANVASOBJECT_POPUPMENU_EVENT, event.GetX(), event.GetY(), event.m_mouseevent );
02920 popup.SetEventObject( this );
02921
02922 if ( !this->ProcessEvent( popup ) )
02923 event.Skip();
02924 }
02925
02926
02927 else if ( m_flags.m_editingCopy && m_flags.m_editable )
02928 {
02929 a2dRestrictionEngine *restrictEngine = a2dCanvasGlobals->GetRestrictionEngine();
02930 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
02931 a2dCanvasObject* parent = PROPID_Parent->GetPropertyValue( this );
02932
02933 static double xshift;
02934 static double yshift;
02935
02936 double xw,yw;
02937 xw = event.GetX();
02938 yw = event.GetY();
02939
02940 double xh,yh;
02941 ic->GetInverseTransform().TransformPoint(xw, yw, xh, yh);
02942
02943 if ( event.GetMouseEvent().Moving() )
02944 {
02945
02946 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
02947 event.Skip();
02948 }
02949 else if ( event.GetMouseEvent().LeftDClick() )
02950 {
02951
02952
02953 EndEdit();
02954 }
02955 else if (event.GetMouseEvent().LeftDown() )
02956 {
02957
02958
02959
02960 a2dHitEvent hitevent = a2dHitEvent( xw, yw, false );
02961 if ( IsHitWorld( *ic, hitevent ) )
02962 {
02963 if (restrictEngine )
02964 restrictEngine->SetRestrictPoint( xw, yw );
02965
02966 if ( 1 )
02967 {
02968 a2dCanvasObject* hit = NULL;
02969 {
02970
02971 a2dCanvasObject* label = original->Find( wxT("__LABEL__") );
02972
02973 if ( label )
02974 {
02975 a2dIterCU cu( *ic, original );
02976 a2dHitEvent hitevent = a2dHitEvent( xw, yw, false );
02977 hit = label->IsHitWorld( *ic, hitevent );
02978 }
02979 else if ( m_flags.m_subEdit )
02980 {
02981 a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_NOROOT );
02982 hit = original->IsHitWorld( *ic, hitevent );
02983 if ( hit && !hit->m_flags.m_subEditAsChild )
02984 hit = NULL;
02985
02986 }
02987 }
02988 if ( hit && hit->GetEditable())
02989 {
02990 a2dIterCU cu( *ic, original );
02991 a2dToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dToolContr );
02992
02993
02994
02995
02996 ic->SetCorridorPath( true, NULL );
02997 controller->StartEditingObject( hit, *ic );
02998 }
02999
03000
03001 else if ( IsDraggable() )
03002 {
03003
03004
03005 ic->SetCorridorPathCaptureObject( this );
03006 ic->GetCanvasView()->PushCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_Move ) );
03007
03008 xshift = GetPosX()-xh;
03009 yshift = GetPosY()-yh;
03010 }
03011 }
03012 }
03013
03014
03015 else
03016 {
03017 EndEdit();
03018 }
03019 }
03020 else if (event.GetMouseEvent().LeftUp() && ic->GetCanvasView()->GetCaptured() )
03021 {
03022
03023 ic->SetCorridorPathCaptureObject( NULL );
03024 ic->GetCanvasView()->PopCursor();
03025
03026 if ( m_lworld != original->GetTransformMatrix() )
03027 {
03028 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( original, PROPID_TransformMatrix, m_lworld ) );
03029
03030 a2dDocviewGlobals->RecordF( this, wxT("setproperty __M_Transform { matrix ( %g %g %g %g %g %g )} transform"),
03031 m_lworld.GetValue(0,0), m_lworld.GetValue(0,1),
03032 m_lworld.GetValue(1,0), m_lworld.GetValue(1,1),
03033 m_lworld.GetValue(2,0), m_lworld.GetValue(2,1) );
03034 }
03035 }
03036 else if ( IsDraggable() && event.GetMouseEvent().Dragging() && ic->GetCanvasView()->GetCaptured() )
03037 {
03038 double x,y;
03039 x = xh + xshift;
03040 y = yh + yshift;
03041
03042 if(restrictEngine)
03043 {
03044
03045 SetPosXY( x, y );
03046
03047 a2dPoint2D point;
03048 double dx, dy;
03049 if ( restrictEngine->RestrictCanvasObjectAtVertexes( this, point, dx, dy ) )
03050 {
03051
03052 x += dx;
03053 y += dy;
03054 }
03055 }
03056 SetPosXY( x, y );
03057 }
03058 else
03059 event.Skip();
03060 }
03061 else
03062 event.Skip();
03063
03064 }
03065
03066 a2dCanvasObjectList* a2dCanvasObject::GetChildObjectList()
03067 {
03068 return m_childobjects;
03069 }
03070
03071 const a2dCanvasObjectList* a2dCanvasObject::GetChildObjectList() const
03072 {
03073 return m_childobjects;
03074 }
03075
03076 a2dCanvasObjectList* a2dCanvasObject::CreateChildObjectList()
03077 {
03078 if ( m_childobjects == wxNullCanvasObjectList )
03079 m_childobjects = new a2dCanvasObjectList();
03080
03081 return m_childobjects;
03082 }
03083
03084
03085 unsigned int a2dCanvasObject::GetChildObjectsCount() const
03086 {
03087 if ( m_childobjects == wxNullCanvasObjectList )
03088 return 0;
03089 return m_childobjects->size();
03090 }
03091
03092
03093 void a2dCanvasObject::SetPending(bool pending)
03094 {
03095 if ( m_ignoreAllSetpending )
03096 return;
03097
03098 m_flags.m_pending = pending;
03099
03100 if ( pending && !m_flags.m_ignoreSetpending )
03101 {
03102 if ( m_flags.m_hasPins && !IsConnect() )
03103 {
03104 SetConnectedPending( pending, true );
03105 }
03106 if ( m_root )
03107 m_root->SetUpdatesPending(true);
03108 }
03109 }
03110
03111 void a2dCanvasObject::SetTransformMatrix( double xt, double yt, double scalex, double scaley, double degrees )
03112 {
03113 m_lworld = a2dAffineMatrix( xt, yt, scalex, scaley, degrees ); SetPending(true);
03114 }
03115
03116 void a2dCanvasObject::SetRotation(double rotation)
03117 {
03118 m_lworld.SetRotation(rotation);
03119 SetPending(true);
03120 }
03121
03122 void a2dCanvasObject::Rotate(double rotation)
03123 {
03124 m_lworld.Rotate(rotation);
03125 SetPending(true);
03126 }
03127
03128 void a2dCanvasObject::SkewX( double angle )
03129 {
03130 m_lworld.SkewX(angle);
03131 SetPending(true);
03132 }
03133
03134 void a2dCanvasObject::SkewY( double angle )
03135 {
03136 m_lworld.SkewY(angle);
03137 SetPending(true);
03138 }
03139
03140 void a2dCanvasObject::Scale(double scalex, double scaley)
03141 {
03142 m_lworld.Scale(scalex, scaley, m_lworld.GetValue(2,0), m_lworld.GetValue(2,1));
03143 SetPending(true);
03144 }
03145
03146 void a2dCanvasObject::Mirror(bool x, bool y)
03147 {
03148 m_lworld.Mirror( x, y );
03149 SetPending(true);
03150 }
03151
03152 void a2dCanvasObject::SetSpecificFlags( bool setOrClear, a2dCanvasObjectFlagsMask which )
03153 {
03154 m_flags.SetSpecificFlags( setOrClear, which );
03155 }
03156
03157 void a2dCanvasObject::SetFlags( a2dCanvasObjectFlagsMask which )
03158 {
03159 m_flags.SetFlags( which );
03160 }
03161
03162 bool a2dCanvasObject::GetFlag( a2dCanvasObjectFlagsMask which ) const
03163 {
03164 return m_flags.GetFlag( which );
03165 }
03166
03167 a2dCanvasObjectFlagsMask a2dCanvasObject::GetFlags() const
03168 {
03169 return m_flags.GetFlags();
03170 }
03171
03172 bool a2dCanvasObject::CheckMask( a2dCanvasObjectFlagsMask mask ) const
03173 {
03174 return m_flags.CheckMask( mask );
03175 }
03176
03177 void a2dCanvasObject::SetHitFlags( a2dCanvasObjectFlagsMask mask )
03178 {
03179 m_hitflags.m_non = (mask & a2dCANOBJ_EVENT_NON) > 0;
03180 m_hitflags.m_fill = (mask & a2dCANOBJ_EVENT_FILL) > 0;
03181 m_hitflags.m_stroke = (mask & a2dCANOBJ_EVENT_STROKE) > 0;
03182 m_hitflags.m_fill_non_transparent = (mask & a2dCANOBJ_EVENT_FILL_NON_TRANSPARENT) > 0;
03183 m_hitflags.m_stroke_non_transparent = (mask & a2dCANOBJ_EVENT_STROKE_NON_TRANSPARENT) > 0;
03184 m_hitflags.m_visible = (mask & a2dCANOBJ_EVENT_VISIBLE) > 0;
03185 m_hitflags.m_all = (mask & a2dCANOBJ_EVENT_ALL) > 0 ;
03186 }
03187
03188 void a2dCanvasObject::foreach_f(void (*fp) (a2dCanvasObject* item) )
03189 {
03190 fp (this);
03191 if ( m_childobjects != wxNullCanvasObjectList )
03192 {
03193 forEachIn( a2dCanvasObjectList, m_childobjects )
03194 {
03195 a2dCanvasObject *obj = *iter;
03196 if (obj )
03197 fp (obj);
03198 }
03199 }
03200 }
03201
03202 void a2dCanvasObject::foreach_mf(void (a2dCanvasObject::*mfp) () )
03203 {
03204 (this->*mfp)();
03205 if ( m_childobjects != wxNullCanvasObjectList )
03206 {
03207 forEachIn( a2dCanvasObjectList, m_childobjects )
03208 {
03209 a2dCanvasObject *obj = *iter;
03210 if ( obj )
03211 (obj->*mfp)();
03212 }
03213 }
03214 }
03215
03216 bool a2dCanvasObject::EditProperties( const a2dPropertyId *id, bool withUndo )
03217 {
03218 a2dNamedPropertyList allprop;
03219
03220 CollectProperties2( &allprop, id, a2dPropertyId::flag_none );
03221
03222 bool res = false;
03223
03224 a2dPropertyEditEvent event( this, &allprop );
03225 event.SetEventObject( this );
03226
03227
03228 if ( ! ProcessEvent( event ) )
03229
03230 a2dDocviewGlobals->GetEventDistributer()->ProcessEvent( event );
03231
03232 if ( event.GetEdited() && !allprop.empty() )
03233 {
03234 res = true;
03235 a2dNamedPropertyList::iterator iter;
03236 for( iter = allprop.begin(); iter != allprop.end(); ++iter )
03237 {
03238 a2dNamedProperty *prop = *iter;
03239 if ( withUndo )
03240 {
03241 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( this, prop ) );
03242
03243
03244 }
03245 else
03246 prop->SetToObject( this );
03247 }
03248 }
03249
03250 return res;
03251 }
03252
03253 bool a2dCanvasObject::DoIgnoreIfNotMember( const a2dPropertyId &id )
03254 {
03255 return id.IsOnlyMember() || id.IsOnlyMemberHint();
03256 }
03257
03258 void a2dCanvasObject::OnPropertyChanged( const a2dPropertyId* id )
03259 {
03260 if ( !id->CheckFlags( a2dPropertyId::flag_norender ) )
03261 {
03262
03263 SetPending( true );
03264
03265 if ( m_childobjects != wxNullCanvasObjectList )
03266 {
03267 forEachIn( a2dCanvasObjectList, m_childobjects )
03268 {
03269 a2dVisibleProperty* visProp = wxDynamicCast( (*iter).Get(), a2dVisibleProperty );
03270 if ( visProp && visProp->GetPropId() == id )
03271 visProp->SetPending( true );
03272 }
03273 }
03274 }
03275 }
03276
03277 a2dText* a2dCanvasObject::SetObjectTip( const wxString& tip, double x, double y, double size, double angle, const a2dFont& font )
03278 {
03279 a2dFont lfont = font;
03280 lfont.SetSize( size );
03281 a2dText* object = new a2dText( tip, x, y, lfont, angle, true );
03282 object->SetLayer( m_layer );
03283 object->SetStroke( *a2dBLACK_STROKE );
03284 object->SetFill( *a2dTRANSPARENT_FILL );
03285 object->SetCanvasDocument( m_root );
03286 object->SetIsProperty( true );
03287 RemoveProperty( PROPID_Objecttip );
03288
03289 a2dCanvasObjectPtrProperty prop( PROPID_Objecttip, object, false, true );
03290 PROPID_Objecttip->SetPropertyToObject( this, &prop );
03291 return object;
03292 }
03293
03294 void a2dCanvasObject::SetTipWindow( const wxString& tip )
03295 {
03296 RemoveProperty( PROPID_TipWindow );
03297
03298 a2dTipWindowProperty prop(PROPID_TipWindow, NULL, tip);
03299 PROPID_TipWindow->SetPropertyToObject( this, &prop );
03300 }
03301
03302 a2dObject* a2dCanvasObject::GetObjectTip()
03303 {
03304 if ( HasDynamicProperties() )
03305 {
03306 return PROPID_Objecttip->GetPropertyValue( this );
03307 }
03308
03309 return 0;
03310 }
03311
03312 void a2dCanvasObject::SetViewDependent(a2dCanvasView* aView, bool viewdependent, bool viewspecific, bool onlyinternalarea, bool deep )
03313 {
03314 wxASSERT_MSG( !aView || aView->GetViewDependentObjects() , wxT("a2dCanvasView::GetViewDependentObjects() is not set") );
03315
03316 if ( deep )
03317 {
03318 a2dWalker_SetViewDependent setv( aView, viewdependent, viewspecific, onlyinternalarea );
03319 setv.Start( this );
03320 return;
03321 }
03322
03323 bool enPending = FALSE;
03324 if(!aView)
03325 {
03326 enPending |= RemoveProperty( PROPID_ViewSpecific );
03327 enPending |= RemoveProperty( PROPID_ViewDependent );
03328 enPending |= RemoveProperty( PROPID_IntViewDependTransform );
03329 }
03330 else
03331 {
03332 if(viewdependent)
03333 {
03334 enPending = TRUE;
03335 PROPID_ViewDependent->SetPropertyToObject( this, aView );
03336 if(onlyinternalarea)
03337 PROPID_IntViewDependTransform->SetPropertyToObject(this, a2dIDENTITY_MATRIX);
03338 }
03339 else
03340 {
03341 a2dCanvasView* view = wxStaticCastNull( PROPID_ViewDependent->GetPropertyValue( this ).Get(), a2dCanvasView );
03342 if ( view == aView)
03343 {
03344 enPending |= RemoveProperty( PROPID_ViewDependent );
03345 enPending |= RemoveProperty( PROPID_IntViewDependTransform );
03346 }
03347 }
03348 if(viewspecific)
03349 {
03350 enPending = TRUE;
03351 PROPID_ViewSpecific->SetPropertyToObject( this, aView );
03352 }
03353 else
03354 {
03355 a2dCanvasView* view = wxStaticCastNull( PROPID_ViewSpecific->GetPropertyValue( this ).Get(), a2dCanvasView );
03356 if ( view == aView)
03357 enPending |= RemoveProperty( PROPID_ViewSpecific );
03358 }
03359 }
03360 if(enPending)
03361 SetPending(true);
03362 }
03363
03364 const a2dShadowStyleProperty* a2dCanvasObject::GetShadowStyle() const
03365 {
03366 return PROPID_Shadowstyle->GetProperty( this );
03367 }
03368
03369 void a2dCanvasObject::SetFill( const a2dFill& fill )
03370 {
03371 if ( !fill.IsNoFill() )
03372 PROPID_Fill->SetPropertyToObject( this, fill );
03373 else
03374 RemoveProperty( PROPID_Fill );
03375 }
03376
03377 void a2dCanvasObject::SetFill( const wxColour& fillcolor, a2dFillStyle fillstyle )
03378 {
03379 a2dFill fill = a2dFill( fillcolor, fillstyle );
03380
03381 PROPID_Fill->SetPropertyToObject( this, fill );
03382 }
03383
03384 void a2dCanvasObject::SetFill( const wxColour& fillcolor, const wxColour& fillcolor2, a2dFillStyle fillstyle )
03385 {
03386 a2dFill fill = a2dFill( fillcolor, fillcolor2, fillstyle );
03387
03388 PROPID_Fill->SetPropertyToObject( this, fill );
03389 }
03390
03391 a2dFill a2dCanvasObject::GetFill() const
03392 {
03393 a2dFill propval = PROPID_Fill->GetPropertyValue( this );
03394 return propval;
03395 }
03396
03397 wxColour a2dCanvasObject::GetFillColour() const
03398 {
03399 if ( !GetFill().IsNoFill() )
03400 return GetFill().GetColour();
03401
03402 if ( m_flags.m_filled )
03403 {
03404 if ( m_root && m_root->GetLayerSetup() )
03405 return m_root->GetLayerSetup()->GetFill(m_layer).GetColour();
03406 return wxColour(0,0,0);
03407 }
03408 else
03409 return a2dTRANSPARENT_FILL->GetColour();
03410 }
03411
03412 void a2dCanvasObject::SetFillColour( const wxColour& colour )
03413 {
03414 a2dFill fill = PROPID_Fill->GetPropertyValue( this );
03415 fill.SetColour( colour );
03416 SetFill( fill );
03417 }
03418
03419 void a2dCanvasObject::SetStroke( const wxColour& strokecolor, double width, a2dStrokeStyle strokestyle )
03420 {
03421 a2dStroke stroke = a2dStroke( strokecolor, (float) width, strokestyle );
03422
03423 PROPID_Stroke->SetPropertyToObject( this, stroke );
03424 }
03425
03426 void a2dCanvasObject::SetStroke( const wxColour& strokecolor, int width, a2dStrokeStyle strokestyle )
03427 {
03428 a2dStroke stroke = a2dStroke( strokecolor, width, strokestyle );
03429
03430 PROPID_Stroke->SetPropertyToObject( this, stroke );
03431 }
03432
03433 void a2dCanvasObject::SetStroke( const a2dStroke& stroke )
03434 {
03435 if ( !stroke.IsNoStroke() )
03436 PROPID_Stroke->SetPropertyToObject( this, stroke );
03437 else
03438 RemoveProperty( PROPID_Stroke, true );
03439 }
03440
03441 a2dStroke a2dCanvasObject::GetStroke() const
03442 {
03443 a2dStroke propval = PROPID_Stroke->GetPropertyValue( this );
03444 return propval;
03445 }
03446
03447 wxColour a2dCanvasObject::GetStrokeColour() const
03448 {
03449 if ( !GetStroke().IsNoStroke() )
03450 return GetStroke().GetColour();
03451
03452 if ( m_root && m_root->GetLayerSetup() )
03453 return m_root->GetLayerSetup()->GetStroke(m_layer).GetColour();
03454
03455 return wxColour(0,0,0);
03456 }
03457
03458 void a2dCanvasObject::SetStrokeColour( const wxColour& colour )
03459 {
03460 a2dStroke stroke = PROPID_Stroke->GetPropertyValue( this );
03461 stroke.SetColour( colour );
03462 SetStroke( stroke );
03463 }
03464
03465 const a2dFill& a2dCanvasObject::MX_GetFill() const
03466 {
03467 if ( HasDynamicProperties() )
03468 {
03469 a2dNamedPropertyList::const_iterator iter;
03470 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03471 {
03472 const a2dNamedProperty *prop = *iter;
03473 if ( prop->GetId() == PROPID_Fill )
03474 {
03475 a2dFillProperty* propfill = wxStaticCast( prop, a2dFillProperty );
03476 return propfill->GetValue();
03477 }
03478 }
03479 }
03480
03481 return *a2dNullFILL;
03482 }
03483
03484 void a2dCanvasObject::MX_SetFill( const a2dFill& value )
03485 {
03486 a2dFill fill = value;
03487 if ( !fill.IsNoFill() && fill.GetType() == a2dFILL_GRADIENT_FILL_LINEAR )
03488 {
03489 double x1 = fill.GetStart().m_x;
03490 double y1 = fill.GetStart().m_y;
03491 double x2 = fill.GetStop().m_x;
03492 double y2 = fill.GetStop().m_y;
03493 if (x1 == x2 && y1 == y2 )
03494 {
03495
03496 a2dBoundingBox& box = GetBbox();
03497 x2 = x1 = box.GetMaxX() - box.GetMinX();
03498 y1 = box.GetMaxY();
03499 y2 = box.GetMinY();
03500
03501 fill = a2dFill( fill.GetColour(), fill.GetColour2(), x1, y1, x2, y2 );
03502 }
03503 }
03504 else if ( !fill.IsNoFill() && fill.GetType() == a2dFILL_GRADIENT_FILL_RADIAL )
03505 {
03506 double xfc = fill.GetFocal().m_x;
03507 double yfc = fill.GetFocal().m_y;
03508 double xe = fill.GetCenter().m_x;
03509 double ye = fill.GetCenter().m_y;
03510 if ( xfc == xe && yfc == ye )
03511 {
03512 a2dBoundingBox& box = GetBbox();
03513 xe = xfc = (box.GetMaxX() + box.GetMinX())/2;
03514 ye = yfc = (box.GetMaxY() + box.GetMinY())/2;
03515 double xr = box.GetMaxX();
03516 double yr = box.GetMaxY();
03517 double radius = wxMax( (xe - xr), (ye - yr) );
03518 fill = a2dFill( fill.GetColour(), fill.GetColour2(), xfc, yfc, xe, ye, radius/2 );
03519 }
03520 }
03521
03522
03523 if ( HasDynamicProperties() )
03524 {
03525 a2dNamedPropertyList::const_iterator iter;
03526 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03527 {
03528 const a2dNamedProperty *prop = *iter;
03529 if ( prop->GetId() == PROPID_Fill )
03530 {
03531 a2dFillProperty* propfill = wxStaticCast( prop, a2dFillProperty );
03532 propfill->SetValue( fill );
03533 return;
03534 }
03535 }
03536 }
03537 a2dFillProperty* prop = new a2dFillProperty( PROPID_Fill, fill );
03538 AddProperty( prop );
03539 }
03540
03541 const a2dStroke& a2dCanvasObject::MX_GetStroke() const
03542 {
03543 if ( HasDynamicProperties() )
03544 {
03545 a2dNamedPropertyList::const_iterator iter;
03546 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03547 {
03548 const a2dNamedProperty *prop = *iter;
03549 if ( prop->GetId() == PROPID_Stroke )
03550 {
03551 a2dStrokeProperty* propstroke = wxStaticCast( prop, a2dStrokeProperty );
03552 return propstroke->GetValue();
03553 }
03554 }
03555 }
03556
03557 return *a2dNullSTROKE;
03558 }
03559
03560 void a2dCanvasObject::MX_SetStroke( const a2dStroke& value )
03561 {
03562 if ( HasDynamicProperties() )
03563 {
03564 a2dNamedPropertyList::const_iterator iter;
03565 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03566 {
03567 const a2dNamedProperty *prop = *iter;
03568 if ( prop->GetId() == PROPID_Stroke )
03569 {
03570 a2dStrokeProperty* propstroke = wxStaticCast( prop, a2dStrokeProperty );
03571 propstroke->SetValue( value );
03572 return;
03573 }
03574 }
03575 }
03576 a2dStrokeProperty* prop = new a2dStrokeProperty( PROPID_Stroke, value );
03577 AddProperty( prop );
03578 }
03579
03580 void a2dCanvasObject::SetDrawerStyle( a2dIterC& ic, a2dStyleProperty* style )
03581 {
03582 a2dLayers* layers = m_root->GetLayerSetup();
03583
03584 if (m_flags.m_filled)
03585 {
03586 if (style)
03587 {
03588 if ( !style->GetFill().IsNoFill() && style->GetFill().IsSameAs(*a2dINHERIT_FILL) )
03589 {
03590
03591 }
03592 else if ( style->GetFill().IsNoFill() )
03593 {
03594 if ( layers)
03595 ic.GetDrawer2D()->SetDrawerFill( layers->GetFill(m_layer) );
03596 else
03597 ic.GetDrawer2D()->SetDrawerFill( *a2dNullFILL );
03598 }
03599 else
03600 ic.GetDrawer2D()->SetDrawerFill( style->GetFill() );
03601
03602 }
03603 else if ( layers)
03604 {
03605 ic.GetDrawer2D()->SetDrawerFill( layers->GetFill(m_layer) );
03606 }
03607 }
03608 else
03609 {
03610 ic.GetDrawer2D()->SetDrawerFill( *a2dTRANSPARENT_FILL );
03611 }
03612
03613 if (style)
03614 {
03615 if ( !style->GetStroke().IsNoStroke() && style->GetStroke().IsSameAs( *a2dINHERIT_STROKE ) )
03616 {
03617
03618 }
03619 else if ( style->GetStroke().IsNoStroke() )
03620 {
03621 if (layers)
03622 ic.GetDrawer2D()->SetDrawerStroke( layers->GetStroke(m_layer) );
03623 else
03624 ic.GetDrawer2D()->SetDrawerStroke( *a2dNullSTROKE );
03625 }
03626 else
03627 ic.GetDrawer2D()->SetDrawerStroke( style->GetStroke() );
03628 }
03629 else if (layers)
03630 {
03631 ic.GetDrawer2D()->SetDrawerStroke( layers->GetStroke(m_layer) );
03632 }
03633 }
03634
03635 void a2dCanvasObject::CaptureMouse( a2dIterC& ic )
03636 {
03637 ic.SetCorridorPath( true, this );
03638 }
03639
03640 void a2dCanvasObject::ReleaseMouse( a2dIterC& ic )
03641 {
03642 ic.SetCorridorPath( false );
03643 }
03644
03645 bool a2dCanvasObject::IsCapturedMouse( a2dIterC& ic ) const
03646 {
03647 return ic.GetCanvasView()->GetCaptured() == this;
03648 }
03649
03650 bool a2dCanvasObject::GeneratePinsPossibleConnections( a2dPinClass* pinClass, a2dConnectTask task, double x, double y )
03651 {
03652 return pinClass->GetConnectionGenerator()->GeneratePossibleConnections( this, pinClass, task, x, y );
03653 }
03654
03655 a2dCanvasObject* a2dCanvasObject::GetConnectTemplate( a2dPinClass* mapThis, a2dCanvasObject* other, a2dPinClass* mapOther ) const
03656 {
03657 return mapThis->GetConnectionGenerator()->GetConnectTemplate( this, mapThis, other, mapOther );
03658 }
03659
03660 a2dCanvasObject* a2dCanvasObject::CreateConnectObject( a2dCanvasObject* parent, a2dPin* pinThis, a2dPin* pinOther, bool undo ) const
03661 {
03662 return pinThis->GetPinClass()->GetConnectionGenerator()->CreateConnectObject( parent, pinThis, pinOther, undo );
03663 }
03664
03665 void a2dCanvasObject::EditFeedback( a2dIterC& ic, const a2dFeedbackId *id, a2dCanvasObject *currentEdit, int depth, a2dCanvasObjectFlagsMask flags, double x, double y )
03666 {
03667 if( depth<=0 && !CheckMask( flags ) )
03668 return;
03669
03670 if( depth==1 && id == &a2dPin::sm_feedbackOnPinmapConnect )
03671 {
03672 a2dFeedbackIdPinMapping* idOnPin = (a2dFeedbackIdPinMapping*) id;
03673
03674 RemovePins( true, true );
03675 a2dHitEvent hitevent = a2dHitEvent( x, y );
03676 a2dCanvasObject* hit = IsHitWorld( ic, hitevent );
03677 if( hit )
03678 GeneratePinsPossibleConnections( idOnPin->GetPinClass(), idOnPin->GetTask(), x, y );
03679 }
03680 else if( depth==1 && id == &a2dPin::sm_feedbackGeneratePin )
03681 {
03682 a2dPin *pin = wxStaticCast( currentEdit, a2dPin );
03683
03684 CanConnectWith( ic, pin, ic.GetHitMarginWorld(), true );
03685 }
03686
03687 if( GetChildObjectsCount() )
03688 {
03689 a2dIterCU cu( ic, this );
03690
03691 a2dCanvasObjectList::iterator iter;
03692
03693
03694
03695 for( iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
03696 {
03697 a2dCanvasObject *obj = *iter;
03698 if ( obj )
03699 obj->EditFeedback( ic, id, currentEdit, depth-1, flags, x, y );
03700 }
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710 if ( id == &a2dPin::sm_feedbackCanConnect
03711 && m_root && ic.GetParent() && HasPins() && !IsConnect() )
03712 {
03713
03714 a2dCanvasObjectList allpinobjects;
03715 ic.GetParent()->CollectObjects( &allpinobjects, wxT(""), a2dCanvasOFlags::HasPins );
03716
03717
03718 a2dCanvasObjectList::iterator iter;
03719
03720
03721
03722 for( iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
03723 {
03724 a2dCanvasObject *obj = *iter;
03725 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
03726 if (pinc)
03727 {
03728 pinc->SetBin( false );
03729 pinc->SetMode( 0 );
03730 }
03731 }
03732
03733 for( iter = allpinobjects.begin(); iter != allpinobjects.end(); ++iter )
03734 {
03735 a2dCanvasObject* obj = *iter;
03736
03737
03738 if ( obj != this && !obj->IsConnect() && obj->DoConnect() )
03739 {
03740 if ( m_flags.m_editingCopy )
03741 {
03742
03743
03744 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
03745 if ( original != obj )
03746 {
03747
03748
03749 this->CanConnectWith( ic, obj, true );
03750 }
03751 }
03752 else
03753 {
03754
03755
03756 this->CanConnectWith( ic, obj, true );
03757 }
03758 }
03759 }
03760
03761
03762 for( iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
03763 {
03764 a2dCanvasObject *obj = *iter;
03765 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
03766 if (pinc && pinc->GetBin() )
03767 {
03768 obj->EditFeedback( ic, &a2dPin::sm_feedbackCanConnect, currentEdit, depth-1, flags, x, y );
03769 pinc->SetBin( false );
03770 }
03771 }
03772 }
03773 }
03774 }
03775
03776 a2dBoundingBox& a2dCanvasObject::GetBbox()
03777 {
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791 if ( !m_bbox.GetValid() )
03792 {
03793 Update( updatemask_force );
03794 SetPending( true );
03795 }
03796
03797 return m_bbox;
03798 }
03799
03800 wxRect a2dCanvasObject::GetAbsoluteArea( a2dIterC& ic, int inflate )
03801 {
03802 int x1,y1,x2,y2;
03803
03804 a2dBoundingBox tmp = GetBbox();
03805 if ( !ic.GetTransform().IsIdentity() )
03806 tmp.MapBbox(ic.GetTransform());
03807
03808
03809
03810
03811
03812
03813 tmp.Enlarge( m_worldExtend );
03814
03815 x1 = ic.GetDrawer2D()->WorldToDeviceX( tmp.GetMinX());
03816 y1 = ic.GetDrawer2D()->WorldToDeviceY( tmp.GetMinY());
03817 x2 = ic.GetDrawer2D()->WorldToDeviceX( tmp.GetMaxX());
03818 y2 = ic.GetDrawer2D()->WorldToDeviceY( tmp.GetMaxY());
03819
03820 if (x1 > x2)
03821 {
03822 int tmp = x1;
03823 x1 = x2;
03824 x2 = tmp;
03825 }
03826 if (y1 > y2)
03827 {
03828 int tmp = y1;
03829 y1 = y2;
03830 y2 = tmp;
03831 }
03832
03833 wxRect tmparea;
03834 tmparea.x = x1;
03835 tmparea.y = y1;
03836
03837 tmparea.width = x2-x1;
03838 tmparea.height = y2-y1;
03839 tmparea.Inflate( m_pixelExtend );
03840
03841
03842 tmparea.Inflate( inflate );
03843
03844 return tmparea;
03845 }
03846
03847 a2dBoundingBox a2dCanvasObject::GetMappedBbox( const a2dAffineMatrix& cworld )
03848 {
03849
03850 a2dBoundingBox tmp = GetBbox();
03851 if ( !cworld.IsIdentity())
03852 tmp.MapBbox(cworld);
03853
03854 return tmp;
03855 }
03856
03857 a2dBoundingBox a2dCanvasObject::GetMappedBbox( a2dIterC& ic, bool withExtend )
03858 {
03859
03860 a2dBoundingBox tmp = GetBbox();
03861 if ( !ic.GetTransform().IsIdentity())
03862 tmp.MapBbox( ic.GetTransform() );
03863
03864 if ( withExtend )
03865 {
03866 if ( m_worldExtend )
03867 tmp.Enlarge( m_worldExtend );
03868 if ( m_pixelExtend )
03869 tmp.Enlarge( ic.GetDrawer2D()->DeviceToWorldXRel( m_pixelExtend ) );
03870 }
03871 return tmp;
03872 }
03873
03874 OVERLAP a2dCanvasObject::GetClipStatus( a2dIterC& ic, OVERLAP clipparent )
03875 {
03876
03877
03878 if ( clipparent == _ON )
03879 {
03880
03881
03882 a2dBoundingBox absarea = GetMappedBbox( ic, true );
03883 return ic.GetDrawer2D()->GetClippingBox().Intersect( absarea );
03884 }
03885
03886 return clipparent;
03887 }
03888
03889
03890 a2dCanvasObject* a2dCanvasObject::ChildIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent, bool filterSelectableLayers )
03891 {
03892 a2dAffineMatrix cworld;
03893 if ( !hitEvent.m_xyRelToChildren )
03894 {
03895 cworld= m_lworld;
03896 cworld.Invert();
03897 }
03898
03899 a2dCanvasObject* res = NULL;
03900
03901 a2dBoundingBox box;
03902
03903
03904
03905
03906 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely);
03907
03908
03909 a2dCanvasObjectList::reverse_iterator boxiter = m_childobjects->rbegin();
03910 while( boxiter != m_childobjects->rend() )
03911 {
03912 a2dCanvasObject *obj = *boxiter;
03913
03914 if ( obj->GetVisible() )
03915 {
03916 if ( obj->m_flags.m_ChildOnlyTranslate )
03917 {
03918 a2dAffineMatrix iworld = m_lworld;
03919 iworld.Invert();
03920 a2dIterCU cu( ic, iworld );
03921 a2dAffineMatrix transworld;
03922 transworld.Translate( GetPosX(), GetPosY() );
03923 a2dIterCU cu2( ic, transworld );
03924 }
03925
03926 OVERLAP clipparent = ic.GetDrawer2D()->GetClippingBox().Intersect( obj->GetBbox() );
03927
03928 if ( clipparent != _OUT &&
03929 (
03930 ! box.GetValid() ||
03931 (
03932 ( obj->GetBbox().GetWidth() < box.GetWidth() || obj->GetBbox().GetHeight() < box.GetHeight() ) &&
03933 obj->GetBbox().PointInBox( hitEvent.m_relx, hitEvent.m_rely,
03934 m_worldExtend + ic.GetHitMarginWorld() + ic.ExtendDeviceToWorld( m_pixelExtend ) )
03935 )
03936 )
03937 )
03938 {
03939 if ( hitEvent.m_option & a2dCANOBJHITOPTION_LAYERS )
03940 {
03941
03942
03943
03944
03945
03946
03947
03948
03949
03950
03951
03952
03953 ic.SetPerLayerMode( true );
03954 unsigned int j;
03955 for ( j=0; j < wxMAXLAYER; j++ )
03956 {
03957 a2dLayerInfo* layerobj;
03958
03959 if ( ic.GetCanvasView()->GetReverseOrder() )
03960 layerobj = GetCanvasDocument()->GetLayerSetup()->GetOrderIndex()[j];
03961 else
03962 layerobj = GetCanvasDocument()->GetLayerSetup()->GetReverseOrderIndex()[j];
03963
03964
03965
03966 if ( layerobj == wxNullLayerInfo )
03967 break;
03968
03969
03970
03971
03972
03973
03974
03975 if ( ic.GetCanvasView()->GetLayerRenderArray()[ layerobj->GetLayer() ].DoRenderLayer() &&
03976 layerobj->GetVisible() &&
03977 ( !filterSelectableLayers || filterSelectableLayers && layerobj->GetSelectable() )
03978 )
03979 {
03980
03981
03982
03983 ic.SetObjectFilter( NULL );
03984 ic.SetLayer( layerobj->GetLayer() );
03985
03986 a2dIterCU cu( ic, cworld );
03987 if ( obj->IsHitWorld( ic, hitEvent ) )
03988 {
03989 res = obj;
03990 box = obj->GetBbox();
03991 }
03992 ic.Reset();
03993 }
03994 }
03995 }
03996 else
03997 {
03998 a2dIterCU cu( ic, cworld );
03999 ic.SetPerLayerMode( false );
04000 if ( obj->IsHitWorld( ic, hitEvent ) )
04001 {
04002 res = obj;
04003 box = GetBbox();
04004 }
04005 ic.Reset();
04006 }
04007 }
04008 }
04009 boxiter++;
04010 }
04011
04012 return res;
04013 }
04014
04015 a2dCanvasObject* a2dCanvasObject::IsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent )
04016 {
04017 if ( m_hitflags.m_non || m_release || !m_flags.m_visible )
04018 return (a2dCanvasObject*) NULL;
04019 if ( hitEvent.m_option & a2dCANOBJHITOPTION_NOTSELECTED && GetSelected() )
04020 return (a2dCanvasObject*) NULL;
04021
04022 if ( !ic.FilterObject( this ) ||
04023 ( ! GetIgnoreLayer() &&
04024 (
04025 !ic.GetCanvasView()->GetLayerRenderArray()[ m_layer ].DoRenderLayer() ||
04026 ( m_root && m_root->GetLayerSetup() && !m_root->GetLayerSetup()->GetVisible(m_layer) )
04027 )
04028 )
04029 )
04030 {
04031 ic.EndFilterObject( this );
04032 return (a2dCanvasObject*) NULL;
04033 }
04034
04035 if ( ic.GetLayer() != m_layer && ic.GetLayer() != wxLAYER_ALL && !m_flags.m_ignoreLayer )
04036 {
04037
04038
04039 if ( m_childobjects == wxNullCanvasObjectList || !m_flags.m_visiblechilds )
04040 {
04041 ic.EndFilterObject( this );
04042 return (a2dCanvasObject*) NULL;
04043 }
04044 if ( ic.GetLayer() != wxLAYER_ALL && m_flags.m_childrenOnSameLayer )
04045 {
04046 ic.EndFilterObject( this );
04047 return (a2dCanvasObject*) NULL;
04048 }
04049 }
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061 if( hitEvent.m_option & a2dCANOBJHITOPTION_NOROOT )
04062 {
04063
04064
04065 if ( m_childobjects == wxNullCanvasObjectList || !m_flags.m_visiblechilds )
04066 {
04067 ic.EndFilterObject( this );
04068 return (a2dCanvasObject*) NULL;
04069 }
04070 }
04071
04072
04073
04074
04075
04076 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely);
04077
04078
04079
04080 if ( ! GetBbox().PointInBox( hitEvent.m_relx, hitEvent.m_rely, m_worldExtend + ic.GetHitMarginWorld() + ic.ExtendDeviceToWorld( m_pixelExtend ) ))
04081 {
04082 ic.EndFilterObject( this );
04083 return (a2dCanvasObject*) NULL;
04084 }
04085
04086
04087
04088
04089 a2dIterCU cu( ic, this );
04090
04091 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely);
04092
04093
04094
04095
04096
04097
04098
04099
04100
04101
04102
04103 if ( HasDynamicProperties() && !( hitEvent.m_option & a2dCANOBJHITOPTION_NOROOT ) )
04104 {
04105 a2dNamedPropertyList::const_iterator iter;
04106 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
04107 {
04108 const a2dNamedProperty *prop = *iter;
04109 a2dCanvasObjectPtrProperty *canvasprop = wxDynamicCast( prop, a2dCanvasObjectPtrProperty );
04110 if ( canvasprop && canvasprop->GetCanRender() && canvasprop->GetVisible() )
04111 {
04112 a2dCanvasObject *canvasobj = canvasprop->GetCanvasObject();
04113 if( canvasobj && canvasobj->GetVisible() )
04114 {
04115 a2dCanvasObject *hit = canvasobj->IsHitWorld( ic, hitEvent );
04116 if ( hit )
04117 {
04118 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04119 {
04120 ic.EndFilterObject( this );
04121 if( hitEvent.m_extendedWanted )
04122 {
04123 hitEvent.m_extended.push_back( a2dExtendedResultItem(
04124 hit,
04125 ic.GetParent(),
04126 hitEvent.m_how,
04127 ic.GetLevel(),
04128 hitEvent.m_id
04129 ));
04130 }
04131 return this;
04132 }
04133 }
04134 }
04135 }
04136 }
04137 }
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147 RenderChild whichchilds;
04148 whichchilds.m_prerender = false;
04149 whichchilds.m_postrender = true;
04150 whichchilds.m_property = false;
04151
04152 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
04153 {
04154
04155 a2dCanvasObject* res = NULL;
04156 if ( res = IsHitWorldChildObjects( ic, whichchilds, hitEvent ) )
04157 {
04158 ic.EndFilterObject( this );
04159 if( hitEvent.m_extendedWanted )
04160 {
04161 hitEvent.m_extended.push_back( a2dExtendedResultItem(
04162 res,
04163 ic.GetParent(),
04164 hitEvent.m_how,
04165 ic.GetLevel(),
04166 hitEvent.m_id
04167 ));
04168 }
04169 return res;
04170 }
04171 }
04172
04173
04174
04175
04176
04177 if ( !( hitEvent.m_option & a2dCANOBJHITOPTION_NOROOT ) &&
04178 ( ic.GetLayer() == m_layer || ic.GetLayer() == wxLAYER_ALL || m_flags.m_ignoreLayer )
04179 )
04180 {
04181 double StrokeExtend = 0;
04182 a2dStroke stroke = GetStroke();
04183
04184 if ( stroke.IsNoStroke() )
04185 {
04186 if ( m_root && m_root->GetLayerSetup())
04187 {
04188 a2dStroke layerpen = m_root->GetLayerSetup()->GetStroke( m_layer );
04189 if ( layerpen.GetPixelStroke() )
04190 StrokeExtend = layerpen.GetWidth()/2;
04191 else
04192 StrokeExtend = layerpen.GetWidth()/2;
04193 }
04194 }
04195 else if ( !stroke.IsSameAs(*a2dTRANSPARENT_STROKE) )
04196 {
04197 if ( stroke.GetPixelStroke() )
04198 {
04199 StrokeExtend = ic.GetDrawer2D()->DeviceToWorldXRel( stroke.GetWidth()/2 );
04200 }
04201 else
04202 StrokeExtend = stroke.GetWidth()/2;
04203 }
04204 ic.SetStrokeWorldExtend( StrokeExtend );
04205
04206 if ( DoIsHitWorld( ic, hitEvent ) )
04207 {
04208 ic.SetStrokeWorldExtend( 0 );
04209
04210 bool isHit = false;
04211
04212 if ( m_hitflags.m_all || m_hitflags.m_visible)
04213 isHit = true;
04214 else if ( m_hitflags.m_stroke && hitEvent.m_how.IsStrokeHit() )
04215 isHit = true;
04216 else if ( m_hitflags.m_fill && hitEvent.m_how.IsFillHit() )
04217 isHit = true;
04218 else if ( m_hitflags.m_fill_non_transparent && hitEvent.m_how.IsFillHit() )
04219 {
04220 if ( !GetFill().IsSameAs( *a2dTRANSPARENT_FILL ) && !GetFill().GetFilling() )
04221 isHit = true;
04222 else if ( m_root && m_root->GetLayerSetup() )
04223 {
04224 if ( !m_root->GetLayerSetup()->GetFill(m_layer).IsSameAs( *a2dTRANSPARENT_FILL )
04225 && !m_root->GetLayerSetup()->GetFill(m_layer).GetFilling() )
04226 isHit = true;
04227 }
04228 }
04229 else if ( m_hitflags.m_stroke_non_transparent && hitEvent.m_how.IsStrokeHit() )
04230 {
04231 if ( GetStroke().IsSameAs( *a2dTRANSPARENT_STROKE ) )
04232 isHit = true;
04233 else if ( m_root && m_root->GetLayerSetup() )
04234 {
04235 if ( !m_root->GetLayerSetup()->GetStroke(m_layer).IsSameAs( *a2dTRANSPARENT_STROKE ) )
04236 isHit = true;
04237 }
04238 }
04239
04240 if (isHit)
04241 {
04242 if( hitEvent.m_extendedWanted )
04243 {
04244 hitEvent.m_extended.push_back( a2dExtendedResultItem(
04245 this,
04246 ic.GetParent(),
04247 hitEvent.m_how,
04248 ic.GetLevel(),
04249 hitEvent.m_id
04250 ));
04251 }
04252 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04253 {
04254 ic.EndFilterObject( this );
04255 return this;
04256 }
04257 }
04258 }
04259 ic.SetStrokeWorldExtend( 0 );
04260 }
04261
04262
04263
04264
04265
04266
04267 if ( whichchilds.m_prerender && m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
04268 {
04269 whichchilds.m_prerender = true;
04270 whichchilds.m_postrender = false;
04271 whichchilds.m_property = false;
04272
04273
04274 a2dCanvasObject* res = NULL;
04275 if ( res = IsHitWorldChildObjects( ic, whichchilds, hitEvent ) )
04276 {
04277 if( hitEvent.m_extendedWanted )
04278 {
04279 hitEvent.m_extended.push_back( a2dExtendedResultItem(
04280 res,
04281 ic.GetParent(),
04282 hitEvent.m_how,
04283 ic.GetLevel(),
04284 hitEvent.m_id
04285 ));
04286 }
04287 ic.EndFilterObject( this );
04288 return this;
04289 }
04290 }
04291
04292 ic.EndFilterObject( this );
04293 return (a2dCanvasObject*) NULL;
04294 }
04295
04296 bool a2dCanvasObject::DoIsHitWorld( a2dIterC& WXUNUSED(ic), a2dHitEvent& hitEvent )
04297 {
04298 return false;
04299 }
04300
04301 a2dCanvasObject* a2dCanvasObject::IsHitWorldChildObjects(
04302 a2dIterC& ic,
04303 RenderChild& whichchilds,
04304 a2dHitEvent& hitEvent
04305 )
04306 {
04307 if (m_childobjects == wxNullCanvasObjectList || m_childobjects->empty() )
04308 return NULL;
04309
04310
04311
04312
04313
04314
04315
04316
04317 wxUint32 optioncurrent = hitEvent.m_option;
04318 hitEvent.m_option = (a2dHitOption) (hitEvent.m_option &~(a2dCANOBJHITOPTION_LAYERS | a2dCANOBJHITOPTION_NOROOT ) );
04319
04320 a2dCanvasObject *foundsofar = (a2dCanvasObject*) NULL;
04321
04322
04323
04324
04325 if ( ic.GetPerLayerMode() && m_flags.m_childrenOnSameLayer && m_root->GetLayerSetup() )
04326 {
04327 wxASSERT_MSG( ic.GetLayer() != wxLAYER_ALL, _T(" a2dIterC::GetPerLayerMode() can only render one layer at the time") );
04328
04329 wxUint16 layer = ic.GetLayer();
04330 unsigned int j;
04331 for ( j=0; j < wxMAXLAYER; j++ )
04332 {
04333 a2dLayerInfo* layerinfo;
04334 if ( ic.GetCanvasView()->GetReverseOrder() )
04335 layerinfo = m_root->GetLayerSetup()->GetOrderIndex()[j];
04336 else
04337 layerinfo = m_root->GetLayerSetup()->GetReverseOrderIndex()[j];
04338
04339
04340
04341 if ( layerinfo == wxNullLayerInfo )
04342 break;
04343
04344
04345
04346
04347
04348 if ( ic.GetCanvasView()->GetLayerRenderArray()[ layerinfo->GetLayer() ].DoRenderLayer()
04349 && layerinfo->GetVisible() )
04350 {
04351 ic.SetLayer( layerinfo->GetLayer() );
04352 a2dCanvasObject *hit = HitChildObjectsOneLayer( ic, whichchilds, hitEvent );
04353 if ( hit )
04354 {
04355 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04356 {
04357 ic.SetLayer( layer );
04358 hitEvent.m_option = optioncurrent;
04359 return hit;
04360 }
04361 foundsofar = hit;
04362 }
04363 }
04364 ic.SetLayer( layer );
04365 }
04366 }
04367 else
04368 {
04369
04370
04371
04372 a2dCanvasObject *hit = HitChildObjectsOneLayer( ic, whichchilds, hitEvent );
04373 if ( hit )
04374 {
04375 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04376 {
04377 hitEvent.m_option = optioncurrent;
04378 return hit;
04379 }
04380 foundsofar = hit;
04381 }
04382 }
04383 hitEvent.m_option = optioncurrent;
04384 return foundsofar;
04385 }
04386
04387 a2dCanvasObject* a2dCanvasObject::HitChildObjectsOneLayer(
04388 a2dIterC& ic,
04389 RenderChild& whichchilds,
04390 a2dHitEvent& hitEvent
04391 )
04392 {
04393 a2dCanvasObject *foundsofar = (a2dCanvasObject*) NULL;
04394
04395 RenderChild detectchilds;
04396 detectchilds.m_postrender = false;
04397 detectchilds.m_prerender = false;
04398 detectchilds.m_property = false;
04399
04400
04401 a2dCanvasObjectList::reverse_iterator iter = m_childobjects->rbegin();
04402 while( iter != m_childobjects->rend() )
04403 {
04404 a2dCanvasObject *obj = *iter;
04405 int olayer = obj->GetLayer();
04406
04407 detectchilds.m_postrender = detectchilds.m_prerender || !obj->GetPreRenderAsChild();
04408 detectchilds.m_prerender = detectchilds.m_postrender || obj->GetPreRenderAsChild();
04409 detectchilds.m_property = detectchilds.m_property || obj->GetIsProperty();
04410
04411
04412 if ( (
04413 ( obj->GetPreRenderAsChild() && whichchilds.m_prerender && !obj->GetIsProperty() ) ||
04414 ( !obj->GetPreRenderAsChild() && whichchilds.m_postrender && !obj->GetIsProperty() ) ||
04415 ( obj->GetIsProperty() && whichchilds.m_property )
04416 )
04417
04418
04419 &&
04420 ( olayer == ic.GetLayer() || ic.GetLayer() == wxLAYER_ALL || obj->GetChildObjectsCount() || obj->GetIgnoreLayer() )
04421 )
04422 {
04423 if ( obj->m_flags.m_ChildOnlyTranslate )
04424 {
04425 a2dAffineMatrix iworld = m_lworld;
04426 iworld.Invert();
04427 a2dIterCU cu( ic, iworld );
04428 a2dAffineMatrix transworld;
04429 transworld.Translate( GetPosX(), GetPosY() );
04430 a2dIterCU cu2( ic, transworld );
04431 a2dCanvasObject *hit = obj->IsHitWorld( ic, hitEvent );
04432 if( hit )
04433 {
04434 foundsofar = obj;
04435 if( obj != hit)
04436 hitEvent.m_how.m_hit = hitEvent.m_how.m_hit | a2dHit::hit_child;
04437 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04438 break;
04439 }
04440 }
04441 else
04442 {
04443 a2dCanvasObject *hit = obj->IsHitWorld( ic, hitEvent );
04444 if( hit )
04445 {
04446 foundsofar = obj;
04447 if( obj != hit)
04448 hitEvent.m_how.m_hit = hitEvent.m_how.m_hit | a2dHit::hit_child;
04449 if( ! ( hitEvent.m_option & a2dCANOBJHITOPTION_ALL ) )
04450 break;
04451 }
04452 }
04453 }
04454 iter++;
04455 }
04456
04457 whichchilds = detectchilds;
04458
04459 return foundsofar;
04460 }
04461
04462
04463 static void ReportHit( a2dCanvasObject* obj, const wxString mes, bool editflag, a2dHitEvent& hitEvent )
04464 {
04465 #ifdef _DEBUG_REPORTHIT
04466 if ( editflag )
04467 {
04468
04469 if ( !hitEvent.m_isHit )
04470 wxLogDebug(wxT("hit %s %p"), mes, obj );
04471 else
04472 wxLogDebug(wxT("nohit %s %p"), mes, obj );
04473 }
04474 #else
04475 #endif
04476 }
04477
04478 bool a2dCanvasObject::ProcessCanvasObjectEvent( a2dIterC& ic, a2dHitEvent& hitEvent )
04479 {
04480 if ( ic.GetCanvasView()->GetCaptured() == this )
04481 {
04482 wxMouseEvent* mouse = wxDynamicCast( hitEvent.m_event, wxMouseEvent );
04483 if (mouse)
04484 {
04485
04486 a2dHit how( a2dHit::hit_captured, a2dHit::stroke1_none, a2dHit::stroke2_none, 0, 0 );
04487
04488 a2dCanvasObjectMouseEvent CanvasObjectMouseEvent( &ic, this, hitEvent.m_how, hitEvent.m_x, hitEvent.m_y, *mouse );
04489 hitEvent.SetProcessed( ProcessEvent( CanvasObjectMouseEvent ) );
04490 }
04491 else
04492 hitEvent.SetProcessed( ProcessEvent( *hitEvent.m_event ) );
04493
04494 if ( m_flags.m_editingCopy )
04495
04496 PROPID_FirstEventInObject->SetPropertyToObject( this, false );
04497
04498 return hitEvent.m_processed;
04499 }
04500
04501
04502
04503
04504
04505
04506 if ( ic.GetCanvasView()->GetEndCorridorObject() == this && !ic.GetCanvasView()->GetCaptured() )
04507 ic.SetFoundCorridorEnd( true );
04508
04509 if ( ic.GetCanvasView()->GetEndCorridorObject() && !ic.GetFoundCorridorEnd() )
04510 {
04511 if ( !m_flags.m_isOnCorridorPath )
04512 return false;
04513 else
04514 {
04515 a2dIterCU cu( ic, this );
04516
04517 RenderChild whichchilds;
04518 whichchilds.m_prerender = true;
04519 whichchilds.m_postrender = true;
04520 whichchilds.m_property = true;
04521
04522 if ( ic.GetCanvasView()->GetEndCorridorObject() == this )
04523 ic.SetFoundCorridorEnd( true );
04524
04525 ProcessCanvasEventChild( ic, whichchilds, hitEvent );
04526
04527 return hitEvent.m_processed;
04528 }
04529 }
04530
04531 if ( m_hitflags.m_non || m_release || !m_flags.m_visible )
04532 return (a2dCanvasObject*) NULL;
04533
04534 if ( ! GetIgnoreLayer() &&
04535 (
04536 !ic.GetCanvasView()->GetLayerRenderArray()[ m_layer ].DoRenderLayer() ||
04537 ( m_root && m_root->GetLayerSetup() && !m_root->GetLayerSetup()->GetVisible(m_layer) )
04538 )
04539 )
04540 {
04541 return (a2dCanvasObject*) NULL;
04542 }
04543
04544 if ( ic.GetLayer() != m_layer && ic.GetLayer() != wxLAYER_ALL && !m_flags.m_ignoreLayer )
04545 {
04546
04547
04548 if ( m_childobjects == wxNullCanvasObjectList || !m_flags.m_visiblechilds )
04549 return (a2dCanvasObject*) NULL;
04550 if ( ic.GetLayer() != wxLAYER_ALL && m_flags.m_childrenOnSameLayer )
04551 return (a2dCanvasObject*) NULL;
04552 }
04553
04554 bool sentmousevent = false;
04555
04556 a2dHit how;
04557 bool wasHit = hitEvent.m_isHit;
04558
04559 hitEvent.m_isHit = false;
04560
04561 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely );
04562
04563
04564 if ( GetBbox().PointInBox( hitEvent.m_relx, hitEvent.m_rely, m_worldExtend + ic.GetHitMarginWorld() + ic.ExtendDeviceToWorld( m_pixelExtend ) ))
04565 {
04566 a2dIterCU cu( ic, this );
04567
04568 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely );
04569
04570
04571 a2dNamedPropertyList::const_iterator iter;
04572 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
04573 {
04574 const a2dNamedProperty *prop = *iter;
04575 a2dCanvasObjectPtrProperty *canvasprop = wxDynamicCast( prop, a2dCanvasObjectPtrProperty );
04576 if ( canvasprop && canvasprop->GetVisible() )
04577 {
04578 a2dCanvasObject *canvasobj = canvasprop->GetCanvasObject();
04579 if( canvasobj )
04580 {
04581 canvasobj->ProcessCanvasObjectEvent( ic, hitEvent );
04582 }
04583 }
04584 }
04585
04586 RenderChild whichchilds;
04587 whichchilds.m_prerender = true;
04588 whichchilds.m_postrender = true;
04589 whichchilds.m_property = true;
04590
04591
04592 if ( m_flags.m_visiblechilds && m_childobjects != wxNullCanvasObjectList )
04593 {
04594 ProcessCanvasEventChild( ic, whichchilds, hitEvent );
04595 }
04596
04597
04598
04599 if ( !hitEvent.m_processed )
04600 {
04601 if ( hitEvent.m_isHit )
04602 {
04603 sentmousevent = true;
04604 }
04605 else if ( ic.GetLayer() == m_layer || ic.GetLayer() == wxLAYER_ALL )
04606 {
04607
04608
04609
04610
04611 double StrokeExtend = 0;
04612 a2dStroke stroke = GetStroke();
04613
04614 if ( stroke.IsNoStroke() )
04615 {
04616 if ( m_root && m_root->GetLayerSetup())
04617 {
04618 a2dStroke layerpen = m_root->GetLayerSetup()->GetStroke( m_layer );
04619 if ( layerpen.GetPixelStroke() )
04620 StrokeExtend = layerpen.GetWidth()/2;
04621 else
04622 StrokeExtend = layerpen.GetWidth()/2;
04623 }
04624 }
04625 else if ( !stroke.IsSameAs(*a2dTRANSPARENT_STROKE) )
04626 {
04627 if ( stroke.GetPixelStroke() )
04628 StrokeExtend = ic.GetDrawer2D()->DeviceToWorldXRel( stroke.GetWidth()/2 );
04629
04630 else
04631 StrokeExtend = stroke.GetWidth()/2;
04632 }
04633 ic.SetStrokeWorldExtend( StrokeExtend );
04634
04635 if ( DoIsHitWorld( ic, hitEvent ) )
04636 {
04637
04638 if ( m_hitflags.m_all || m_hitflags.m_visible)
04639 hitEvent.m_isHit = true;
04640 else if ( m_hitflags.m_stroke && how.IsStrokeHit() )
04641 hitEvent.m_isHit = true;
04642 else if ( m_hitflags.m_fill && how.IsFillHit() )
04643 hitEvent.m_isHit = true;
04644 else if ( m_hitflags.m_fill_non_transparent && how.IsFillHit() )
04645 {
04646 if ( !GetFill().IsSameAs( *a2dTRANSPARENT_FILL ) )
04647 hitEvent.m_isHit = true;
04648 else if ( m_root && m_root->GetLayerSetup() )
04649 {
04650 if ( !m_root->GetLayerSetup()->GetFill(m_layer).IsSameAs( *a2dTRANSPARENT_FILL ) )
04651 hitEvent.m_isHit = true;
04652 }
04653 }
04654 else if ( m_hitflags.m_stroke_non_transparent && how.IsStrokeHit() )
04655 {
04656 if ( !GetStroke().IsSameAs( *a2dTRANSPARENT_FILL ) )
04657 hitEvent.m_isHit = true;
04658 else if ( m_root && m_root->GetLayerSetup() )
04659 {
04660 if ( !m_root->GetLayerSetup()->GetStroke(m_layer).IsSameAs( *a2dTRANSPARENT_STROKE ) )
04661 hitEvent.m_isHit = true;
04662 }
04663 }
04664
04665
04666 if ( hitEvent.m_isHit )
04667 sentmousevent = true;
04668 }
04669 else
04670 {
04671 ReportHit( this, wxT("no hit on object"), m_flags.m_editingCopy, hitEvent );
04672 }
04673 }
04674 else
04675 ReportHit( this, wxT("no hit or wrong layer"), m_flags.m_editingCopy, hitEvent );
04676 }
04677 else
04678 {
04679 ReportHit( this, wxT("processed no hit"), m_flags.m_editingCopy, hitEvent );
04680 }
04681 }
04682 else
04683 {
04684 ReportHit( this, wxT("no box hit"), m_flags.m_editingCopy, hitEvent );
04685 }
04686
04687 ic.GetInverseTransform().TransformPoint( hitEvent.m_x, hitEvent.m_y, hitEvent.m_relx, hitEvent.m_rely );
04688
04689 if ( sentmousevent )
04690 {
04691
04692 if ( !ic.GetDeepestHit() )
04693 {
04694
04695
04696 ic.SetDeepestHit( this );
04697 }
04698 wxMouseEvent* mouse = wxDynamicCast( hitEvent.m_event, wxMouseEvent );
04699 if (mouse)
04700 {
04701 a2dCanvasObjectMouseEvent CanvasObjectMouseEvent( &ic, this, hitEvent.m_how, hitEvent.m_x, hitEvent.m_y, *mouse );
04702 hitEvent.SetProcessed( ProcessEvent( CanvasObjectMouseEvent ) );
04703 }
04704 else
04705 hitEvent.SetProcessed( ProcessEvent( *hitEvent.m_event ) );
04706
04707 if ( m_flags.m_editingCopy )
04708
04709 PROPID_FirstEventInObject->SetPropertyToObject( this, false );
04710 }
04711
04712
04713 if ( (*hitEvent.m_event).GetEventType() == wxEVT_MOTION)
04714 {
04715 wxMouseEvent* mouse = wxDynamicCast( hitEvent.m_event, wxMouseEvent );
04716 hitEvent.m_event->Skip(true);
04717
04718 if ( hitEvent.m_isHit && !m_flags.m_MouseInObject )
04719 {
04720 ReportHit( this, wxT("enter"), m_flags.m_editingCopy, hitEvent );
04721
04722 m_flags.m_MouseInObject = true;
04723 a2dCanvasObjectMouseEvent enter( &ic, this, wxEVT_CANVASOBJECT_ENTER_EVENT, hitEvent.m_x, hitEvent.m_y, *mouse );
04724
04725
04726 hitEvent.SetProcessed( ProcessEvent( enter ) );
04727
04728 hitEvent.m_event->Skip(true);
04729 hitEvent.SetProcessed( false );
04730 }
04731 else if ( !hitEvent.m_isHit && m_flags.m_MouseInObject )
04732 {
04733 ReportHit( this, wxT("leave"), m_flags.m_editingCopy, hitEvent );
04734
04735
04736
04737
04738
04739
04740 LeaveInObjects( ic, hitEvent );
04741
04742 m_flags.m_MouseInObject = false;
04743 a2dCanvasObjectMouseEvent leave( &ic, this, wxEVT_CANVASOBJECT_LEAVE_EVENT, hitEvent.m_x, hitEvent.m_y, *mouse );
04744
04745 hitEvent.SetProcessed( ProcessEvent( leave ) );
04746
04747 hitEvent.m_event->Skip(true);
04748 hitEvent.SetProcessed( false );
04749 }
04750 }
04751
04752 hitEvent.m_isHit |= wasHit;
04753
04754 ic.SetStrokeWorldExtend( 0 );
04755 return hitEvent.m_processed;
04756 }
04757
04758 bool a2dCanvasObject::RestrictToObject( a2dRestrictionEngine* engine, a2dSnapToWhatMask snapToWhat )
04759 {
04760
04761 if ( !m_flags.m_snap_to )
04762 return false;
04763
04764 bool res = false;
04765 if ( snapToWhat & a2dRestrictionEngine::snapToPins ||
04766 snapToWhat & a2dRestrictionEngine::snapToPinsUnconnected
04767 )
04768 {
04769 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_hasPins )
04770 {
04771 forEachIn( a2dCanvasObjectList, m_childobjects )
04772 {
04773 a2dCanvasObject *obj = *iter;
04774 a2dPin* pin = wxDynamicCast( obj, a2dPin );
04775 if (pin && !pin->GetRelease( ) )
04776 {
04777 if ( snapToWhat & a2dRestrictionEngine::snapToPins ||
04778 ( snapToWhat & a2dRestrictionEngine::snapToPinsUnconnected && !pin->ConnectedTo() )
04779 )
04780 {
04781
04782 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( pin->GetAbsX(), pin->GetAbsY() ));
04783 }
04784 }
04785 }
04786 }
04787 }
04788 if ( snapToWhat & a2dRestrictionEngine::snapToObjectPos )
04789 {
04790 res |= engine->SetPointSnapResultIfCloser( GetPosXY() );
04791 }
04792 if ( snapToWhat & a2dRestrictionEngine::snapToObjectVertexes )
04793 {
04794 a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths( true );
04795 if ( vectorpaths != wxNullCanvasObjectList )
04796 {
04797 forEachIn( a2dCanvasObjectList, vectorpaths )
04798 {
04799 a2dVectorPath* obj = wxStaticCast( (*iter).Get(), a2dVectorPath );
04800 if ( obj->RestrictToObject( engine, snapToWhat ) )
04801 {
04802 res = true;
04803 }
04804 }
04805 delete vectorpaths;
04806 }
04807 }
04808
04809 if ( snapToWhat & a2dRestrictionEngine::snapToBoundingBox )
04810 {
04811 a2dBoundingBox untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_EDIT );
04812 if ( untrans.GetWidth() == 0 || untrans.GetWidth() == 0 )
04813 untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_CHILDREN | a2dCANOBJ_BBOX_EDIT );
04814
04815 double x,y,w,h;
04816 x = untrans.GetMinX();
04817 y = untrans.GetMinY();
04818 w = untrans.GetWidth();
04819 h = untrans.GetHeight();
04820
04821 double tx, ty;
04822 m_lworld.TransformPoint( x ,y, tx, ty );
04823 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04824 m_lworld.TransformPoint( x ,y+h, tx, ty );
04825 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04826 m_lworld.TransformPoint( x+w ,y+h, tx, ty );
04827 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04828 m_lworld.TransformPoint( x+w ,y+h, tx, ty );
04829 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04830 m_lworld.TransformPoint( x+w ,y, tx, ty );
04831 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04832 m_lworld.TransformPoint( x ,y+h/2, tx, ty );
04833 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04834 m_lworld.TransformPoint( x+w/2 ,y+h, tx, ty );
04835 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04836 m_lworld.TransformPoint( x+w ,y+h/2, tx, ty );
04837 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04838 m_lworld.TransformPoint( x+w/2 ,y, tx, ty );
04839 res |= engine->SetPointSnapResultIfCloser( a2dPoint2D( tx, ty ) );
04840 }
04841
04842 if ( snapToWhat & a2dRestrictionEngine::snapToObjectSegments )
04843 {
04844 a2dLine& p = engine->GetLineToSnap();
04845 }
04846
04847 return res;
04848 }
04849
04850 a2dCanvasObjectList* a2dCanvasObject::GetSnapVpath( a2dSnapToWhatMask snapToWhat )
04851 {
04852 a2dVpath* segments = new a2dVpath();
04853 a2dVectorPath* snappath = new a2dVectorPath( segments );
04854 a2dCanvasObjectList* snappathlist = new a2dCanvasObjectList();
04855 snappathlist->push_back( snappath );
04856
04857 if ( snapToWhat & a2dRestrictionEngine::snapToPins ||
04858 snapToWhat & a2dRestrictionEngine::snapToPinsUnconnected
04859 )
04860 {
04861 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_hasPins )
04862 {
04863 forEachIn( a2dCanvasObjectList, m_childobjects )
04864 {
04865 a2dCanvasObject *obj = *iter;
04866 a2dPin* pin = wxDynamicCast( obj, a2dPin );
04867 if (pin && !pin->GetRelease( ) )
04868 {
04869 if ( snapToWhat & a2dRestrictionEngine::snapToPins ||
04870 ( snapToWhat & a2dRestrictionEngine::snapToPinsUnconnected && !pin->ConnectedTo() )
04871 )
04872 {
04873 a2dVpathSegment* seg = new a2dVpathSegment( pin->GetPosX(), pin->GetPosY(), a2dPATHSEG_MOVETO );
04874 segments->Add(seg);
04875 }
04876 }
04877 }
04878 }
04879 }
04880 if ( snapToWhat & a2dRestrictionEngine::snapToObjectPos )
04881 {
04882 a2dVpathSegment* seg = new a2dVpathSegment( GetPosX(), GetPosY(), a2dPATHSEG_MOVETO );
04883 segments->Add(seg);
04884 }
04885
04886 if ( snapToWhat & a2dRestrictionEngine::snapToObjectVertexes )
04887 {
04888 a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths( true );
04889 if ( vectorpaths != wxNullCanvasObjectList )
04890 {
04891 snappathlist->TakeOverFrom( vectorpaths );
04892 delete vectorpaths;
04893 }
04894 }
04895
04896 if ( snapToWhat & a2dRestrictionEngine::snapToBoundingBox )
04897 {
04898 a2dBoundingBox untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_EDIT );
04899 if ( untrans.GetWidth() == 0 || untrans.GetWidth() == 0 )
04900 untrans = GetUnTransformedBbox( a2dCANOBJ_BBOX_CHILDREN | a2dCANOBJ_BBOX_EDIT );
04901
04902 double x,y,w,h;
04903 x = untrans.GetMinX();
04904 y = untrans.GetMinY();
04905 w = untrans.GetWidth();
04906 h = untrans.GetHeight();
04907
04908 double tx, ty;
04909 m_lworld.TransformPoint( x ,y, tx, ty );
04910 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04911 m_lworld.TransformPoint( x ,y+h, tx, ty );
04912 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04913 m_lworld.TransformPoint( x+w ,y+h, tx, ty );
04914 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04915 m_lworld.TransformPoint( x+w ,y+h, tx, ty );
04916 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04917 m_lworld.TransformPoint( x+w ,y, tx, ty );
04918 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04919 m_lworld.TransformPoint( x ,y+h/2, tx, ty );
04920 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04921 m_lworld.TransformPoint( x+w/2 ,y+h, tx, ty );
04922 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04923 m_lworld.TransformPoint( x+w ,y+h/2, tx, ty );
04924 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04925 m_lworld.TransformPoint( x+w/2 ,y, tx, ty );
04926 segments->Add( new a2dVpathSegment( tx, ty, a2dPATHSEG_MOVETO ));
04927 }
04928
04929 if ( snapToWhat & a2dRestrictionEngine::snapToObjectSegments )
04930 {
04931 }
04932
04933 return snappathlist;
04934 }
04935
04936 bool a2dCanvasObject::SwitchChildNamed( const wxString& objectname, a2dCanvasObject* newobject )
04937 {
04938 if (m_childobjects != wxNullCanvasObjectList )
04939 return m_childobjects->SwitchObjectNamed( objectname, newobject );
04940
04941 return false;
04942 }
04943
04944 int a2dCanvasObject::CollectObjects( a2dCanvasObjectList* total, const wxString& classname, a2dCanvasObjectFlagsMask mask,
04945 const a2dPropertyId *id, const a2dBoundingBox& bbox ) const
04946 {
04947 if (m_childobjects != wxNullCanvasObjectList )
04948 {
04949 return m_childobjects->CollectObjects( total, classname, mask, id, bbox );
04950 }
04951 return 0;
04952 }
04953
04954 a2dCanvasObject* a2dCanvasObject::Find( const wxString& objectname, const wxString& classname, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *propid, const wxString& valueAsString, wxUint32 id ) const
04955 {
04956 if (m_childobjects != wxNullCanvasObjectList )
04957 return m_childobjects->Find( objectname, classname, mask, propid, valueAsString, id );
04958
04959 return (a2dCanvasObject*) NULL;
04960 }
04961
04962 a2dCanvasObject* a2dCanvasObject::Find( a2dCanvasObject* obj ) const
04963 {
04964 if ( m_childobjects != wxNullCanvasObjectList )
04965 return m_childobjects->Find( obj );
04966 else
04967 return 0;
04968 }
04969
04970 void a2dCanvasObject::AddPending( a2dIterC& ic )
04971 {
04972 bool childpending = false;
04973 {
04974 a2dIterCU cu( ic, this );
04975
04976 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
04977 {
04978 forEachIn( a2dCanvasObjectList, m_childobjects )
04979 {
04980 a2dCanvasObject *obj = *iter;
04981
04982
04983 if ( obj )
04984 {
04985 childpending = ( obj->m_flags.m_pending || obj->m_release ) || childpending;
04986 obj->AddPending( ic );
04987 }
04988 }
04989 }
04990
04991 DoAddPending( ic );
04992 }
04993
04994
04995
04996
04997
04998 if( m_flags.m_resizeToChilds )
04999 m_flags.m_pending |= childpending;
05000
05001 if (m_flags.m_pending || m_release )
05002 {
05003
05004 if ( m_release )
05005 {
05006
05007
05008
05009 if ( m_layer != wxLAYER_DEFAULT && !m_flags.m_ignoreSetpending )
05010 ic.GetCanvasView()->SetLayerCheck( m_layer );
05011 }
05012 else if ( m_flags.m_pending )
05013 {
05014
05015 if ( m_layer != wxLAYER_DEFAULT )
05016 ic.GetCanvasView()->GetLayerRenderArray()[ m_layer ].SetAvailable( true );
05017 }
05018
05019
05020 bool foundMiniUpdate = false;
05021 a2dNamedPropertyList::const_iterator iter;
05022 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05023 {
05024 const a2dNamedProperty *prop = *iter;
05025 if ( prop->GetId() == PROPID_BoundingBox )
05026 {
05027 ic.GetCanvasView()->AddPendingUpdateArea( wxStaticCast( prop, a2dBoudingBoxProperty )->GetValue() );
05028 foundMiniUpdate = true;
05029 }
05030 }
05031
05032
05033 if ( !foundMiniUpdate )
05034 {
05035
05036
05037 wxRect absarea = GetAbsoluteArea( ic );
05038 ic.GetCanvasView()->AddPendingUpdateArea(absarea);
05039 }
05040 }
05041
05042 }
05043
05044 void a2dCanvasObject::DoAddPending( a2dIterC& WXUNUSED(ic) )
05045 {
05046 }
05047
05048 void a2dCanvasObject::UpdateViewDependentObjects( a2dIterC& ic )
05049 {
05050
05051
05052 a2dCanvasView* view = wxStaticCastNull( PROPID_ViewSpecific->GetPropertyValue( this ).Get(), a2dCanvasView );
05053 if ( view != ic.GetCanvasView())
05054 return;
05055
05056
05057
05058 a2dCanvasView* view2 = wxStaticCastNull( PROPID_ViewDependent->GetPropertyValue( this ).Get(), a2dCanvasView );
05059 if ( view2 == ic.GetCanvasView())
05060 {
05061 DoUpdateViewDependentTransform(ic);
05062 }
05063
05064 a2dIterCU cu( ic, this );
05065
05066 DoUpdateViewDependentObjects(ic);
05067
05068 if ( m_childobjects != wxNullCanvasObjectList )
05069 {
05070 forEachIn( a2dCanvasObjectList, m_childobjects )
05071 {
05072 a2dCanvasObject *obj = *iter;
05073
05074 if (obj )
05075 obj->UpdateViewDependentObjects( ic );
05076 }
05077 }
05078 }
05079
05080 void a2dCanvasObject::DoUpdateViewDependentTransform( a2dIterC& ic )
05081 {
05082 a2dNamedProperty* propSpec = GetProperty( PROPID_IntViewDependTransform );
05083 if ( !propSpec )
05084 {
05085 a2dAffineMatrix tworld = ic.GetTransform();
05086
05087 a2dAffineMatrix withoutScale(ic.GetMappingTransform() * tworld * m_lworld);
05088 withoutScale.RemoveScale();
05089 a2dAffineMatrix invertMapping(ic.GetMappingTransform());
05090 invertMapping.Invert();
05091 a2dAffineMatrix newRelative(ic.GetInverseTransform());
05092 newRelative *= invertMapping;
05093 newRelative *= withoutScale;
05094 m_lworld = newRelative;
05095 SetPending(true);
05096 delete propSpec;
05097 }
05098 }
05099
05100 void a2dCanvasObject::DoUpdateViewDependentObjects( a2dIterC& ic )
05101 {
05102 a2dNamedProperty* propSpec = GetProperty( PROPID_IntViewDependTransform );
05103 if ( propSpec )
05104 {
05105 a2dMatrixProperty* propMatrix = wxStaticCast(propSpec, a2dMatrixProperty);
05106
05107 a2dAffineMatrix tworld = ic.GetTransform();
05108 a2dAffineMatrix withoutScale(ic.GetMappingTransform() * tworld );
05109 withoutScale.RemoveScale();
05110 a2dAffineMatrix invertMapping(ic.GetMappingTransform());
05111 invertMapping.Invert();
05112 a2dAffineMatrix newRelative(ic.GetInverseTransform());
05113 newRelative *= invertMapping;
05114 newRelative *= withoutScale;
05115
05116 propMatrix->SetValue( newRelative );
05117 SetPending(true);
05118 delete propSpec;
05119 }
05120
05121 }
05122
05123 void a2dCanvasObject::DependencyPending( a2dWalkerIOHandler* handler )
05124 {
05125
05126
05127 a2dCanvasObject* parent = wxDynamicCast( handler->GetParent(), a2dCanvasObject );
05128 if ( parent && parent->GetHighLight() && !parent->GetPending() && GetPending() )
05129 {
05130 parent->SetPending( true );
05131 }
05132 }
05133
05134 void a2dCanvasObject::DoRender( a2dIterC& ic, OVERLAP WXUNUSED(clipparent) )
05135 {
05136 if ( m_childobjects->size() == 0 )
05137 {
05138 double x1;
05139 double y1;
05140 ic.GetTransform().TransformPoint( 0, 0, x1, y1 );
05141 int dx = ic.GetDrawer2D()->WorldToDeviceX(x1);
05142 int dy = ic.GetDrawer2D()->WorldToDeviceY(y1);
05143
05144 ic.GetDrawer2D()->PushIdentityTransform();
05145 ic.GetDrawer2D()->DrawLine( dx - 3, dy, dx + 4, dy);
05146 ic.GetDrawer2D()->DrawLine( dx, dy + 3, dx, dy - 4);
05147 ic.GetDrawer2D()->PopTransform();
05148 }
05149 }
05150
05151 void a2dCanvasObject::Render( a2dIterC& ic, OVERLAP clipparent )
05152 {
05153
05154 if ( m_release )
05155 return;
05156
05157 if ( !ic.FilterObject( this ) )
05158 {
05159 ic.EndFilterObject( this );
05160 return;
05161 }
05162
05163
05164
05165
05166
05167
05168
05169
05170
05171
05172
05173
05174 if ( !m_flags.m_NoRenderCanvasObject && GetBbox().GetWidth() && GetBbox().GetHeight() )
05175 {
05176 a2dBoundingBox absarea = GetBbox();
05177 if ( !ic.GetTransform().IsIdentity())
05178 absarea.MapBbox( ic.GetTransform() );
05179
05180 if ( m_worldExtend )
05181 absarea.Enlarge( m_worldExtend );
05182 if ( m_pixelExtend )
05183 absarea.Enlarge( ic.GetDrawer2D()->DeviceToWorldXRel( m_pixelExtend ) );
05184
05185 double size = wxMax( absarea.GetWidth(), absarea.GetHeight() );
05186 if ( ic.GetDrawer2D()->GetPrimitiveThreshold() != 0
05187 && size < ic.GetDrawer2D()->DeviceToWorldXRel( ic.GetDrawer2D()->GetPrimitiveThreshold() ) )
05188 {
05189 if ( ic.GetDrawer2D()->GetThresholdDrawRectangle() )
05190 {
05191 wxRect absareadev = GetAbsoluteArea( ic, 0 );
05192 ic.GetDrawer2D()->DrawRoundedRectangle( GetBbox().GetMinX(), GetBbox().GetMinY(),
05193 GetBbox().GetWidth(), GetBbox().GetHeight(),0);
05194
05195 if ( m_flags.m_HighLight )
05196 DrawHighLighted( ic );
05197 }
05198 ic.EndFilterObject( this );
05199 return;
05200 }
05201 }
05202
05203
05204 {
05205
05206
05207
05208 a2dIterCU cu( ic, this );
05209
05210
05211
05212
05213
05214
05215
05216 bool fillset = false;
05217 bool strokeset = false;
05218 bool viewSpecific = false;
05219
05220 a2dLayers* layers = m_root->GetLayerSetup();
05221
05222
05223
05224 if ( HasDynamicProperties() )
05225 {
05226 bool firstclip = false;
05227
05228 a2dNamedPropertyList::const_iterator iter;
05229 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05230 {
05231 const a2dNamedProperty *prop = *iter;
05232 a2dObject* obj = prop->GetRefObjectNA();
05233 if ( wxDynamicCast(prop , a2dFillProperty ) )
05234 {
05235 a2dFill fill = wxStaticCast( prop, a2dFillProperty )->GetValue();
05236 if (m_flags.m_filled)
05237 {
05238 if ( fill.IsSameAs(*a2dINHERIT_FILL) )
05239 fillset = true;
05240 else if ( fill.IsNoFill() )
05241 fillset = false;
05242 else
05243 {
05244 ic.GetDrawer2D()->SetDrawerFill( fill );
05245 fillset = true;
05246 }
05247 }
05248 else
05249 {
05250 ic.GetDrawer2D()->SetDrawerFill( *a2dTRANSPARENT_FILL );
05251 fillset = true;
05252 }
05253
05254 }
05255 else if ( wxDynamicCast(prop, a2dStrokeProperty ) )
05256 {
05257 a2dStroke stroke = wxStaticCast( prop, a2dStrokeProperty )->GetValue();
05258 if ( stroke.IsSameAs(*a2dINHERIT_STROKE) )
05259 strokeset = true;
05260 else if ( stroke.IsNoStroke() )
05261 strokeset = false;
05262 else
05263 {
05264 strokeset = true;
05265 ic.GetDrawer2D()->SetDrawerStroke( stroke );
05266 }
05267
05268 }
05269 else if ( !m_flags.m_editingCopy && wxDynamicCast( prop, a2dClipPathProperty) )
05270 {
05271
05272 wxStaticCast( prop, a2dClipPathProperty )->PushClip( ic.GetCanvasView(), firstclip ? a2dCLIP_OR : a2dCLIP_AND );
05273 firstclip = true;
05274 }
05275 else if ( m_flags.m_showshadow && wxDynamicCast( prop, a2dShadowStyleProperty) )
05276 {
05277 a2dShadowStyleProperty* shadow = wxStaticCast( prop, a2dShadowStyleProperty );
05278 double dx = cos( shadow->GetExtrudeAngle() ) * shadow->GetExtrudeDepth();
05279 double dy = sin( shadow->GetExtrudeAngle() ) * shadow->GetExtrudeDepth();
05280
05281 a2dAffineMatrix tworld = ic.GetTransform();
05282
05283 SetDrawerStyle( ic, shadow );
05284 tworld.Translate( dx, dy );
05285
05286
05287
05288 ic.GetDrawer2D()->SetTransform( tworld );
05289
05290 DoRender( ic, clipparent );
05291 tworld.Translate( -dx, -dy );
05292
05293
05294 ic.GetDrawer2D()->SetTransform( tworld );
05295 }
05296 else if ( wxDynamicCast( prop, a2dCanvasObjectPtrProperty) )
05297 {
05298 a2dCanvasObjectPtrProperty* torender = wxStaticCast( prop, a2dCanvasObjectPtrProperty );
05299
05300 if (
05301 torender->GetCanRender() &&
05302 torender->GetPreRender() &&
05303 torender->GetCanvasObject() &&
05304 torender->GetVisible() &&
05305 ( !torender->GetSelectedOnly() || IsSelected() )
05306 )
05307 torender->GetCanvasObject()->Render( ic, clipparent );
05308 }
05309 else if ( prop->GetId() == PROPID_ViewSpecific && prop->GetRefObject() != ic.GetCanvasView() )
05310 {
05311 viewSpecific = true;
05312 }
05313 }
05314 }
05315
05316 if ( viewSpecific )
05317 {
05318 ic.EndFilterObject( this );
05319 return;
05320 }
05321
05322
05323 if ( layers )
05324 {
05325 if ( !fillset )
05326 ic.GetDrawer2D()->SetDrawerFill( layers->GetFill(m_layer) );
05327 if ( !strokeset )
05328 ic.GetDrawer2D()->SetDrawerStroke( layers->GetStroke(m_layer) );
05329 }
05330 else
05331 {
05332 if ( !fillset )
05333 ic.GetDrawer2D()->SetDrawerFill( *a2dBLACK_FILL );
05334 if ( !strokeset )
05335 ic.GetDrawer2D()->SetDrawerStroke( *a2dBLACK_STROKE );
05336 }
05337
05338
05339 a2dFill currentdrawer_fill = ic.GetDrawer2D()->GetDrawerFill();
05340 a2dStroke currentdrawer_stroke = ic.GetDrawer2D()->GetDrawerStroke();
05341
05342
05343
05344 RenderChild whichchilds;
05345 whichchilds.m_prerender = true;
05346 whichchilds.m_postrender = false;
05347 whichchilds.m_property = false;
05348
05349 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05350 {
05351
05352 RenderChildObjects( ic, whichchilds, clipparent );
05353
05354
05355 }
05356
05357
05358
05359
05360
05361
05362
05363
05364 if ( ic.GetLayer() == m_layer || ic.GetLayer() == wxLAYER_ALL || m_flags.m_ignoreLayer )
05365 {
05366
05367
05368
05369
05370
05371 DoRender( ic, clipparent );
05372
05373
05374
05375
05376
05377 ic.GetDrawer2D()->SetDrawerFill( currentdrawer_fill );
05378 ic.GetDrawer2D()->SetDrawerStroke( currentdrawer_stroke );
05379 }
05380
05381 if ( whichchilds.m_postrender && m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05382 {
05383 whichchilds.m_prerender = false;
05384 whichchilds.m_postrender = true;
05385 whichchilds.m_property = false;
05386
05387
05388 RenderChildObjects( ic, whichchilds, clipparent );
05389
05390
05391 }
05392
05393
05394
05395
05396
05397 if ( whichchilds.m_property && m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05398 {
05399 whichchilds.m_prerender = false;
05400 whichchilds.m_postrender = false;
05401 whichchilds.m_property = true;
05402
05403 RenderChildObjects( ic, whichchilds, clipparent );
05404
05405
05406 }
05407
05408
05409 if ( HasDynamicProperties() )
05410 {
05411
05412 a2dNamedPropertyList::const_iterator iter;
05413 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05414 {
05415 const a2dNamedProperty *prop = *iter;
05416 a2dObject* obj = prop->GetRefObjectNA();
05417 if ( wxDynamicCast( prop, a2dClipPathProperty ) && !m_flags.m_editingCopy )
05418 {
05419 wxStaticCast( prop, a2dClipPathProperty )->PopClip( ic.GetCanvasView() );
05420 }
05421
05422
05423 if ( wxDynamicCast( prop, a2dCanvasObjectPtrProperty ) )
05424 {
05425
05426 a2dCanvasObjectPtrProperty* torender = wxStaticCast( prop, a2dCanvasObjectPtrProperty );
05427
05428 if (
05429 torender->GetCanRender() &&
05430 !torender->GetPreRender() &&
05431 torender->GetCanvasObject() &&
05432 torender->GetVisible() &&
05433 ( !torender->GetSelectedOnly() || IsSelected() )
05434 )
05435 {
05436 torender->GetCanvasObject()->Render( ic, clipparent );
05437 }
05438 }
05439
05440
05441
05442 else if ( prop->GetCanRender() && obj && prop->GetVisible()
05443 )
05444 {
05445 a2dCanvasObject* canobj = wxDynamicCast( obj, a2dCanvasObject );
05446 if ( canobj )
05447 canobj->Render( ic, clipparent );
05448 }
05449 }
05450 }
05451 }
05452
05453 if ( m_flags.m_HighLight )
05454 DrawHighLighted( ic );
05455
05456 ic.EndFilterObject( this );
05457 }
05458
05459 void a2dCanvasObject::DrawHighLighted( a2dIterC& ic )
05460 {
05461
05462
05463
05464 ic.GetDrawer2D()->SetDrawerStroke( a2dCanvasGlobals->GetHighLightStroke() );
05465 ic.GetDrawer2D()->SetDrawerFill( a2dCanvasGlobals->GetHighLightFill() );
05466
05467 ic.GetDrawer2D()->DrawRoundedRectangle( m_bbox.GetMinX(), m_bbox.GetMinY(), m_bbox.GetWidth(), m_bbox.GetHeight() ,0 );
05468 }
05469
05470 a2dBoundingBox a2dCanvasObject::DoGetUnTransformedBbox( a2dBboxFlags WXUNUSED(flags) ) const
05471 {
05472 return a2dBoundingBox();
05473 }
05474
05475 a2dBoundingBox a2dCanvasObject::GetUnTransformedBbox( a2dBboxFlags flags ) const
05476 {
05477 a2dBoundingBox box = DoGetUnTransformedBbox( flags );
05478 if ( (flags & a2dCANOBJ_BBOX_CHILDREN)
05479 && m_childobjects != wxNullCanvasObjectList
05480 && m_flags.m_visiblechilds )
05481 {
05482 a2dCanvasObjectList::iterator iter;
05483 for( iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
05484 {
05485 a2dCanvasObject *obj = *iter;
05486 if ( obj )
05487 obj->Update( a2dCanvasObject::update_save );
05488 }
05489
05490 for( iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
05491 {
05492 a2dCanvasObject *obj = *iter;
05493
05494 if( obj && obj->GetVisible() )
05495 box.Expand( obj->GetBbox() );
05496 }
05497 }
05498
05499
05500
05501 if (!box.GetValid())
05502 {
05503
05504
05505 box.Expand(0, 0);
05506 }
05507
05508 return box;
05509 }
05510
05511 a2dBoundingBox a2dCanvasObject::GetCalculatedBoundingBox( int nChildLevels )
05512 {
05513 a2dBoundingBox box = DoGetUnTransformedBbox();
05514 if ( nChildLevels >= 1 && m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05515 {
05516 forEachIn( a2dCanvasObjectList, m_childobjects )
05517 {
05518 a2dCanvasObject *obj = *iter;
05519 if ( obj )
05520 box.Expand( obj->GetCalculatedBoundingBox( nChildLevels - 1 ) );
05521 }
05522 }
05523
05524
05525
05526 if (!box.GetValid())
05527 {
05528
05529 box.Expand(0, 0);
05530 }
05531
05532 box.MapBbox( m_lworld );
05533
05534 return box;
05535 }
05536
05537 bool a2dCanvasObject::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
05538 {
05539 if ( !m_bbox.GetValid() )
05540 {
05541 m_bbox = DoGetUnTransformedBbox();
05542 if ( m_bbox.GetValid() )
05543 {
05544 m_bbox.MapBbox(m_lworld);
05545 return true;
05546 }
05547 }
05548 return false;
05549 }
05550
05551 bool a2dCanvasObject::Update( UpdateMode mode )
05552 {
05553 a2dBoundingBox oldbbox = m_bbox;
05554
05555 a2dLayers* layers = NULL;
05556 if ( m_root && m_root->GetLayerSetup() )
05557 {
05558
05559
05560
05561 layers = m_root->GetLayerSetup();
05562 layers->GetLayerIndex()[ m_layer ]->SetAvailable( true );
05563 }
05564 bool changed = false;
05565
05566 if ( m_childobjects != wxNullCanvasObjectList )
05567 {
05568 wxString str = GetClassInfo()->GetClassName();
05569 m_flags.m_NoRenderCanvasObject = str.IsSameAs( wxT("a2dCanvasObject") );
05570 if ( m_flags.m_NoRenderCanvasObject )
05571 m_flags.m_NoRenderCanvasObject = m_flags.m_NoRenderCanvasObject && m_childobjects->size() == 0;
05572
05573 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
05574 while( iter != m_childobjects->end() )
05575 {
05576 a2dCanvasObjectList::value_type obj = *iter;
05577
05578 if ( obj && obj->m_release )
05579 {
05580
05581
05582
05583 a2dCanvasObject* parent = PROPID_Parent->GetPropertyValue( obj );
05584 if ( ( parent == NULL ) || ( parent != NULL && parent == this ) )
05585 {
05586 if ( obj->HasPins() )
05587 obj->DisConnectWith( this );
05588 wxUint16 layer = obj->GetLayer();
05589 if ( ! obj->GetIgnoreSetpending() )
05590 SentChangeLayerEvent( layer );
05591 iter = m_childobjects->erase( iter );
05592 changed = true;
05593 }
05594 }
05595 else
05596 iter++;
05597 }
05598 if ( m_childobjects->empty() && !GetIgnoreLayer() )
05599 {
05600 delete m_childobjects;
05601 m_childobjects = wxNullCanvasObjectList;
05602 }
05603 }
05604
05605
05606
05607 if ( (mode == updatemask_force) || m_flags.m_pending || !m_bbox.GetValid() )
05608 {
05609
05610 changed = true;
05611 m_flags.m_HasToolObjectsBelow = m_flags.m_editingCopy;
05612 m_flags.m_HasSelectedObjectsBelow = m_flags.m_selected;
05613 m_flags.m_NoRenderCanvasObject = false;
05614
05615 m_pixelExtend = 0;
05616 m_worldExtend = 0;
05617
05618 a2dNamedPropertyList::const_iterator iter;
05619 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05620 {
05621 const a2dNamedProperty *prop = *iter;
05622 a2dObject* obj = prop->GetRefObjectNA();
05623 if ( wxDynamicCast(prop , a2dStrokeProperty ) )
05624 {
05625 a2dStroke stroke = wxStaticCast( prop , a2dStrokeProperty )->GetValue();
05626
05627 if ( stroke.IsNoStroke() )
05628 {
05629 if ( m_root && layers )
05630 {
05631 a2dStroke layerpen = layers->GetStroke( m_layer );
05632 if ( layerpen.GetPixelStroke() )
05633 {
05634 m_pixelExtend = (wxUint16) (layerpen.GetWidth()/2);
05635 }
05636 else
05637 {
05638 m_worldExtend = layerpen.GetWidth()/2;
05639 }
05640 }
05641 }
05642 else if ( !stroke.IsSameAs(*a2dTRANSPARENT_STROKE) )
05643 {
05644 if ( stroke.GetPixelStroke() )
05645 {
05646 m_pixelExtend = (wxUint16) (stroke.GetWidth()/2);
05647 }
05648 else
05649 {
05650 m_worldExtend = stroke.GetWidth()/2;
05651 }
05652 }
05653
05654 }
05655 else if ( prop->GetId() == a2dCanvasObject::PROPID_ToolObject ||
05656 prop->GetId() == a2dCanvasObject::PROPID_ToolDecoration
05657 )
05658 m_flags.m_HasToolObjectsBelow = true;
05659 }
05660 }
05661
05662
05663
05664
05665
05666
05667
05668 bool childchanged = false;
05669
05670 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds)
05671 {
05672 forEachIn( a2dCanvasObjectList, m_childobjects )
05673 {
05674 a2dCanvasObject *obj = *iter;
05675 if ( !obj )
05676 continue;
05677
05678 childchanged = obj->Update( mode ) || childchanged;
05679 m_flags.m_HasToolObjectsBelow = m_flags.m_HasToolObjectsBelow || obj->m_flags.m_HasToolObjectsBelow;
05680 m_flags.m_HasSelectedObjectsBelow = m_flags.m_HasSelectedObjectsBelow || obj->m_flags.m_HasSelectedObjectsBelow;
05681
05682
05683
05684 }
05685 }
05686
05687 bool propertychanged = false;
05688
05689 if ( HasDynamicProperties() )
05690 {
05691 a2dNamedPropertyList::const_iterator iter;
05692 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05693 {
05694 const a2dNamedProperty *prop = *iter;
05695 a2dObject* obj = prop->GetRefObjectNA();
05696 if ( wxDynamicCast( prop, a2dShadowStyleProperty) )
05697 {
05698 propertychanged = changed;
05699 }
05700 else if ( wxDynamicCast( obj, a2dCanvasObject) && prop->GetCanRender() && prop->GetVisible() &&
05701 wxDynamicCast( obj, a2dCanvasObject)->GetVisible() )
05702 {
05703 propertychanged = wxStaticCast( obj, a2dCanvasObject )->Update( mode ) || propertychanged;
05704 }
05705 else if ( mode & update_includebboxprop && prop->GetId() == PROPID_BoundingBox )
05706 propertychanged = true;
05707 }
05708 }
05709
05710
05711
05712 a2dBoundingBox childbox;
05713
05714
05715 a2dBoundingBox childboxOnlyTranslate;
05716
05717
05718 a2dBoundingBox propbox;
05719
05720 a2dBoundingBox clipbox;
05721 double maxworldextend = 0;
05722 double maxpixelextend = 0;
05723 a2dShadowStyleProperty* shadow = NULL;
05724
05725
05726
05727
05728 if ( changed || childchanged || propertychanged )
05729 {
05730 m_bbox.SetValid(false);
05731 changed = true;
05732
05733 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05734 {
05735 a2dAffineMatrix transworld;
05736 transworld.Translate( GetPosX(), GetPosY() );
05737 forEachIn( a2dCanvasObjectList, m_childobjects )
05738 {
05739 a2dCanvasObject *obj = *iter;
05740
05741 if( obj && obj->GetVisible() )
05742 {
05743 if ( obj->m_flags.m_ChildOnlyTranslate )
05744 {
05745 childboxOnlyTranslate = obj->GetBbox();
05746 childboxOnlyTranslate.MapBbox( transworld );
05747 }
05748 else
05749 childbox.Expand( obj->GetBbox() );
05750
05751 maxworldextend = wxMax( obj->m_worldExtend, maxworldextend );
05752 maxpixelextend = wxMax( obj->m_pixelExtend, maxpixelextend );
05753 }
05754 }
05755
05756 if ( childboxOnlyTranslate.GetValid() )
05757 {
05758 childboxOnlyTranslate.Enlarge( maxworldextend );
05759 }
05760
05761 if ( childbox.GetValid() )
05762 {
05763 childbox.Enlarge( maxworldextend );
05764 }
05765 m_pixelExtend = (wxUint16) wxMax( (int) maxpixelextend, m_pixelExtend );
05766 }
05767
05768 if ( HasDynamicProperties() )
05769 {
05770 a2dNamedPropertyList::const_iterator iter;
05771 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
05772 {
05773 const a2dNamedProperty *prop = *iter;
05774 a2dObject* obj = prop->GetRefObjectNA();
05775 if ( wxDynamicCast( prop, a2dClipPathProperty ) )
05776 {
05777 if ( obj )
05778 {
05779 clipbox.Expand( wxStaticCast( obj, a2dCanvasObject )->GetMappedBbox( m_lworld ) );
05780
05781
05782
05783 if ( wxDynamicCast( obj, a2dCanvasObject) && wxDynamicCast( obj, a2dCanvasObject)->GetVisible() )
05784 {
05785 propbox.Expand( wxStaticCast( obj, a2dCanvasObject )->GetMappedBbox( m_lworld ) );
05786 }
05787 }
05788 }
05789 else if ( wxDynamicCast( prop, a2dShadowStyleProperty ) )
05790 {
05791 shadow = wxStaticCast( prop, a2dShadowStyleProperty );
05792 }
05793 else if ( wxDynamicCast( obj, a2dCanvasObject ) && prop->GetCanRender() && prop->GetVisible() && wxDynamicCast( obj, a2dCanvasObject)->GetVisible() )
05794 {
05795 propbox.Expand( wxStaticCast( obj, a2dCanvasObject )->GetMappedBbox( m_lworld ) );
05796 }
05797 else if ( mode & update_includebboxprop && prop->GetId() == PROPID_BoundingBox )
05798 propbox.Expand( wxStaticCast( prop, a2dBoudingBoxProperty )->GetValue() );
05799 }
05800 }
05801 }
05802
05803 if ( childboxOnlyTranslate.GetValid() )
05804 childbox.Expand( childboxOnlyTranslate );
05805
05806
05807
05808
05809
05810
05811
05812
05813 changed = DoUpdate( mode, childbox, clipbox, propbox ) || changed;
05814
05815 if ( childbox.GetValid() )
05816 {
05817 childbox.MapBbox( m_lworld );
05818 m_bbox.Expand( childbox );
05819 }
05820
05821 if ( shadow )
05822 {
05823 double dx = cos( shadow->GetExtrudeAngle())* shadow->GetExtrudeDepth();
05824 double dy = sin( shadow->GetExtrudeAngle())* shadow->GetExtrudeDepth();
05825
05826 a2dBoundingBox shadowbox = m_bbox;
05827 shadowbox.Translate( dx, dy );
05828 propbox.Expand( shadowbox );
05829 }
05830 if ( propbox.GetValid() )
05831 m_bbox.Expand( propbox );
05832
05833 if ( clipbox.GetValid() && !m_flags.m_editingCopy )
05834 m_bbox.And( &clipbox );
05835
05836
05837 if( ( mode & update_save ) )
05838 {
05839
05840
05841 if ( oldbbox.GetValid() && m_bbox.GetValid() && m_bbox.Intersect( oldbbox ) != _IN )
05842 {
05843 PROPID_BoundingBox->SetPropertyToObject( this, oldbbox );
05844
05845 SetPending( true );
05846 }
05847 }
05848
05849 if (!m_bbox.GetValid())
05850 {
05851 changed = true;
05852
05853 m_bbox.Expand(m_lworld.GetValue(2,0),m_lworld.GetValue(2,1));
05854 }
05855
05856 return changed;
05857 }
05858
05859 a2dPropertyIdRefObject* a2dCanvasObject::a2dDoUpdateImmediateData::PROPID_RouteData = NULL;
05860
05861
05862 a2dDynamicIdMap& a2dCanvasObject::a2dDoUpdateImmediateData::GetPropertyIdMap()
05863 {
05864 return sm_dymPropIds;
05865 }
05866 bool a2dCanvasObject::a2dDoUpdateImmediateData::AddPropertyId( a2dPropertyId *dynproperty )
05867 {
05868 if ( sm_dymPropIds.find( dynproperty->GetName() ) == sm_dymPropIds.end() )
05869 sm_dymPropIds[ dynproperty->GetName() ]= dynproperty;
05870 else
05871 wxASSERT_MSG( 0, _("The property id name '") + dynproperty->GetName() + _("' already exists in #a2dCanvasObject") );
05872 return true;
05873 }
05874 bool a2dCanvasObject::a2dDoUpdateImmediateData::HasPropertyId( const a2dPropertyId* id ) const
05875 {
05876 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
05877 {
05878 wxString name = (*i).first;
05879 a2dPropertyIdPtr propId = (*i).second;
05880 if ( propId == id )
05881 return true;
05882 }
05883 return a2dPropObject::HasPropertyId( id );
05884 }
05885 a2dPropertyId* a2dCanvasObject::a2dDoUpdateImmediateData::HasPropertyId( const wxString& name )
05886 {
05887 if ( sm_dymPropIds.find( name ) != sm_dymPropIds.end() )
05888 return sm_dymPropIds[ name ];
05889 return a2dPropObject::HasPropertyId( name );
05890 }
05891 const a2dNamedProperty *a2dCanvasObject::a2dDoUpdateImmediateData::FindProperty( const wxString &idName ) const
05892 {
05893 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
05894 {
05895 wxString name = (*i).first;
05896 a2dPropertyIdPtr propId = (*i).second;
05897 if ( propId->GetName() == idName )
05898 return GetProperty( propId );
05899 }
05900 return a2dPropObject::FindProperty( idName );
05901 }
05902 void a2dCanvasObject::a2dDoUpdateImmediateData::CollectProperties2( a2dNamedPropertyList *total, const a2dPropertyId *id, a2dPropertyId::Flags flags ) const
05903 {
05904 for ( a2dDynamicIdMap::iterator i = sm_dymPropIds.begin(); i != sm_dymPropIds.end(); i++ )
05905 {
05906 wxString name = (*i).first;
05907 a2dPropertyIdPtr p = (*i).second;
05908 if( p->CheckCollect( id, flags ) )
05909 {
05910 a2dNamedProperty* dprop = p->GetPropertyAsNamedProperty( this );
05911 if ( dprop )
05912 total->push_back( dprop );
05913 }
05914 }
05915 return a2dPropObject::CollectProperties2( total, id, flags );
05916 }
05917 a2dDynamicIdMap a2dCanvasObject::a2dDoUpdateImmediateData::sm_dymPropIds;
05918 static bool initPropa2dCanvasObjecta2dDoUpdateImmediateData = a2dCanvasObject::a2dDoUpdateImmediateData::InitializePropertyIds();
05919 bool a2dCanvasObject::a2dDoUpdateImmediateData::InitializePropertyIds()
05920
05921 {
05922 PROPID_RouteData = new a2dPropertyIdRefObject( wxT("routedata"), a2dPropertyId::flag_temporary|a2dPropertyId::flag_listonly, 0 );
05923 AddPropertyId( PROPID_RouteData );
05924
05925 return true;
05926 }
05927
05928 a2dCanvasObject::a2dDoUpdateImmediateData::a2dDoUpdateImmediateData( bool final, a2dBaseTool *tool, a2dCanvasObject* parent )
05929 {
05930 m_tool = tool;
05931 m_parent = parent;
05932 if ( !m_parent && m_tool && m_tool->GetCanvasView() )
05933 m_parent = m_tool->GetCanvasView()->GetShowObject();
05934
05935 wxASSERT_MSG( m_parent, wxT("m_parent must be set") );
05936
05937 SetNonDynamic();
05938 m_phase = 0;
05939 m_phaserequest = 0;
05940 m_phasedone = 0;
05941 m_phase_first = true;
05942 m_final = final;
05943 m_original = false;
05944 m_allowreconnectbegin = false;
05945 m_allowreconnectend = false;
05946 m_sortbeforenextphase = false;
05947 }
05948
05949 void a2dCanvasObject::UpdateImmediate( bool final, a2dBaseTool *tool, a2dCanvasObject* parent, a2dDoUpdateImmediateData *data )
05950 {
05951 a2dDoUpdateImmediateData ldata( final, tool, parent );
05952 if( !data )
05953 data = &ldata;
05954
05955
05956 for(;;)
05957 {
05958 DoUpdateImmediate( data );
05959
05960
05961 if( !data->m_phaserequest )
05962 break;
05963
05964
05965 data->m_phasedone |= (1<<data->m_phase);
05966
05967
05968 for( data->m_phase=0; ! (data->m_phaserequest & (1<<data->m_phase) ); data->m_phase++ );
05969
05970
05971 data->m_phaserequest &= ~ ( 1 << data->m_phase );
05972
05973
05974 data->m_phase_first = (data->m_phasedone & ( 1 << data->m_phase ) ) == 0;
05975 }
05976 }
05977
05978 void a2dCanvasObject::DoUpdateImmediate( a2dDoUpdateImmediateData *data )
05979 {
05980 if ( m_childobjects != wxNullCanvasObjectList && m_flags.m_visiblechilds )
05981 {
05982 forEachIn( a2dCanvasObjectList, m_childobjects )
05983 {
05984 a2dCanvasObject *obj = *iter;
05985 if ( !obj )
05986 continue;
05987 obj->DoUpdateImmediate( data );
05988 }
05989 }
05990 }
05991
05992 bool a2dCanvasObject::IsRecursive()
05993 {
05994 return GetChildObjectsCount() != 0;
05995 }
05996
05997 void a2dCanvasObject::MakeReferencesUnique()
05998 {
05999 if ( m_childobjects != wxNullCanvasObjectList )
06000 m_childobjects->MakeUnique();
06001 }
06002
06003 void a2dCanvasObject::WalkerWithContext( a2dIterC& ic, wxObject* parent, a2dWalkerIOHandlerWithContext& handler )
06004 {
06005 if ( handler.GetUseCheck() && GetCheck() )
06006 return;
06007
06008 handler.IncCurrentDepth();
06009
06010 handler.WalkTask( ic, parent, this, a2dWalker_a2dCanvasObjectStart );
06011
06012 {
06013 a2dIterCU cu( ic, this );
06014 DoWalkerWithContext( ic, parent, handler );
06015 }
06016
06017 handler.WalkTask( ic, parent, this, a2dWalker_a2dCanvasObjectEnd );
06018 handler.DecCurrentDepth();
06019 }
06020
06021 void a2dCanvasObject::DoWalkerWithContext( a2dIterC& ic, wxObject *parent, a2dWalkerIOHandlerWithContext& handler )
06022 {
06023
06024
06025 if ( handler.GetDepthFirst() && m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06026 {
06027 forEachIn( a2dCanvasObjectList, m_childobjects )
06028 {
06029 a2dCanvasObject *obj = *iter;
06030 if ( obj && !obj->GetRelease() && obj->IsRecursive() )
06031 obj->WalkerWithContext( ic, this, handler );
06032 }
06033 }
06034
06035 if ( handler.WalkTask( ic, parent, this, a2dWalker_a2dCanvasObjectPreChild ) &&
06036 m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06037 {
06038 forEachIn( a2dCanvasObjectList, m_childobjects )
06039 {
06040 a2dCanvasObject *obj = *iter;
06041 if ( obj && !obj->GetRelease() &&
06042 !( handler.GetDepthFirst() && obj->IsRecursive() ) )
06043 obj->WalkerWithContext( ic, this, handler );
06044 }
06045 }
06046
06047 if ( handler.WalkTask( ic, parent, this, a2dWalker_a2dCanvasObjectPostChild ) &&
06048 m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06049 {
06050 forEachIn( a2dCanvasObjectList, m_childobjects )
06051 {
06052 a2dCanvasObject *obj = *iter;
06053 if ( obj && !obj->GetRelease() &&
06054 !( handler.GetDepthFirst() && obj->IsRecursive() ) )
06055 obj->WalkerWithContext( ic, this, handler );
06056 }
06057 }
06058 }
06059
06060 void a2dCanvasObject::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
06061 {
06062 handler.WalkTask( parent, this, a2dWalker_a2dCanvasObjectStart );
06063
06064 a2dPropObject::DoWalker( parent, handler );
06065
06066
06067
06068 if ( handler.GetDepthFirst() && m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06069 {
06070 forEachIn( a2dCanvasObjectList, m_childobjects )
06071 {
06072 a2dCanvasObject *obj = *iter;
06073 if ( obj && !obj->GetRelease() && obj->IsRecursive() )
06074 obj->Walker( this, handler );
06075 }
06076 }
06077
06078 if ( handler.WalkTask( parent, this, a2dWalker_a2dCanvasObjectPreChild ) &&
06079 m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06080 {
06081 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
06082 int childNum = m_childobjects->size();
06083 int childPos = 0;
06084 #endif
06085 forEachIn( a2dCanvasObjectList, m_childobjects )
06086 {
06087 a2dCanvasObject *obj = *iter;
06088 if ( obj && !obj->GetRelease() &&
06089 !( handler.GetDepthFirst() && obj->IsRecursive() ) )
06090 obj->Walker( this, handler );
06091 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
06092 childPos++;
06093 #endif
06094 }
06095 }
06096
06097 if ( handler.WalkTask( parent, this, a2dWalker_a2dCanvasObjectPostChild ) &&
06098 m_childobjects != wxNullCanvasObjectList && !handler.GetStopWalking() )
06099 {
06100 forEachIn( a2dCanvasObjectList, m_childobjects )
06101 {
06102 a2dCanvasObject *obj = *iter;
06103 if ( obj && !obj->GetRelease() &&
06104 !( handler.GetDepthFirst() && obj->IsRecursive() ) )
06105 obj->Walker( this, handler );
06106 }
06107 }
06108
06109 handler.WalkTask( parent, this, a2dWalker_a2dCanvasObjectEnd );
06110 }
06111
06112 #if wxART2D_USE_CVGIO
06113
06114 void a2dCanvasObject::DoSave( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite )
06115 {
06116 if ( xmlparts == a2dXmlSer_attrib )
06117 {
06118 a2dEvtHandler::DoSave( this, out, xmlparts, towrite);
06119
06120 if ( wxLAYER_DEFAULT != m_layer )
06121 {
06122 out.WriteAttribute( wxT("layer"), m_layer );
06123 }
06124
06125 wxString s;
06126
06127 if ( m_flags.m_selected != m_flagsInit.m_selected ) s = s + wxT(" selected") ;
06128 if ( m_flags.m_selectable != m_flagsInit.m_selectable ) s = s + wxT(" selectable");
06129 if ( m_flags.m_subEdit != m_flagsInit.m_subEdit ) s = s + wxT(" subedit");
06130 if ( m_flags.m_subEditAsChild != m_flagsInit.m_subEditAsChild ) s = s + wxT(" subeditaschild");
06131 if ( m_flags.m_visible != m_flagsInit.m_visible ) s = s + wxT(" visible");
06132 if ( m_flags.m_draggable != m_flagsInit.m_draggable ) s = s + wxT(" draggable");
06133 if ( m_flags.m_showshadow != m_flagsInit.m_showshadow ) s = s + wxT(" shadow");
06134 if ( m_flags.m_filled != m_flagsInit.m_filled ) s = s + wxT(" filled");
06135 if ( m_flags.m_a != m_flagsInit.m_a ) s = s + wxT(" a");
06136 if ( m_flags.m_b != m_flagsInit.m_b ) s = s + wxT(" b");
06137 if ( m_flags.m_generatePins != m_flagsInit.m_generatePins ) s = s + wxT(" generatePins");
06138 if ( m_flags.m_bin != m_flagsInit.m_bin ) s = s + wxT(" bin");
06139 if ( m_flags.m_snap != m_flagsInit.m_snap ) s = s + wxT(" snap");
06140 if ( m_flags.m_pushin != m_flagsInit.m_pushin ) s = s + wxT(" pushin");
06141 if ( m_flags.m_ChildOnlyTranslate != m_flagsInit.m_ChildOnlyTranslate ) s = s + wxT(" ChildOnlyTranslate");
06142
06143 if ( !s.IsEmpty() )
06144 out.WriteAttribute( wxT("flags"), s );
06145
06146 s = wxT("");
06147 if (m_hitflags.m_non) s = s + wxT(" non") ;
06148 if (m_hitflags.m_fill) s = s + wxT(" fill") ;
06149 if (m_hitflags.m_stroke) s = s + wxT(" stroke") ;
06150 if (m_hitflags.m_fill_non_transparent) s = s + wxT(" fill_non_transparent");
06151 if (m_hitflags.m_stroke_non_transparent) s = s + wxT(" stroke_non_transparent");
06152 if (m_hitflags.m_visible) s = s + wxT(" visible") ;
06153 if (m_hitflags.m_all) s = s + wxT(" all") ;
06154
06155 out.WriteAttribute( wxT("hitflags"), s );
06156
06157 if (!m_lworld.IsIdentity())
06158 {
06159
06160 out.WriteNewLine();
06161 s.Printf ( wxT("matrix( %g %g %g %g %g %g )"),
06162 m_lworld.GetValue(0,0), m_lworld.GetValue(0,1),
06163 m_lworld.GetValue(1,0), m_lworld.GetValue(1,1),
06164 m_lworld.GetValue(2,0), m_lworld.GetValue(2,1)
06165 );
06166 out.WriteAttribute( wxT("transform"), s );
06167 out.WriteNewLine();
06168 }
06169
06170 if ( GetFill().IsSameAs(*a2dINHERIT_FILL) )
06171 {
06172 out.WriteAttribute( wxT("fill"), wxT("inherit") );
06173 }
06174 if ( GetStroke().IsSameAs(*a2dINHERIT_STROKE) )
06175 {
06176 out.WriteAttribute( wxT("stroke"), wxT("inherit") );
06177 }
06178 }
06179 else
06180 {
06181 a2dEvtHandler::DoSave( this, out, xmlparts, towrite);
06182
06183 if (m_childobjects != wxNullCanvasObjectList )
06184 {
06185 forEachIn( a2dCanvasObjectList, m_childobjects )
06186 {
06187 a2dCanvasObject *obj = *iter;
06188 if ( obj )
06189 obj->Save( this, out, towrite);
06190
06191 }
06192 }
06193 }
06194 }
06195
06196 bool a2dCanvasObject::ParseCvgTransForm( a2dAffineMatrix& result, a2dIOHandlerXmlSerIn& parser )
06197 {
06198 wxString str = parser.GetAttributeValue( wxT("transform") );
06199 wxString error;
06200 if ( !str.IsEmpty() && !::ParseCvgTransForm( result, str, error ) )
06201 {
06202 a2dDocviewGlobals->ReportErrorF( a2dError_XMLparse, _("CVG : invalid transform %s at line %d"), str.c_str(), parser.GetCurrentLineNumber());
06203 return true;
06204 }
06205
06206 return true;
06207 }
06208
06209 void a2dCanvasObject::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
06210 {
06211
06212 if ( xmlparts == a2dXmlSer_attrib )
06213 {
06214 a2dEvtHandler::DoLoad( parent, parser, xmlparts );
06215
06216 ParseCvgTransForm( m_lworld, parser );
06217
06218 m_layer = parser.GetAttributeValueUint16( wxT("layer"), 0 );
06219
06220 wxString flags = parser.GetAttributeValue( wxT("flags") );
06221 wxStringTokenizer tkz( flags );
06222
06223 while ( tkz.HasMoreTokens() )
06224 {
06225 wxString token = tkz.GetNextToken();
06226
06227 if ( token == wxT("selected") )
06228 m_flags.m_selected = true;
06229 else if ( token == wxT("selectable") )
06230 m_flags.m_selectable = true;
06231 else if ( token == wxT("subedit") )
06232 m_flags.m_subEdit = true;
06233 else if ( token == wxT("subeditaschild") )
06234 m_flags.m_subEditAsChild = true;
06235 else if ( token == wxT("visible") )
06236 m_flags.m_visible = true;
06237 else if ( token == wxT("draggable") )
06238 m_flags.m_draggable = true;
06239 else if ( token == wxT("showshadow") )
06240 m_flags.m_showshadow = true;
06241 else if ( token == wxT("filled") )
06242 m_flags.m_filled = true;
06243 else if ( token == wxT("a") )
06244 m_flags.m_a = true;
06245 else if ( token == wxT("b") )
06246 m_flags.m_b = true;
06247 else if ( token == wxT("generatePins") )
06248 m_flags.m_generatePins = true;
06249 else if ( token == wxT("bin") )
06250 m_flags.m_bin = true;
06251 else if ( token == wxT("snap") )
06252 m_flags.m_snap = true;
06253 else if ( token == wxT("snap_to") )
06254 m_flags.m_snap_to = true;
06255 else if ( token == wxT("pushin") )
06256 m_flags.m_pushin = true;
06257 else if ( token == wxT("ChildOnlyTranslate") )
06258 m_flags.m_ChildOnlyTranslate = true;
06259 }
06260
06261
06262 wxString hitflags = parser.GetAttributeValue( wxT("hitflags") );
06263 m_hitflags.m_non = hitflags.Find( wxT("non") ) != -1;
06264 m_hitflags.m_fill = hitflags.Find( wxT("fill") ) != -1;
06265 m_hitflags.m_stroke = hitflags.Find( wxT("stroke") ) != -1;
06266 m_hitflags.m_fill_non_transparent = hitflags.Find( wxT("fill_non_transparent") ) != -1;
06267 m_hitflags.m_stroke_non_transparent = hitflags.Find( wxT("stroke_non_transparent") ) != -1;
06268 m_hitflags.m_visible = hitflags.Find( wxT("visible") ) != -1;
06269 m_hitflags.m_all = hitflags.Find( wxT("all") ) != -1;
06270 }
06271 else
06272 {
06273
06274
06275
06276 if ( parser.GetTagName() == wxT("properties") )
06277 {
06278 parser.Next();
06279 while( parser.GetTagName() == wxT("o") )
06280 {
06281 wxString classname = parser.GetAttributeValue( wxT("classname") );
06282 wxObject *obj = parser.CreateObject( classname );
06283 a2dNamedPropertyPtr property = wxDynamicCast( obj, a2dNamedProperty );
06284 if ( property )
06285 {
06286 property->Load( this, parser );
06287 if ( parser.GetLastError() == a2dError_NoError )
06288 property->SetToObject( this );
06289 }
06290 else if( wxDynamicCast( obj, a2dFill ) )
06291 {
06292
06293 wxStaticCast( obj, a2dFill )->Load( this, parser );
06294 a2dCanvasObject::PROPID_Fill->SetPropertyToObject( this, *wxStaticCast( obj, a2dFill ) );
06295 delete obj;
06296 }
06297 else if( wxDynamicCast( obj, a2dStroke ) )
06298 {
06299
06300 wxStaticCast( obj, a2dStroke )->Load( this, parser );
06301 a2dCanvasObject::PROPID_Stroke->SetPropertyToObject( this, *wxStaticCast( obj, a2dStroke ) );
06302 delete obj;
06303 }
06304 else
06305 {
06306 a2dDocviewGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dNamedProperty %s, will be skipped line %d"),
06307 classname.c_str(), parser.GetCurrentLineNumber() );
06308 parser.SkipSubTree();
06309 parser.Require( END_TAG, wxT("o") );
06310 parser.Next();
06311 }
06312 }
06313
06314 parser.Require( END_TAG, wxT("properties") );
06315 parser.Next();
06316 }
06317
06318 while( parser.GetEventType() == START_TAG && parser.GetTagName() == wxT("o") )
06319 {
06320 wxString classname = parser.GetAttributeValue( wxT("classname") );
06321 a2dCanvasObject* object = wxDynamicCast( parser.CreateObject( classname ), a2dCanvasObject );
06322 if ( !object )
06323 {
06324 a2dDocviewGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dCanvasObject %s, will be skipped line %d"),
06325 classname.c_str(), parser.GetCurrentLineNumber() );
06326 parser.SkipSubTree();
06327 parser.Require( END_TAG, wxT("o") );
06328 parser.Next();
06329 }
06330 else
06331 {
06332 Append( object );
06333 object->Load( this, parser );
06334
06335
06336
06337
06338 a2dSmrtPtr<class a2dObject>* obj = (a2dSmrtPtr<class a2dObject>*) &(m_childobjects->back());
06339 parser.ResolveOrAdd( obj );
06340 }
06341 }
06342 }
06343 }
06344
06345 void a2dCanvasObject::DoLoadOneObject( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag WXUNUSED(xmlparts) )
06346 {
06347 if ( parser.GetTagName() == wxT("o") )
06348 {
06349 parser.Require( START_TAG, wxT("o") );
06350
06351 wxString classname = parser.GetAttributeValue( wxT("classname") );
06352 a2dCanvasObject* o = wxStaticCast( parser.CreateObject( classname ), a2dCanvasObject );
06353 if ( !o )
06354 {
06355 a2dDocviewGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dCanvasObject %s, will be skipped line %d"),
06356 classname.c_str(), parser.GetCurrentLineNumber() );
06357 parser.SkipSubTree();
06358 parser.Require( END_TAG, wxT("o") );
06359 parser.Next();
06360 }
06361 else
06362 o->Load( parent, parser );
06363 }
06364 }
06365
06366 #endif //wxART2D_USE_CVGIO
06367
06368 a2dBoundingBox a2dCanvasObject::GetClipBox( a2dIterC& WXUNUSED(ic) )
06369 {
06370 a2dBoundingBox bbox;
06371 if ( HasDynamicProperties() )
06372 {
06373 a2dNamedPropertyList::const_iterator iter;
06374 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
06375 {
06376 const a2dNamedProperty *prop = *iter;
06377 a2dClipPathProperty *clipprop = wxDynamicCast( prop, a2dClipPathProperty );
06378 if ( clipprop )
06379 {
06380 a2dBoundingBox tmp;
06381 tmp.Expand( clipprop->GetClipObject()->GetMappedBbox( m_lworld ) );
06382 bbox.Expand( tmp );
06383 }
06384 }
06385 }
06386 return bbox;
06387 }
06388
06389 void a2dCanvasObject::SetLayer( wxUint16 layer)
06390 {
06391 wxASSERT_MSG( wxMAXLAYER > layer , wxT(" layer > wxMAXLAYER, index to high") );
06392
06393 SetPending(true);
06394 m_layer = layer;
06395 if (m_root)
06396 {
06397 wxASSERT_MSG( m_root->GetLayerSetup()->GetLayerIndex()[m_layer] != wxNullLayerInfo,
06398 wxT("layer not defined in layer table") );
06399 }
06400 };
06401
06402 void a2dCanvasObject::SetCanvasDocument( a2dCanvasDocument *root, bool recurse )
06403 {
06404 m_root = root;
06405
06406
06407
06408
06409
06410
06411
06412 if ( recurse )
06413 {
06414 a2dWalker_SetCanvasDocument setRecursive( root );
06415 setRecursive.Start( this );
06416 }
06417 }
06418
06419 void a2dCanvasObject::RenderChildObjects( a2dIterC& ic, RenderChild& whichchilds, OVERLAP clipparent )
06420 {
06421 if (m_childobjects == wxNullCanvasObjectList || m_childobjects->empty() )
06422 return;
06423
06424 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
06425
06426
06427
06428 if ( ic.GetPerLayerMode() && m_flags.m_childrenOnSameLayer && m_root->GetLayerSetup() )
06429 {
06430 wxASSERT_MSG( ic.GetLayer() != wxLAYER_ALL, _T(" a2dIterC::GetPerLayerMode() can only render one layer at the time") );
06431
06432 unsigned int j;
06433 for ( j=0; j < wxMAXLAYER; j++ )
06434 {
06435 a2dLayerInfo* layerinfo;
06436
06437 if ( ic.GetCanvasView()->GetReverseOrder() )
06438 layerinfo = GetCanvasDocument()->GetLayerSetup()->GetReverseOrderIndex()[j];
06439 else
06440 layerinfo = GetCanvasDocument()->GetLayerSetup()->GetOrderIndex()[j];
06441
06442
06443
06444 if ( layerinfo == wxNullLayerInfo )
06445 break;
06446
06447
06448
06449
06450 if ( ic.GetLayer() == wxLAYER_ALL ||
06451 ( ic.GetCanvasView()->GetLayerRenderArray()[ layerinfo->GetLayer() ].DoRenderLayer()
06452 && layerinfo->GetVisible()
06453 )
06454 )
06455 {
06456 RenderChildObjectsOneLayer( ic, whichchilds, clipparent );
06457 }
06458 }
06459 }
06460 else
06461 {
06462
06463
06464
06465 RenderChildObjectsOneLayer( ic, whichchilds, clipparent );
06466 }
06467
06468
06469 }
06470
06471 void a2dCanvasObject::RenderChildObjectsOneLayer( a2dIterC& ic, RenderChild& whichchilds, OVERLAP clipparent )
06472 {
06473 if ( m_childobjects == wxNullCanvasObjectList )
06474 return;
06475
06476 RenderChild detectchilds;
06477 detectchilds.m_postrender = false;
06478 detectchilds.m_prerender = false;
06479 detectchilds.m_property = false;
06480
06481
06482 a2dFill currentdrawer_fill = ic.GetDrawer2D()->GetDrawerFill();
06483 a2dStroke currentdrawer_stroke = ic.GetDrawer2D()->GetDrawerStroke();
06484
06485 forEachIn( a2dCanvasObjectList, m_childobjects )
06486 {
06487 a2dCanvasObject *obj = *iter;
06488 if ( !obj )
06489 continue;
06490
06491 int olayer=obj->GetLayer();
06492
06493
06494 detectchilds.m_postrender = detectchilds.m_postrender || !obj->GetPreRenderAsChild();
06495 detectchilds.m_prerender = detectchilds.m_prerender || obj->GetPreRenderAsChild();
06496 detectchilds.m_property = detectchilds.m_property || obj->GetIsProperty();
06497
06498
06499 if ( (
06500 ( obj->GetPreRenderAsChild() && whichchilds.m_prerender && !obj->GetIsProperty() ) ||
06501 ( !obj->GetPreRenderAsChild() && whichchilds.m_postrender && !obj->GetIsProperty() ) ||
06502 ( obj->GetIsProperty() && whichchilds.m_property )
06503 )
06504
06505
06506 &&
06507 ( olayer == ic.GetLayer() || ic.GetLayer() == wxLAYER_ALL || obj->GetChildObjectsCount() || obj->GetIgnoreLayer() )
06508 )
06509 {
06510
06511
06512
06513
06514
06515
06516
06517
06518
06519
06520
06521
06522
06523 OVERLAP childclip = _IN;
06524 if ( clipparent != _IN )
06525 childclip = obj->GetClipStatus( ic, clipparent );
06526
06527 if ( childclip != _OUT )
06528 {
06529
06530
06531
06532
06533
06534
06535
06536
06537 if ( obj->HasDynamicProperties() )
06538 {
06539 if ( !obj->GetFill().IsNoFill() && obj->GetFill().IsSameAs(*a2dINHERIT_FILL) )
06540 ic.GetDrawer2D()->SetDrawerFill( currentdrawer_fill );
06541
06542
06543 }
06544
06545 if ( obj->m_flags.m_ChildOnlyTranslate )
06546 {
06547 a2dAffineMatrix iworld = m_lworld;
06548 iworld.Invert();
06549 a2dIterCU cu( ic, iworld );
06550 a2dAffineMatrix transworld;
06551 transworld.Translate( GetPosX(), GetPosY() );
06552 a2dIterCU cu2( ic, transworld );
06553 obj->Render( ic, childclip );
06554 }
06555 else
06556 obj->Render( ic, childclip );
06557 }
06558
06559 }
06560 }
06561
06562 ic.GetDrawer2D()->SetDrawerFill( currentdrawer_fill );
06563 ic.GetDrawer2D()->SetDrawerStroke( currentdrawer_stroke );
06564
06565 whichchilds = detectchilds;
06566 }
06567
06568 a2dCanvasObject* a2dCanvasObject::CreateHierarchy( a2dCanvasObjectFlagsMask mask, bool createref )
06569 {
06570 a2dCanvasObject* group=0;
06571
06572 if ( m_childobjects == wxNullCanvasObjectList )
06573 m_childobjects = new a2dCanvasObjectList();
06574
06575 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
06576 while( iter != m_childobjects->end() )
06577 {
06578 a2dCanvasObjectList::value_type obj = *iter;
06579 if ( obj && obj->CheckMask(mask))
06580 {
06581 if (!group)
06582 group=new a2dCanvasObject();
06583
06584 iter = m_childobjects->erase( iter );
06585 group->Append(obj);
06586 }
06587 else
06588 iter++;
06589 }
06590
06591 if (!group)
06592 return group;
06593
06594 group->SetCanvasDocument(m_root);
06595 group->SetIgnoreLayer( true );
06596
06597 group->Update( updatemask_force );
06598
06599
06600 double dx,dy;
06601 dx=group->GetBbox().GetMinX();
06602 dy=group->GetBbox().GetMinY();
06603
06604
06605 for( iter = group->m_childobjects->begin(); iter != group->m_childobjects->end(); ++iter )
06606 {
06607 a2dCanvasObject *obj = *iter;
06608 if (obj )
06609 obj->Translate(-dx,-dy);
06610 }
06611
06612 if (createref)
06613 {
06614 a2dCanvasObjectReference* ref= new a2dCanvasObjectReference(dx,dy,group);
06615 ref->SetCanvasDocument(m_root);
06616 Append(ref);
06617 }
06618 else
06619 {
06620 group->SetPosXY(dx,dy);
06621 Append(group);
06622 }
06623
06624 Update( updatemask_force );
06625 return group;
06626 }
06627
06628 void a2dCanvasObject::RemoveHierarchy()
06629 {
06630 if ( m_childobjects != wxNullCanvasObjectList )
06631 {
06632 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
06633 while( iter != m_childobjects->end() )
06634 {
06635 a2dCanvasObjectList::value_type directChild = *iter;
06636
06637 if ( directChild && directChild->m_childobjects != wxNullCanvasObjectList )
06638 {
06639 a2dCanvasObjectList::iterator subiter = directChild->m_childobjects->begin();
06640 while( subiter != directChild->m_childobjects->end() )
06641 {
06642 a2dCanvasObjectList::value_type subchild = *subiter;
06643
06644 if ( subchild && !subchild->GetRelease() )
06645 {
06646 subchild->Transform( directChild->GetTransformMatrix() );
06647 m_childobjects->push_front( subchild );
06648 subiter = directChild->m_childobjects->erase( subiter );
06649 }
06650 else
06651 subiter++;
06652 }
06653 }
06654 iter++;
06655 }
06656 }
06657 }
06658
06659 bool a2dCanvasObject::EliminateMatrix()
06660 {
06661 if ( m_childobjects == wxNullCanvasObjectList )
06662 {
06663 m_lworld.Identity();
06664 return true;
06665 }
06666
06667 forEachIn( a2dCanvasObjectList, m_childobjects )
06668 {
06669 a2dCanvasObject *obj = *iter;
06670 if (obj )
06671 obj->Transform( m_lworld );
06672 }
06673 m_lworld.Identity();
06674 return true;
06675 }
06676
06677 void a2dCanvasObject::Prepend( a2dCanvasObject* obj )
06678 {
06679
06680
06681
06682 if (m_root)
06683 obj->SetCanvasDocument(m_root);
06684
06685 if ( m_childobjects == wxNullCanvasObjectList )
06686 m_childobjects = new a2dCanvasObjectList();
06687
06688 m_childobjects->push_front( obj );
06689 obj->SetPending(true);
06690 }
06691
06692 void a2dCanvasObject::Append( a2dCanvasObject* obj )
06693 {
06694
06695
06696
06697 if (m_root)
06698 {
06699 obj->SetCanvasDocument(m_root);
06700 }
06701
06702 if ( m_childobjects == wxNullCanvasObjectList )
06703 m_childobjects = new a2dCanvasObjectList();
06704
06705 m_childobjects->push_back( obj );
06706 obj->SetPending(true);
06707
06708 if ( wxDynamicCast(obj, a2dPin) )
06709 m_flags.m_hasPins = true;
06710 }
06711
06712 void a2dCanvasObject::Insert( size_t before, a2dCanvasObject* obj, bool ignoreReleased )
06713 {
06714
06715
06716
06717 if (m_root)
06718 obj->SetCanvasDocument(m_root);
06719
06720 if ( m_childobjects == wxNullCanvasObjectList )
06721 m_childobjects = new a2dCanvasObjectList();
06722
06723 m_childobjects->Insert( before, obj, ignoreReleased );
06724 }
06725
06726 int a2dCanvasObject::ReleaseChild( a2dCanvasObject* obj, bool backwards, bool all, bool now )
06727 {
06728 if ( obj == 0 )
06729 return 0;
06730 if ( m_childobjects == wxNullCanvasObjectList )
06731 return 0;
06732
06733 int totalreleased;
06734 {
06735
06736 a2dCanvasObjectPtr keepAlive=obj;
06737
06738 totalreleased = m_childobjects->Release( obj, backwards, all, now );
06739 if ( totalreleased )
06740 {
06741 if ( obj->HasPins() )
06742 obj->DisConnectWith( this );
06743 }
06744 }
06745
06746 if ( now )
06747 {
06748 SentChangeLayerEvent( obj->GetLayer() );
06749 SetPending( true );
06750 }
06751
06752
06753
06754 if ( m_childobjects != wxNullCanvasObjectList && !m_childobjects->size() )
06755 {
06756 delete m_childobjects;
06757 m_childobjects = wxNullCanvasObjectList;
06758 }
06759
06760 return totalreleased;
06761 }
06762
06763 bool a2dCanvasObject::ReleaseChildObjects(a2dCanvasObjectFlagsMask mask)
06764 {
06765 if ( m_childobjects == wxNullCanvasObjectList )
06766 return false;
06767
06768 bool did = false;
06769
06770 if ( m_childobjects->size() && m_childobjects->Release( mask ) )
06771 {
06772 SentChangeLayerEvent( wxLAYER_ALL );
06773
06774 SetPending(true);
06775 did = true;
06776 }
06777
06778
06779
06780 if ( m_childobjects != wxNullCanvasObjectList && !m_childobjects->size() )
06781 {
06782 delete m_childobjects;
06783 m_childobjects = wxNullCanvasObjectList;
06784 }
06785
06786 return did;
06787 }
06788
06789 int a2dCanvasObject::IndexOf( a2dCanvasObject* obj ) const
06790 {
06791 if ( m_childobjects == wxNullCanvasObjectList )
06792 return -1;
06793
06794 return m_childobjects->IndexOf( obj );
06795 }
06796
06797
06798
06799 void a2dCanvasObject::SetTemplate(bool b)
06800 {
06801 m_flags.m_template = b;
06802 }
06803
06804
06805 void a2dCanvasObject::SetExternal(bool b)
06806 {
06807 m_flags.m_external = b;
06808 }
06809
06810
06811 void a2dCanvasObject::SetUsed(bool b)
06812 {
06813 m_flags.m_used = b;
06814 }
06815
06816
06817 bool a2dCanvasObject::GetTemplate() const
06818 {
06819 return m_flags.m_template;
06820 }
06821
06822
06823 bool a2dCanvasObject::GetExternal() const
06824 {
06825 return m_flags.m_external;
06826 }
06827
06828
06829 bool a2dCanvasObject::GetUsed() const
06830 {
06831 return m_flags.m_used;
06832 }
06833
06834 bool a2dCanvasObject::IsTemporary_DontSave() const
06835 {
06836 if ( PROPID_TemporaryObject->GetPropertyValue( this ) )
06837 return true;
06838
06839
06840 if( HasProperty( a2dCanvasObject::PROPID_ToolObject ) )
06841 return true;
06842
06843 if( m_flags.m_editingCopy )
06844 return true;
06845
06846 return false;
06847 }
06848
06849 void a2dCanvasObject::ShowPins( bool onoff )
06850 {
06851 if ( m_childobjects == wxNullCanvasObjectList )
06852 return;
06853
06854 forEachIn( a2dCanvasObjectList, m_childobjects )
06855 {
06856 a2dCanvasObject *obj = *iter;
06857 a2dPin* pin = wxDynamicCast( obj, a2dPin );
06858 if (pin)
06859 pin->SetVisible( onoff );
06860 }
06861 }
06862
06863 void a2dCanvasObject::SetRenderConnectedPins( bool onoff )
06864 {
06865 if ( m_childobjects == wxNullCanvasObjectList )
06866 return;
06867
06868 forEachIn( a2dCanvasObjectList, m_childobjects )
06869 {
06870 a2dCanvasObject *obj = *iter;
06871 a2dPin* pin = wxDynamicCast( obj, a2dPin );
06872 if (pin)
06873 pin->SetRenderConnected( onoff );
06874 }
06875 }
06876
06877 void a2dCanvasObject::CreateWireEditCopies( a2dCanvasObjectList *originals, a2dCanvasObjectList *copies )
06878 {
06879 if( HasPins(true) )
06880 {
06881 SetBin( true );
06882 forEachIn( a2dCanvasObjectList, m_childobjects )
06883 {
06884 a2dCanvasObject *obj = *iter;
06885 if ( !obj )
06886 continue;
06887
06888 a2dPin *pin = wxDynamicCast( obj, a2dPin );
06889 if( !pin || pin->GetRelease( ))
06890 continue;
06891
06892 a2dPin *otherpin = pin->ConnectedTo();
06893 if( !otherpin )
06894 continue;
06895
06896 a2dCanvasObject *connect = otherpin->GetParent();
06897 if( !connect )
06898 continue;
06899 else if ( !connect->IsConnect() )
06900 {
06901 if ( !connect->GetBin() )
06902 {
06903
06904
06905
06906 a2dCanvasObject* endWire = new a2dWireEnd( pin->GetPosX(), pin->GetPosY() );
06907 a2dPin* endpin = wxStaticCast( otherpin->TClone( clone_setoriginal | clone_reconnectable ) , a2dPin );
06908 endpin->SetPosXY(0,0);
06909 endpin->SetParent( endWire );
06910 endWire->Append( endpin );
06911 PROPID_Original->SetPropertyToObject( endWire, connect );
06912
06913
06914 endWire->SetSpecificFlags( true, a2dCanvasOFlags::EditingCopy );
06915 copies->push_back( endWire );
06916 }
06917 continue;
06918 }
06919
06920
06921 if( originals->Find( connect ) )
06922 continue;
06923
06924 a2dCanvasObject
06925 *copy = connect->TClone( clone_childs | clone_seteditcopy | clone_setoriginal | clone_reconnectable );
06926
06927 originals->push_back( connect );
06928 copies->push_back( copy );
06929
06930
06931 copy->SetSpecificFlags( true, a2dCanvasOFlags::EditingCopy );
06932
06933
06934 copy->SetEditable( false );
06935
06936
06937 connect->CreateWireEditCopies( originals, copies );
06938 }
06939 SetBin( false );
06940 }
06941 }
06942
06943 void a2dCanvasObject::RestoreConnectionsAfterCloning( a2dCanvasCommandProcessor *cp )
06944 {
06945 forEachIn( a2dCanvasObjectList, m_childobjects )
06946 {
06947 a2dCanvasObject *obj = *iter;
06948 if ( !obj )
06949 continue;
06950 obj->RestoreConnectionsAfterCloning( cp );
06951 }
06952 }
06953
06954 void a2dCanvasObject::ClearAllPinConnections( class a2dCanvasCommandProcessor *cp )
06955 {
06956 forEachIn( a2dCanvasObjectList, m_childobjects )
06957 {
06958 a2dCanvasObject *obj = *iter;
06959 if ( !obj )
06960 continue;
06961 obj->ClearAllPinConnections( cp );
06962 }
06963 }
06964
06965 bool a2dCanvasObject::HasPins( bool realcheck )
06966 {
06967 if ( m_childobjects == wxNullCanvasObjectList )
06968 return false;
06969
06970 if ( !realcheck )
06971 return m_flags.m_hasPins;
06972
06973 forEachIn( a2dCanvasObjectList, m_childobjects )
06974 {
06975 a2dCanvasObject *obj = *iter;
06976 a2dPin* pin = wxDynamicCast( obj, a2dPin );
06977 if (pin && !pin->GetRelease( ) )
06978 {
06979 m_flags.m_hasPins = true;
06980 return true;
06981 }
06982 }
06983 m_flags.m_hasPins = false;
06984 return false;
06985 }
06986
06987 a2dPin* a2dCanvasObject::HasPinNamed( const wxString pinName, bool NotConnected )
06988 {
06989 if ( m_childobjects == wxNullCanvasObjectList )
06990 return NULL;
06991
06992 forEachIn( a2dCanvasObjectList, m_childobjects )
06993 {
06994 a2dCanvasObject *obj = *iter;
06995 a2dPin* pin = wxDynamicCast( obj, a2dPin );
06996 if (pin && !pin->GetRelease( ) &&
06997 pin->GetName().Matches( pinName ) &&
06998 ( !NotConnected || pin->ConnectedTo() == NULL ) )
06999 {
07000 return pin;
07001 }
07002 }
07003 return NULL;
07004 }
07005
07006 int a2dCanvasObject::GetPinCount()
07007 {
07008 if ( m_childobjects == wxNullCanvasObjectList )
07009 return 0;
07010
07011 int nrpins = 0;
07012
07013 forEachIn( a2dCanvasObjectList, m_childobjects )
07014 {
07015 a2dCanvasObject *obj = *iter;
07016 if ( !obj )
07017 continue;
07018 a2dPin* pin = wxDynamicCast( obj, a2dPin );
07019 if (pin && !pin->GetRelease( ) )
07020 nrpins++;
07021 }
07022 return nrpins;
07023 }
07024
07025 a2dPin* a2dCanvasObject::AddPin( const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass* pinClass )
07026 {
07027
07028
07029 wxASSERT_MSG( pinClass , wxT("pinClass may not be NULL") );
07030
07031 a2dPin *newPin = wxStaticCast( pinClass->GetPin()->Clone( clone_deep ), a2dPin );
07032
07033 newPin->SetName( name );
07034 newPin->SetParent( this );
07035 newPin->SetPinClass( pinClass );
07036 newPin->SetPosXY( x, y );
07037 newPin->SetDynamicPin( (a2dpinFlags & a2dPin::dynamic) > 0);
07038 newPin->SetTemporaryPin( (a2dpinFlags & a2dPin::temporary) > 0 );
07039 newPin->SetObjectPin( (a2dpinFlags & a2dPin::objectPin) > 0 );
07040
07041
07042 m_flags.m_hasPins = true;
07043
07044 Append( newPin );
07045
07046 return newPin;
07047 }
07048
07049 void a2dCanvasObject::RemovePins( bool NotConnected, bool onlyTemporary, bool now )
07050 {
07051 if ( m_childobjects == wxNullCanvasObjectList )
07052 return;
07053
07054 bool all = true;
07055
07056 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
07057 while( iter != m_childobjects->end() )
07058 {
07059 a2dCanvasObjectList::value_type obj = *iter;
07060 a2dPin* pin = wxDynamicCast( obj.Get(), a2dPin );
07061 if ( pin )
07062 {
07063
07064
07065
07066 if (
07067 ( !NotConnected || !pin->ConnectedTo() ) &&
07068 ( !onlyTemporary || pin->IsTemporaryPin() && !pin->GetMouseInObject() )
07069 )
07070 {
07071 if ( now )
07072 {
07073 iter = m_childobjects->erase( iter );
07074 }
07075 else
07076 {
07077 pin->SetRelease( true );
07078 pin->SetPending( true );
07079 iter++;
07080 }
07081 }
07082 else
07083 {
07084 all = false;
07085 iter++;
07086 }
07087 }
07088 else
07089 iter++;
07090 }
07091 if (all)
07092 m_flags.m_hasPins = false;
07093 }
07094
07095 bool a2dCanvasObject::IsConnected( bool needsupdate, a2dCanvasObject* toConnect )
07096 {
07097 bool res=false;
07098
07099 if ( m_childobjects == wxNullCanvasObjectList || !m_flags.m_hasPins )
07100 return false;
07101
07102 forEachIn( a2dCanvasObjectList, m_childobjects )
07103 {
07104 a2dCanvasObject *obj = *iter;
07105 a2dPin* pin = wxDynamicCast( obj, a2dPin );
07106 if (pin)
07107 {
07108 if (pin->ConnectedTo() && ( !toConnect || toConnect == pin->ConnectedTo()->GetParent() ) )
07109 {
07110 if (needsupdate)
07111 {
07112 if (pin->ConnectedTo()->GetParent()->NeedsUpdateWhenConnected())
07113 return true;
07114 }
07115 else
07116 return true;
07117 }
07118 }
07119 }
07120
07121 return res;
07122 }
07123
07124 bool a2dCanvasObject::CanConnectWith( a2dIterC &ic, a2dCanvasObject* toConnect, bool autocreate )
07125 {
07126 if ( m_childobjects == wxNullCanvasObjectList || !HasPins() )
07127 return false;
07128
07129 bool done=false;
07130
07131 forEachIn( a2dCanvasObjectList, m_childobjects )
07132 {
07133 a2dCanvasObject *obj = *iter;
07134 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07135 if ( pinc && !pinc->GetRelease( ) )
07136 {
07137
07138 a2dPin* connect = toConnect->CanConnectWith( ic, pinc, ic.GetHitMarginWorld(), autocreate );
07139 if ( connect && connect->ConnectedTo() != pinc && !pinc->GetBin() )
07140 {
07141 pinc->SetBin( true );
07142 done = true;
07143 }
07144 }
07145 }
07146
07147 return done;
07148 }
07149
07150 bool a2dCanvasObject::DoCanConnectWith( a2dIterC &ic, a2dPin* pin, double WXUNUSED(margin), bool autocreate )
07151 {
07152 if ( autocreate )
07153 {
07154
07155 RemovePins( true, true );
07156 a2dHitEvent hitevent = a2dHitEvent( pin->GetAbsX(), pin->GetAbsY(), false );
07157 a2dCanvasObject* hit = IsHitWorld( ic, hitevent );
07158 if( hit )
07159 {
07160 bool found = false;
07161
07162 found = GeneratePins( pin->GetPinClass(), a2d_ObjectPinClass_ToConnectPinClassWire_InOut, pin->GetPosX(), pin->GetPosY() ) || found;
07163 return found;
07164 }
07165 }
07166 return false;
07167 }
07168
07169 a2dPin* a2dCanvasObject::CanConnectWith( a2dIterC &ic, a2dPin* pin, double margin, bool autocreate )
07170 {
07171 if ( !m_flags.m_doConnect )
07172 return (a2dPin*) NULL;
07173
07174 DoCanConnectWith( ic, pin, margin, autocreate );
07175
07176 if ( m_childobjects == wxNullCanvasObjectList )
07177 return (a2dPin*) NULL;
07178
07179 forEachIn( a2dCanvasObjectList, m_childobjects )
07180 {
07181 a2dCanvasObject *obj = *iter;
07182 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07183 if (pinc && !pinc->GetRelease( ) )
07184 {
07185 if (fabs( pin->GetAbsX() - pinc->GetAbsX() ) < margin &&
07186 fabs( pin->GetAbsY() - pinc->GetAbsY() ) < margin &&
07187 pin->MayConnectTo( pinc ) )
07188 {
07189 return pinc;
07190 }
07191 }
07192 }
07193
07194 return (a2dPin*)NULL;
07195 }
07196
07197 bool a2dCanvasObject::ConnectWith( a2dCanvasObject* parent, a2dPin* pin, double margin, bool undo )
07198 {
07199 a2dIterC ic;
07200 a2dPin* pinfound = CanConnectWith( ic, pin, margin, true );
07201 if ( pinfound && pinfound->IsTemporaryPin() )
07202 {
07203 pinfound = wxStaticCast( pinfound->Clone( clone_deep ), a2dPin );
07204 pinfound->SetTemporaryPin( false );
07205 m_root->GetCommandProcessor()->Submit( new a2dCommand_AddObject( pinfound->GetParent(), pinfound ), true );
07206 }
07207 if ( pinfound )
07208 {
07209 ConnectPins( parent, pinfound, pin, undo );
07210 return true;
07211 }
07212 return false;
07213 }
07214
07215 bool a2dCanvasObject::ConnectWith( a2dCanvasObject* parent, a2dCanvasObject* toConnect, const wxString& pinname, double margin, bool undo )
07216 {
07217 if ( m_childobjects == wxNullCanvasObjectList || !m_flags.m_doConnect || toConnect == this )
07218 return false;
07219
07220 bool done=false;
07221 forEachIn( a2dCanvasObjectList, m_childobjects )
07222 {
07223 a2dCanvasObject *obj = *iter;
07224 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07225 if ( pinc && !pinc->GetRelease( ))
07226 {
07227 if (pinname.IsEmpty())
07228 {
07229
07230 for( a2dCanvasObjectList::iterator itero = toConnect->m_childobjects->begin(); itero != toConnect->m_childobjects->end(); ++itero )
07231 {
07232 a2dCanvasObject *obj = *itero;
07233 if ( !obj )
07234 continue;
07235 a2dPin* pinother = wxDynamicCast( obj, a2dPin );
07236 if ( pinother && !pinother->GetRelease( ))
07237 {
07238 bool fits = false;
07239 if ( fabs( pinother->GetAbsX() - pinc->GetAbsX() ) < margin &&
07240 fabs( pinother->GetAbsY() - pinc->GetAbsY() ) < margin )
07241 fits = true;
07242
07243 if ( fits &&
07244 ( pinother->ConnectedTo() != pinc &&
07245 pinother->MayConnectTo( pinc ) )
07246 )
07247 {
07248
07249
07250
07251
07252
07253
07254
07255
07256 if (
07257 ( pinother->ConnectedTo() && pinother->ConnectedTo()->GetParent() == this ) ||
07258 ( pinother->GetParent()->IsConnected( false, this ) )
07259 )
07260 {
07261 if ( pinother->GetParent()->IsConnect() )
07262 {
07263
07264 }
07265 else
07266 {
07267
07268 }
07269 }
07270
07271
07272 else if (
07273 pinc->ConnectedTo() && pinother->ConnectedTo() &&
07274 pinc->ConnectedTo()->GetParent() == pinother->ConnectedTo()->GetParent()
07275 )
07276 {
07277
07278
07279 }
07280 else
07281 {
07282 ConnectPins( parent, pinc, pinother, undo );
07283 }
07284 done = true;
07285 }
07286 }
07287 }
07288 }
07289 else
07290 {
07291
07292 for( a2dCanvasObjectList::iterator itero = toConnect->m_childobjects->begin(); itero != toConnect->m_childobjects->end(); ++itero )
07293 {
07294 a2dCanvasObject *obj = *itero;
07295 if ( !obj )
07296 continue;
07297 a2dPin* pinother = wxDynamicCast( obj, a2dPin );
07298 if ( pinother && !pinother->GetRelease( ) && pinname == pinother->GetName())
07299 {
07300 if ( fabs( pinother->GetAbsX() - pinc->GetAbsX() ) < margin &&
07301 fabs( pinother->GetAbsY() - pinc->GetAbsY() ) < margin &&
07302 pinother->MayConnectTo( pinc )
07303 )
07304 {
07305 if ( pinother->ConnectedTo() != pinc )
07306 ConnectPins( parent, pinc, pinother, undo );
07307 return true;
07308 }
07309 else
07310 {
07311 CreateConnectObject( parent, pinc, pinother, undo );
07312 return true;
07313 }
07314 }
07315 }
07316 }
07317 }
07318 }
07319
07320 return done;
07321 }
07322
07323 void a2dCanvasObject::ConnectPins( a2dCanvasObject* WXUNUSED(parent), a2dPin* pinc, a2dPin* pinother, bool undo )
07324 {
07325 wxASSERT_MSG( fabs( pinc->GetAbsX() - pinother->GetAbsX() ) < a2dCanvasGlobals->ACCUR() &&
07326 fabs( pinc->GetAbsY() - pinother->GetAbsY() ) < a2dCanvasGlobals->ACCUR()
07327 , _("two pins are not at same position") );
07328
07329 if ( undo )
07330 {
07331 m_root->GetCommandProcessor()->Submit( new a2dCommand_ConnectPins( pinc, pinother ), true );
07332 }
07333 else
07334 {
07335 pinc->ConnectTo( NULL );
07336 pinother->ConnectTo( NULL );
07337 pinc->ConnectTo( pinother );
07338 pinother->ConnectTo( pinc );
07339 }
07340 }
07341
07342 void a2dCanvasObject::ConnectPinsCreateConnect( a2dCanvasObject* parent, a2dPin* pinc, a2dPin* pinother, bool undo )
07343 {
07344 a2dWirePolylineL* wire;
07345
07346 if ( pinother->ConnectedTo() == pinc && pinc->ConnectedTo() == pinother )
07347 {
07348 if ( fabs( pinc->GetAbsX() - pinother->GetAbsX() ) < a2dCanvasGlobals->ACCUR() &&
07349 fabs( pinc->GetAbsY() - pinother->GetAbsY() ) < a2dCanvasGlobals->ACCUR() )
07350 {
07351
07352 return;
07353 }
07354 else
07355 {
07356
07357 ConnectPins( parent, NULL, NULL, undo );
07358 }
07359 }
07360
07361 if ( !pinother->ConnectedTo() && !pinc->ConnectedTo() )
07362 {
07363 if ( fabs( pinc->GetAbsX() - pinother->GetAbsX() ) < a2dCanvasGlobals->ACCUR() &&
07364 fabs( pinc->GetAbsY() - pinother->GetAbsY() ) < a2dCanvasGlobals->ACCUR() )
07365 {
07366 ConnectPins( parent, pinc, pinother, undo );
07367 }
07368 else
07369 {
07370 CreateConnectObject( parent, pinc, pinother, undo );
07371 }
07372 return;
07373 }
07374
07375
07376
07377
07378
07379
07380
07381 if ( pinc->ConnectedTo() && pinother->ConnectedTo() &&
07382 pinc->ConnectedTo()->GetParent() == pinother->ConnectedTo()->GetParent() &&
07383 pinc->ConnectedTo()->GetParent()->IsConnect()
07384 )
07385 {
07386 return;
07387 }
07388
07389
07390 a2dPin* allreadyconnectedatpinc = pinc->ConnectedTo();
07391 a2dPin* allreadyconnectedatpinother = pinother->ConnectedTo();
07392
07393
07394
07395 if ( pinc->GetParent()->IsConnect() )
07396 {
07397 wire = wxStaticCast( pinc->GetParent(), a2dWirePolylineL );
07398
07399 wire->ConnectWith( parent, pinother, undo );
07400 }
07401 else if ( pinother->GetParent()->IsConnect() )
07402 {
07403 wire = wxStaticCast( pinother->GetParent(), a2dWirePolylineL );
07404
07405 wire->ConnectWith( parent, pinc, undo );
07406 }
07407
07408
07409 else if ( allreadyconnectedatpinc && allreadyconnectedatpinc->GetParent()->IsConnect() )
07410 {
07411 wire = wxStaticCast( allreadyconnectedatpinc->GetParent(), a2dWirePolylineL );
07412
07413 wire->ConnectWith( parent, pinother, undo );
07414 }
07415 else if ( allreadyconnectedatpinother && allreadyconnectedatpinother->GetParent()->IsConnect() )
07416 {
07417 wire = wxStaticCast( allreadyconnectedatpinother->GetParent(), a2dWirePolylineL );
07418
07419 wire->ConnectWith( parent, pinc, undo );
07420 }
07421 else
07422 {
07423
07424 a2dCanvasObject* wire = CreateConnectObject( parent, pinc, pinother, undo );
07425
07426 pinc->ConnectTo( NULL );
07427 if ( allreadyconnectedatpinc )
07428 {
07429 allreadyconnectedatpinc->ConnectTo( NULL );
07430 wire->ConnectWith( parent, allreadyconnectedatpinc, undo );
07431 }
07432
07433 pinother->ConnectTo( NULL );
07434 if ( allreadyconnectedatpinother )
07435 {
07436 allreadyconnectedatpinother->ConnectTo( NULL );
07437 wire->ConnectWith( parent, allreadyconnectedatpinother, undo );
07438 }
07439
07440
07441 wire->ConnectWith( parent, pinother, undo );
07442 wire->ConnectWith( parent, pinc, undo );
07443 }
07444 }
07445
07446 bool a2dCanvasObject::DisConnectWith( a2dCanvasObject* WXUNUSED(parent), a2dCanvasObject* toConnect, const wxString& pinname )
07447 {
07448 if ( m_childobjects == wxNullCanvasObjectList )
07449 return false;
07450
07451 bool done=false;
07452 forEachIn( a2dCanvasObjectList, m_childobjects )
07453 {
07454 a2dCanvasObject *obj = *iter;
07455 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07456 if ( pinc )
07457 {
07458 if ( toConnect )
07459 {
07460 for( a2dCanvasObjectList::iterator itero = toConnect->m_childobjects->begin(); itero != toConnect->m_childobjects->end(); ++itero )
07461 {
07462 a2dCanvasObject *obj = *itero;
07463 a2dPin* pinother = wxDynamicCast( obj, a2dPin );
07464 if ( pinother && pinother->ConnectedTo() == pinc )
07465 {
07466 if ( pinname.IsEmpty() || pinname == pinc->GetName() )
07467 {
07468 pinc->ConnectTo( NULL );
07469 pinother->ConnectTo( NULL );
07470 done=true;
07471 }
07472 }
07473 }
07474 }
07475 else if ( pinc->ConnectedTo() )
07476 {
07477 pinc->ConnectedTo()->ConnectTo( NULL );
07478 pinc->ConnectTo( NULL );
07479 done=true;
07480 }
07481 }
07482 }
07483 return done;
07484 }
07485
07486 bool a2dCanvasObject::DisConnectAt( a2dCanvasObject* WXUNUSED(parent), a2dPin* pin )
07487 {
07488 if ( m_childobjects == wxNullCanvasObjectList )
07489 return false;
07490
07491 bool done=false;
07492 forEachIn( a2dCanvasObjectList, m_childobjects )
07493 {
07494 a2dCanvasObject *obj = *iter;
07495 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07496 if ( pinc )
07497 {
07498 if ( pinc == pin )
07499 {
07500 pinc->ConnectedTo()->ConnectTo( NULL );
07501 pinc->ConnectTo( NULL );
07502 done=true;
07503 }
07504 else if ( pinc->ConnectedTo() == pin )
07505 {
07506 pinc->ConnectTo( NULL );
07507 pin->ConnectTo( NULL );
07508 done=true;
07509 }
07510 }
07511 }
07512 return done;
07513 }
07514
07515 void a2dCanvasObject::ReWireConnected( a2dCanvasObject* parent, bool undo )
07516 {
07517 if ( parent && HasPins() && !IsConnect() )
07518 {
07519
07520 if ( DoConnect() )
07521 {
07522 a2dCanvasObjectList allpinobjects;
07523 parent->CollectObjects( &allpinobjects, wxT(""), a2dCanvasOFlags::HasPins );
07524 for( a2dCanvasObjectList::const_iterator iter = allpinobjects.begin(); iter != allpinobjects.end(); ++iter )
07525 {
07526 a2dCanvasObject *obj = *iter;
07527 if ( obj != this && !obj->m_flags.m_editingCopy && !obj->IsConnect() && obj->DoConnect() )
07528 {
07529
07530
07531 ConnectWith( parent, obj , wxT(""), a2dCanvasGlobals->ACCUR(), undo );
07532 }
07533 }
07534 }
07535 }
07536 }
07537
07538 bool a2dCanvasObject::CreateWiresOnPins( a2dCanvasObject* parent, bool undo )
07539 {
07540 if ( m_childobjects == wxNullCanvasObjectList )
07541 return false;
07542
07543 if ( HasPins() && !IsConnect() && DoConnect())
07544 {
07545 bool done=false;
07546 forEachIn( a2dCanvasObjectList, m_childobjects )
07547 {
07548 a2dCanvasObject *obj = *iter;
07549 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07550 if ( pinc && !pinc->GetRelease() )
07551 {
07552
07553 if ( pinc->ConnectedTo() && !pinc->ConnectedTo()->GetParent()->IsConnect() )
07554 {
07555 CreateConnectObject( parent, pinc, pinc->ConnectedTo(), undo );
07556 done = true;
07557 }
07558 }
07559 }
07560 return done;
07561 }
07562 return false;
07563 }
07564
07565 bool a2dCanvasObject::GetConnected( a2dCanvasObjectList* connected, bool needsupdate )
07566 {
07567 bool res=false;
07568 forEachIn( a2dCanvasObjectList, m_childobjects )
07569 {
07570 a2dCanvasObject *obj = *iter;
07571 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07572 if ( pinc && pinc->ConnectedTo() )
07573 {
07574 if (needsupdate)
07575 {
07576 if ( pinc->ConnectedTo()->GetParent()->NeedsUpdateWhenConnected())
07577 {
07578 res=true;
07579 connected->push_back( pinc->ConnectedTo()->GetParent() );
07580 }
07581 }
07582 else
07583 {
07584 res=true;
07585 connected->push_back( pinc->ConnectedTo()->GetParent() );
07586 }
07587 }
07588 }
07589 return res;
07590 }
07591
07592 bool a2dCanvasObject::SetConnectedPending( bool WXUNUSED(onoff), bool needsupdateonly )
07593 {
07594 bool res=false;
07595 forEachIn( a2dCanvasObjectList, m_childobjects )
07596 {
07597 a2dCanvasObject *obj = *iter;
07598 a2dPin* pinc = wxDynamicCast( obj, a2dPin );
07599 if ( pinc && pinc->ConnectedTo() && !pinc->GetRelease( ) )
07600 {
07601 a2dCanvasObject* conparent = pinc->ConnectedTo()->GetParent();
07602 if ( conparent && !conparent->GetRelease() )
07603 {
07604 if ( needsupdateonly )
07605 {
07606 if ( conparent->NeedsUpdateWhenConnected())
07607 {
07608 res=true;
07609 conparent->SetPending( true );
07610 }
07611 }
07612 else
07613 {
07614 res=true;
07615 conparent->SetPending( true );
07616 }
07617 }
07618 }
07619 }
07620 return res;
07621 }
07622
07623 bool a2dCanvasObject::ProcessCanvasEventChild( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent )
07624 {
07625 if ( m_childobjects == wxNullCanvasObjectList )
07626 return false;
07627
07628 a2dCanvasObjectList::iterator iter = m_childobjects->begin();
07629
07630 if ( iter != m_childobjects->end() )
07631 {
07632
07633
07634 if( ic.GetPerLayerMode() && m_flags.m_childrenOnSameLayer && m_root->GetLayerSetup() )
07635 {
07636 wxASSERT_MSG( ic.GetLayer() != wxLAYER_ALL, _T(" a2dIterC::GetPerLayerMode() can only hit one layer at the time") );
07637
07638 wxUint16 layer = ic.GetLayer();
07639 unsigned int j;
07640 for ( j=0; j < wxMAXLAYER; j++ )
07641 {
07642 a2dLayerInfo* layerinfo;
07643
07644 if ( ic.GetCanvasView()->GetReverseOrder() )
07645 layerinfo = GetCanvasDocument()->GetLayerSetup()->GetOrderIndex()[j];
07646 else
07647 layerinfo = GetCanvasDocument()->GetLayerSetup()->GetReverseOrderIndex()[j];
07648
07649
07650
07651 if ( layerinfo == wxNullLayerInfo )
07652 break;
07653
07654
07655
07656
07657
07658 if ( ic.GetCanvasView()->GetLayerRenderArray()[ layerinfo->GetLayer() ].DoRenderLayer()
07659 && layerinfo->GetVisible() )
07660 {
07661 ic.SetLayer( layerinfo->GetLayer() );
07662 ProcessCanvasEventChildOneLayer( ic, whichchilds, hitEvent );
07663 }
07664 }
07665 ic.SetLayer( layer );
07666 }
07667 else
07668 {
07669
07670
07671
07672 ProcessCanvasEventChildOneLayer( ic, whichchilds, hitEvent );
07673 }
07674 }
07675 return hitEvent.m_processed;
07676 }
07677
07678 bool a2dCanvasObject::ProcessCanvasEventChildOneLayer( a2dIterC& ic, RenderChild& whichchilds, a2dHitEvent& hitEvent )
07679 {
07680 RenderChild detectchilds;
07681 detectchilds.m_postrender = false;
07682 detectchilds.m_prerender = false;
07683 detectchilds.m_property = false;
07684
07685
07686
07687 a2dCanvasObjectList::reverse_iterator iter = m_childobjects->rbegin();
07688 while( iter != m_childobjects->rend() )
07689 {
07690 a2dCanvasObject *obj = *iter;
07691 int olayer = obj->GetLayer();
07692
07693 detectchilds.m_postrender = detectchilds.m_prerender || !obj->GetPreRenderAsChild();
07694 detectchilds.m_prerender = detectchilds.m_postrender || obj->GetPreRenderAsChild();
07695 detectchilds.m_property = detectchilds.m_property || obj->GetIsProperty();
07696
07697 iter++;
07698
07699
07700 if ( (
07701 ( obj->GetPreRenderAsChild() && whichchilds.m_prerender && !obj->GetIsProperty() ) ||
07702 ( !obj->GetPreRenderAsChild() && whichchilds.m_postrender && !obj->GetIsProperty() ) ||
07703 ( obj->GetIsProperty() && whichchilds.m_property )
07704 )
07705
07706
07707 &&
07708 ( olayer == ic.GetLayer() || ic.GetLayer() == wxLAYER_ALL || obj->GetChildObjectsCount() || obj->GetIgnoreLayer() )
07709 )
07710 {
07711 obj->ProcessCanvasObjectEvent( ic, hitEvent );
07712 }
07713 }
07714
07715 whichchilds = detectchilds;
07716
07717 return hitEvent.m_processed;
07718 }
07719
07720 #ifdef _DEBUG
07721
07722 void a2dCanvasObject::Dump( int indent )
07723 {
07724 wxString line( wxT(' '), indent );
07725
07726 line+= wxString::Format( wxT("a ((%s*)0x%p), x=%lg, y=%lg"), GetClassInfo()->GetClassName(), this, GetPosX(), GetPosY() );
07727
07728 DoDump( indent, &line );
07729
07730 wxLogDebug( line );
07731
07732 forEachIn( a2dCanvasObjectList, m_childobjects )
07733 {
07734 a2dCanvasObject *obj = *iter;
07735 obj->Dump( indent + 2 );
07736 }
07737 }
07738
07739 void a2dCanvasObject::DoDump( int WXUNUSED(indent), wxString *line )
07740 {
07741 if( HasProperty( PROPID_ToolObject ) )
07742 *line += wxT(" pTO");
07743 if( HasProperty( PROPID_ToolDecoration ) )
07744 *line += wxT(" pTD");
07745 if( HasProperty( PROPID_Editcopy ) )
07746 *line += wxT(" pEC");
07747 if( HasProperty( PROPID_Original ) )
07748 *line += wxT(" pOR");
07749 if( m_flags.m_editingCopy )
07750 *line += wxT(" fEC");
07751 if( m_flags.m_editing )
07752 *line += wxT(" fED");
07753 }
07754
07755 #endif