diff --git a/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.cxx b/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.cxx index eb4278ac70..07d1ac9381 100755 --- a/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.cxx +++ b/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.cxx @@ -48,7 +48,7 @@ OCAFSample_CommonDriver::OCAFSample_CommonDriver() //purpose : //======================================================================= -Standard_Integer OCAFSample_CommonDriver::Execute(TFunction_Logbook& theLogbook) const +Standard_Integer OCAFSample_CommonDriver::Execute(Handle(TFunction_Logbook)& theLogbook) const { Handle(TDF_Reference) aReference; TopoDS_Shape aMaster, aTool; @@ -77,14 +77,14 @@ Standard_Integer OCAFSample_CommonDriver::Execute(TFunction_Logbook& theLogbook) TDocStd_Modified::Add(aNode->Father()->Label()); - theLogbook.SetImpacted(Label()); + theLogbook->SetImpacted(Label()); TDocStd_Modified::Add(Label()); - theLogbook.SetImpacted(ResultLabel); + theLogbook->SetImpacted(ResultLabel); TDF_ChildIterator anIterator(ResultLabel); for(; anIterator.More(); anIterator.Next()) { - theLogbook.SetImpacted(anIterator.Value()); + theLogbook->SetImpacted(anIterator.Value()); } return OK_OPERATION; diff --git a/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.hxx b/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.hxx index 6baa193907..7a2d8607c1 100755 --- a/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.hxx +++ b/samples/mfc/standard/06_Ocaf/src/OCAFSample_CommonDriver.hxx @@ -55,7 +55,7 @@ public: // Methods PUBLIC // Standard_EXPORT OCAFSample_CommonDriver(); -Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& theLogbook) const; +Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& theLogbook) const; Standard_EXPORT ~OCAFSample_CommonDriver(); diff --git a/samples/mfc/standard/06_Ocaf/src/OCAFSample_Driver.hxx b/samples/mfc/standard/06_Ocaf/src/OCAFSample_Driver.hxx index 6378870330..704f37b307 100755 --- a/samples/mfc/standard/06_Ocaf/src/OCAFSample_Driver.hxx +++ b/samples/mfc/standard/06_Ocaf/src/OCAFSample_Driver.hxx @@ -59,8 +59,8 @@ public: // Methods PUBLIC // Standard_EXPORT void Validate(TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Boolean MustExecute(const TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual Standard_Boolean MustExecute(const Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& log) const; Standard_EXPORT virtual Standard_Boolean Arguments(TDF_LabelMap& theArgs) const; Standard_EXPORT virtual Standard_Boolean Results(TDF_LabelMap& theRes) const; Standard_EXPORT ~OCAFSample_Driver(); diff --git a/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp b/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp index acd6e09611..0ef62eddf5 100755 --- a/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp +++ b/samples/mfc/standard/06_Ocaf/src/OcafDoc.cpp @@ -336,7 +336,7 @@ void COcafDoc::OnModify() Standard_GUID myDriverID=TFF->GetDriverGUID(); Handle(TDocStd_Document) D = GetOcafDoc(); - TFunction_Logbook log; + Handle(TFunction_Logbook) log = TFunction_Logbook::Set(D->Main()); TCollection_AsciiString Message("\ // Modification and recomputation of the selected object \n\ @@ -607,7 +607,7 @@ D->CommitCommand(); \n\ // Recompute the cut object if it must be (look at the MustExecute function code) // if (myCutDriver->MustExecute(log)) // { - log.SetTouched(LabObject); + log->SetTouched(LabObject); if(myCutDriver->Execute(log)) MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Recompute failed", L"Modify cut", MB_ICONEXCLAMATION); // } diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.cxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.cxx index e976b411fd..3a2c35d657 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.cxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.cxx @@ -37,10 +37,10 @@ TOcafFunction_BoxDriver::TOcafFunction_BoxDriver() //purpose : Validation of the object label, its arguments and its results. //======================================================================= -void TOcafFunction_BoxDriver::Validate(TFunction_Logbook& log) const +void TOcafFunction_BoxDriver::Validate(Handle(TFunction_Logbook)& log) const { // We validate the object label ( Label() ), all the arguments and the results of the object: - log.SetValid(Label(), Standard_True); + log->SetValid(Label(), Standard_True); } //======================================================================= @@ -49,10 +49,10 @@ void TOcafFunction_BoxDriver::Validate(TFunction_Logbook& log) const // : be invoked. If the object label or an argument is modified, // : we must recompute the object - to call the method Execute(). //======================================================================= -Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& log) const +Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const Handle(TFunction_Logbook)& log) const { // If the object's label is modified: - if (log.IsModified(Label())) return Standard_True; + if (log->IsModified(Label())) return Standard_True; // Cut (in our simple case) has two arguments: The original shape, and the tool shape. // They are on the child labels of the box's label: @@ -60,12 +60,12 @@ Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& l // ToolNShape - is attached to the second child label. // // Let's check them: - if (log.IsModified(Label().FindChild(1))) return Standard_True; // width. - if (log.IsModified(Label().FindChild(2))) return Standard_True; // length, - if (log.IsModified(Label().FindChild(3))) return Standard_True; // width. - if (log.IsModified(Label().FindChild(4))) return Standard_True; // length, - if (log.IsModified(Label().FindChild(5))) return Standard_True; // width. - if (log.IsModified(Label().FindChild(6))) return Standard_True; // length, + if (log->IsModified(Label().FindChild(1))) return Standard_True; // width. + if (log->IsModified(Label().FindChild(2))) return Standard_True; // length, + if (log->IsModified(Label().FindChild(3))) return Standard_True; // width. + if (log->IsModified(Label().FindChild(4))) return Standard_True; // length, + if (log->IsModified(Label().FindChild(5))) return Standard_True; // width. + if (log->IsModified(Label().FindChild(6))) return Standard_True; // length, // if there are no any modifications concerned the box, // it's not necessary to recompute (to call the method Execute()): @@ -83,7 +83,7 @@ Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& l // : if there are no any mistakes occurred we return 0: // : 0 - no mistakes were found. //======================================================================= -Standard_Integer TOcafFunction_BoxDriver::Execute(TFunction_Logbook& /*log*/) const +Standard_Integer TOcafFunction_BoxDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const { // Get the values of dimension and position attributes Handle(TDataStd_Real) TSR; diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.hxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.hxx index 48fd044ec2..d249ad91fc 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.hxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_BoxDriver.hxx @@ -56,9 +56,9 @@ public: // Standard_EXPORT static const Standard_GUID& GetID() ; Standard_EXPORT TOcafFunction_BoxDriver(); -Standard_EXPORT virtual void Validate(TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Boolean MustExecute(const TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Boolean MustExecute(const Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& log) const; Standard_EXPORT ~TOcafFunction_BoxDriver(); diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.cxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.cxx index 0731e03b57..88fa765ccf 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.cxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.cxx @@ -42,10 +42,10 @@ TOcafFunction_CutDriver::TOcafFunction_CutDriver() //purpose : Validation of the object label, its arguments and its results. //======================================================================= -void TOcafFunction_CutDriver::Validate(TFunction_Logbook& log) const +void TOcafFunction_CutDriver::Validate(Handle(TFunction_Logbook)& log) const { // We validate the object label ( Label() ), all the arguments and the results of the object: - log.SetValid(Label(), Standard_True); + log->SetValid(Label(), Standard_True); } //======================================================================= @@ -55,10 +55,10 @@ void TOcafFunction_CutDriver::Validate(TFunction_Logbook& log) const // : we must recompute the object - to call the method Execute(). //======================================================================= -Standard_Boolean TOcafFunction_CutDriver::MustExecute(const TFunction_Logbook& log) const +Standard_Boolean TOcafFunction_CutDriver::MustExecute(const Handle(TFunction_Logbook)& log) const { // If the object's label is modified: - if (log.IsModified(Label())) return Standard_True; + if (log->IsModified(Label())) return Standard_True; // Cut (in our simple case) has two arguments: The original shape, and the tool shape. // They are on the child labels of the cut's label: @@ -76,11 +76,11 @@ Standard_Boolean TOcafFunction_CutDriver::MustExecute(const TFunction_Logbook& l TDF_Tool::Entry(Label(), aEntry); cout << "Entry: "<Get())) return Standard_True; // Original shape. + if (log->IsModified(OriginalRef->Get())) return Standard_True; // Original shape. Handle(TDF_Reference) ToolRef; Label().FindChild(2).FindAttribute(TDF_Reference::GetID(),ToolRef); - if (log.IsModified(ToolRef->Get())) return Standard_True; // Tool shape. + if (log->IsModified(ToolRef->Get())) return Standard_True; // Tool shape. // if there are no any modifications concerned the cut, // it's not necessary to recompute (to call the method Execute()): @@ -99,7 +99,7 @@ Standard_Boolean TOcafFunction_CutDriver::MustExecute(const TFunction_Logbook& l // : 0 - no mistakes were found. //======================================================================= -Standard_Integer TOcafFunction_CutDriver::Execute(TFunction_Logbook& /*log*/) const +Standard_Integer TOcafFunction_CutDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const { // Let's get the arguments (OriginalNShape, ToolNShape of the object): diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.hxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.hxx index 098a1e6d38..da7ab59021 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.hxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CutDriver.hxx @@ -56,9 +56,9 @@ public: // Standard_EXPORT static const Standard_GUID& GetID() ; Standard_EXPORT TOcafFunction_CutDriver(); -Standard_EXPORT virtual void Validate(TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Boolean MustExecute(const TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Boolean MustExecute(const Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& log) const; Standard_EXPORT ~TOcafFunction_CutDriver(); diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.cxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.cxx index ea5a9b28d7..467f149f35 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.cxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.cxx @@ -39,10 +39,10 @@ TOcafFunction_CylDriver::TOcafFunction_CylDriver() //purpose : Validation of the object label, its arguments and its results. //======================================================================= -void TOcafFunction_CylDriver::Validate(TFunction_Logbook& log) const +void TOcafFunction_CylDriver::Validate(Handle(TFunction_Logbook)& log) const { // We validate the object label ( Label() ), all the arguments and the results of the object: - log.SetValid(Label(), Standard_True); + log->SetValid(Label(), Standard_True); } //======================================================================= @@ -51,19 +51,19 @@ void TOcafFunction_CylDriver::Validate(TFunction_Logbook& log) const // : be invoked. If the object label or an argument is modified, // : we must recompute the object - to call the method Execute(). //======================================================================= -Standard_Boolean TOcafFunction_CylDriver::MustExecute(const TFunction_Logbook& log) const +Standard_Boolean TOcafFunction_CylDriver::MustExecute(const Handle(TFunction_Logbook)& log) const { // If the object's label is modified: - if (log.IsModified(Label())) return Standard_True; + if (log->IsModified(Label())) return Standard_True; // Cylinder (in our simple case) has 5 arguments: // // Let's check them: - if (log.IsModified(Label().FindChild(1))) return Standard_True; // radius. - if (log.IsModified(Label().FindChild(2))) return Standard_True; // height, - if (log.IsModified(Label().FindChild(3))) return Standard_True; // x. - if (log.IsModified(Label().FindChild(4))) return Standard_True; // y, - if (log.IsModified(Label().FindChild(5))) return Standard_True; // z. + if (log->IsModified(Label().FindChild(1))) return Standard_True; // radius. + if (log->IsModified(Label().FindChild(2))) return Standard_True; // height, + if (log->IsModified(Label().FindChild(3))) return Standard_True; // x. + if (log->IsModified(Label().FindChild(4))) return Standard_True; // y, + if (log->IsModified(Label().FindChild(5))) return Standard_True; // z. // if there are no any modifications concerned the Cyl, // it's not necessary to recompute (to call the method Execute()): @@ -81,7 +81,7 @@ Standard_Boolean TOcafFunction_CylDriver::MustExecute(const TFunction_Logbook& l // : if there are no any mistakes occurred we return 0: // : 0 - no mistakes were found. //======================================================================= -Standard_Integer TOcafFunction_CylDriver::Execute(TFunction_Logbook& /*log*/) const +Standard_Integer TOcafFunction_CylDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const { // Get the values of dimension and position attributes Handle(TDataStd_Real) TSR; diff --git a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.hxx b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.hxx index 165d21d395..07b5f5624f 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.hxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcafFunction_CylDriver.hxx @@ -56,9 +56,9 @@ public: // Standard_EXPORT static const Standard_GUID& GetID() ; Standard_EXPORT TOcafFunction_CylDriver(); -Standard_EXPORT virtual void Validate(TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Boolean MustExecute(const TFunction_Logbook& log) const; -Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Boolean MustExecute(const Handle(TFunction_Logbook)& log) const; +Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& log) const; Standard_EXPORT ~TOcafFunction_CylDriver(); diff --git a/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.cxx b/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.cxx index fa41e6b35b..7447a12526 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.cxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.cxx @@ -88,7 +88,7 @@ TDF_Label TOcaf_Commands::CreateBox(Standard_Real x, Standard_Real y, Standard_R Handle(TFunction_Function) myFunction = TFunction_Function::Set(L, TOcafFunction_BoxDriver::GetID()); // Initialize and execute the box driver (look at the "Execute()" code) - TFunction_Logbook log; + Handle(TFunction_Logbook) log = TFunction_Logbook::Set(L); Handle(TOcafFunction_BoxDriver) myBoxDriver; // Find the TOcafFunction_BoxDriver in the TFunction_DriverTable using its GUID @@ -143,7 +143,7 @@ TDF_Label TOcaf_Commands::CreateCyl(Standard_Real x, Standard_Real y, Standard_R Handle(TFunction_Function) myFunction = TFunction_Function::Set(L, TOcafFunction_CylDriver::GetID()); // Initialize and execute the cylinder driver (look at the "Execute()" code) - TFunction_Logbook log; + Handle(TFunction_Logbook) log = TFunction_Logbook::Set(L); Handle(TOcafFunction_CylDriver) myCylDriver; // Find the TOcafFunction_CylDriver in the TFunction_DriverTable using its GUID @@ -156,7 +156,7 @@ TDF_Label TOcaf_Commands::CreateCyl(Standard_Real x, Standard_Real y, Standard_R } -TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real w, Standard_Real l, Standard_Real h, const TCollection_ExtendedString &Name, TFunction_Logbook &log) +TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real w, Standard_Real l, Standard_Real h, const TCollection_ExtendedString &Name, Handle(TFunction_Logbook) &log) { // Set the name attribute (if it's not null) Handle(TDataStd_Name) myStdName; @@ -170,7 +170,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(1), w); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(2).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -178,7 +178,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(2), l); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(3).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -186,7 +186,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(3), h); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(4).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -194,7 +194,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(4), x); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(5).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -202,7 +202,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(5), y); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(6).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -210,7 +210,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(6), z); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } // Get the TFunction_Function used to create the box @@ -231,7 +231,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R if (myBoxDriver->MustExecute(log)) { // Set the box touched, it will be usefull to recompute an object which used this box as attribute - log.SetTouched(MainLab); + log->SetTouched(MainLab); if(myBoxDriver->Execute(log)) MessageBox (NULL, L"Recompute failed", L"Modify box", MB_ICONEXCLAMATION); } @@ -239,7 +239,7 @@ TDF_Label TOcaf_Commands::ModifyBox(Standard_Real x, Standard_Real y, Standard_R return MainLab; } -TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString &Name, TFunction_Logbook &log) +TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString &Name, Handle(TFunction_Logbook) &log) { // Set the name attribute (if it's not null) Handle(TDataStd_Name) myStdName; @@ -253,7 +253,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(1), r); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(2).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -261,7 +261,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(2), h); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(3).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -269,7 +269,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(3), x); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(4).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -277,7 +277,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(4), y); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } MainLab.FindChild(5).FindAttribute(TDataStd_Real::GetID(),curReal); @@ -285,7 +285,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R { TDataStd_Real::Set(MainLab.FindChild(5), z); // Set the label of the attribute as touched for next recomputation - log.SetTouched(curReal->Label()); + log->SetTouched(curReal->Label()); } // Get the TFunction_Function used to create the cylinder @@ -306,7 +306,7 @@ TDF_Label TOcaf_Commands::ModifyCyl(Standard_Real x, Standard_Real y, Standard_R if (myCylDriver->MustExecute(log)) { // Set the cylinder touched, it will be usefull to recompute an object which used this cylinder as attribute - log.SetTouched(MainLab); + log->SetTouched(MainLab); if(myCylDriver->Execute(log)) MessageBoxW (NULL, L"Recompute failed", L"Modify cylinder", MB_ICONEXCLAMATION); } @@ -344,7 +344,7 @@ TDF_Label TOcaf_Commands::Cut(TDF_Label ObjectLab, TDF_Label ToolObjectLab) Handle(TFunction_Function) myFunction = TFunction_Function::Set(L, TOcafFunction_CutDriver::GetID()); // Initialize and execute the cut driver (look at the "Execute()" code) - TFunction_Logbook log; + Handle(TFunction_Logbook) log = TFunction_Logbook::Set(L); Handle(TOcafFunction_CutDriver) myCutDriver; // Find the TOcafFunction_CutDriver in the TFunction_DriverTable using its GUID diff --git a/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.hxx b/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.hxx index 9725a1d05e..694922418c 100755 --- a/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.hxx +++ b/samples/mfc/standard/06_Ocaf/src/TOcaf_Commands.hxx @@ -43,9 +43,9 @@ class TOcaf_Commands { public: TDF_Label Cut( TDF_Label ObjectLab, TDF_Label ToolObjectLab); - TDF_Label ModifyBox(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real w, Standard_Real l, Standard_Real h, const TCollection_ExtendedString& Name, TFunction_Logbook &log); + TDF_Label ModifyBox(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real w, Standard_Real l, Standard_Real h, const TCollection_ExtendedString& Name, Handle(TFunction_Logbook) &log); TDF_Label CreateBox(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real w, Standard_Real l, Standard_Real h, const TCollection_ExtendedString& Name); - TDF_Label ModifyCyl(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString &Name, TFunction_Logbook &log); + TDF_Label ModifyCyl(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString &Name, Handle(TFunction_Logbook) &log); TDF_Label CreateCyl(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString& Name); // Methods PUBLIC diff --git a/src/DNaming/DNaming_BooleanOperationDriver.cxx b/src/DNaming/DNaming_BooleanOperationDriver.cxx index 7eb4fefb36..5e813761a5 100644 --- a/src/DNaming/DNaming_BooleanOperationDriver.cxx +++ b/src/DNaming/DNaming_BooleanOperationDriver.cxx @@ -75,14 +75,14 @@ DNaming_BooleanOperationDriver::DNaming_BooleanOperationDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_BooleanOperationDriver::Validate(TFunction_Logbook&) const +void DNaming_BooleanOperationDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_BooleanOperationDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_BooleanOperationDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -91,7 +91,7 @@ Standard_Boolean DNaming_BooleanOperationDriver::MustExecute(const TFunction_Log //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_BooleanOperationDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_BooleanOperationDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -162,7 +162,7 @@ Standard_Integer DNaming_BooleanOperationDriver::Execute(TFunction_Logbook& theL } if(!anIsDone) return -1; else { - theLog.SetValid(RESPOSITION(aFunction),Standard_True); + theLog->SetValid(RESPOSITION(aFunction),Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_BooleanOperationDriver.hxx b/src/DNaming/DNaming_BooleanOperationDriver.hxx index ebc7ec691a..3754ee237f 100644 --- a/src/DNaming/DNaming_BooleanOperationDriver.hxx +++ b/src/DNaming/DNaming_BooleanOperationDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_BoxDriver.cxx b/src/DNaming/DNaming_BoxDriver.cxx index cbc4ba62e7..6002c2a1ed 100644 --- a/src/DNaming/DNaming_BoxDriver.cxx +++ b/src/DNaming/DNaming_BoxDriver.cxx @@ -44,14 +44,14 @@ DNaming_BoxDriver::DNaming_BoxDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_BoxDriver::Validate(TFunction_Logbook&) const +void DNaming_BoxDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_BoxDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_BoxDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -60,7 +60,7 @@ Standard_Boolean DNaming_BoxDriver::MustExecute(const TFunction_Logbook&) const //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_BoxDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_BoxDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -103,7 +103,7 @@ Standard_Integer DNaming_BoxDriver::Execute(TFunction_Logbook& theLog) const if(!aLocation.IsIdentity()) TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True); - theLog.SetValid(RESPOSITION(aFunction), Standard_True); + theLog->SetValid(RESPOSITION(aFunction), Standard_True); aFunction->SetFailure(DONE); return 0; diff --git a/src/DNaming/DNaming_BoxDriver.hxx b/src/DNaming/DNaming_BoxDriver.hxx index 3749201ef2..ba4f65d07a 100644 --- a/src/DNaming/DNaming_BoxDriver.hxx +++ b/src/DNaming/DNaming_BoxDriver.hxx @@ -48,17 +48,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_CylinderDriver.cxx b/src/DNaming/DNaming_CylinderDriver.cxx index a3def40ddc..d04eed4a68 100644 --- a/src/DNaming/DNaming_CylinderDriver.cxx +++ b/src/DNaming/DNaming_CylinderDriver.cxx @@ -51,14 +51,14 @@ DNaming_CylinderDriver::DNaming_CylinderDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_CylinderDriver::Validate(TFunction_Logbook&) const +void DNaming_CylinderDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_CylinderDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_CylinderDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -67,7 +67,7 @@ Standard_Boolean DNaming_CylinderDriver::MustExecute(const TFunction_Logbook&) c //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_CylinderDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_CylinderDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -155,8 +155,7 @@ Standard_Integer DNaming_CylinderDriver::Execute(TFunction_Logbook& theLog) cons if(!aLocation.IsIdentity()) TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True); - - theLog.SetValid(RESPOSITION(aFunction), Standard_True); + theLog->SetValid(RESPOSITION(aFunction), Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_CylinderDriver.hxx b/src/DNaming/DNaming_CylinderDriver.hxx index 56e4d5bc3f..5c3ac22970 100644 --- a/src/DNaming/DNaming_CylinderDriver.hxx +++ b/src/DNaming/DNaming_CylinderDriver.hxx @@ -48,17 +48,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_FilletDriver.cxx b/src/DNaming/DNaming_FilletDriver.cxx index 003bc04acd..002eb079e1 100644 --- a/src/DNaming/DNaming_FilletDriver.cxx +++ b/src/DNaming/DNaming_FilletDriver.cxx @@ -52,14 +52,14 @@ DNaming_FilletDriver::DNaming_FilletDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_FilletDriver::Validate(TFunction_Logbook&) const +void DNaming_FilletDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_FilletDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_FilletDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -68,7 +68,7 @@ Standard_Boolean DNaming_FilletDriver::MustExecute(const TFunction_Logbook&) con //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_FilletDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_FilletDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -160,7 +160,7 @@ Standard_Integer DNaming_FilletDriver::Execute(TFunction_Logbook& theLog) const // Naming LoadNamingDS(RESPOSITION(aFunction), aMkFillet, aCONTEXT); - theLog.SetValid(RESPOSITION(aFunction),Standard_True); + theLog->SetValid(RESPOSITION(aFunction),Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_FilletDriver.hxx b/src/DNaming/DNaming_FilletDriver.hxx index 05aa8f014c..9a172501b8 100644 --- a/src/DNaming/DNaming_FilletDriver.hxx +++ b/src/DNaming/DNaming_FilletDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_Line3DDriver.cxx b/src/DNaming/DNaming_Line3DDriver.cxx index 3b03187e38..370bd285e4 100644 --- a/src/DNaming/DNaming_Line3DDriver.cxx +++ b/src/DNaming/DNaming_Line3DDriver.cxx @@ -64,14 +64,14 @@ DNaming_Line3DDriver::DNaming_Line3DDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_Line3DDriver::Validate(TFunction_Logbook&) const +void DNaming_Line3DDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_Line3DDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_Line3DDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -80,7 +80,7 @@ Standard_Boolean DNaming_Line3DDriver::MustExecute(const TFunction_Logbook&) con //function : Execute //purpose : Execute the function //======================================================================= -Standard_Integer DNaming_Line3DDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_Line3DDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -185,7 +185,7 @@ Standard_Integer DNaming_Line3DDriver::Execute(TFunction_Logbook& theLog) const if(!aLocation.IsIdentity()) TNaming::Displace(aResultLabel, aLocation, Standard_True); - theLog.SetValid(aResultLabel, Standard_True); + theLog->SetValid(aResultLabel, Standard_True); aFunction->SetFailure(DONE); return 0; diff --git a/src/DNaming/DNaming_Line3DDriver.hxx b/src/DNaming/DNaming_Line3DDriver.hxx index 956d692bcd..9cbbddbaf0 100644 --- a/src/DNaming/DNaming_Line3DDriver.hxx +++ b/src/DNaming/DNaming_Line3DDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_ModelingCommands.cxx b/src/DNaming/DNaming_ModelingCommands.cxx index 366df6c144..475d1987e0 100644 --- a/src/DNaming/DNaming_ModelingCommands.cxx +++ b/src/DNaming/DNaming_ModelingCommands.cxx @@ -455,18 +455,12 @@ static Standard_Integer DNaming_BoxDZ (Draw_Interpretor& theDI, return 1; } -//======================================================================= -static TFunction_Logbook& GetLogBook () -{ - static TFunction_Logbook myLog; - return myLog; -} //======================================================================= //function : Compute //purpose : Performs the calling to a driver with the given Function ID. //======================================================================= static Standard_Integer ComputeFunction(const Handle(TFunction_Function)& theFun, - TFunction_Logbook& theLog) + Handle(TFunction_Logbook)& theLog) { Handle(TFunction_DriverTable) aTable = TFunction_DriverTable::Get(); Handle(TFunction_Driver) aDriver; @@ -506,6 +500,7 @@ static Standard_Integer DNaming_SolveFlatFrom (Draw_Interpretor& /*theDI*/, #ifdef OCCT_DEBUG cout << "DNaming_SolveFlatFrom: Father label = " << entry << endl; #endif + Handle(TFunction_Logbook) logbook = TFunction_Logbook::Set(FatherLab); Standard_Boolean found(Standard_False); TDF_ChildIterator it(FatherLab, Standard_False); for(;it.More(); it.Next()) { @@ -526,7 +521,9 @@ static Standard_Integer DNaming_SolveFlatFrom (Draw_Interpretor& /*theDI*/, else { TDF_Tool::Entry(funLabel, entry); try { - Standard_Integer aRes = ComputeFunction(aFun, GetLogBook()); + // We clear the logbook because the execution starts not from the begining of the function list (some functions ar skipped). + logbook->Clear(); + Standard_Integer aRes = ComputeFunction(aFun, logbook); if(aRes != 0) { cout << "DNaming_SolveFlatFrom: Driver failed at label = " << entry << endl; return 1; @@ -558,13 +555,14 @@ static Standard_Integer DNaming_InitLogBook (Draw_Interpretor& /*theDI*/, Handle(TDocStd_Document) aDoc; Standard_CString aDocS(theArg[1]); if (!DDocStd::GetDocument(aDocS, aDoc)) return 1; - if(GetLogBook().IsEmpty()) { + Handle(TFunction_Logbook) logbook = TFunction_Logbook::Set(aDoc->Main()); + if(logbook->IsEmpty()) { #ifdef OCCT_DEBUG cout << "DNaming_InitLogBook : is empty" <Clear(); #ifdef OCCT_DEBUG cout << "DNaming_InitLogBook : cleaned" <Main()); + if(logbook->IsEmpty()) cout << "DNaming_CheckLogBook : is empty" <GetValid(); TDF_MapIteratorOfLabelMap it(aMap); TCollection_AsciiString entry; cout << "DNaming_CheckLogBook : LogBook current state:" <. //======================================================================= -void DNaming_PointDriver::Validate(TFunction_Logbook&) const +void DNaming_PointDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_PointDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_PointDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -63,7 +63,7 @@ Standard_Boolean DNaming_PointDriver::MustExecute(const TFunction_Logbook&) cons //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_PointDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_PointDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -117,7 +117,7 @@ Standard_Integer DNaming_PointDriver::Execute(TFunction_Logbook& theLog) const if(!aLocation.IsIdentity()) TNaming::Displace(aResultLabel, aLocation, Standard_True); - theLog.SetValid(aResultLabel, Standard_True); + theLog->SetValid(aResultLabel, Standard_True); aFunction->SetFailure(DONE); return 0; diff --git a/src/DNaming/DNaming_PointDriver.hxx b/src/DNaming/DNaming_PointDriver.hxx index d6010bad67..54b6c625be 100644 --- a/src/DNaming/DNaming_PointDriver.hxx +++ b/src/DNaming/DNaming_PointDriver.hxx @@ -46,17 +46,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_PrismDriver.cxx b/src/DNaming/DNaming_PrismDriver.cxx index b19d34ae3a..85ad6a35f6 100644 --- a/src/DNaming/DNaming_PrismDriver.cxx +++ b/src/DNaming/DNaming_PrismDriver.cxx @@ -66,14 +66,14 @@ DNaming_PrismDriver::DNaming_PrismDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_PrismDriver::Validate(TFunction_Logbook&) const +void DNaming_PrismDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyses in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_PrismDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_PrismDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -94,7 +94,7 @@ static void Write(const TopoDS_Shape& shape, //function : Execute //purpose : Executes the function //======================================================================= -Standard_Integer DNaming_PrismDriver::Execute(TFunction_Logbook& theLog) const { +Standard_Integer DNaming_PrismDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if(aFunction.IsNull()) return -1; @@ -206,7 +206,7 @@ Standard_Integer DNaming_PrismDriver::Execute(TFunction_Logbook& theLog) const { if(!aLocation.IsIdentity()) TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True); - theLog.SetValid(RESPOSITION(aFunction),Standard_True); + theLog->SetValid(RESPOSITION(aFunction),Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_PrismDriver.hxx b/src/DNaming/DNaming_PrismDriver.hxx index 55436d91c8..27ae8ad114 100644 --- a/src/DNaming/DNaming_PrismDriver.hxx +++ b/src/DNaming/DNaming_PrismDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_RevolutionDriver.cxx b/src/DNaming/DNaming_RevolutionDriver.cxx index 9d13a8d975..62fa95bbe0 100644 --- a/src/DNaming/DNaming_RevolutionDriver.cxx +++ b/src/DNaming/DNaming_RevolutionDriver.cxx @@ -70,14 +70,14 @@ DNaming_RevolutionDriver::DNaming_RevolutionDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_RevolutionDriver::Validate(TFunction_Logbook&) const +void DNaming_RevolutionDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyses in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_RevolutionDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_RevolutionDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -86,7 +86,7 @@ Standard_Boolean DNaming_RevolutionDriver::MustExecute(const TFunction_Logbook&) //function : Execute //purpose : Executes the function //======================================================================= -Standard_Integer DNaming_RevolutionDriver::Execute(TFunction_Logbook& theLog) const { +Standard_Integer DNaming_RevolutionDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(), aFunction); if(aFunction.IsNull()) return -1; @@ -259,7 +259,7 @@ Standard_Integer DNaming_RevolutionDriver::Execute(TFunction_Logbook& theLog) co if(!aLocation.IsIdentity()) TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True); - theLog.SetValid(RESPOSITION(aFunction),Standard_True); + theLog->SetValid(RESPOSITION(aFunction),Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_RevolutionDriver.hxx b/src/DNaming/DNaming_RevolutionDriver.hxx index 20b9f3a86c..6e00e0f9a8 100644 --- a/src/DNaming/DNaming_RevolutionDriver.hxx +++ b/src/DNaming/DNaming_RevolutionDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_SelectionDriver.cxx b/src/DNaming/DNaming_SelectionDriver.cxx index ad1e152874..7f5846dfac 100644 --- a/src/DNaming/DNaming_SelectionDriver.cxx +++ b/src/DNaming/DNaming_SelectionDriver.cxx @@ -45,7 +45,7 @@ DNaming_SelectionDriver::DNaming_SelectionDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_SelectionDriver::Validate(TFunction_Logbook& ) const +void DNaming_SelectionDriver::Validate(Handle(TFunction_Logbook)& ) const {} //======================================================================= @@ -53,7 +53,7 @@ void DNaming_SelectionDriver::Validate(TFunction_Logbook& ) const //purpose : Analyse in if the loaded function must be // executed (i.e.arguments are modified) or not. //======================================================================= -Standard_Boolean DNaming_SelectionDriver::MustExecute(const TFunction_Logbook& ) const { +Standard_Boolean DNaming_SelectionDriver::MustExecute(const Handle(TFunction_Logbook)& ) const { return Standard_True; } @@ -82,7 +82,7 @@ static void Write(const TopoDS_Shape& shape, #include #include -Standard_Integer DNaming_SelectionDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_SelectionDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -105,7 +105,7 @@ Standard_Integer DNaming_SelectionDriver::Execute(TFunction_Logbook& theLog) con TNaming_Selector aSelector(aRLabel); TDF_LabelMap aMap; - aMap = theLog.ChangeValid(); + theLog->GetValid(aMap); #ifdef OCCT_DEBUG cout <<"#E_DNaming_SelectionDriver:: Valid Label Map:"<SetValid(aRLabel); Handle(TNaming_NamedShape) aNS; if(!aRLabel.FindAttribute(TNaming_NamedShape::GetID(),aNS)) { cout <<"%%%WARNING: DNaming_SelectionDriver::NamedShape is not found"< if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_SphereDriver.cxx b/src/DNaming/DNaming_SphereDriver.cxx index 1c8366ee6a..7e0aea74d7 100644 --- a/src/DNaming/DNaming_SphereDriver.cxx +++ b/src/DNaming/DNaming_SphereDriver.cxx @@ -55,14 +55,14 @@ DNaming_SphereDriver::DNaming_SphereDriver() //function : Validate //purpose : Validates labels of a function in //======================================================================= -void DNaming_SphereDriver::Validate(TFunction_Logbook&) const +void DNaming_SphereDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyses in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_SphereDriver::MustExecute(const TFunction_Logbook&) const { +Standard_Boolean DNaming_SphereDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -70,7 +70,7 @@ Standard_Boolean DNaming_SphereDriver::MustExecute(const TFunction_Logbook&) con //function : Execute //purpose : Executes the function //======================================================================= -Standard_Integer DNaming_SphereDriver::Execute(TFunction_Logbook& theLog) const { +Standard_Integer DNaming_SphereDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); if(aFunction.IsNull()) return -1; @@ -127,7 +127,7 @@ Standard_Integer DNaming_SphereDriver::Execute(TFunction_Logbook& theLog) const if(!aLocation.IsIdentity()) TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True); - theLog.SetValid(RESPOSITION(aFunction), Standard_True); + theLog->SetValid(RESPOSITION(aFunction), Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_SphereDriver.hxx b/src/DNaming/DNaming_SphereDriver.hxx index 5038f94baf..5715be12d3 100644 --- a/src/DNaming/DNaming_SphereDriver.hxx +++ b/src/DNaming/DNaming_SphereDriver.hxx @@ -48,17 +48,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/DNaming/DNaming_TransformationDriver.cxx b/src/DNaming/DNaming_TransformationDriver.cxx index 698b09b946..5f8761a0a1 100644 --- a/src/DNaming/DNaming_TransformationDriver.cxx +++ b/src/DNaming/DNaming_TransformationDriver.cxx @@ -86,14 +86,14 @@ DNaming_TransformationDriver::DNaming_TransformationDriver() //function : Validate //purpose : Validates labels of a function in . //======================================================================= -void DNaming_TransformationDriver::Validate(TFunction_Logbook&) const +void DNaming_TransformationDriver::Validate(Handle(TFunction_Logbook)&) const {} //======================================================================= //function : MustExecute //purpose : Analyse in if the loaded function must be executed //======================================================================= -Standard_Boolean DNaming_TransformationDriver::MustExecute(const TFunction_Logbook&) const +Standard_Boolean DNaming_TransformationDriver::MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; } @@ -103,7 +103,7 @@ Standard_Boolean DNaming_TransformationDriver::MustExecute(const TFunction_Logbo //function : Execute //purpose : Execute the function and push in the impacted labels //======================================================================= -Standard_Integer DNaming_TransformationDriver::Execute(TFunction_Logbook& theLog) const +Standard_Integer DNaming_TransformationDriver::Execute(Handle(TFunction_Logbook)& theLog) const { Handle(TFunction_Function) aFunction; Label().FindAttribute(TFunction_Function::GetID(),aFunction); @@ -178,7 +178,7 @@ Standard_Integer DNaming_TransformationDriver::Execute(TFunction_Logbook& theLog // Naming LoadNamingDS(RESPOSITION(aFunction), aContextNS, aTransformation); - theLog.SetValid(RESPOSITION(aFunction),Standard_True); + theLog->SetValid(RESPOSITION(aFunction),Standard_True); aFunction->SetFailure(DONE); return 0; } diff --git a/src/DNaming/DNaming_TransformationDriver.hxx b/src/DNaming/DNaming_TransformationDriver.hxx index 0756dcdc58..1231705804 100644 --- a/src/DNaming/DNaming_TransformationDriver.hxx +++ b/src/DNaming/DNaming_TransformationDriver.hxx @@ -49,17 +49,17 @@ public: //! the valid label scope. //! execution of function //! ====================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Analyse in if the loaded function must be executed //! (i.e.arguments are modified) or not. //! If the Function label itself is modified, the function must //! be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; //! Execute the function and push in the impacted //! labels (see method SetImpacted). - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& theLog) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE; diff --git a/src/TFunction/TFunction_Driver.cxx b/src/TFunction/TFunction_Driver.cxx index a3aa5bdd20..3e4859a7a5 100644 --- a/src/TFunction/TFunction_Driver.cxx +++ b/src/TFunction/TFunction_Driver.cxx @@ -47,14 +47,15 @@ void TFunction_Driver::Init(const TDF_Label& L) //purpose : Validates labels of a function //======================================================================= -void TFunction_Driver::Validate(TFunction_Logbook& log) const +void TFunction_Driver::Validate(Handle(TFunction_Logbook)& log) const { TDF_LabelList res; Results(res); + TDF_ListIteratorOfLabelList itr(res); for (; itr.More(); itr.Next()) { - log.SetValid(itr.Value(), Standard_True); + log->SetValid(itr.Value(), Standard_True); } } @@ -64,15 +65,16 @@ void TFunction_Driver::Validate(TFunction_Logbook& log) const //purpose : Analyzes the labels in the logbook //======================================================================= -Standard_Boolean TFunction_Driver::MustExecute(const TFunction_Logbook& log) const +Standard_Boolean TFunction_Driver::MustExecute(const Handle(TFunction_Logbook)& log) const { // Check modification of arguments. TDF_LabelList args; Arguments(args); + TDF_ListIteratorOfLabelList itr(args); for (; itr.More(); itr.Next()) { - if (log.IsModified(itr.Value())) + if (log->IsModified(itr.Value())) return Standard_True; } return Standard_False; diff --git a/src/TFunction/TFunction_Driver.hxx b/src/TFunction/TFunction_Driver.hxx index 8bfd9a26a4..9c0b5555b5 100644 --- a/src/TFunction/TFunction_Driver.hxx +++ b/src/TFunction/TFunction_Driver.hxx @@ -62,18 +62,18 @@ public: //! method even if the function is not executed. //! execution of function //! ===================== - Standard_EXPORT virtual void Validate (TFunction_Logbook& log) const; + Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& log) const; //! Analyzes the labels in the logbook log. //! Returns true if attributes have been modified. //! If the function label itself has been modified, the function must be executed. - Standard_EXPORT virtual Standard_Boolean MustExecute (const TFunction_Logbook& log) const; + Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& log) const; //! Executes the function in this function driver and //! puts the impacted labels in the logbook log. //! arguments & results of functions //! ================================ - Standard_EXPORT virtual Standard_Integer Execute (TFunction_Logbook& log) const = 0; + Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& log) const = 0; //! The method fills-in the list by labels, //! where the arguments of the function are located. diff --git a/src/TFunction/TFunction_IFunction.cxx b/src/TFunction/TFunction_IFunction.cxx index a2edd49969..b2eb0ecbcc 100644 --- a/src/TFunction/TFunction_IFunction.cxx +++ b/src/TFunction/TFunction_IFunction.cxx @@ -406,7 +406,7 @@ const TFunction_DoubleMapOfIntegerLabel& TFunction_IFunction::GetAllFunctions() //purpose : Returns the Logbook. //======================================================================= -TFunction_Logbook& TFunction_IFunction::GetLogbook() const +Handle(TFunction_Logbook) TFunction_IFunction::GetLogbook() const { return TFunction_Scope::Set(myLabel)->GetLogbook(); } diff --git a/src/TFunction/TFunction_IFunction.hxx b/src/TFunction/TFunction_IFunction.hxx index 10752c046a..b469a68d20 100644 --- a/src/TFunction/TFunction_IFunction.hxx +++ b/src/TFunction/TFunction_IFunction.hxx @@ -97,7 +97,7 @@ public: Standard_EXPORT const TFunction_DoubleMapOfIntegerLabel& GetAllFunctions() const; //! Returns the Logbook - keeper of modifications. - Standard_EXPORT TFunction_Logbook& GetLogbook() const; + Standard_EXPORT Handle(TFunction_Logbook) GetLogbook() const; //! Returns a driver of the function. Standard_EXPORT Handle(TFunction_Driver) GetDriver (const Standard_Integer thread = 0) const; diff --git a/src/TFunction/TFunction_Logbook.cxx b/src/TFunction/TFunction_Logbook.cxx index 0f04ee5f92..81d197afce 100644 --- a/src/TFunction/TFunction_Logbook.cxx +++ b/src/TFunction/TFunction_Logbook.cxx @@ -21,8 +21,46 @@ #include #include #include +#include #include #include +#include + +//======================================================================= +//function : GetID +//purpose : Static method to get an ID +//======================================================================= +const Standard_GUID& TFunction_Logbook::GetID() +{ + static Standard_GUID TFunction_LogbookID("CF519724-5CA4-4B90-835F-8919BE1DDE4B"); + return TFunction_LogbookID; +} + +//======================================================================= +//function : Set +//purpose : Finds or creates a Scope attribute +//======================================================================= + +Handle(TFunction_Logbook) TFunction_Logbook::Set(const TDF_Label& Access) +{ + Handle(TFunction_Logbook) S; + if (!Access.Root().FindAttribute(TFunction_Logbook::GetID(), S)) + { + S = new TFunction_Logbook(); + Access.Root().AddAttribute(S); + } + return S; +} + +//======================================================================= +//function : ID +//purpose : Returns GUID of the function +//======================================================================= + +const Standard_GUID& TFunction_Logbook::ID() const +{ + return GetID(); +} //======================================================================= //function : TFunction_Logbook @@ -38,9 +76,13 @@ TFunction_Logbook::TFunction_Logbook():isDone(Standard_False) void TFunction_Logbook::Clear() { - myTouched.Clear(); - myImpacted.Clear(); - myValid.Clear(); + if (!IsEmpty()) + { + Backup(); + myTouched.Clear(); + myImpacted.Clear(); + myValid.Clear(); + } } //======================================================================= @@ -59,15 +101,22 @@ Standard_Boolean TFunction_Logbook::IsEmpty () const //======================================================================= Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L, - const Standard_Boolean WithChildren) const + const Standard_Boolean WithChildren) const { - if (myTouched.Contains(L)) return Standard_True; - if (myImpacted.Contains(L)) return Standard_True; - if (WithChildren) { + if (myTouched.Contains(L)) + return Standard_True; + if (myImpacted.Contains(L)) + return Standard_True; + if (WithChildren) + { TDF_ChildIterator itr(L); for (; itr.More(); itr.Next()) + { if (IsModified(itr.Value(), Standard_True)) - return Standard_True; + { + return Standard_True; + } + } } return Standard_False; } @@ -78,34 +127,169 @@ Standard_Boolean TFunction_Logbook::IsModified(const TDF_Label& L, //======================================================================= void TFunction_Logbook::SetValid(const TDF_Label& L, - const Standard_Boolean WithChildren) + const Standard_Boolean WithChildren) { + Backup(); myValid.Add(L); - if (WithChildren) { + if (WithChildren) + { TDF_ChildIterator itr(L, Standard_True); - for (; itr.More(); itr.Next()) { + for (; itr.More(); itr.Next()) + { myValid.Add(itr.Value()); } } } +void TFunction_Logbook::SetValid(const TDF_LabelMap& Ls) +{ + Backup(); + TDF_MapIteratorOfLabelMap itrm(Ls); + for (; itrm.More(); itrm.Next()) + { + const TDF_Label& L = itrm.Key(); + myValid.Add(L); + } +} + //======================================================================= //function : SetImpacted //purpose : //======================================================================= void TFunction_Logbook::SetImpacted(const TDF_Label& L, - const Standard_Boolean WithChildren) + const Standard_Boolean WithChildren) { + Backup(); myImpacted.Add(L); - if (WithChildren) { + if (WithChildren) + { TDF_ChildIterator itr(L, Standard_True); - for (; itr.More(); itr.Next()) { + for (; itr.More(); itr.Next()) + { myImpacted.Add(itr.Value()); } } } +//======================================================================= +//function : GetValid +//purpose : Returns valid labels. +//======================================================================= + +void TFunction_Logbook::GetValid(TDF_LabelMap& Ls) const +{ + // Copy valid labels. + TDF_MapIteratorOfLabelMap itrm(myValid); + for (; itrm.More(); itrm.Next()) + { + const TDF_Label& L = itrm.Key(); + Ls.Add(L); + } +} + +//======================================================================= +//function : Restore +//purpose : Undos (and redos) the attribute. +//======================================================================= + +void TFunction_Logbook::Restore(const Handle(TDF_Attribute)& other) +{ + Handle(TFunction_Logbook) logbook = Handle(TFunction_Logbook)::DownCast(other); + + // Status. + isDone = logbook->isDone; + + // Valid labels + TDF_MapIteratorOfLabelMap itrm; + for (itrm.Initialize(logbook->myValid); itrm.More(); itrm.Next()) + { + myValid.Add(itrm.Key()); + } + // Touched labels + for (itrm.Initialize(logbook->myTouched); itrm.More(); itrm.Next()) + { + myTouched.Add(itrm.Key()); + } + // Impacted labels + for (itrm.Initialize(logbook->myImpacted); itrm.More(); itrm.Next()) + { + myImpacted.Add(itrm.Key()); + } +} + +//======================================================================= +//function : Paste +//purpose : Method for Copy mechanism +//======================================================================= + +void TFunction_Logbook::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TFunction_Logbook) logbook = Handle(TFunction_Logbook)::DownCast(into); + + // Status. + logbook->isDone = isDone; + + // Touched. + logbook->myTouched.Clear(); + TDF_MapIteratorOfLabelMap itr(myTouched); + for (; itr.More(); itr.Next()) + { + const TDF_Label& L = itr.Value(); + if (!L.IsNull()) + { + TDF_Label relocL; + if (RT->HasRelocation(L, relocL)) + logbook->myTouched.Add(relocL); + else + logbook->myTouched.Add(L); + } + } + + // Impacted. + logbook->myImpacted.Clear(); + itr.Initialize(myImpacted); + for (; itr.More(); itr.Next()) + { + const TDF_Label& L = itr.Value(); + if (!L.IsNull()) + { + TDF_Label relocL; + if (RT->HasRelocation(L, relocL)) + logbook->myImpacted.Add(relocL); + else + logbook->myImpacted.Add(L); + } + } + + // Valid. + logbook->myValid.Clear(); + itr.Initialize(myValid); + for (; itr.More(); itr.Next()) + { + const TDF_Label& L = itr.Value(); + if (!L.IsNull()) + { + TDF_Label relocL; + if (RT->HasRelocation(L, relocL)) + logbook->myValid.Add(relocL); + else + logbook->myValid.Add(L); + } + } +} + +//======================================================================= +//function : NewEmpty +//purpose : Returns new empty graph node attribute +//======================================================================= + +Handle(TDF_Attribute) TFunction_Logbook::NewEmpty() const +{ + return new TFunction_Logbook(); +} + //======================================================================= //function : Dump //purpose : Dump of modifications @@ -118,17 +302,20 @@ Standard_OStream& TFunction_Logbook::Dump(Standard_OStream& stream) const stream<<"Done = "< #include +#include #include #include class TDF_Label; +class Standard_GUID; +class TFunction_Logbook; +class TDF_Attribute; +class TDF_RelocationTable; +class TFunction_Logbook; +DEFINE_STANDARD_HANDLE(TFunction_Logbook, TDF_Attribute) //! This class contains information which is written and //! read during the solving process. Information is divided @@ -34,25 +41,32 @@ class TDF_Label; //! * Touched Labels (modified by the end user), //! * Impacted Labels (modified during execution of the function), //! * Valid Labels (within the valid label scope). -class TFunction_Logbook +class TFunction_Logbook : public TDF_Attribute { public: - - DEFINE_STANDARD_ALLOC - - //! next methods are solving declaration - //! =================================== + //! Finds or Creates a TFunction_Logbook attribute at the root label accessed by . + //! Returns the attribute. + Standard_EXPORT static Handle(TFunction_Logbook) Set(const TDF_Label& Access); + + //! Returns the GUID for logbook attribute. + Standard_EXPORT static const Standard_GUID& GetID(); + + + //! The methods manipulating the data + //! (touched, impacted and valid labels) + // ==================================== + + //! Constructor (empty). Standard_EXPORT TFunction_Logbook(); //! Clears this logbook to its default, empty state. Standard_EXPORT void Clear(); - Standard_EXPORT Standard_Boolean IsEmpty() const; //! Sets the label L as a touched label in this logbook. //! In other words, L is understood to have been modified by the end user. - void SetTouched (const TDF_Label& L); + Standard_EXPORT void SetTouched (const TDF_Label& L); //! Sets the label L as an impacted label in this logbook. //! This method is called by execution of the function driver. @@ -60,62 +74,59 @@ public: //! Sets the label L as a valid label in this logbook. Standard_EXPORT void SetValid (const TDF_Label& L, const Standard_Boolean WithChildren = Standard_False); - - TDF_LabelMap& ChangeValid(); + Standard_EXPORT void SetValid (const TDF_LabelMap& Ls); //! Returns True if the label L is touched or impacted. This method //! is called by . //! If is set to true, the method checks //! all the sublabels of too. - //! next method to consult solving result - //! ===================================== Standard_EXPORT Standard_Boolean IsModified (const TDF_Label& L, const Standard_Boolean WithChildren = Standard_False) const; - //! Returns the map of touched labels in this logbook. //! A touched label is the one modified by the end user. - const TDF_LabelMap& GetTouched() const; - + Standard_EXPORT const TDF_LabelMap& GetTouched() const; //! Returns the map of impacted labels contained in this logbook. - const TDF_LabelMap& GetImpacted() const; + Standard_EXPORT const TDF_LabelMap& GetImpacted() const; //! Returns the map of valid labels in this logbook. - const TDF_LabelMap& GetValid() const; + Standard_EXPORT const TDF_LabelMap& GetValid() const; + Standard_EXPORT void GetValid(TDF_LabelMap& Ls) const; - //! Sets if the execution failed - void Done (const Standard_Boolean status); + //! Sets status of execution. + Standard_EXPORT void Done (const Standard_Boolean status); - Standard_Boolean IsDone() const; + //! Returns status of execution. + Standard_EXPORT Standard_Boolean IsDone() const; + + + //! The methods inherited from TDF_Attribute + // ======================================== + + //! Returns the ID of the attribute. + Standard_EXPORT const Standard_GUID& ID() const; - Standard_EXPORT Standard_OStream& Dump (Standard_OStream& stream) const; - - - - -protected: - - - + //! Undos (and redos) the attribute. + Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& with); + + //! Pastes the attribute to another label. + Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const; + + //! Returns a new empty instance of the attribute. + Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; + + //! Prints th data of the attributes (touched, impacted and valid labels). + Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE; private: - - TDF_LabelMap myTouched; TDF_LabelMap myImpacted; TDF_LabelMap myValid; Standard_Boolean isDone; - - }; - #include - - - - #endif // _TFunction_Logbook_HeaderFile diff --git a/src/TFunction/TFunction_Logbook.lxx b/src/TFunction/TFunction_Logbook.lxx index 6b6d9fbd9e..b84c7326fc 100644 --- a/src/TFunction/TFunction_Logbook.lxx +++ b/src/TFunction/TFunction_Logbook.lxx @@ -16,7 +16,11 @@ inline void TFunction_Logbook::SetTouched(const TDF_Label& L) { - myTouched.Add(L); + if (!myTouched.Contains(L)) + { + Backup(); + myTouched.Add(L); + } } inline const TDF_LabelMap& TFunction_Logbook::GetTouched() const @@ -29,11 +33,6 @@ inline const TDF_LabelMap& TFunction_Logbook::GetImpacted() const return myImpacted; } -inline TDF_LabelMap& TFunction_Logbook::ChangeValid() -{ - return myValid; -} - inline const TDF_LabelMap& TFunction_Logbook::GetValid() const { return myValid; @@ -41,7 +40,11 @@ inline const TDF_LabelMap& TFunction_Logbook::GetValid() const inline void TFunction_Logbook::Done(const Standard_Boolean status) { - isDone = status; + if (isDone != status) + { + Backup(); + isDone = status; + } } inline Standard_Boolean TFunction_Logbook::IsDone() const diff --git a/src/TFunction/TFunction_Scope.cxx b/src/TFunction/TFunction_Scope.cxx index e7730383e7..95e56bec87 100644 --- a/src/TFunction/TFunction_Scope.cxx +++ b/src/TFunction/TFunction_Scope.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include //======================================================================= @@ -175,9 +174,11 @@ const TDF_Label& TFunction_Scope::GetFunction(const Standard_Integer ID) const //purpose : Returns the Logbook. //======================================================================= -TFunction_Logbook& TFunction_Scope::GetLogbook() +Handle(TFunction_Logbook) TFunction_Scope::GetLogbook() const { - return myLogbook; + Handle(TFunction_Logbook) logbook; + FindAttribute(TFunction_Logbook::GetID(), logbook); + return logbook; } //======================================================================= @@ -192,26 +193,6 @@ void TFunction_Scope::Restore(const Handle(TDF_Attribute)& other) // Functions myFunctions = S->myFunctions; // copying... myFreeID = S->myFreeID; - - // Logbook - myLogbook.Clear(); - TDF_MapIteratorOfLabelMap itrm; - // Valid labels - for (itrm.Initialize(S->myLogbook.GetValid()); itrm.More(); itrm.Next()) - { - myLogbook.SetValid(itrm.Key(), Standard_False); - } - // Touched labels - for (itrm.Initialize(S->myLogbook.GetTouched()); itrm.More(); itrm.Next()) - { - myLogbook.SetTouched(itrm.Key()); - } - // Impacted labels - for (itrm.Initialize(S->myLogbook.GetImpacted()); itrm.More(); itrm.Next()) - { - myLogbook.SetImpacted(itrm.Key(), Standard_False); - } - myLogbook.Done(S->myLogbook.IsDone()); } //======================================================================= diff --git a/src/TFunction/TFunction_Scope.hxx b/src/TFunction/TFunction_Scope.hxx index 73bbb86180..faf49571f5 100644 --- a/src/TFunction/TFunction_Scope.hxx +++ b/src/TFunction/TFunction_Scope.hxx @@ -83,7 +83,7 @@ public: //! Returns the Logbook used in TFunction_Driver methods. //! Implementation of Attribute methods //! =================================== - Standard_EXPORT TFunction_Logbook& GetLogbook(); + Standard_EXPORT Handle(TFunction_Logbook) GetLogbook() const; Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; @@ -120,7 +120,6 @@ private: TFunction_DoubleMapOfIntegerLabel myFunctions; - TFunction_Logbook myLogbook; Standard_Integer myFreeID;