// $Revision: 1.34 $ //======================================================================= // file CanvasCommands.C // // description Standard canvas command classes. // // modifications rtw 01/8/94 new file, added TAdoptCanvasGraphicCmd // rtw 01/27/94 added more commands // // Copyright (C) 1994 Taligent, Inc. All rights reserved. // All rights reserved. //======================================================================== #ifndef Taligent_CANVASCOMMANDS #include "CanvasCommands.h" #endif # ifndef Taligent_ASSERTIONS # include # endif #ifndef Taligent_RGBCOLOR #include #endif #ifndef Taligent_GRAFEDITTRACE #include "GrafEditTrace.h" #endif // ******************************************************************************** // class TAdoptCanvasGraphicCmd // // description Use for adopting canvas graphics into the canvas representation. // Any graphics that are selected are replaced and saved for undo. // // ******************************************************************************** MCollectibleDefinitionsMacro (TAdoptCanvasGraphicCmd, kOriginalVersion); TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd () : fGraphic (NIL), fID (TCanvasGraphicID::kInvalidID), fAdoptionPreference(true), TCommandOn (kSerialUndo) { PVMARK("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd(empty)\n"); #endif } TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd (MCanvasGraphic* adoptGraphic, bool adoptAtFront) : fGraphic (adoptGraphic), fID (TCanvasGraphicID::kInvalidID), fAdoptionPreference(adoptAtFront), TCommandOn (kSerialUndo) { PVMARK("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd(graphic)"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd(graphic)\n"); #endif } TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd (const TAdoptCanvasGraphicCmd &source) : fID (source.fID), fGraphic (NIL), fAdoptionPreference(source.fAdoptionPreference), TCommandOn(source) { PVMARK("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd(copy)"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::TAdoptCanvasGraphicCmd(copy)\n"); #endif if(source.fGraphic != NIL) fGraphic = ::Copy (*source.fGraphic.GetObject()); } TAdoptCanvasGraphicCmd::~TAdoptCanvasGraphicCmd() { PVMARK("TAdoptCanvasGraphicCmd::~TAdoptCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::~TAdoptCanvasGraphicCmd\n"); #endif } TAdoptCanvasGraphicCmd& TAdoptCanvasGraphicCmd::operator= (const TAdoptCanvasGraphicCmd& source) { PVMARK("TAdoptCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::operator=\n"); #endif if ( this != &source ) { TCommandOn::operator= (source); if(*source.fGraphic) fGraphic = ::Copy (*source.fGraphic.GetObject()); fID = source.fID; fAdoptionPreference = source.fAdoptionPreference; } return *this; } TStream& TAdoptCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TAdoptCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TCommandOn::operator>>= (toWhere); ::Flatten (fGraphic.GetObject(), toWhere); fID >>= toWhere; fAdoptionPreference >>= toWhere; return toWhere; } TStream& TAdoptCanvasGraphicCmd::operator<<=(TStream& fromWhere) { PVMARK("TAdoptCanvasGraphicCmd::operator<<="); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TCommandOn::operator<<= (fromWhere); MCanvasGraphic* temp = NIL; ::Resurrect (temp, fromWhere); fGraphic = temp; fID <<= fromWhere; fAdoptionPreference <<= fromWhere; return fromWhere; } void TAdoptCanvasGraphicCmd::HandleDoBegin (MCanvasSelection& selection) { PVMARK("TAdoptCanvasGraphicCmd::HandleDoBegin"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::HandleDoBegin\n"); #endif Assertion ( fGraphic != NIL, "TAdoptCanvasGraphicCmd::HandleDoBegin -- Can't adopt NIL graphic"); MCanvasRepresentation* r = selection.GetCanvasRepresentationForWriting (); Assertion ( r != NIL, "TAdoptCanvasGraphicCmd::HandleDoBegin -- Undefined representation"); fID = fGraphic->GetID(); selection.Invalidate (TGArea(fGraphic->GetLooseFitBounds())); selection.SelectGraphic (*fGraphic); if (fAdoptionPreference) r->AdoptAtFront ( fGraphic.OrphanObject() ); else r->AdoptAtBack ( fGraphic.OrphanObject() ); } void TAdoptCanvasGraphicCmd::HandleUndo (MCanvasSelection& selection) { PVMARK("TAdoptCanvasGraphicCmd::HandleUndo"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::HandleUndo\n"); #endif Assertion ( fID != TCanvasGraphicID::kInvalidID, "TAdoptCanvasGraphicCmd::HandleUndo -- Invalid ID"); MCanvasRepresentation* r = selection.GetCanvasRepresentationForWriting (); Assertion ( r != NIL, "TAdoptCanvasGraphicCmd::HandleUndo -- Undefined representation"); fGraphic = r->Orphan (fID); Assertion ( fGraphic != NIL, "TAdoptCanvasGraphicCmd::HandleUndo -- Graphic not found"); selection.Invalidate (TGArea(fGraphic->GetLooseFitBounds())); fID = TCanvasGraphicID::kInvalidID; } void TAdoptCanvasGraphicCmd::HandleRedo (MCanvasSelection& selection) { PVMARK("TAdoptCanvasGraphicCmd::HandleRedo"); #ifdef DEBUG ::qprintf("TAdoptCanvasGraphicCmd::HandleRedo\n"); #endif Assertion ( fGraphic != NIL, "TAdoptCanvasGraphicCmd::HandleRedo -- Graphic is NIL"); MCanvasRepresentation* r = selection.GetCanvasRepresentationForWriting (); Assertion ( r != NIL, "TAdoptCanvasGraphicCmd::HandleRedo -- Undefined representation"); fID = fGraphic->GetID(); selection.Invalidate (TGArea(fGraphic->GetLooseFitBounds())); selection.SelectGraphic (*fGraphic); if (fAdoptionPreference) r->AdoptAtFront ( fGraphic.OrphanObject() ); else r->AdoptAtBack ( fGraphic.OrphanObject() ); } // ******************************************************************************** // class TDeleteCanvasGraphicCmd // // description Deletes each canvas graphic in the selection from the associates // canvas representation. // // ******************************************************************************** TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd () : TCommandOn (kSerialUndo), fUndoRedoGraphics (NIL), fUndoRedoLocations (NIL), fUndoRedoOrder (NIL) { PVMARK("TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd\n"); #endif fUndoRedoGraphics = new TCanvasGraphicAssociationsWith; fUndoRedoLocations = new TCanvasGraphicAssociationsWith; TMCollectibleComparator* comparator = new TMCollectibleComparator; TPolymorphicStreamer* streamer = new TPolymorphicStreamer; fUndoRedoOrder = new TDequeOf (comparator, streamer); } TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd (const TDeleteCanvasGraphicsCmd& source) : TCommandOn(source), fUndoRedoGraphics (NIL), fUndoRedoLocations (NIL), fUndoRedoOrder (NIL) { PVMARK("TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::TDeleteCanvasGraphicsCmd\n"); #endif fUndoRedoGraphics = ::Copy (*source.fUndoRedoGraphics.GetObject()); fUndoRedoLocations = ::Copy (*source.fUndoRedoLocations.GetObject()); TMCollectibleComparator* comparator = new TMCollectibleComparator; TPolymorphicStreamer* streamer = new TPolymorphicStreamer; fUndoRedoOrder = new TDequeOf (comparator, streamer); if ( source.fUndoRedoOrder ) { TIteratorOver* i = source.fUndoRedoOrder->CreateIterator (); if (i) { TCanvasGraphicID* id = i->First (); while (id) { fUndoRedoOrder->AddLast (::Copy(*id)); id = i->Next (); } delete i; } } } TDeleteCanvasGraphicsCmd::~TDeleteCanvasGraphicsCmd () { PVMARK("TDeleteCanvasGraphicsCmd::~TDeleteCanvasGraphicsCmd"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::~TDeleteCanvasGraphicsCmd\n"); #endif fUndoRedoOrder->DeleteAll (); } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TDeleteCanvasGraphicsCmd, kOriginalVersion); TStream& TDeleteCanvasGraphicsCmd::operator>>= (TStream& toWhere) const { PVMARK("TDeleteCanvasGraphicsCmd::operator>>="); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::operator>>=\n"); #endif WriteVersion (toWhere); TCommandOn::operator>>= (toWhere); ::Flatten (fUndoRedoGraphics.GetObject(), toWhere); ::Flatten (fUndoRedoLocations.GetObject(), toWhere); ::Flatten (fUndoRedoOrder.GetObject(), toWhere); return toWhere; } TStream& TDeleteCanvasGraphicsCmd::operator<<= (TStream& fromWhere) { PVMARK("TDeleteCanvasGraphicsCmd::operator<<="); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TCommandOn::operator<<= (fromWhere); TCanvasGraphicAssociationsWith* undoRedoGraphics; Resurrect (undoRedoGraphics, fromWhere); fUndoRedoGraphics = undoRedoGraphics; TCanvasGraphicAssociationsWith* undoRedoLocations; Resurrect (undoRedoLocations, fromWhere); fUndoRedoLocations = undoRedoLocations; TDequeOf* undoRedoOrder; Resurrect (undoRedoOrder, fromWhere); fUndoRedoOrder = undoRedoOrder; return fromWhere; } TDeleteCanvasGraphicsCmd& TDeleteCanvasGraphicsCmd::operator= (const TDeleteCanvasGraphicsCmd& source) { PVMARK("TDeleteCanvasGraphicsCmd::operator="); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::operator=\n"); #endif TCommandOn::operator= (source); fUndoRedoGraphics = ::Copy (*source.fUndoRedoGraphics.GetObject()); fUndoRedoLocations = ::Copy (*source.fUndoRedoLocations.GetObject()); TMCollectibleComparator* comparator = new TMCollectibleComparator; TPolymorphicStreamer* streamer = new TPolymorphicStreamer; fUndoRedoOrder = new TDequeOf (comparator, streamer); if ( source.fUndoRedoOrder ) { TIteratorOver* i = source.fUndoRedoOrder->CreateIterator (); if (i) { TCanvasGraphicID* id = i->First (); while (id) { fUndoRedoOrder->AddLast (::Copy(*id)); id = i->Next (); } delete i; } } return *this; } void TDeleteCanvasGraphicsCmd::HandleDoBegin (MCanvasSelection& selection) { PVMARK("TDeleteCanvasGraphicsCmd::BeginChange"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::BeginChange\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); TDeleterFor i = selection.CreateIterator (); MCanvasGraphic* g = i->First (); while (g) { TCanvasGraphicID id = g->GetID (); selection.Invalidate (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID before = rep->Before(id); MCanvasGraphic* deleted = rep->Orphan (id); fUndoRedoGraphics->AdoptAssociation (id, deleted); fUndoRedoLocations->AdoptAssociation (id, ::Copy(before)); fUndoRedoOrder->Push (::Copy(id)); g = i->Next (); } } void TDeleteCanvasGraphicsCmd::HandleUndo (MCanvasSelection& selection) { PVMARK("TDeleteCanvasGraphicsCmd::HandleUndo"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::HandleUndo\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); TCanvasGraphicID* id = fUndoRedoOrder->Pop (); while ( id ) { MCanvasGraphic* deleted = fUndoRedoGraphics->OrphanAssociation (*id); TCanvasGraphicID* before = fUndoRedoLocations->OrphanAssociation (*id); if ( *before != TCanvasGraphicID::kInvalidID ) rep->AdoptAfter (*before, deleted); else rep->AdoptAtFront (deleted); selection.Invalidate (TGArea(deleted->GetLooseFitBounds())); delete id; delete before; id = fUndoRedoOrder->Pop (); } } void TDeleteCanvasGraphicsCmd::HandleRedo (MCanvasSelection& selection) { PVMARK("TDeleteCanvasGraphicsCmd::BeginChange"); #ifdef DEBUG ::qprintf("TDeleteCanvasGraphicsCmd::BeginChange\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); TDeleterFor i = selection.CreateIterator (); MCanvasGraphic* g = i->First (); while (g) { TCanvasGraphicID id = g->GetID (); selection.Invalidate (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID before = rep->Before(id); MCanvasGraphic* deleted = rep->Orphan (id); fUndoRedoGraphics->AdoptAssociation (id, deleted); fUndoRedoLocations->AdoptAssociation (id, ::Copy(before)); fUndoRedoOrder->Push (::Copy(id)); g = i->Next (); } } // ******************************************************************************** // class TChangeCanvasGraphicCmd // // description A useful base class for commands that do something to each // canvas graphic in the selection. This base class implements // HandleDoBegin to iterate over all graphics in the selection // and calls DoChange for each, passing you the graphic to change. // You change the graphic. // // ******************************************************************************** TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd () : TCommandOn (kSerialUndo) { PVMARK("TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd(empty)"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd(empty)\n"); #endif } TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd (const TChangeCanvasGraphicCmd& source) : TCommandOn (source) { PVMARK("TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd(copy)"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::TChangeCanvasGraphicCmd(copy)\n"); #endif } TChangeCanvasGraphicCmd::~TChangeCanvasGraphicCmd () { PVMARK("TChangeCanvasGraphicCmd::~TChangeCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::~TChangeCanvasGraphicCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TChangeCanvasGraphicCmd, kOriginalVersion); TStream& TChangeCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TChangeCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TCommandOn::operator>>= (toWhere); return toWhere; } TStream& TChangeCanvasGraphicCmd::operator<<= (TStream& fromWhere) { PVMARK("TChangeCanvasGraphicCmd::operator<<="); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TCommandOn::operator<<= (fromWhere); return fromWhere; } TChangeCanvasGraphicCmd& TChangeCanvasGraphicCmd::operator= (const TChangeCanvasGraphicCmd& source) { PVMARK("TChangeCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::operator=\n"); #endif TCommandOn::operator= (source); return *this; } //======================================== // TChangeCanvasGraphicCmd Methods //======================================== void TChangeCanvasGraphicCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic&) { PVMARK("TChangeCanvasGraphicCmd::BeginChange"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::BeginChange\n"); #endif } void TChangeCanvasGraphicCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic&) { PVMARK("TChangeCanvasGraphicCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::ContinueChange\n"); #endif } void TChangeCanvasGraphicCmd::UndoChange (MCanvasRepresentation&, MCanvasGraphic&) { PVMARK("TChangeCanvasGraphicCmd::UndoChange"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::UndoChange\n"); #endif } void TChangeCanvasGraphicCmd::RedoChange (MCanvasRepresentation&, MCanvasGraphic&) { PVMARK("TChangeCanvasGraphicCmd::RedoChange"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::RedoChange\n"); #endif } //======================================== // TCommandOn<> Overrides //======================================== void TChangeCanvasGraphicCmd::HandleDoBegin (MCanvasSelection& selection) { PVMARK("TChangeCanvasGraphicCmd::HandleDoBegin"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::HandleDoBegin\n"); #endif // Obtaining a TDocumentComponentWriteEntry is unnecessary here because the method // TDocumentComponentCommandBinindg::WriteLockAndCall (which was called by // TAbstractDocumentComponentCommandBining::DoBegin) took care of that before calling us... MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); if ( rep ) { TGArea invalidArea; TDeleterFor i = selection.CreateIterator (); if (i) { MCanvasGraphic* g = i->First (); while (g) { invalidArea.Add (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID id = g->GetID (); BeginChange (*rep, *g); g = rep->Lookup (id); invalidArea.Add (TGArea(g->GetLooseFitBounds())); g = i->Next (); } } selection.Invalidate (invalidArea); } } void TChangeCanvasGraphicCmd::HandleDoIncrement (MCanvasSelection& selection) { PVMARK("TChangeCanvasGraphicCmd::HandleDoIncrement"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::HandleDoIncrement\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); if ( rep ) { TGArea invalidArea; TDeleterFor i = selection.CreateIterator (); if (i) { MCanvasGraphic* g = i->First (); while (g) { invalidArea.Add (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID id = g->GetID (); ContinueChange (*rep, *g); g = rep->Lookup (id); invalidArea.Add (TGArea(g->GetLooseFitBounds())); g = i->Next (); } } selection.Invalidate (invalidArea); } } void TChangeCanvasGraphicCmd::HandleDoEnd () { PVMARK("TChangeCanvasGraphicCmd::HandleDoEnd"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::HandleDoEnd\n"); #endif } void TChangeCanvasGraphicCmd::HandleUndo (MCanvasSelection& selection) { PVMARK("TChangeCanvasGraphicCmd::HandleUndo"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::HandleUndo\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); if ( rep ) { TGArea invalidArea; TDeleterFor i = selection.CreateIterator (); if (i) { MCanvasGraphic* g = i->First (); while (g) { invalidArea.Add (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID id = g->GetID (); UndoChange (*rep, *g); g = rep->Lookup (id); invalidArea.Add (TGArea(g->GetLooseFitBounds())); g = i->Next (); } } selection.Invalidate (invalidArea); } } void TChangeCanvasGraphicCmd::HandleRedo (MCanvasSelection& selection) { PVMARK("TChangeCanvasGraphicCmd::HandleRedo"); #ifdef DEBUG ::qprintf("TChangeCanvasGraphicCmd::HandleRedo\n"); #endif MCanvasRepresentation* rep = selection.GetCanvasRepresentationForWriting (); if ( rep ) { TGArea invalidArea; TDeleterFor i = selection.CreateIterator (); if (i) { MCanvasGraphic* g = i->First (); while (g) { invalidArea.Add (TGArea(g->GetLooseFitBounds())); TCanvasGraphicID id = g->GetID (); RedoChange (*rep, *g); g = rep->Lookup (id); invalidArea.Add (TGArea(g->GetLooseFitBounds())); g = i->Next (); } } selection.Invalidate (invalidArea); } } bool TChangeCanvasGraphicCmd::HandleCanDo (const MCanvasSelection& selection) const { PVMARK("TChangeCanvasGraphicCmd::HandleCanDo(MCanvasSelection&)"); return ( selection.NumberOfSelectedGraphics () > 0 ); } // ******************************************************************************** // class TSetCanvasGraphicFillColorCmd // // description A command that sets the fill color of each graphic in the // selection. It also saves the old colors for individual graphics // and associates them with the graphic ids. When called to // undo, it looks up the old color associated with the id and re-applies // it. // // ******************************************************************************** TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd () : fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(empty)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd (const TColor& color) : fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(color)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(color)\n"); #endif fColor = ::Copy(color); fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd (const TSetCanvasGraphicFillColorCmd& source) : TChangeCanvasGraphicCmd (source), fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(copy)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd(copy)\n"); #endif fColor = ::Copy (*source.fColor.GetObject()); fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TSetCanvasGraphicFillColorCmd::~TSetCanvasGraphicFillColorCmd () { PVMARK("TSetCanvasGraphicFillColorCmd::~TSetCanvasGraphicFillColorCmd"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::~TSetCanvasGraphicFillColorCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TSetCanvasGraphicFillColorCmd, kOriginalVersion); TStream& TSetCanvasGraphicFillColorCmd::operator>>= (TStream& toWhere) const { PVMARK("TSetCanvasGraphicFillColorCmd::operator>>="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); ::Flatten (fColor.GetObject(), toWhere); ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } TStream& TSetCanvasGraphicFillColorCmd::operator<<= (TStream& fromWhere) { PVMARK("TSetCanvasGraphicFillColorCmd::operator<<="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); TColor* color; Resurrect (color, fromWhere); fColor = color; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } TSetCanvasGraphicFillColorCmd& TSetCanvasGraphicFillColorCmd::operator= (const TSetCanvasGraphicFillColorCmd& source) { PVMARK("TSetCanvasGraphicFillColorCmd::operator="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fColor = ::Copy(*source.fColor.GetObject()); fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } return *this; } void TSetCanvasGraphicFillColorCmd::SetColor (const TColor& color) { PVMARK("TSetCanvasGraphicFillColorCmd::SetColor"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::SetColor\n"); #endif fColor = ::Copy (color); } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TSetCanvasGraphicFillColorCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFillColorCmd::BeginChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); TRGBColor* test = (TRGBColor*)fColor.GetObject(); if ( fColor ) { TColorPaint* newPaint = new TColorPaint (*fColor); if ( newPaint ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFillPaint (newPaint); graphic.AdoptBundle (bundle); } else delete newPaint; } } } void TSetCanvasGraphicFillColorCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFillColorCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::ContinueChange\n"); #endif TRGBColor* test = (TRGBColor*)fColor.GetObject(); if ( fColor ) { TColorPaint* newPaint = new TColorPaint (*fColor); if ( newPaint ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFillPaint (newPaint); graphic.AdoptBundle (bundle); } else delete newPaint; } } } void TSetCanvasGraphicFillColorCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFillColorCmd::UndoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TSetCanvasGraphicFillColorCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFillColorCmd::RedoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFillColorCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TSetCanvasGraphicFrameColorCmd // // description A command that sets the frame color of each graphic in the // selection. It also saves the old colors for individual graphics // and associates them with the graphic ids. When called to // undo, it looks up the old color associated with the id and re-applies // it. // // ******************************************************************************** TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd () : fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (empty)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (const TColor& color) : fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (color)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (color)\n"); #endif fColor = ::Copy(color); fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (const TSetCanvasGraphicFrameColorCmd& source) : TChangeCanvasGraphicCmd (source), fColor (NIL), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (copy)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::TSetCanvasGraphicFrameColorCmd (copy)\n"); #endif fColor = ::Copy (*source.fColor.GetObject()); fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TSetCanvasGraphicFrameColorCmd::~TSetCanvasGraphicFrameColorCmd () { PVMARK("TSetCanvasGraphicFrameColorCmd::~TSetCanvasGraphicFrameColorCmd"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::~TSetCanvasGraphicFrameColorCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TSetCanvasGraphicFrameColorCmd, kOriginalVersion); TStream& TSetCanvasGraphicFrameColorCmd::operator>>= (TStream& toWhere) const { PVMARK("TSetCanvasGraphicFrameColorCmd::operator>>="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); ::Flatten (fColor.GetObject(), toWhere); ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } TStream& TSetCanvasGraphicFrameColorCmd::operator<<= (TStream& fromWhere) { PVMARK("TSetCanvasGraphicFrameColorCmd::operator<<="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); TColor* color; Resurrect (color, fromWhere); fColor = color; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } TSetCanvasGraphicFrameColorCmd& TSetCanvasGraphicFrameColorCmd::operator= (const TSetCanvasGraphicFrameColorCmd& source) { PVMARK("TSetCanvasGraphicFrameColorCmd::operator="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fColor = ::Copy(*source.fColor.GetObject()); fUndoRedoMemory = ::Copy (*fUndoRedoMemory.GetObject()); } return *this; } void TSetCanvasGraphicFrameColorCmd::SetColor (const TColor& color) { PVMARK("TSetCanvasGraphicFrameColorCmd::SetColor"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::SetColor\n"); #endif fColor = ::Copy(color); } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TSetCanvasGraphicFrameColorCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFrameColorCmd::BeginChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); if ( fColor ) { TColorPaint* newPaint = new TColorPaint (*fColor); if ( newPaint ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFramePaint (newPaint); graphic.AdoptBundle (bundle); } else delete newPaint; } } } void TSetCanvasGraphicFrameColorCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFrameColorCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::ContinueChange\n"); #endif TRGBColor* test = (TRGBColor*)fColor.GetObject(); if ( fColor ) { TColorPaint* newPaint = new TColorPaint (*fColor); if ( newPaint ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFillPaint (newPaint); graphic.AdoptBundle (bundle); } else delete newPaint; } } } void TSetCanvasGraphicFrameColorCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFrameColorCmd::UndoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TSetCanvasGraphicFrameColorCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicFrameColorCmd::RedoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicFrameColorCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TSetCanvasGraphicLineWidthCmd // // description A command that sets the line width of each graphic in the // selection. It also saves the old widths for individual graphics // and associates them with the graphic ids. When called to // undo, it looks up the old width associated with the id and reapplies // it. // // ******************************************************************************** TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd () : fWidth (1.0), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (empty)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (GCoordinate width) : fWidth (width), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (width)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (width)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (const TSetCanvasGraphicLineWidthCmd& source) : TChangeCanvasGraphicCmd (source), fWidth (source.fWidth), fUndoRedoMemory (NIL) { PVMARK("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (copy)"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::TSetCanvasGraphicLineWidthCmd (copy)\n"); #endif fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TSetCanvasGraphicLineWidthCmd::~TSetCanvasGraphicLineWidthCmd () { PVMARK("TSetCanvasGraphicLineWidthCmd::~TSetCanvasGraphicLineWidthCmd"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::~TSetCanvasGraphicLineWidthCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TSetCanvasGraphicLineWidthCmd, kOriginalVersion); TStream& TSetCanvasGraphicLineWidthCmd::operator>>= (TStream& toWhere) const { PVMARK("TSetCanvasGraphicLineWidthCmd::operator>>="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); fWidth >>= toWhere; ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } TStream& TSetCanvasGraphicLineWidthCmd::operator<<= (TStream& fromWhere) { PVMARK("TSetCanvasGraphicLineWidthCmd::operator<<="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); fWidth <<= fromWhere; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } TSetCanvasGraphicLineWidthCmd& TSetCanvasGraphicLineWidthCmd::operator= (const TSetCanvasGraphicLineWidthCmd& source) { PVMARK("TSetCanvasGraphicLineWidthCmd::operator="); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fWidth = source.fWidth; fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } return *this; } void TSetCanvasGraphicLineWidthCmd::SetWidth (GCoordinate width) { PVMARK("TSetCanvasGraphicLineWidthCmd::SetWidth"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::SetWidth\n"); #endif fWidth = width; } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TSetCanvasGraphicLineWidthCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicLineWidthCmd::BeginChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::BeginChange\n"); #endif MCanvasGraphic* copy = ::Copy (graphic); TCanvasGraphicID id = graphic.GetID (); fUndoRedoMemory->AdoptAssociation (id, copy); TSolidPen* newPen = new TSolidPen (fWidth); if ( newPen ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFramePen (newPen); graphic.AdoptBundle (bundle); } } } void TSetCanvasGraphicLineWidthCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicLineWidthCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::ContinueChange\n"); #endif TSolidPen* newPen = new TSolidPen (fWidth); if ( newPen ) { TGrafBundle* bundle = graphic.OrphanBundle (); if ( bundle ) { bundle->AdoptFramePen (newPen); graphic.AdoptBundle (bundle); } } } void TSetCanvasGraphicLineWidthCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicLineWidthCmd::UndoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TSetCanvasGraphicLineWidthCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TSetCanvasGraphicLineWidthCmd::RedoChange"); #ifdef DEBUG ::qprintf("TSetCanvasGraphicLineWidthCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TScaleCanvasGraphicCmd // // description A command that scales each graphic in the selection by a // specified scale factor (x and y) around a specified center of // scaling. All scaling can be centered around a single // absolute point, or around a relative point (top, bottom, // left, right, or center) with respect to each graphic in the // selection. Undo reverses the scaling. Round-off error // can make this slightly imprecise, but it's much cheaper than // cloning the entire graphics for undo. // // ******************************************************************************** TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd () : fScaleFactor (TGPoint::kOrigin), fCenter (TGPoint::kOrigin), fUndoRedoMemory (NIL) { PVMARK("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(empty)"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd (const TGPoint& center) : fScaleFactor (TGPoint(1.,1.)), fCenter (center), fUndoRedoMemory (NIL) { PVMARK("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(center)"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(center)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd (const TGPoint& scaleFactor, const TGPoint& center) : fScaleFactor (scaleFactor), fCenter (center), fUndoRedoMemory (NIL) { PVMARK("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(scaleFactor,center)"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd(scaleFactor,center)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd (const TScaleCanvasGraphicCmd& source) : TChangeCanvasGraphicCmd (source), fScaleFactor (source.fScaleFactor), fCenter (source.fCenter), fUndoRedoMemory (NIL) { PVMARK("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd (copy)"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::TScaleCanvasGraphicCmd (copy)\n"); #endif fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TScaleCanvasGraphicCmd::~TScaleCanvasGraphicCmd () { PVMARK("TScaleCanvasGraphicCmd::~TScaleCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::~TScaleCanvasGraphicCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TScaleCanvasGraphicCmd, kOriginalVersion); TStream& TScaleCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TScaleCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); fScaleFactor >>= toWhere; fCenter >>= toWhere; ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } #ifndef NO_Internal void TScaleCanvasGraphicCmd::HandleStreamOutIncrementDelta(TStream& toWhere) const { PVMARK("TScaleCanvasGraphicCmd::HandleStreamOutIncrementDelta\n"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::HandleStreamOutIncrementDelta\n"); #endif fScaleFactor >>= toWhere; fCenter >>= toWhere; } #endif TStream& TScaleCanvasGraphicCmd::operator<<= (TStream& fromWhere) { PVMARK("TScaleCanvasGraphicCmd::operator<<="); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); fScaleFactor <<= fromWhere; fCenter <<= fromWhere; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } #ifndef NO_Internal void TScaleCanvasGraphicCmd::HandleStreamInIncrementDelta(TStream& fromWhere) { PVMARK("TScaleCanvasGraphicCmd::HandleStreamInIncrementDelta"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::HandleStreamInIncrementDelta\n"); #endif fScaleFactor <<= fromWhere; fCenter <<= fromWhere; } #endif TScaleCanvasGraphicCmd& TScaleCanvasGraphicCmd::operator= (const TScaleCanvasGraphicCmd& source) { PVMARK("TScaleCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fScaleFactor = source.fScaleFactor; fCenter = source.fCenter; fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } return *this; } void TScaleCanvasGraphicCmd::SetScaleFactor (const TGPoint& scaleFactor) { PVMARK("TScaleCanvasGraphicCmd::SetScaleFactor"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::SetScaleFactor\n"); #endif fScaleFactor = scaleFactor; } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TScaleCanvasGraphicCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TScaleCanvasGraphicCmd::BeginChange"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); graphic.ScaleBy (fScaleFactor, fCenter); } void TScaleCanvasGraphicCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TScaleCanvasGraphicCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::ContinueChange\n"); #endif graphic.ScaleBy (fScaleFactor, fCenter); } void TScaleCanvasGraphicCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TScaleCanvasGraphicCmd::UndoChange"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TScaleCanvasGraphicCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TScaleCanvasGraphicCmd::RedoChange"); #ifdef DEBUG ::qprintf("TScaleCanvasGraphicCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TRotateCanvasGraphicCmd // // description A command that rotates each graphic in the selection by a // specified number of degrees around a specified center of // rotation. All rotation can be centered around a single // absolute point, or around a relative point (top, bottom, // left, right, or center) with respect to each graphic in the // selection. Undo reverses the rotation. Round-off error // can make this slightly imprecise, but it's much cheaper than // cloning the entire graphics for undo. // // ******************************************************************************** TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd () : fAngle (0.0), fCenter (TGPoint::kOrigin), fUndoRedoMemory (NIL) { PVMARK("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(empty)"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd (const TGPoint& center) : fAngle (0.0), fCenter (center), fUndoRedoMemory (NIL) { PVMARK("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(center)"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(center)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd (GCoordinate angle, const TGPoint& center) : fAngle (angle), fCenter (center), fUndoRedoMemory (NIL) { PVMARK("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(angle,center)"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(angle,center)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd (const TRotateCanvasGraphicCmd& source) : TChangeCanvasGraphicCmd (source), fAngle (source.fAngle), fCenter (source.fCenter), fUndoRedoMemory (NIL) { PVMARK("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(copy)"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::TRotateCanvasGraphicCmd(copy)\n"); #endif fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TRotateCanvasGraphicCmd::~TRotateCanvasGraphicCmd () { PVMARK("TRotateCanvasGraphicCmd::~TRotateCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::~TRotateCanvasGraphicCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TRotateCanvasGraphicCmd, kOriginalVersion); TStream& TRotateCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TRotateCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); fAngle >>= toWhere; fCenter >>= toWhere; ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } #ifndef NO_Internal void TRotateCanvasGraphicCmd::HandleStreamOutIncrementDelta(TStream& toWhere) const { PVMARK("TRotateCanvasGraphicCmd::HandleStreamOutIncrementDelta"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::HandleStreamOutIncrementDelta\n"); #endif fAngle >>= toWhere; fCenter >>= toWhere; } #endif TStream& TRotateCanvasGraphicCmd::operator<<= (TStream& fromWhere) { PVMARK("TRotateCanvasGraphicCmd::operator<<= "); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::operator<<= \n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); fAngle <<= fromWhere; fCenter <<= fromWhere; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } #ifndef NO_Internal void TRotateCanvasGraphicCmd::HandleStreamInIncrementDelta(TStream& fromWhere) { PVMARK("TRotateCanvasGraphicCmd::HandleStreamInIncrementDelta"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::HandleStreamInIncrementDelta\n"); #endif fAngle <<= fromWhere; fCenter <<= fromWhere; } #endif TRotateCanvasGraphicCmd& TRotateCanvasGraphicCmd::operator= (const TRotateCanvasGraphicCmd& source) { PVMARK("TRotateCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fAngle = source.fAngle; fCenter = source.fCenter; fUndoRedoMemory = ::Copy (*fUndoRedoMemory.GetObject()); } return *this; } void TRotateCanvasGraphicCmd::SetAngle (GCoordinate angle) { PVMARK("TRotateCanvasGraphicCmd::SetAngle"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::SetAngle\n"); #endif fAngle = angle; } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TRotateCanvasGraphicCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TRotateCanvasGraphicCmd::BeginChange"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); graphic.RotateBy (fAngle, fCenter); } void TRotateCanvasGraphicCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TRotateCanvasGraphicCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::ContinueChange\n"); #endif graphic.RotateBy (fAngle, fCenter); } void TRotateCanvasGraphicCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TRotateCanvasGraphicCmd::UndoChange"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TRotateCanvasGraphicCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TRotateCanvasGraphicCmd::RedoChange"); #ifdef DEBUG ::qprintf("TRotateCanvasGraphicCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TTranslateCanvasGraphicCmd // // description A command that translates each graphic in the selection by a // specified offset (x and y). Undo reverses the translation. // Round-off error can make this slightly imprecise, but it's much // cheaper than cloning the entire graphics for undo. // // ******************************************************************************** TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd () : fOffset (TGPoint::kOrigin), fUndoRedoMemory (NIL) { PVMARK("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(empty)"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(empty)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd (const TGPoint& offset) : fOffset (offset), fUndoRedoMemory (NIL) { PVMARK("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(offset)"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(offset)\n"); #endif fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd (const TTranslateCanvasGraphicCmd& source) : TChangeCanvasGraphicCmd (source), fOffset (source.fOffset), fUndoRedoMemory (NIL) { PVMARK("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(source)"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::TTranslateCanvasGraphicCmd(source)\n"); #endif fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TTranslateCanvasGraphicCmd::~TTranslateCanvasGraphicCmd () { PVMARK("TTranslateCanvasGraphicCmd::~TTranslateCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::~TTranslateCanvasGraphicCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TTranslateCanvasGraphicCmd, kOriginalVersion); TStream& TTranslateCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TTranslateCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); fOffset >>= toWhere; ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } #ifndef NO_Internal void TTranslateCanvasGraphicCmd::HandleStreamInIncrementDelta(TStream& fromWhere) { PVMARK("TTranslateCanvasGraphicCmd::HandleStreamInIncrementDelta"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::HandleStreamInIncrementDelta\n"); #endif fOffset <<= fromWhere; } #endif TStream& TTranslateCanvasGraphicCmd::operator<<= (TStream& fromWhere) { PVMARK("TTranslateCanvasGraphicCmd::operator<<="); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); fOffset <<= fromWhere; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } #ifndef NO_Internal void TTranslateCanvasGraphicCmd::HandleStreamOutIncrementDelta(TStream& fromWhere) const { PVMARK("TTranslateCanvasGraphicCmd::HandleStreamOutIncrementDelta"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::HandleStreamOutIncrementDelta\n"); #endif fOffset >>= fromWhere; } #endif TTranslateCanvasGraphicCmd& TTranslateCanvasGraphicCmd::operator= (const TTranslateCanvasGraphicCmd& source) { PVMARK("TTranslateCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fOffset = source.fOffset; fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } return *this; } void TTranslateCanvasGraphicCmd::SetOffset (const TGPoint& offset) { PVMARK("TTranslateCanvasGraphicCmd::SetOffset"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::SetOffset\n"); #endif fOffset = offset; } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TTranslateCanvasGraphicCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TTranslateCanvasGraphicCmd::BeginChange"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); graphic.TranslateBy (fOffset); } void TTranslateCanvasGraphicCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TTranslateCanvasGraphicCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::ContinueChange\n"); #endif graphic.TranslateBy (fOffset); } void TTranslateCanvasGraphicCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TTranslateCanvasGraphicCmd::UndoChange"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TTranslateCanvasGraphicCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TTranslateCanvasGraphicCmd::RedoChange"); #ifdef DEBUG ::qprintf("TTranslateCanvasGraphicCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); } // ******************************************************************************** // class TTranslateCanvasGraphicCmd // // description A command that translates each graphic in the selection by a // specified offset (x and y). Undo reverses the translation. // Round-off error can make this slightly imprecise, but it's much // cheaper than cloning the entire graphics for undo. // // ******************************************************************************** TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd () : fTransform (NIL), fUndoRedoMemory (NIL) { PVMARK("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(empty)"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(empty)\n"); #endif fTransform = new TGrafMatrix; fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd (const TGrafMatrix& tform) : fTransform (NIL), fUndoRedoMemory (NIL) { PVMARK("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(offset)"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(offset)\n"); #endif fTransform = ::Copy (tform); fUndoRedoMemory = new TCanvasGraphicAssociationsWith; } TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd (const TTransformCanvasGraphicCmd& source) : TChangeCanvasGraphicCmd (source), fTransform (NIL), fUndoRedoMemory (NIL) { PVMARK("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(source)"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::TTransformCanvasGraphicCmd(source)\n"); #endif fTransform = ::Copy (*source.fTransform.GetObject()); fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } TTransformCanvasGraphicCmd::~TTransformCanvasGraphicCmd () { PVMARK("TTransformCanvasGraphicCmd::~TTransformCanvasGraphicCmd"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::~TTransformCanvasGraphicCmd\n"); #endif } //======================================== // MCollectible Overrides //======================================== MCollectibleDefinitionsMacro (TTransformCanvasGraphicCmd, kOriginalVersion); TStream& TTransformCanvasGraphicCmd::operator>>= (TStream& toWhere) const { PVMARK("TTransformCanvasGraphicCmd::operator>>="); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::operator>>=\n"); #endif WriteVersion (toWhere); TChangeCanvasGraphicCmd::operator>>= (toWhere); ::Flatten (fTransform.GetObject(), toWhere); ::Flatten (fUndoRedoMemory.GetObject(), toWhere); return toWhere; } #ifndef NO_Internal void TTransformCanvasGraphicCmd::HandleStreamOutIncrementDelta(TStream& toWhere) const { PVMARK("TTransformCanvasGraphicCmd::HandleStreamOutIncrementDelta"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::HandleStreamOutIncrementDelta\n"); #endif ::Flatten(fTransform.GetObject(), toWhere); } #endif TStream& TTransformCanvasGraphicCmd::operator<<= (TStream& fromWhere) { PVMARK("TTransformCanvasGraphicCmd::operator<<="); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::operator<<=\n"); #endif VersionInfo version = ReadVersion (fromWhere); if ( version != kOriginalVersion ) throw TGlobalExceptionKludge (kStreamBadVersion, 0); TChangeCanvasGraphicCmd::operator<<= (fromWhere); TGrafMatrix* transform; Resurrect (transform, fromWhere); fTransform = transform; TCanvasGraphicAssociationsWith* undoRedoMemory; Resurrect (undoRedoMemory, fromWhere); fUndoRedoMemory = undoRedoMemory; return fromWhere; } #ifndef NO_Internal void TTransformCanvasGraphicCmd::HandleStreamInIncrementDelta(TStream& fromWhere) { PVMARK("TTransformCanvasGraphicCmd::HandleStreamInIncrementDelta\n"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::HandleStreamInIncrementDelta\n"); #endif TGrafMatrix *transform; ::Resurrect(transform,fromWhere); fTransform = transform; } #endif TTransformCanvasGraphicCmd& TTransformCanvasGraphicCmd::operator= (const TTransformCanvasGraphicCmd& source) { PVMARK("TTransformCanvasGraphicCmd::operator="); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::operator=\n"); #endif if ( this != &source ) { TChangeCanvasGraphicCmd::operator= (source); fTransform = ::Copy (*source.fTransform.GetObject()); fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject()); } return *this; } void TTransformCanvasGraphicCmd::SetTransform (const TGrafMatrix& tform) { PVMARK("TTransformCanvasGraphicCmd::SetOffset"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::SetOffset\n"); #endif fTransform = ::Copy (tform); } //======================================== // TChangeCanvasGraphicCmd Overrides //======================================== void TTransformCanvasGraphicCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TTransformCanvasGraphicCmd::BeginChange"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::BeginChange\n"); #endif fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic)); graphic.TransformBy (*fTransform); } void TTransformCanvasGraphicCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic) { PVMARK("TTransformCanvasGraphicCmd::ContinueChange"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::ContinueChange\n"); #endif graphic.TransformBy (*fTransform); } void TTransformCanvasGraphicCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TTransformCanvasGraphicCmd::UndoChange"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::UndoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic); fUndoRedoMemory->AdoptAssociation (id, redoGraphic); } void TTransformCanvasGraphicCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic) { PVMARK("TTransformCanvasGraphicCmd::RedoChange"); #ifdef DEBUG ::qprintf("TTransformCanvasGraphicCmd::RedoChange\n"); #endif TCanvasGraphicID id = graphic.GetID (); MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id); MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic); fUndoRedoMemory->AdoptAssociation (id, undoGraphic); }