]> OCCT Git - occt-wok.git/commitdiff
No comments
authorcas <cas@opencascade.com>
Wed, 26 Apr 2000 18:32:56 +0000 (18:32 +0000)
committercas <cas@opencascade.com>
Wed, 26 Apr 2000 18:32:56 +0000 (18:32 +0000)
src/WOKernel/WOKernel_Workbench.cxx
src/WOKernel/WOKernel_Workshop.cxx

index bdebabe8bb08759e87ad64e73b20a4aed2a3a430..0aeb9f70628fa6decd0b4338d3f34a1e45bdbc1a 100755 (executable)
@@ -163,31 +163,27 @@ Handle(TColStd_HSequenceOfHAsciiString) WOKernel_Workbench::GetUnitList()
 //function : Open
 //purpose  : opens a Wb
 //=======================================================================
-void WOKernel_Workbench::Open()
-{
-  if(IsOpened()) return;
-  {
+void WOKernel_Workbench :: Open () {
 
   Handle(WOKernel_Workbench) afather;
if (  IsOpened ()  ) return;
 
+ Handle( WOKernel_Workbench ) afather;
 
-    // Ouverture des wb ancetres d'abord (recusivement)
-    if(!Father().IsNull()) 
-      {
-       afather= Session()->GetWorkbench(Father()); 
-       afather->Open();
+ if (  !Father ().IsNull ()  ) {
 
-      }
+  afather = Session () -> GetWorkbench (  Father ()  );
+
+  if (  !afather.IsNull ()  ) afather -> Open ();
 
+ }  //end if
     
   GetParams();
GetParams ();
 
-    // Ouverture Nesting
-    WOKernel_UnitNesting::Open();
+ WOKernel_UnitNesting :: Open ();
 
   SetOpened();
-  }
-}
SetOpened ();
+
+}  // end WOKernel_Workbench :: Open
 
 //=======================================================================
 //function : Close
index 72c9a575c87b4da158813cd91af5b77329b990e4..c4e5019f199c31dc188ebeb4455665f5657c3569 100755 (executable)
@@ -381,37 +381,58 @@ Handle(TColStd_HSequenceOfHAsciiString) WOKernel_Workshop::ParcelsInUse() const
 //function : DumpWorkbenchList
 //purpose  : Updates Workbench list
 //=======================================================================
-void WOKernel_Workshop::DumpWorkbenchList() const 
-{
-  Standard_Integer i;
-  Handle(WOKernel_File) wblistfile;
+void WOKernel_Workshop :: DumpWorkbenchList () const {
 
-  wblistfile = new WOKernel_File(this, GetFileType("WorkbenchListFile"));
-  wblistfile->GetPath();
+ Standard_Integer                 i;
+ Handle( WOKernel_File ) wblistfile;
+
+ wblistfile = new WOKernel_File (  this, GetFileType ( "WorkbenchListFile" )  );
+
+ wblistfile -> GetPath ();
+
+ Handle( TCollection_HAsciiString ) aNewPath  = new TCollection_HAsciiString (
+                                                     wblistfile -> Path () -> Name ()
+                                                    );
+ Handle( TCollection_HAsciiString ) anOldPath = new TCollection_HAsciiString ( aNewPath );
 
-  ofstream astream(wblistfile->Path()->Name()->ToCString(), ios::out);
+ aNewPath -> AssignCat ( ".bak" );
+
+ wblistfile -> Path () -> MoveTo (
+                           new WOKUtils_Path ( aNewPath )
+                          );
+
+ ofstream astream (  anOldPath -> ToCString (), ios :: out  );
   
-  if(!astream)
-    {
-      ErrorMsg << "WOKernel_Workshop::AddWorkbench" << "Could not open " << wblistfile->Path()->Name() << endm;
-      Standard_ProgramError::Raise("WOKernel_Workshop::AddWorkbench");
-    }
+ if ( !astream ) {
+
+  ErrorMsg << "WOKernel_Workshop::AddWorkbench"
+           << "Could not open "
+           << wblistfile -> Path () -> Name ()
+           << endm;
+  Standard_ProgramError :: Raise ( "WOKernel_Workshop::AddWorkbench" );
+
+ }  // end if
   
-  for(i = 1 ; i <= myworkbenches->Length() ; i++)
-    {
-      Handle(WOKernel_Workbench) abench = Session()->GetWorkbench(myworkbenches->Value(i));
+ for (  i = 1; i <= myworkbenches -> Length (); ++i ) {
 
-      astream << abench->Name()->ToCString();
-      if(abench->Father().IsNull() == Standard_False)
-       {
-         astream << " " << Session()->GetWorkbench(abench->Father())->Name()->ToCString();
-       }
-      astream << endl;
-    }
-  return;
-}
+  Handle( WOKernel_Workbench ) abench =
+   Session () -> GetWorkbench (  myworkbenches -> Value ( i )  );
+
+  astream << abench -> Name () -> ToCString ();
+
+  if (  !abench -> Father ().IsNull ()  ) {
+
+   Handle( WOKernel_Workbench ) aWb = Session () -> GetWorkbench (  abench -> Father ()  );
+
+   if (  !aWb.IsNull ()  ) astream << " " << aWb -> Name () -> ToCString ();
+
+  }  // end if
 
+  astream << endl;
 
+ }  // end for
+
+}  // end WOKernel_Workshop :: DumpWorkbenchList
 //=======================================================================
 //function : AddWorkbench
 //purpose  : Adds a wb to the workshop (i.e. updates WBLIST)
