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/canvas/objlist.h"
00022 #include "wx/canvas/drawer.h"
00023 #include "wx/canvas/canglob.h"
00024 #include "wx/canvas/algos.h"
00025 #include "wx/general/smrtptr.inl"
00026
00027 #include "wx/general/a2dlist.h"
00028 #include "wx/general/a2dlist.inl"
00029
00030 #include <math.h>
00031 #include <algorithm>
00032
00033
00034
00035
00036
00037
00038
00039 #ifdef _MSC_VER
00040 #pragma warning(disable: 4660)
00041 #endif
00042
00043 template class a2dSmrtPtrList<a2dCanvasObject>;
00044
00045 #ifdef _MSC_VER
00046 #pragma warning(default: 4660)
00047 #endif
00048
00049
00050
00051
00052
00053 a2dCanvasObjectList *wxNullCanvasObjectList;
00054
00055 bool XYSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y)
00056 {
00057 a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
00058 a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
00059
00060 if ( firstc->GetPosX() < secondc->GetPosX() )
00061 return true;
00062 if ( firstc->GetPosX() == secondc->GetPosX() )
00063 if ( firstc->GetPosY() < secondc->GetPosY() )
00064 return true;
00065 return false;
00066 }
00067
00068 bool XRevYSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y)
00069 {
00070 a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
00071 a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
00072
00073 if ( firstc->GetPosX() < secondc->GetPosX() )
00074 return true;
00075 if ( firstc->GetPosX() == secondc->GetPosX() )
00076 if ( firstc->GetPosY() > secondc->GetPosY() )
00077 return true;
00078 return false;
00079 }
00080
00081 bool YXSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y)
00082 {
00083 a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
00084 a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
00085
00086 if ( firstc->GetPosY() < secondc->GetPosY() )
00087 return true;
00088 if ( firstc->GetPosY() == secondc->GetPosY() )
00089 if ( firstc->GetPosX() < secondc->GetPosX() )
00090 return true;
00091 return false;
00092 }
00093
00094 bool YRevXSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y)
00095 {
00096 a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
00097 a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
00098
00099 if ( firstc->GetPosY() < secondc->GetPosY() )
00100 return true;
00101 if ( firstc->GetPosY() == secondc->GetPosY() )
00102 if ( firstc->GetPosX() > secondc->GetPosX() )
00103 return true;
00104 return false;
00105 }
00106
00107
00108
00109
00110
00111 a2dCanvasObjectList::a2dCanvasObjectList()
00112 {
00113 }
00114
00115 a2dCanvasObjectList::~a2dCanvasObjectList()
00116 {
00117 }
00118
00119 void a2dCanvasObjectList::SortXY()
00120 {
00121 s_a2dCanvasObjectSorter = &XYSorter;
00122 sort();
00123 }
00124
00125 void a2dCanvasObjectList::SortXRevY()
00126 {
00127 s_a2dCanvasObjectSorter = &XRevYSorter;
00128 sort();
00129 }
00130
00131 void a2dCanvasObjectList::SortYX()
00132 {
00133 s_a2dCanvasObjectSorter = &YXSorter;
00134 sort();
00135 }
00136
00137 void a2dCanvasObjectList::SortYRevX()
00138 {
00139 s_a2dCanvasObjectSorter = &YRevXSorter;
00140 sort();
00141 }
00142
00143 void a2dCanvasObjectList::MakeUnique()
00144 {
00145 a2dCanvasObjectList::iterator iter = begin();
00146 while( iter != end() )
00147 {
00148 a2dCanvasObjectList::value_type obj = *iter;
00149 if ( obj && obj->GetOwnedBy() > 2)
00150 {
00151 *iter = obj->TClone( a2dObject::clone_deep );
00152 }
00153 iter++;
00154 }
00155 }
00156
00157 a2dCanvasObjectList& a2dCanvasObjectList::operator=( const a2dCanvasObjectList& other )
00158 {
00159 wxASSERT( this != wxNullCanvasObjectList );
00160
00161 if ( &other == wxNullCanvasObjectList )
00162 return *this;
00163
00164 clear();
00165 for( a2dCanvasObjectList::const_iterator iter = other.begin(); iter != other.end(); ++iter )
00166 {
00167 a2dCanvasObject *obj = *iter;
00168 push_back( obj );
00169 }
00170 return *this;
00171 }
00172
00173 a2dCanvasObjectList* a2dCanvasObjectList::Clone( a2dObject::CloneOptions options ) const
00174 {
00175 if ( this == wxNullCanvasObjectList )
00176 return wxNullCanvasObjectList;
00177
00178 a2dCanvasObjectList* a = new a2dCanvasObjectList();
00179
00180 for( a2dCanvasObjectList::const_iterator iter = begin(); iter != end(); ++iter )
00181 {
00182 a2dCanvasObject *obj = *iter;
00183 if ( obj && options & a2dObject::clone_childs )
00184 {
00185 a2dCanvasObject *objnew=obj->TClone( options );
00186 a->push_back(objnew);
00187 }
00188 else
00189 a->push_back( obj );
00190 }
00191
00192 return a;
00193 }
00194
00195 a2dCanvasObjectList* a2dCanvasObjectList::Clone( a2dCanvasObjectFlagsMask mask, a2dObject::CloneOptions options, a2dlist< long >* objectsIndex, const a2dBoundingBox& bbox ) const
00196 {
00197 if ( this == wxNullCanvasObjectList )
00198 return wxNullCanvasObjectList;
00199
00200 a2dCanvasObjectList* a = new a2dCanvasObjectList();
00201 a2dAffineMatrix tworld;
00202
00203 int index = 0;
00204 for( a2dCanvasObjectList::const_iterator iter = begin(); iter != end(); ++iter )
00205 {
00206 a2dCanvasObjectList::value_type obj = *iter;
00207 if ( !obj->GetRelease() && obj->CheckMask(mask) )
00208 {
00209 bool pass = true;
00210 if ( bbox.GetValid() )
00211 {
00212 a2dBoundingBox tmp;
00213 tmp.Expand( obj->GetMappedBbox( tworld) );
00214 if (bbox.Intersect(tmp) != _IN )
00215 pass = false;
00216 }
00217 if ( pass )
00218 {
00219 if ( options & a2dObject::clone_deep )
00220 {
00221 a2dCanvasObject *objnew=obj->TClone( options );
00222 a->push_back(objnew);
00223 }
00224 else
00225 a->push_back( obj );
00226 if ( objectsIndex )
00227 objectsIndex->push_back( index );
00228 }
00229
00230 }
00231 if ( !obj->GetRelease() )
00232 index++;
00233 }
00234
00235 return a;
00236 }
00237
00238 a2dCanvasObjectList* a2dCanvasObjectList::CloneChecked( a2dObject::CloneOptions options, a2dlist< long >* objectsIndex ) const
00239 {
00240 if ( this == wxNullCanvasObjectList )
00241 return wxNullCanvasObjectList;
00242
00243 a2dCanvasObjectList* a = new a2dCanvasObjectList();
00244
00245 int index = 0;
00246 for( a2dCanvasObjectList::const_iterator iter = begin(); iter != end(); ++iter )
00247 {
00248 a2dCanvasObjectList::value_type obj = *iter;
00249 if ( !obj->GetRelease() && obj->GetCheck() )
00250 {
00251 if ( options & a2dObject::clone_deep )
00252 {
00253 a2dCanvasObject *objnew=obj->TClone( options );
00254 a->push_back(objnew);
00255 }
00256 else
00257 a->push_back( obj );
00258 if ( objectsIndex )
00259 objectsIndex->push_back( index );
00260 }
00261 if ( !obj->GetRelease() )
00262 index++;
00263 }
00264
00265 return a;
00266 }
00267
00268 bool a2dCanvasObjectList::ChangeLayer( wxUint16 layer, a2dCanvasObjectFlagsMask mask )
00269 {
00270
00271
00272
00273
00274
00275
00276
00277
00278 bool did=false;
00279 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00280 {
00281 a2dCanvasObject *obj = *iter;
00282 if ( obj && obj->CheckMask(mask))
00283 {
00284 did=true;
00285 obj->SetLayer(layer);
00286 }
00287 }
00288
00289 return did;
00290 }
00291
00292 int a2dCanvasObjectList::Release(a2dCanvasObjectFlagsMask mask, const wxString& classname, const a2dPropertyId *id, const wxString& name, bool now )
00293 {
00294 int did = 0;
00295 a2dCanvasObjectList::iterator iter = begin();
00296 while( iter != end() )
00297 {
00298 a2dCanvasObjectList::value_type obj = *iter;
00299 if ( obj &&
00300 (classname.IsEmpty() || obj->GetClassInfo()->GetClassName()==classname ) &&
00301 ( !id || obj->HasProperty(id) ) &&
00302 ( name.IsEmpty() || obj->GetName() == name ) &&
00303 ( obj->CheckMask(mask))
00304 )
00305 {
00306 did++;
00307 if ( now )
00308 {
00309 iter = erase( iter );
00310 }
00311 else
00312 {
00313 obj->SetRelease( true );
00314 obj->SetPending( true );
00315 iter++;
00316 }
00317 }
00318 else
00319 iter++;
00320 }
00321
00322 return did;
00323 }
00324
00325 int a2dCanvasObjectList::Release( a2dCanvasObject* object, bool backwards, bool all, bool now, const a2dPropertyId *id )
00326 {
00327 int did = 0;
00328 if ( backwards )
00329 {
00330 a2dCanvasObjectList::reverse_iterator iter = rbegin();
00331 while( iter != rend() )
00332 {
00333 a2dCanvasObject *obj = *iter;
00334 if ( obj && object == obj && ( !id || obj->HasProperty(id) ) )
00335 {
00336 if ( now )
00337 {
00338 iterator it( iter.base() ) ;
00339 -- it ;
00340 erase( it ) ;
00341 iter++;
00342
00343 }
00344 else
00345 {
00346 obj->SetRelease( true );
00347 obj->SetPending( true );
00348 iter++;
00349 }
00350 did++;
00351
00352 if ( !all )
00353 break;
00354 }
00355 else
00356 iter++;
00357 }
00358 }
00359 else
00360 {
00361 a2dCanvasObjectList::iterator iter = begin();
00362 while( iter != end() )
00363 {
00364 a2dCanvasObject *obj = *iter;
00365
00366 if ( obj && object == obj && ( !id || obj->HasProperty(id) ) )
00367 {
00368 if ( now )
00369 {
00370 iter = erase( iter );
00371 }
00372 else
00373 {
00374 obj->SetRelease( true );
00375 obj->SetPending( true );
00376 iter++;
00377 }
00378 did++;
00379
00380 if ( !all )
00381 break;
00382
00383 }
00384 else
00385 iter++;
00386 }
00387 }
00388
00389 return did;
00390 }
00391
00392 int a2dCanvasObjectList::Copy( double x, double y, a2dCanvasObjectFlagsMask mask, long target, bool check )
00393 {
00394 int nr = 0;
00395
00396 a2dCanvasObjectList::iterator iter = begin();
00397 while( iter != end() )
00398 {
00399 a2dCanvasObjectList::value_type obj = *iter;
00400 if ( obj && check )
00401 obj->SetCheck(false);
00402 if ( obj && obj->CheckMask(mask))
00403 {
00404 nr++;
00405 a2dCanvasObject *objn=obj->TClone( a2dObject::clone_deep | a2dObject::clone_reconnectable );
00406 push_front(objn);
00407 objn->Translate(x,y);
00408 objn->SetPending(true);
00409 objn->SetSpecificFlags( false, mask );
00410 if ( check )
00411 objn->SetCheck(true);
00412 if ( target != -1 )
00413 objn->SetLayer( target );
00414 }
00415 ++iter;
00416 }
00417
00418 for( iter = begin(); iter != end(); ++iter )
00419 {
00420 a2dCanvasObjectList::value_type obj = *iter;
00421 if ( obj && obj->CheckMask(mask))
00422 {
00423 obj->RestoreConnectionsAfterCloning();
00424 }
00425 }
00426
00427 return nr;
00428 }
00429
00430 int a2dCanvasObjectList::Move( double x, double y, a2dCanvasObjectFlagsMask mask, long target, bool check )
00431 {
00432 int nr = 0;
00433
00434 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00435 {
00436 a2dCanvasObject *obj = *iter;
00437 if ( obj && check )
00438 obj->SetCheck(false);
00439 if ( obj && obj->CheckMask(mask))
00440 {
00441 nr++;
00442 obj->Translate(x,y);
00443 if ( check )
00444 obj->SetCheck(true);
00445 if ( target != -1 )
00446 obj->SetLayer( target );
00447 }
00448 }
00449
00450 return nr;
00451 }
00452
00453 int a2dCanvasObjectList::BringToTop( a2dCanvasObjectFlagsMask mask, bool check )
00454 {
00455 a2dCanvasObjectList toTop;
00456
00457 int nr = 0;
00458 a2dCanvasObjectList::iterator iter = begin();
00459 while( iter != end() )
00460 {
00461 a2dCanvasObjectList::value_type obj = *iter;
00462 if ( obj && check )
00463 obj->SetCheck(false);
00464 if ( obj && obj->CheckMask(mask))
00465 {
00466 if ( check )
00467 obj->SetCheck(true);
00468 toTop.push_back( obj );
00469 nr++;
00470 iter = erase( iter );
00471 obj->SetPending(true);
00472 }
00473 else
00474 iter++;
00475 }
00476 iter = toTop.begin();
00477 while( iter != toTop.end() )
00478 {
00479 a2dCanvasObjectList::value_type obj = *iter;
00480 push_back( obj );
00481 iter++;
00482 }
00483 return nr;
00484 }
00485
00486 int a2dCanvasObjectList::BringToBack( a2dCanvasObjectFlagsMask mask, bool check )
00487 {
00488 int nr = 0;
00489 a2dCanvasObjectList::iterator iter = begin();
00490 while( iter != end() )
00491 {
00492 a2dCanvasObjectList::value_type obj = *iter;
00493 if ( obj && check )
00494 obj->SetCheck(false);
00495 if ( obj && obj->CheckMask(mask))
00496 {
00497 if ( check )
00498 obj->SetCheck(true);
00499 nr++;
00500 iter = erase( iter );
00501 insert( begin(), obj );
00502 obj->SetPending(true);
00503 }
00504 else
00505 iter++;
00506 }
00507
00508 return nr;
00509 }
00510
00511 bool a2dCanvasObjectList::SetSpecificFlags( bool setOrClear, a2dCanvasObjectFlagsMask which,
00512 const wxString& classname,
00513 a2dCanvasObjectFlagsMask whichobjects,
00514 const a2dBoundingBox& bbox,
00515 const a2dAffineMatrix& tworld )
00516 {
00517 bool did=false;
00518 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00519 {
00520 a2dCanvasObject *obj = *iter;
00521 if ( obj &&
00522 ( classname.IsEmpty() || obj->GetClassInfo()->GetClassName() == classname ) &&
00523 obj->CheckMask(whichobjects) )
00524 {
00525 if ( bbox.GetValid() )
00526 {
00527 a2dBoundingBox tmp;
00528 tmp.Expand( obj->GetMappedBbox( tworld) );
00529 if (bbox.Intersect(tmp) == _IN )
00530 {
00531 did=true;
00532 obj->SetSpecificFlags( setOrClear, which );
00533 }
00534 }
00535 else
00536 {
00537 did=true;
00538 obj->SetSpecificFlags( setOrClear, which );
00539 }
00540 }
00541 }
00542 return did;
00543 }
00544
00545 a2dCanvasObject* a2dCanvasObjectList::Find( a2dCanvasObject* obj ) const
00546 {
00547 a2dCanvasObject* cobj;
00548
00549 for( const_iterator iter = begin(); iter != end(); ++iter )
00550 {
00551 cobj= *iter;
00552 if ( cobj && obj == cobj )
00553 return cobj;
00554 }
00555
00556 return (a2dCanvasObject*) NULL;
00557 }
00558
00559 a2dCanvasObject* a2dCanvasObjectList::Find( const wxString& objectname, const wxString& classname, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *propid, const wxString& valueAsString, wxUint32 id ) const
00560 {
00561 a2dCanvasObject* cobj;
00562
00563 for( const_iterator iter = begin(); iter != end(); ++iter )
00564 {
00565 cobj= *iter;
00566
00567 if ( cobj &&
00568 ( objectname.IsEmpty() || objectname.Matches( cobj->GetName() ) ) &&
00569 ( classname.IsEmpty() || cobj->GetClassInfo()->GetClassName() == classname ) &&
00570 ( id == 0 || cobj->GetUniqueSerializationId() == (int)id ) &&
00571 ( !propid || cobj->HasProperty( propid, valueAsString ) ) &&
00572 ( cobj->CheckMask(mask) )
00573 )
00574 return cobj;
00575 }
00576
00577 return (a2dCanvasObject*) NULL;
00578 }
00579
00580 bool a2dCanvasObjectList::SwitchObjectNamed( const wxString& objectname, a2dCanvasObject* newobject )
00581 {
00582 a2dCanvasObject* cobj;
00583
00584 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00585 {
00586 cobj = *iter;
00587
00588 if ( cobj && cobj->GetName() == objectname )
00589 {
00590 newobject->SetCanvasDocument( cobj->GetCanvasDocument() );
00591 *iter = newobject;
00592 return true;
00593 }
00594 }
00595
00596 return false;
00597 }
00598
00599 bool a2dCanvasObjectList::SetDrawerStyle( const a2dFill& fill, const a2dStroke& stroke, a2dCanvasObjectFlagsMask mask )
00600 {
00601 bool did=false;
00602
00603 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00604 {
00605 a2dCanvasObject *obj = *iter;
00606 if ( obj && obj->CheckMask(mask) )
00607 {
00608 did=true;
00609 obj->SetFill( fill );
00610 obj->SetStroke( stroke );
00611 }
00612 }
00613
00614 return did;
00615 }
00616
00617 void a2dCanvasObjectList::Transform( const a2dAffineMatrix& tworld , const wxString& type, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *id )
00618 {
00619 a2dCanvasObject* cobj;
00620
00621 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00622 {
00623 cobj = *iter;
00624
00625 if ( cobj &&
00626 (type.IsEmpty() || cobj->GetClassInfo()->GetClassName()==type ) &&
00627 ( !id || cobj->HasProperty( id ) ) &&
00628 (cobj->CheckMask(mask))
00629 )
00630 {
00631 cobj->Transform( tworld );
00632 }
00633 }
00634 }
00635
00636 void a2dCanvasObjectList::SetTransform( const a2dAffineMatrix& tworld , const wxString& type, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *id )
00637 {
00638 a2dCanvasObject* cobj;
00639
00640 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00641 {
00642 cobj = *iter;
00643
00644 if ( cobj &&
00645 (type.IsEmpty() || cobj->GetClassInfo()->GetClassName()==type ) &&
00646 ( !id || cobj->HasProperty( id ) ) &&
00647 (cobj->CheckMask(mask))
00648 )
00649 {
00650 cobj->SetTransformMatrix( tworld );
00651 }
00652 }
00653 }
00654
00655 int a2dCanvasObjectList::CollectObjects( a2dCanvasObjectList* total, const wxString& type, a2dCanvasObjectFlagsMask mask,
00656 const a2dPropertyId *id,
00657 const a2dBoundingBox& bbox
00658 )
00659 {
00660 a2dCanvasObject* cobj;
00661 int count = 0;
00662
00663 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00664 {
00665 cobj = *iter;
00666
00667 if ( cobj &&
00668 !bbox.GetValid() || bbox.Intersect( cobj->GetBbox() ) == _IN )
00669 {
00670 if ( (type.IsEmpty() || cobj->GetClassInfo()->GetClassName()==type ) &&
00671 ( !id || cobj->HasProperty( id ) ) &&
00672 (cobj->CheckMask(mask))
00673 )
00674 {
00675 if ( total && total != wxNullCanvasObjectList )
00676 total->push_back(cobj);
00677 count++;
00678 }
00679 }
00680 }
00681
00682 return count;
00683 }
00684
00685 int a2dCanvasObjectList::TakeOverTo( a2dCanvasObjectList* total, const wxString& type, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *id )
00686 {
00687 int count = 0;
00688
00689 a2dCanvasObjectList::iterator iter = begin();
00690 while( iter != end() )
00691 {
00692 a2dCanvasObjectList::value_type cobj = *iter;
00693
00694 if ( cobj &&
00695 (type.IsEmpty() || cobj->GetClassInfo()->GetClassName()==type ) &&
00696 ( !id || cobj->HasProperty( id ) ) &&
00697 (cobj->CheckMask(mask))
00698 )
00699 {
00700 if ( total && total != wxNullCanvasObjectList )
00701 {
00702 iter = erase( iter );
00703 total->push_back( cobj );
00704 }
00705 else
00706 iter++;
00707 count++;
00708 }
00709 else
00710 iter++;
00711 }
00712
00713 return count;
00714 }
00715
00716 int a2dCanvasObjectList::TakeOverFrom( a2dCanvasObjectList* total, const wxString& type, a2dCanvasObjectFlagsMask mask, const a2dPropertyId *id )
00717 {
00718 return total->TakeOverTo( this, type, mask, id );
00719 }
00720
00721 void a2dCanvasObjectList::RestoreConnectionsAfterCloning( a2dCanvasCommandProcessor *cp )
00722 {
00723 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00724 {
00725 a2dCanvasObjectList::value_type cobj = *iter;
00726
00727 if ( cobj )
00728 cobj->RestoreConnectionsAfterCloning( cp );
00729 }
00730 }
00731
00732 bool UpdateImmediatePrioritySorter (const a2dCanvasObjectPtr& a, const a2dCanvasObjectPtr& b)
00733 {
00734 int pa = a2dCanvasObject::PROPID_UpdateImmediatePriority->GetPropertyValue( a.Get() );
00735 int pb = a2dCanvasObject::PROPID_UpdateImmediatePriority->GetPropertyValue( b.Get() );
00736 return pa < pb;
00737 }
00738
00739 void a2dCanvasObjectList::UpdateImmediate( bool final, a2dBaseTool *tool, a2dCanvasObject *extra, a2dCanvasObject* parent, a2dCanvasObject::a2dDoUpdateImmediateData *data )
00740 {
00741 if( empty() )
00742 return;
00743
00744 a2dCanvasObject::a2dDoUpdateImmediateData ldata( final, tool, parent );
00745 if( !data )
00746 data = &ldata;
00747
00748 int cnt=0;
00749
00750 for(;;)
00751 {
00752
00753 int oldphase = data->m_phase;
00754
00755 if( extra )
00756 {
00757 extra->DoUpdateImmediate( data );
00758 }
00759
00760 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00761 {
00762 a2dCanvasObject *obj = *iter;
00763 if ( obj )
00764 obj->DoUpdateImmediate( data );
00765 }
00766
00767
00768 if( !data->m_phaserequest )
00769 break;
00770
00771
00772 data->m_phasedone |= (1<<data->m_phase);
00773
00774
00775 for( data->m_phase=0; ! (data->m_phaserequest & (1<<data->m_phase) ); data->m_phase++ );
00776
00777
00778 data->m_phaserequest &= ~ ( 1 << data->m_phase );
00779
00780
00781 data->m_phase_first = (data->m_phasedone & ( 1 << data->m_phase ) ) == 0;
00782
00783
00784 if( data->m_sortbeforenextphase && data->m_phase != oldphase )
00785 {
00786 s_a2dCanvasObjectSorter = &UpdateImmediatePrioritySorter;
00787 sort();
00788 }
00789
00790
00791 cnt++;
00792 if( cnt>1000 )
00793 {
00794 wxASSERT(0);
00795 break;
00796 }
00797 }
00798
00799
00800 }
00801
00802 void a2dCanvasObjectList::AssertUnique()
00803 {
00804 #ifdef _DEBUG
00805 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00806 {
00807 for( a2dCanvasObjectList::iterator iter2 = iter; (++iter2) != end(); )
00808 {
00809 wxASSERT( *iter != *iter2 );
00810 }
00811 }
00812 #endif
00813 }
00814
00815 void a2dCanvasObjectList::Insert( size_t before, a2dCanvasObject* obj, bool ignoreReleased )
00816 {
00817 a2dCanvasObjectList::iterator iter = begin();
00818
00819 if ( !ignoreReleased && before > size() )
00820 push_back( obj );
00821 else
00822 {
00823 size_t i;
00824 for( i = 0; i < before; i++ )
00825 {
00826 a2dCanvasObject *obj = *iter;
00827 if ( ignoreReleased && obj->GetRelease() )
00828 i--;
00829 iter++;
00830 }
00831 insert( iter, obj );
00832 }
00833 obj->SetPending(true);
00834 }
00835
00836
00837
00838
00839 a2dCorridor::a2dCorridor()
00840 {
00841 }
00842
00843 a2dCorridor::~a2dCorridor()
00844 {
00845 }
00846
00847 a2dCorridor::a2dCorridor( const a2dIterC &ic )
00848 {
00849 a2dIterCU* iter = ic.m_bottom;
00850 if ( iter )
00851 {
00852 m_relativetransform = ic.m_bottom->GetTransform();
00853 m_inverseRelativetransform = ic.m_bottom->GetInverseTransform();
00854 }
00855 while ( iter )
00856 {
00857 if ( iter->GetObject() )
00858 push_front( iter->GetObject() );
00859 iter = iter->GetParent();
00860 }
00861 m_capture = ic.GetCanvasView()->GetCaptured();
00862 }
00863
00864 a2dCorridor::a2dCorridor( const a2dCanvasView& view )
00865 {
00866 a2dWalker_CollectCanvasObjects findcorridor( a2dCanvasOFlags::IsOnCorridorPath );
00867 if ( view.GetShowObject() )
00868 {
00869 findcorridor.Start( view.GetShowObject() );
00870 if( findcorridor.m_found.size() )
00871 {
00872 this->TakeOverFrom( &findcorridor.m_found );
00873 }
00874 else
00875 push_back( view.GetShowObject() );
00876 }
00877
00878 a2dCanvasObject* cobj;
00879 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00880 {
00881 cobj = *iter;
00882 if ( cobj )
00883 {
00884 m_relativetransform *= cobj->GetTransformMatrix();
00885 }
00886 }
00887
00888 m_inverseRelativetransform = m_relativetransform;
00889 m_inverseRelativetransform.Invert();
00890 m_capture = view.GetCaptured();
00891 }
00892
00893 void a2dCorridor::Push( a2dCanvasObject* object )
00894 {
00895 push_back( object );
00896
00897 a2dCanvasObject* cobj;
00898 for( a2dCanvasObjectList::iterator iter = begin(); iter != end(); ++iter )
00899 {
00900 cobj = *iter;
00901 if ( cobj )
00902 {
00903 m_relativetransform *= cobj->GetTransformMatrix();
00904 }
00905 }
00906
00907 m_inverseRelativetransform = m_relativetransform;
00908 m_inverseRelativetransform.Invert();
00909 }
00910