@@ -433,20 +454,47 @@ void WOKernel_Workshop::AddWorkbench(const Handle(WOKernel_Workbench)& aworkbenc
 //function : RemoveWorkbench
 //purpose  :
 //=======================================================================
-void WOKernel_Workshop::RemoveWorkbench(const Handle(WOKernel_Workbench)& aworkbench)
-{
-  Standard_Integer i;
+void WOKernel_Workshop :: RemoveWorkbench (
+                           const Handle( WOKernel_Workbench )& aworkbench
+                          ) {
+
+ Standard_Integer                   i, j = 0;
+ Handle( TCollection_HAsciiString ) kids = new TCollection_HAsciiString ();
   
-  for(i = 1 ; i <= myworkbenches->Length() ; i++)
-    {
-      if(myworkbenches->Value(i)->IsSameString(aworkbench->FullName()))
-       {
-         myworkbenches->Remove(i);
-         break;
-       }
-    }
+ for (  i = 1; i <= myworkbenches -> Length (); ++i  ) {
+
+  Handle( TCollection_HAsciiString ) aFather;
+  Handle( WOKernel_Workbench       ) aWb = Session () -> GetWorkbench (
+                                                          myworkbenches -> Value ( i )
+                                                         );
+
+  if (  !aWb.IsNull ()  ) aFather = aWb -> Father ();
+
+  if (   myworkbenches -> Value ( i ) -> IsSameString (  aworkbench -> FullName ()  )   )
+
+   j = i;
+
+  if (   !aFather.IsNull () && aFather -> IsSameString (  aworkbench -> FullName ()  )   ) {
+
+   kids -> AssignCat (  aWb -> FullName ()  );
+   kids -> AssignCat ( " "                  );
+
+  }  // end if
+
+ }  // end for
+
+ if (  !kids -> IsEmpty ()  )
+
+  WarningMsg << "WOKernel_Workshop :: RemoveWorkbench"
+             << "workbench '" << aworkbench -> FullName ()
+             << "' has ancestors ( "
+             << kids << ")"
+             << endm;
+
+ if ( j != 0 ) myworkbenches -> Remove ( j );
   
-  Session()->RemoveEntity(aworkbench);
-  DumpWorkbenchList();
-  return;
-}
+ Session () -> RemoveEntity ( aworkbench );
+
+ DumpWorkbenchList ();
+
+}  // end WOKernel_Workshop :: RemoveWorkbench