mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
113
src/DDF/DDF.cdl
Executable file
113
src/DDF/DDF.cdl
Executable file
@@ -0,0 +1,113 @@
|
||||
-- File: DDF.cdl
|
||||
-- -------
|
||||
-- Author: DAUTRY Philippe
|
||||
---Copyright: MATRA DATAVISION 1997
|
||||
|
||||
---Version: 0.0
|
||||
---History: Version Date Purpose
|
||||
-- 0.0 Feb 10 1997 Creation
|
||||
|
||||
|
||||
|
||||
package DDF
|
||||
|
||||
---Purpose: Provides facilities to manipulate data framework
|
||||
-- in a Draw-Commands environment.
|
||||
|
||||
uses
|
||||
|
||||
Standard,
|
||||
Draw,
|
||||
TCollection,
|
||||
TDF
|
||||
|
||||
is
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Classes
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
class Data;
|
||||
---Purpose : Encapsulates a data framework from TDF.
|
||||
|
||||
class Browser;
|
||||
---Purpose : Browses a data framework from TDF.
|
||||
|
||||
class Transaction;
|
||||
---Purpose: Encapsulates a Transaction from TDF.
|
||||
|
||||
class TransactionStack
|
||||
instantiates Stack from TCollection (Transaction from DDF);
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Package methods
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
|
||||
GetDF (Name : in out CString from Standard;
|
||||
DF : in out Data from TDF;
|
||||
Complain : in Boolean from Standard = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Search in draw directory the framewok identified
|
||||
-- by its name <Name>. returns True if found. In that
|
||||
-- case <DF> is setted.
|
||||
|
||||
|
||||
FindLabel (DF : in Data from TDF;
|
||||
Entry : in CString from Standard;
|
||||
Label : in out Label from TDF;
|
||||
Complain : in Boolean from Standard = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Search in <DF> the label identified by its entry
|
||||
-- <Entry>. returns <True> if found. In that case
|
||||
-- <Label> is setted.
|
||||
|
||||
AddLabel (DF : in Data from TDF;
|
||||
Entry : in CString from Standard;
|
||||
Label : in out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose : Search in <DF> the label identified by its entry
|
||||
-- <Entry>. if label doesn't exist, create and add
|
||||
-- the Label in <DF>. In that case return True.
|
||||
|
||||
|
||||
Find (DF : in Data from TDF;
|
||||
Entry : in CString from Standard;
|
||||
ID : in GUID from Standard;
|
||||
A : in out Attribute from TDF;
|
||||
Complain : Boolean from Standard = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Search in <DF> the attribute identified by its
|
||||
-- <ID> and its <entry>. returns <True> if found. In
|
||||
-- that case A is setted.
|
||||
|
||||
|
||||
ReturnLabel(theCommands : in out Interpretor from Draw; L : Label from TDF)
|
||||
returns Interpretor from Draw;
|
||||
---C++: return &
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Commands
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
AllCommands (theCommands : in out Interpretor from Draw);
|
||||
|
||||
|
||||
BasicCommands (theCommands : in out Interpretor from Draw);
|
||||
---Purpose : Basic commands.
|
||||
|
||||
DataCommands (theCommands : in out Interpretor from Draw);
|
||||
---Purpose : Data framework commands
|
||||
-- create, clear & copy.
|
||||
|
||||
TransactionCommands (theCommands : in out Interpretor from Draw);
|
||||
---Purpose : open commit abort a transaction
|
||||
-- undo facilities.
|
||||
|
||||
BrowserCommands (theCommands : in out Interpretor from Draw);
|
||||
---Purpose : Browser commands .
|
||||
|
||||
end DDF;
|
||||
|
||||
|
||||
|
138
src/DDF/DDF.cxx
Executable file
138
src/DDF/DDF.cxx
Executable file
@@ -0,0 +1,138 @@
|
||||
// File: DDF.cxx
|
||||
// -------
|
||||
// Author: DAUTRY Philippe
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Feb 10 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF.ixx>
|
||||
|
||||
#include <DDF_Data.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : AddLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF::AddLabel
|
||||
|
||||
(
|
||||
const Handle(TDF_Data)& DF,
|
||||
const Standard_CString Entry,
|
||||
TDF_Label& Label
|
||||
)
|
||||
{
|
||||
TDF_Tool::Label (DF,Entry,Label,Standard_True);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
|
||||
const Standard_CString Entry,
|
||||
TDF_Label& Label,
|
||||
const Standard_Boolean Complain)
|
||||
{
|
||||
Label.Nullify();
|
||||
TDF_Tool::Label(DF,Entry,Label,Standard_False);
|
||||
if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl;
|
||||
return !Label.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF::GetDF (Standard_CString& Name,
|
||||
Handle(TDF_Data)& DF,
|
||||
const Standard_Boolean Complain)
|
||||
{
|
||||
Handle(Standard_Transient) t = Draw::Get(Name, Complain);
|
||||
Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
|
||||
//Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain));
|
||||
if (!DDF.IsNull()) {
|
||||
DF = DDF->DataFramework();
|
||||
return Standard_True;
|
||||
}
|
||||
if (Complain) cout <<"framework "<<Name<<" not found "<< endl;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Find
|
||||
//purpose : Finds an attribute.
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
|
||||
const Standard_CString Entry,
|
||||
const Standard_GUID& ID,
|
||||
Handle(TDF_Attribute)& A,
|
||||
const Standard_Boolean Complain)
|
||||
{
|
||||
TDF_Label L;
|
||||
if (FindLabel(DF,Entry,L,Complain)) {
|
||||
if (L.FindAttribute(ID,A)) return Standard_True;
|
||||
if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReturnLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
|
||||
{
|
||||
TCollection_AsciiString S;
|
||||
TDF_Tool::Entry(L,S);
|
||||
di << S.ToCString();
|
||||
return di;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AllCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF::AllCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
DDF::BasicCommands (theCommands);
|
||||
DDF::DataCommands (theCommands);
|
||||
DDF::TransactionCommands (theCommands);
|
||||
DDF::BrowserCommands (theCommands);
|
||||
// define the TCL variable DDF
|
||||
const char* com = "set DDF";
|
||||
theCommands.Eval(com);
|
||||
}
|
||||
|
||||
|
||||
|
79
src/DDF/DDF_AttributeBrowser.cxx
Executable file
79
src/DDF/DDF_AttributeBrowser.cxx
Executable file
@@ -0,0 +1,79 @@
|
||||
// File: DDF_AttributeBrowser.cxx
|
||||
// ------------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Oct 6 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF_AttributeBrowser.hxx>
|
||||
|
||||
static DDF_AttributeBrowser* DDF_FirstBrowser = NULL;
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_AttributeBrowser
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_AttributeBrowser::DDF_AttributeBrowser
|
||||
(Standard_Boolean (*test)(const Handle(TDF_Attribute)&),
|
||||
TCollection_AsciiString (*open)(const Handle(TDF_Attribute)&),
|
||||
TCollection_AsciiString (*text)(const Handle(TDF_Attribute)&))
|
||||
: myTest(test),
|
||||
myOpen(open),
|
||||
myText(text),
|
||||
myNext(DDF_FirstBrowser)
|
||||
{
|
||||
DDF_FirstBrowser = this;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Test
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF_AttributeBrowser::Test
|
||||
(const Handle(TDF_Attribute)&anAtt) const
|
||||
{return (*myTest) (anAtt);}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Open
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_AttributeBrowser::Open
|
||||
(const Handle(TDF_Attribute)& anAtt) const
|
||||
{ return (*myOpen) (anAtt);}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Text
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_AttributeBrowser::Text
|
||||
(const Handle(TDF_Attribute)& anAtt) const
|
||||
{return (*myText) (anAtt);}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindBrowser
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_AttributeBrowser* DDF_AttributeBrowser::FindBrowser
|
||||
(const Handle(TDF_Attribute)&anAtt)
|
||||
{
|
||||
DDF_AttributeBrowser* browser = DDF_FirstBrowser;
|
||||
while (browser) {
|
||||
if (browser->Test(anAtt)) break;
|
||||
browser = browser->Next();
|
||||
}
|
||||
return browser;
|
||||
}
|
57
src/DDF/DDF_AttributeBrowser.hxx
Executable file
57
src/DDF/DDF_AttributeBrowser.hxx
Executable file
@@ -0,0 +1,57 @@
|
||||
// File: DDF_AttributeBrowser.hxx
|
||||
// ------------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Oct 6 1997 Creation
|
||||
|
||||
|
||||
|
||||
#ifndef DDF_AttributeBrowser_HeaderFile
|
||||
#define DDF_AttributeBrowser_HeaderFile
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
|
||||
class DDF_AttributeBrowser {
|
||||
|
||||
public :
|
||||
|
||||
Standard_EXPORT DDF_AttributeBrowser
|
||||
(Standard_Boolean (*test)(const Handle(TDF_Attribute)&),
|
||||
TCollection_AsciiString (*open) (const Handle(TDF_Attribute)&),
|
||||
TCollection_AsciiString (*text) (const Handle(TDF_Attribute)&)
|
||||
);
|
||||
|
||||
|
||||
Standard_Boolean Test
|
||||
(const Handle(TDF_Attribute)&anAtt) const;
|
||||
TCollection_AsciiString Open
|
||||
(const Handle(TDF_Attribute)&anAtt) const;
|
||||
TCollection_AsciiString Text
|
||||
(const Handle(TDF_Attribute)&anAtt) const;
|
||||
inline DDF_AttributeBrowser* Next() {return myNext;}
|
||||
|
||||
static DDF_AttributeBrowser* FindBrowser
|
||||
(const Handle(TDF_Attribute)&anAtt);
|
||||
|
||||
private :
|
||||
|
||||
Standard_Boolean (*myTest)
|
||||
(const Handle(TDF_Attribute)&);
|
||||
|
||||
TCollection_AsciiString (*myOpen)
|
||||
(const Handle(TDF_Attribute)&);
|
||||
|
||||
TCollection_AsciiString (*myText)
|
||||
(const Handle(TDF_Attribute)&);
|
||||
|
||||
DDF_AttributeBrowser* myNext;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
336
src/DDF/DDF_BasicCommands.cxx
Executable file
336
src/DDF/DDF_BasicCommands.cxx
Executable file
@@ -0,0 +1,336 @@
|
||||
// File: DDF_BasicCommands.cxx
|
||||
// ---------------------
|
||||
// Author: DAUTRY Philippe & VAUTHIER Jean-Claude
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Feb 10 1997 Creation
|
||||
|
||||
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <TDF_ComparisonTool.hxx>
|
||||
#include <TDF_CopyTool.hxx>
|
||||
#include <TDF_ClosureMode.hxx>
|
||||
#include <TDF_ClosureTool.hxx>
|
||||
|
||||
#include <DDF_Data.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
#include <TColStd_HSequenceOfAsciiString.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_DataSet.hxx>
|
||||
#include <TDF_Delta.hxx>
|
||||
#include <TDF_IDFilter.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
#include <DDF_IOStream.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Children
|
||||
//purpose : Returns a list of sub-label entries.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_Children (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
TCollection_AsciiString entry;
|
||||
|
||||
if (!DDF::GetDF (a[1], DF)) return 1;
|
||||
|
||||
TDF_Label lab;
|
||||
if (n == 3) TDF_Tool::Label(DF,a[2],lab);
|
||||
|
||||
if (lab.IsNull()) {
|
||||
di<<"0";
|
||||
}
|
||||
else {
|
||||
for (TDF_ChildIterator itr(lab); itr.More(); itr.Next()) {
|
||||
TDF_Tool::Entry(itr.Value(),entry);
|
||||
//TCollection_AsciiString entry(itr.Value().Tag());
|
||||
di<<entry.ToCString()<<" ";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Attributes
|
||||
//purpose : Returns a list of label attributes.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_Attributes (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n != 3) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
|
||||
if (!DDF::GetDF (a[1], DF)) return 1;
|
||||
|
||||
TDF_Label lab;
|
||||
TDF_Tool::Label(DF,a[2],lab);
|
||||
|
||||
if (lab.IsNull()) return 1;
|
||||
|
||||
for (TDF_AttributeIterator itr(lab); itr.More(); itr.Next()) {
|
||||
di<<itr.Value()->DynamicType()->Name()<<" ";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ForgetAll
|
||||
//purpose : "ForgetAll dfname Label"
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_ForgetAll(Draw_Interpretor& /*di*/,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n != 3) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
|
||||
if (!DDF::GetDF (a[1], DF)) return 1;
|
||||
|
||||
TDF_Label label;
|
||||
TDF_Tool::Label(DF,a[2],label);
|
||||
if (label.IsNull()) return 1;
|
||||
label.ForgetAllAttributes();
|
||||
//POP pour NT
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// save/restore & Store/Retrieve commands
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
//==========================================================
|
||||
// ErrorMessage
|
||||
//==========================================================
|
||||
|
||||
void ErrorMessage (const Storage_Error n)
|
||||
{
|
||||
cout << "Storage Error: " << flush;
|
||||
|
||||
switch (n) {
|
||||
case Storage_VSOk:
|
||||
cout << "no problem" << endl;
|
||||
break;
|
||||
case Storage_VSOpenError:
|
||||
cout << "while opening the stream" << endl;
|
||||
break;
|
||||
case Storage_VSModeError:
|
||||
cout << "the stream is opened with a wrong mode for operation " << endl;
|
||||
break;
|
||||
case Storage_VSCloseError:
|
||||
cout << "while closing the stream" << endl;
|
||||
break;
|
||||
case Storage_VSAlreadyOpen:
|
||||
cout << "stream is already opened" << endl;
|
||||
break;
|
||||
case Storage_VSNotOpen:
|
||||
cout << "stream not opened" << endl;
|
||||
break;
|
||||
case Storage_VSSectionNotFound:
|
||||
cout << "the section is not found" << endl;
|
||||
break;
|
||||
case Storage_VSWriteError:
|
||||
cout << "error during writing" << endl;
|
||||
break;
|
||||
case Storage_VSFormatError:
|
||||
cout << "wrong format error occured while reading" << endl;
|
||||
break;
|
||||
case Storage_VSUnknownType:
|
||||
cout << "try to read an unknown type" << endl;
|
||||
break;
|
||||
case Storage_VSTypeMismatch:
|
||||
cout << "try to read a wrong primitive type (read a char while expecting a real)" << endl;
|
||||
break;
|
||||
case Storage_VSInternalError:
|
||||
cout << "internal error" << endl;
|
||||
break;
|
||||
case Storage_VSExtCharParityError: cout << "parity error" << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "unknown error code" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_SetTagger
|
||||
//purpose : SetTagger (DF, entry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_SetTagger (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
TDF_TagSource::Set(L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_SetTagger : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_NewTag
|
||||
//purpose : NewTag (DF,[father]
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_NewTag (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
Handle(TDF_TagSource) A;
|
||||
if (!DDF::Find(DF,arg[2],TDF_TagSource::GetID(),A)) return 1;
|
||||
di << A->NewTag ();
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_NewTag : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_NewChild
|
||||
//purpose : NewChild(DF,[father])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_NewChild (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if (nb>=2){
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
if (nb == 2) {
|
||||
TDF_Label free = TDF_TagSource::NewChild(DF->Root());
|
||||
di << free.Tag();
|
||||
return 0;
|
||||
}
|
||||
else if (nb == 3) {
|
||||
TDF_Label fatherlabel;
|
||||
if (!DDF::FindLabel(DF,arg[2],fatherlabel)) return 1;
|
||||
TDF_Label free = TDF_TagSource::NewChild (fatherlabel);
|
||||
di << arg[2] << ":" << free.Tag();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
di << "DDF_NewChild : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Label (DF,freeentry)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_Label (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (a[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::FindLabel(DF,a[2],L,Standard_False)) {
|
||||
DDF::AddLabel(DF,a[2],L);
|
||||
//di << "Label : " << a[2] << " created" << "\n";
|
||||
}
|
||||
//else di << "Label : " << a[2] << " retrieved" << "\n";
|
||||
DDF::ReturnLabel(di,L);
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_Label : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BasicCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF::BasicCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DF basic commands";
|
||||
|
||||
// Label :
|
||||
|
||||
theCommands.Add ("SetTagger",
|
||||
"SetTagger (DF, entry)",
|
||||
__FILE__, DDF_SetTagger, g);
|
||||
|
||||
theCommands.Add ("NewTag",
|
||||
"NewTag (DF, tagger)",
|
||||
__FILE__, DDF_NewTag, g);
|
||||
|
||||
theCommands.Add ("NewChild",
|
||||
"NewChild (DF, [tagger])",
|
||||
__FILE__, DDF_NewChild, g);
|
||||
|
||||
theCommands.Add ("Children",
|
||||
" Returns the list of label children: Children DF label",
|
||||
__FILE__, DDF_Children, g);
|
||||
|
||||
theCommands.Add ("Attributes",
|
||||
" Returns the list of label attributes: Attributes DF label",
|
||||
__FILE__, DDF_Attributes, g);
|
||||
|
||||
theCommands.Add ("ForgetAll",
|
||||
"Forgets all attributes from the label: ForgetAll DF Label",
|
||||
__FILE__, DDF_ForgetAll, g);
|
||||
|
||||
theCommands.Add ("Label",
|
||||
"Label DF entry",
|
||||
__FILE__, DDF_Label, g);
|
||||
|
||||
|
||||
}
|
99
src/DDF/DDF_Browser.cdl
Executable file
99
src/DDF/DDF_Browser.cdl
Executable file
@@ -0,0 +1,99 @@
|
||||
-- File: DDF_Browser.cdl
|
||||
-- ---------------
|
||||
-- Author: DAUTRY Philippe
|
||||
-- <fid@fox.paris1.matra-dtv.fr>
|
||||
---Copyright: MATRA DATAVISION 1997
|
||||
|
||||
---Version: 0.0
|
||||
---History: Version Date Purpose
|
||||
-- 0.0 Oct 3 1997 Creation
|
||||
|
||||
|
||||
class Browser from DDF inherits Drawable3D from Draw
|
||||
|
||||
---Purpose: Browses a data framework.
|
||||
|
||||
uses
|
||||
|
||||
Data from TDF,
|
||||
Label from TDF,
|
||||
AttributeIndexedMap from TDF,
|
||||
Interpretor from Draw,
|
||||
Display from Draw,
|
||||
AsciiString from TCollection
|
||||
|
||||
-- raises
|
||||
|
||||
is
|
||||
|
||||
Create (aDF : Data from TDF)
|
||||
returns mutable Browser from DDF;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display);
|
||||
|
||||
|
||||
Copy (me)
|
||||
returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
|
||||
Dump (me; S : in out OStream)
|
||||
is redefined;
|
||||
|
||||
Whatis (me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
|
||||
-- Specific methods -------------------------------------------------------
|
||||
|
||||
Data (me : mutable; aDF : Data from TDF);
|
||||
|
||||
Data (me)
|
||||
returns Data from TDF;
|
||||
|
||||
OpenRoot(me)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns a string composed with the sub-label
|
||||
-- entries of <myDF>.
|
||||
|
||||
OpenLabel(me; aLab : Label from TDF)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns a string composed with the sub-label
|
||||
-- entries of <aLab>.
|
||||
|
||||
OpenAttributeList(me : mutable;
|
||||
aLab : Label from TDF)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns a string composed with the attribute index
|
||||
-- (found in <myAttMap>) of <aLab>.
|
||||
|
||||
OpenAttribute(me : mutable;
|
||||
anIndex : Integer from Standard = 0)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns a string composed with the list of
|
||||
-- referenced attribute index of the attribute
|
||||
-- <anIndex>. For exemple, it is usefull for
|
||||
-- TDataStd_Group. It uses a mecanism based on a
|
||||
-- DDF_AttributeBrowser.
|
||||
|
||||
Information(me)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns information about <me> to be displayed in
|
||||
-- information window.
|
||||
|
||||
Information(me; aLab : Label from TDF)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns information about <aLab> to be displayed
|
||||
-- in information window.
|
||||
|
||||
Information(me; anIndex : Integer from Standard = 0)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose: Returns information about attribute <anIndex> to
|
||||
-- be displayed in information window.
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myDF : Data from TDF;
|
||||
myAttMap : AttributeIndexedMap from TDF;
|
||||
|
||||
end Browser;
|
293
src/DDF/DDF_Browser.cxx
Executable file
293
src/DDF/DDF_Browser.cxx
Executable file
@@ -0,0 +1,293 @@
|
||||
// File: DDF_Browser.cxx
|
||||
// ---------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Oct 3 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF_Browser.ixx>
|
||||
|
||||
#include <DDF_AttributeBrowser.hxx>
|
||||
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF.hxx>
|
||||
|
||||
#include <TDataStd_Name.hxx>
|
||||
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Communication convention with tcl:
|
||||
// tcl waits for a string of characters, being an information list.
|
||||
// In this list, each item is separated from another by a separator: '\'.
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
#define TDF_BrowserSeparator1 '\\'
|
||||
#define TDF_BrowserSeparator2 ' '
|
||||
#define TDF_BrowserSeparator3 '#'
|
||||
#define TDF_BrowserSeparator4 ','
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_Browser
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_Browser::DDF_Browser(const Handle(TDF_Data)& aDF)
|
||||
: myDF(aDF)
|
||||
{}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Browser::DrawOn(Draw_Display& /*dis*/) const
|
||||
{
|
||||
//cout<<"DDF_Browser"<<endl;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDF_Browser::Copy() const
|
||||
{ return new DDF_Browser(myDF); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Browser::Dump(Standard_OStream& S) const
|
||||
{
|
||||
S<<"DDF_Browser on a DF:"<<endl;
|
||||
S<<myDF;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Browser::Whatis(Draw_Interpretor& I) const
|
||||
{ I<<"Data Framework Browser"; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Data
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Browser::Data(const Handle(TDF_Data)& aDF)
|
||||
{ myDF = aDF; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Data
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Data) DDF_Browser::Data() const
|
||||
{ return myDF; }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenRoot
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::OpenRoot() const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
const TDF_Label& root = myDF->Root();
|
||||
TDF_Tool::Entry(root,list);
|
||||
Handle(TDataStd_Name) name;
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
list.AssignCat("\"");
|
||||
if (root.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
TCollection_AsciiString tmpStr(name->Get(),'?');
|
||||
tmpStr.ChangeAll(' ','_');
|
||||
list.AssignCat(tmpStr);
|
||||
}
|
||||
list.AssignCat("\"");
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!root.MayBeModified()) list.AssignCat("Not");
|
||||
list.AssignCat("Modified");
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (root.HasAttribute() || (root.HasChild())) {
|
||||
list.AssignCat("1");
|
||||
}
|
||||
else {
|
||||
list.AssignCat("0");
|
||||
}
|
||||
//cout<<"OpenRoot: "<<list<<endl;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenLabel
|
||||
//purpose :
|
||||
// an item is composed as follows:
|
||||
// "Entry "Name" Modified|NotModified 0|1"
|
||||
// the end bit shows if the label has attributes or children.
|
||||
// The 1st can be
|
||||
// "AttributeList Modified|NotModified"
|
||||
// The items are separated by "\\".
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const
|
||||
{
|
||||
Standard_Boolean split = Standard_False;
|
||||
TCollection_AsciiString entry, list;
|
||||
if (aLab.HasAttribute() || aLab.AttributesModified()) {
|
||||
list.AssignCat("AttributeList");
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!aLab.AttributesModified()) list.AssignCat("Not");
|
||||
list.AssignCat("Modified");
|
||||
split = Standard_True;
|
||||
}
|
||||
Handle(TDataStd_Name) name;
|
||||
for (TDF_ChildIterator itr(aLab); itr.More(); itr.Next()) {
|
||||
if (split) list.AssignCat(TDF_BrowserSeparator1);
|
||||
TDF_Tool::Entry(itr.Value(),entry);
|
||||
list.AssignCat(entry);
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
list.AssignCat("\"");
|
||||
if (itr.Value().FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
TCollection_AsciiString tmpStr(name->Get(),'?');
|
||||
tmpStr.ChangeAll(' ','_');
|
||||
list.AssignCat(tmpStr);
|
||||
}
|
||||
list.AssignCat("\"");
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!itr.Value().MayBeModified()) list.AssignCat("Not");
|
||||
list.AssignCat("Modified");
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
// May be open.
|
||||
if (itr.Value().HasAttribute() || (itr.Value().HasChild()))
|
||||
list.AssignCat("1");
|
||||
else
|
||||
list.AssignCat("0");
|
||||
|
||||
split = Standard_True;
|
||||
}
|
||||
//cout<<"OpenLabel: "<<list<<endl;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenAttributeList
|
||||
//purpose :
|
||||
// an item is composed as follows:
|
||||
// "DynamicType#MapIndex TransactionIndex Valid|Notvalid Forgotten|NotForgotten Backuped|NotBackuped"
|
||||
// The items are separated by "\\".
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::OpenAttributeList
|
||||
(const TDF_Label& aLab)
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
Standard_Boolean split1 = Standard_False;
|
||||
for (TDF_AttributeIterator itr(aLab,Standard_False);itr.More();itr.Next()) {
|
||||
if (split1) list.AssignCat(TDF_BrowserSeparator1);
|
||||
const Handle(TDF_Attribute)& att = itr.Value();
|
||||
const Standard_Integer index = myAttMap.Add(att);
|
||||
TCollection_AsciiString indexStr(index);
|
||||
list.AssignCat(att->DynamicType()->Name());
|
||||
list.AssignCat(TDF_BrowserSeparator3);
|
||||
list.AssignCat(indexStr);
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
list.AssignCat(att->Transaction());
|
||||
// Valid.
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!att->IsValid()) list.AssignCat("Not");
|
||||
list.AssignCat("Valid");
|
||||
// Forgotten.
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!att->IsForgotten()) list.AssignCat("Not");
|
||||
list.AssignCat("Forgotten");
|
||||
// Backuped.
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
if (!att->IsBackuped()) list.AssignCat("Not");
|
||||
list.AssignCat("Backuped");
|
||||
// May be open.
|
||||
list.AssignCat(TDF_BrowserSeparator2);
|
||||
DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
|
||||
if (br) list.AssignCat("1");
|
||||
else list.AssignCat("0");
|
||||
split1 = Standard_True;
|
||||
}
|
||||
//cout<<"OpenAttributeList: "<<list<<endl;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenAttribute
|
||||
//purpose : Attribute's intrinsic information given by an attribute browser.
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::OpenAttribute
|
||||
(const Standard_Integer anIndex)
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
Handle(TDF_Attribute) att = myAttMap.FindKey(anIndex);
|
||||
DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
|
||||
if (br) list = br->Open(att);
|
||||
//cout<<"OpenAttribute: "<<list<<endl;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Information
|
||||
//purpose : Information about <myDF>.
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::Information() const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Information
|
||||
//purpose : Information about a label.
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::Information(const TDF_Label& /*aLab*/) const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Information
|
||||
//purpose : Information about an attribute.
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString DDF_Browser::Information(const Standard_Integer /*anIndex*/) const
|
||||
{
|
||||
TCollection_AsciiString list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
193
src/DDF/DDF_BrowserCommands.cxx
Executable file
193
src/DDF/DDF_BrowserCommands.cxx
Executable file
@@ -0,0 +1,193 @@
|
||||
// File: DDF_BrowserCommands.cxx
|
||||
// -----------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Oct 3 1997 Creation
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <DDF.hxx>
|
||||
#include <DDF_Browser.hxx>
|
||||
#include <DDF_Data.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#ifdef WNT
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : DFBrowse
|
||||
//purpose :
|
||||
// arg 1 : DF name
|
||||
// [arg 2] : Browser name
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DFBrowse (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n<2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF (a[1], DF)) return 1;
|
||||
|
||||
Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF);
|
||||
char *name = new char[50];
|
||||
if (n == 3) sprintf(name,"browser_%s",a[2]);
|
||||
else sprintf(name,"browser_%s",a[1]);
|
||||
|
||||
Draw::Set (name, NewDDFBrowser);
|
||||
TCollection_AsciiString inst1("dftree ");
|
||||
inst1.AssignCat(name);
|
||||
di.Eval(inst1.ToCString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DFOpenLabel
|
||||
//purpose :
|
||||
// arg 1 : Browser name
|
||||
// [arg 2] : Label name
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(DDF_Browser) browser =
|
||||
Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
|
||||
|
||||
TDF_Label lab;
|
||||
if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
|
||||
|
||||
if (lab.IsNull()) {
|
||||
TCollection_AsciiString list = browser->OpenRoot();
|
||||
di<<list.ToCString();
|
||||
}
|
||||
else {
|
||||
TCollection_AsciiString list = browser->OpenLabel(lab);
|
||||
di<<list.ToCString();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DFOpenAttributeList
|
||||
//purpose :
|
||||
// arg 1 : Browser name
|
||||
// arg 2 : Label name
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 3) return 1;
|
||||
|
||||
Handle(DDF_Browser) browser =
|
||||
Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
|
||||
|
||||
TDF_Label lab;
|
||||
TDF_Tool::Label(browser->Data(),a[2],lab);
|
||||
|
||||
if (lab.IsNull()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString list = browser->OpenAttributeList(lab);
|
||||
di << list.ToCString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DFOpenAttribute
|
||||
//purpose :
|
||||
// arg 1 : Browser name
|
||||
// arg 2 : Attribute index
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 3) return 1;
|
||||
|
||||
Handle(DDF_Browser) browser =
|
||||
Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
|
||||
|
||||
Standard_Integer index = atoi(a[2]);
|
||||
|
||||
TCollection_AsciiString list = browser->OpenAttribute(index);
|
||||
|
||||
di<<list.ToCString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BrowserCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF::BrowserCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
/*
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DF browser commands";
|
||||
|
||||
theCommands.Add
|
||||
("DFBrowse",
|
||||
"Creates a browser on a df: DFBrowse dfname [browsername]",
|
||||
__FILE__, DFBrowse, g);
|
||||
|
||||
theCommands.Add
|
||||
("DFOpenLabel",
|
||||
"DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the list of sub-label entries: DFOpenLabel browsername [label]",
|
||||
__FILE__, DFOpenLabel, g);
|
||||
|
||||
theCommands.Add
|
||||
("DFOpenAttributeList",
|
||||
"DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the attribute list of a label: DFOpenLabel browsername label",
|
||||
__FILE__, DFOpenAttributeList, g);
|
||||
|
||||
theCommands.Add
|
||||
("DFOpenAttribute",
|
||||
"DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the reference list of an attribute: DFOpenLabel browsername attributeindex",
|
||||
__FILE__, DFOpenAttribute, g);
|
||||
#if 0
|
||||
theCommands.Add
|
||||
("DFDisplayInfo",
|
||||
"DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
|
||||
__FILE__, DFDisplayInfo, g);
|
||||
#endif
|
||||
*/
|
||||
}
|
57
src/DDF/DDF_Data.cdl
Executable file
57
src/DDF/DDF_Data.cdl
Executable file
@@ -0,0 +1,57 @@
|
||||
-- File: DDF_Data.cdl
|
||||
-- ------------
|
||||
-- Author: DAUTRY Philippe
|
||||
---Copyright: MATRA DATAVISION 1997
|
||||
|
||||
---Version: 0.0
|
||||
---History: Version Date Purpose
|
||||
-- 0.0 Feb 10 1997 Creation
|
||||
|
||||
|
||||
class Data from DDF inherits Drawable3D from Draw
|
||||
|
||||
---Purpose : Encapsulates a data framework in a drawable object
|
||||
|
||||
uses
|
||||
|
||||
Data from TDF,
|
||||
Interpretor from Draw,
|
||||
Display from Draw
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (aDF : Data from TDF)
|
||||
returns mutable Data from DDF;
|
||||
|
||||
|
||||
DrawOn (me; dis : in out Display);
|
||||
|
||||
|
||||
Copy (me)
|
||||
returns mutable Drawable3D from Draw
|
||||
is redefined;
|
||||
|
||||
|
||||
Dump (me; S : in out OStream)
|
||||
is redefined;
|
||||
|
||||
|
||||
DataFramework (me : mutable; aDF : Data from TDF);
|
||||
|
||||
|
||||
DataFramework (me)
|
||||
returns Data from TDF;
|
||||
|
||||
|
||||
Whatis (me; I : in out Interpretor from Draw)
|
||||
is redefined;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myDF : Data from TDF;
|
||||
|
||||
end Data;
|
||||
|
||||
|
100
src/DDF/DDF_Data.cxx
Executable file
100
src/DDF/DDF_Data.cxx
Executable file
@@ -0,0 +1,100 @@
|
||||
// File: DDF_Data.cxx
|
||||
// ------------
|
||||
// Author: VAUTHIER Jean-Claude & DAUTRY Philippe
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Feb 10 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF_Data.ixx>
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_IDFilter.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_Data
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_Data::DDF_Data(const Handle(TDF_Data)& aDF) : myDF (aDF) {}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DrawOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Data::DrawOn(Draw_Display& dis) const
|
||||
|
||||
{ cout<<"DDF_Data"<<endl; }
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DDF_Data::Copy() const { return new DDF_Data (myDF); }
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Data::Dump(Standard_OStream& S) const
|
||||
|
||||
{
|
||||
TDF_Tool::DeepDump(S,myDF);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DataFramework
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Data) DDF_Data::DataFramework () const { return myDF; }
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DataFramework
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Data::DataFramework (const Handle(TDF_Data)& aDF)
|
||||
|
||||
{ myDF = aDF; }
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Whatis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Data::Whatis (Draw_Interpretor& I) const
|
||||
|
||||
{
|
||||
I << "Data Framework";
|
||||
}
|
424
src/DDF/DDF_DataCommands.cxx
Executable file
424
src/DDF/DDF_DataCommands.cxx
Executable file
@@ -0,0 +1,424 @@
|
||||
// File: DDF_DataCommands.cxx
|
||||
// --------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Sep 30 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <TDF_ClosureMode.hxx>
|
||||
#include <TDF_ClosureTool.hxx>
|
||||
#include <TDF_CopyTool.hxx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
#include <DDF_Data.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_DataSet.hxx>
|
||||
#include <TDF_IDFilter.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_CopyLabel.hxx>
|
||||
#include <TDF_CopyLabel.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_AttributeMap.hxx>
|
||||
#include <TDF_MapIteratorOfAttributeMap.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeDF
|
||||
//purpose : Creates a new data framework.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer MakeDF (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle (Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(DDF_Data) NewDDF;
|
||||
|
||||
if (!D.IsNull ()) {
|
||||
NewDDF = Handle(DDF_Data)::DownCast (D);
|
||||
if (!NewDDF.IsNull ()) {
|
||||
di<<"DDF_BasicCommands::MakeDF - Sorry, this Data Framework already exists"<<"\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(TDF_Data) NewDF = new TDF_Data ();
|
||||
NewDDF = new DDF_Data (NewDF);
|
||||
Draw::Set (a[1], NewDDF);
|
||||
//DeltaDS.Nullify();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearDF
|
||||
//purpose : Creates a new data framework.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer ClearDF (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle (Draw_Drawable3D) D = Draw::Get(a[1]);
|
||||
Handle(DDF_Data) DDF;
|
||||
|
||||
if (!D.IsNull ()) {
|
||||
DDF = Handle(DDF_Data)::DownCast (D);
|
||||
if (!DDF.IsNull ()) {
|
||||
Handle(TDF_Data) DF = DDF->DataFramework ();
|
||||
if (!DF.IsNull ()) {
|
||||
Handle(TDF_Data) NewEmpty = new TDF_Data;
|
||||
DDF->DataFramework (NewEmpty);
|
||||
//DeltaDS.Nullify();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
di<<"DDF_BasicCommands::MakeDF - Sorry, this Data Framework doesn't exist"<<"\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CopyDF
|
||||
//purpose : CopyDF.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer CopyDF (Draw_Interpretor& /*di*/,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 4 || n > 5) return 1;
|
||||
|
||||
|
||||
Handle(TDF_Data) DF1;
|
||||
Handle(TDF_Data) DF2;
|
||||
Standard_CString Entry1;
|
||||
Standard_CString Entry2;
|
||||
|
||||
if (!DDF::GetDF (a[1], DF1)) return 1;
|
||||
|
||||
Entry1 = a[2];
|
||||
Entry2 = a[3];
|
||||
|
||||
if (n == 4) {
|
||||
DF2 = DF1;
|
||||
Entry2 = a[3];
|
||||
}
|
||||
else if (n == 5) {
|
||||
if (!DDF::GetDF (a[3], DF2)) return 1;
|
||||
Entry2 = a[4];
|
||||
}
|
||||
|
||||
TDF_Label Label1;
|
||||
if (!DDF::FindLabel (DF1, Entry1, Label1)) return 1;
|
||||
|
||||
TDF_Label Label2;
|
||||
if (!DDF::FindLabel (DF2, Entry2, Label2, Standard_False)) {
|
||||
DDF::AddLabel(DF2,Entry2,Label2);
|
||||
}
|
||||
|
||||
|
||||
Handle(TDF_DataSet) DataSet = new TDF_DataSet;
|
||||
DataSet->AddRoot(Label1);
|
||||
TDF_ClosureTool::Closure(DataSet);
|
||||
Handle(TDF_RelocationTable) Reloc = new TDF_RelocationTable();
|
||||
Reloc->SetRelocation(Label1,Label2);
|
||||
TDF_CopyTool::Copy (DataSet, Reloc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MiniDumpDF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer MiniDumpDF (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle (Draw_Drawable3D) D;
|
||||
Handle(DDF_Data) DDF;
|
||||
|
||||
D = Draw::Get(a[1]);
|
||||
|
||||
if (D.IsNull ()) {
|
||||
di<<"DDF_BasicCommands : Sorry this Data Framework doesn't exist"<<"\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
DDF = Handle(DDF_Data)::DownCast (D);
|
||||
|
||||
if (DDF.IsNull ()) {
|
||||
di<<"DDF_BasicCommands : Sorry this Data Framework doesn't exist"<<"\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
di<<"*********** Dump of "<<a[1]<<" ***********"<<"\n";
|
||||
|
||||
//DDF->DataFramework()->Dump(cout);
|
||||
Standard_SStream aSStream;
|
||||
DDF->DataFramework()->Dump(aSStream);
|
||||
aSStream << ends;
|
||||
di << aSStream << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : XDumpDF
|
||||
//purpose : eXtended deep dump of a DataFramework
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer XDumpDF (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle (Draw_Drawable3D) D;
|
||||
Handle(DDF_Data) DDF;
|
||||
|
||||
D = Draw::Get(a[1]);
|
||||
|
||||
if (D.IsNull ()) {
|
||||
di<<"DDF_BasicCommands : Sorry this Data Framework doesn't exist"<<"\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
DDF = Handle(DDF_Data)::DownCast (D);
|
||||
|
||||
if (DDF.IsNull ()) {
|
||||
di<<"DDF_BasicCommands : Sorry this Data Framework doesn't exist"<<"\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
di<<"*********** Dump of "<<a[1]<<" ***********"<<"\n";
|
||||
|
||||
TDF_IDFilter filter(Standard_False);
|
||||
//TDF_Tool::ExtendedDeepDump(cout,DDF->DataFramework(),filter);
|
||||
Standard_SStream aSStream;
|
||||
TDF_Tool::ExtendedDeepDump(aSStream,DDF->DataFramework(),filter);
|
||||
aSStream << ends;
|
||||
di << aSStream <<"\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CopyLabel_SCopy
|
||||
//purpose : CopyLabel (DF,fromlabel,tolabel)
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer CopyLabel_SCopy (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
TDF_Label SOURCE,TARGET;
|
||||
if (n == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
if (!DDF::FindLabel(DF,a[2],SOURCE)) return 1;
|
||||
if (DDF::FindLabel(DF,a[3],TARGET)) {
|
||||
di << " target label is already setted "<< "\n";
|
||||
return 1;
|
||||
}
|
||||
DDF::AddLabel(DF,a[3],TARGET);
|
||||
TDF_CopyLabel cop;
|
||||
cop.Load(SOURCE, TARGET);
|
||||
cop.Perform();
|
||||
if (!cop.IsDone())
|
||||
di << "copy not done" << "\n";
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_CopyLabel : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_CheckAttr
|
||||
//purpose : CheckAttr (DOC,label1,label2)
|
||||
// : Checks references of attributes of label1 and label2
|
||||
// : in order to find shareable attributes
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDF_CheckAttrs (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
TDF_Label SOURCE,TARGET;
|
||||
if (n == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
if (!DDF::FindLabel(DF,a[2],SOURCE)) return 1;
|
||||
if (!DDF::FindLabel(DF,a[3],TARGET)) return 1;
|
||||
|
||||
Handle(TDF_DataSet) ds1 = new TDF_DataSet();
|
||||
Handle(TDF_DataSet) ds2 = new TDF_DataSet();
|
||||
Standard_Boolean Shar = Standard_False;
|
||||
for (TDF_AttributeIterator itr(SOURCE); itr.More(); itr.Next()) {
|
||||
itr.Value()->References(ds1);
|
||||
// cout<<"\tSource Attribute dynamic type = "<<itr.Value()->DynamicType()<<endl;
|
||||
const TDF_AttributeMap& attMap = ds1->Attributes(); //attMap
|
||||
for (TDF_MapIteratorOfAttributeMap attMItr(attMap);attMItr.More(); attMItr.Next()) {
|
||||
Handle(TDF_Attribute) sAtt = attMItr.Key();
|
||||
// cout<<"\t\tSource references attribute dynamic type = "<<sAtt->DynamicType()<<endl;
|
||||
for (TDF_AttributeIterator itr2(TARGET); itr2.More(); itr2.Next()) {
|
||||
itr2.Value()->References(ds2);
|
||||
// cout<<"\t\t\tTARGET attribute dynamic type = "<<itr2.Value()->DynamicType()<<endl;
|
||||
const TDF_AttributeMap& attMap2 = ds2->Attributes(); //attMap
|
||||
for (TDF_MapIteratorOfAttributeMap attMItr2(attMap2);attMItr2.More(); attMItr2.Next()) {
|
||||
Handle(TDF_Attribute) tAtt = attMItr2.Key();
|
||||
// cout<<"\t\t\t\tTarget reference attribute dynamic type = "<<tAtt->DynamicType()<<endl;
|
||||
if (tAtt->IsInstance(sAtt->DynamicType()))
|
||||
if(tAtt == sAtt) {
|
||||
TCollection_AsciiString entr1,entr2;
|
||||
if(!Shar) {
|
||||
TDF_Tool::Entry(SOURCE, entr1);
|
||||
TDF_Tool::Entry(TARGET, entr2);
|
||||
//cout<<"\tSHAREABLE attribute(s) found between Lab1 = "<<entr1<<" and Lab2 = "<<entr2<<endl;
|
||||
di<<"\tSHAREABLE attribute(s) found between Lab1 = "<<entr1.ToCString()<<" and Lab2 = "<<entr2.ToCString()<<"\n";
|
||||
Shar = Standard_True;
|
||||
}
|
||||
TDF_Tool::Entry(sAtt->Label(), entr1);
|
||||
//cout<<"\tAttribute dynamic type = "<<sAtt->DynamicType()<<",\tlocated on Label = "<<entr1<<endl;
|
||||
di<<"\tAttribute dynamic type = ";
|
||||
Standard_SStream aSStream;
|
||||
sAtt->DynamicType()->Print(aSStream);
|
||||
aSStream << ends;
|
||||
di << aSStream;
|
||||
di<<",\tlocated on Label = "<<entr1.ToCString()<<"\n";
|
||||
}
|
||||
}
|
||||
ds2->Clear();
|
||||
}
|
||||
}
|
||||
ds1->Clear();
|
||||
}
|
||||
if(!Shar)
|
||||
di << "Shareable attributes not found" << "\n";
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_CheckAttrs : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_Checklabel
|
||||
//purpose : CheckLabel (DOC,label1,label2)
|
||||
// : prints all structure of first level attributes with its references
|
||||
//=======================================================================
|
||||
static Standard_Integer DDF_CheckLabel (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
// TDF_Label SOURCE,TARGET;
|
||||
TDF_Label SOURCE;
|
||||
if (n == 3) {
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
if (!DDF::FindLabel(DF,a[2],SOURCE)) return 1;
|
||||
|
||||
Handle(TDF_DataSet) ds1 = new TDF_DataSet();
|
||||
for (TDF_AttributeIterator itr(SOURCE); itr.More(); itr.Next()) {
|
||||
itr.Value()->References(ds1);
|
||||
//cout<<"\tSource Attribute dynamic type = "<<itr.Value()->DynamicType()<<endl;
|
||||
di<<"\tSource Attribute dynamic type = ";
|
||||
Standard_SStream aSStream1;
|
||||
itr.Value()->DynamicType()->Print(aSStream1);
|
||||
aSStream1 << ends;
|
||||
di << aSStream1 << "\n";
|
||||
const TDF_AttributeMap& attMap = ds1->Attributes(); //attMap
|
||||
for (TDF_MapIteratorOfAttributeMap attMItr(attMap);attMItr.More(); attMItr.Next()) {
|
||||
Handle(TDF_Attribute) sAtt = attMItr.Key();
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(sAtt->Label(), entry);
|
||||
//cout<<"\t\tReferences attribute dynamic type = "<<sAtt->DynamicType()<<",\tLabel = "<<entry<<endl;
|
||||
di<<"\t\tReferences attribute dynamic type = ";
|
||||
Standard_SStream aSStream2;
|
||||
sAtt->DynamicType()->Print(aSStream2);
|
||||
di << aSStream2;
|
||||
di<<",\tLabel = "<<entry.ToCString()<<"\n";
|
||||
}
|
||||
ds1->Clear();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
di << "DDF_ChecLabel : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DataCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF::DataCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DF Data Framework commands";
|
||||
|
||||
// Data Framework :
|
||||
// ++++++++++++++++
|
||||
theCommands.Add ("MakeDF",
|
||||
"Makes a new DF: MakeDF dfname",
|
||||
__FILE__, MakeDF, g);
|
||||
|
||||
theCommands.Add ("ClearDF",
|
||||
"Clears a DF: ClearDF dfname",
|
||||
__FILE__, ClearDF, g);
|
||||
|
||||
theCommands.Add ("CopyDF",
|
||||
"Copies a label: CopyDF dfname1 entry1 [dfname2] entry2",
|
||||
__FILE__, CopyDF, g);
|
||||
|
||||
theCommands.Add ("XDumpDF",
|
||||
"Exented deep dump of a DF (with attributes content): DumpDF dfname",
|
||||
__FILE__, XDumpDF, g);
|
||||
|
||||
theCommands.Add ("MiniDumpDF",
|
||||
"Mini dump of a DF (with attributes content): DumpDF dfname",
|
||||
__FILE__, MiniDumpDF, g);
|
||||
|
||||
theCommands.Add ("CopyLabel",
|
||||
"CopyLabel (DOC, from, to)",
|
||||
__FILE__, CopyLabel_SCopy, g);
|
||||
|
||||
theCommands.Add("CheckAttrs","CheckAttrs DocName Lab1 Lab2 ",
|
||||
__FILE__, DDF_CheckAttrs, g);
|
||||
|
||||
theCommands.Add("CheckLabel","CheckLabel DocName Label ",
|
||||
__FILE__, DDF_CheckLabel, g);
|
||||
|
||||
}
|
1340
src/DDF/DDF_IOStream.cxx
Executable file
1340
src/DDF/DDF_IOStream.cxx
Executable file
File diff suppressed because it is too large
Load Diff
278
src/DDF/DDF_IOStream.hxx
Executable file
278
src/DDF/DDF_IOStream.hxx
Executable file
@@ -0,0 +1,278 @@
|
||||
// File: DDF_IOStream.hxx
|
||||
// --------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Aug 22 1997 Creation
|
||||
|
||||
// This file has been written using FSD_File.hxx as template.
|
||||
// This is a specific adaptation for Draw use (save & restore commands).
|
||||
// It is not sure at all this code is portable on any other plateform than
|
||||
// SUN OS. Don't use it anywhere else.
|
||||
// Thanks for comprehension. (22 august 97)
|
||||
|
||||
|
||||
#ifndef DDF_IOStream_HeaderFile
|
||||
#define DDF_IOStream_HeaderFile
|
||||
|
||||
// File generated by CPPExt (Value)
|
||||
// Copyright (C) 1991,1995 by
|
||||
//
|
||||
// MATRA DATAVISION, FRANCE
|
||||
//
|
||||
// This software is furnished in accordance with the terms and conditions
|
||||
// of the contract and with the inclusion of the above copyright notice.
|
||||
// This software or any other copy thereof may not be provided or otherwise
|
||||
// be made available to any other person. No title to an ownership of the
|
||||
// software is hereby transferred.
|
||||
//
|
||||
// At the termination of the contract, the software and all copies of this
|
||||
// software must be deleted.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _Storage_BaseDriver_HeaderFile
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_Error_HeaderFile
|
||||
#include <Storage_Error.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_OpenMode_HeaderFile
|
||||
#include <Storage_OpenMode.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Character_HeaderFile
|
||||
#include <Standard_Character.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_ExtCharacter_HeaderFile
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_ShortReal_HeaderFile
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_CString_HeaderFile
|
||||
#include <Standard_CString.hxx>
|
||||
#endif
|
||||
#include <Storage_Position.hxx>
|
||||
|
||||
class Storage_StreamTypeMismatchError;
|
||||
class Storage_StreamFormatError;
|
||||
class Storage_StreamWriteError;
|
||||
class Storage_StreamExtCharParityError;
|
||||
|
||||
class TColStd_SequenceOfExtendedString;
|
||||
|
||||
#ifndef Standard_EXPORT
|
||||
#ifdef WNT
|
||||
#define Standard_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define Standard_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
#ifdef WNT
|
||||
#pragma warning (disable : 4275)
|
||||
#endif
|
||||
|
||||
class Standard_EXPORT DDF_IOStream : public Storage_BaseDriver {
|
||||
|
||||
public:
|
||||
|
||||
// Methods PUBLIC
|
||||
//
|
||||
DDF_IOStream();
|
||||
Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
|
||||
Storage_Error Open(istream* anIStream) ;
|
||||
Storage_Error Open(ostream* anOStream) ;
|
||||
Standard_Boolean IsEnd() ;
|
||||
Storage_Position Tell() { return -1; }
|
||||
static Storage_Error IsGoodFileType(istream* anIStream) ;
|
||||
Storage_Error BeginWriteInfoSection() ;
|
||||
void WriteInfo(const Standard_Integer nbObj,const TCollection_AsciiString& dbVersion,const TCollection_AsciiString& date,const TCollection_AsciiString& schemaName,const TCollection_AsciiString& schemaVersion,const TCollection_ExtendedString& appName,const TCollection_AsciiString& appVersion,const TCollection_ExtendedString& objectType,const TColStd_SequenceOfAsciiString& userInfo) ;
|
||||
Storage_Error EndWriteInfoSection() ;
|
||||
Storage_Error BeginReadInfoSection() ;
|
||||
void ReadInfo(Standard_Integer& nbObj,TCollection_AsciiString& dbVersion,TCollection_AsciiString& date,TCollection_AsciiString& schemaName,TCollection_AsciiString& schemaVersion,TCollection_ExtendedString& appName,TCollection_AsciiString& appVersion,TCollection_ExtendedString& objectType,TColStd_SequenceOfAsciiString& userInfo) ;
|
||||
Storage_Error EndReadInfoSection() ;
|
||||
Storage_Error BeginWriteCommentSection() ;
|
||||
void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
|
||||
Storage_Error EndWriteCommentSection() ;
|
||||
Storage_Error BeginReadCommentSection() ;
|
||||
void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
|
||||
Storage_Error EndReadCommentSection() ;
|
||||
Storage_Error BeginWriteTypeSection() ;
|
||||
void SetTypeSectionSize(const Standard_Integer aSize) ;
|
||||
void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
|
||||
Storage_Error EndWriteTypeSection() ;
|
||||
Storage_Error BeginReadTypeSection() ;
|
||||
Standard_Integer TypeSectionSize() ;
|
||||
void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
|
||||
Storage_Error EndReadTypeSection() ;
|
||||
Storage_Error BeginWriteRootSection() ;
|
||||
void SetRootSectionSize(const Standard_Integer aSize) ;
|
||||
void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
|
||||
Storage_Error EndWriteRootSection() ;
|
||||
Storage_Error BeginReadRootSection() ;
|
||||
Standard_Integer RootSectionSize() ;
|
||||
void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
|
||||
Storage_Error EndReadRootSection() ;
|
||||
Storage_Error BeginWriteRefSection() ;
|
||||
void SetRefSectionSize(const Standard_Integer aSize) ;
|
||||
void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
|
||||
Storage_Error EndWriteRefSection() ;
|
||||
Storage_Error BeginReadRefSection() ;
|
||||
Standard_Integer RefSectionSize() ;
|
||||
void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
|
||||
Storage_Error EndReadRefSection() ;
|
||||
Storage_Error BeginWriteDataSection() ;
|
||||
void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
|
||||
void BeginWritePersistentObjectData() ;
|
||||
void BeginWriteObjectData() ;
|
||||
void EndWriteObjectData() ;
|
||||
void EndWritePersistentObjectData() ;
|
||||
Storage_Error EndWriteDataSection() ;
|
||||
Storage_Error BeginReadDataSection() ;
|
||||
void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
|
||||
void BeginReadPersistentObjectData() ;
|
||||
void BeginReadObjectData() ;
|
||||
void EndReadObjectData() ;
|
||||
void EndReadPersistentObjectData() ;
|
||||
Storage_Error EndReadDataSection() ;
|
||||
void SkipObject() ;
|
||||
Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
|
||||
Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Character aValue)
|
||||
{
|
||||
return PutCharacter(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
|
||||
{
|
||||
return PutExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Integer aValue)
|
||||
{
|
||||
return PutInteger(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
|
||||
{
|
||||
return PutBoolean(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Real aValue)
|
||||
{
|
||||
return PutReal(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
|
||||
{
|
||||
return PutShortReal(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
|
||||
Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Character& aValue)
|
||||
{
|
||||
return GetCharacter(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
|
||||
{
|
||||
return GetExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Integer& aValue)
|
||||
{
|
||||
return GetInteger(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
|
||||
{
|
||||
return GetBoolean(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Real& aValue)
|
||||
{
|
||||
return GetReal(aValue);
|
||||
}
|
||||
|
||||
Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
|
||||
{
|
||||
return GetShortReal(aValue);
|
||||
}
|
||||
|
||||
Storage_Error Close() ;
|
||||
void Destroy() ;
|
||||
~DDF_IOStream()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Methods PROTECTED
|
||||
//
|
||||
void ReadLine(TCollection_AsciiString& buffer) ;
|
||||
void ReadWord(TCollection_AsciiString& buffer) ;
|
||||
void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
|
||||
void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
|
||||
void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
|
||||
void ReadString(TCollection_AsciiString& buffer) ;
|
||||
void FlushEndOfLine() ;
|
||||
Storage_Error FindTag(const Standard_CString aTag) ;
|
||||
|
||||
|
||||
// Fields PROTECTED
|
||||
//
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Methods PRIVATE
|
||||
//
|
||||
static const Standard_CString MagicNumber() ;
|
||||
|
||||
|
||||
// Fields PRIVATE
|
||||
//
|
||||
//FSD_FStream myStream;
|
||||
istream* myIStream;
|
||||
ostream* myOStream;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifdef WNT
|
||||
#pragma warning (default : 4275)
|
||||
#endif
|
||||
|
||||
|
||||
// other inline functions and methods (like "C++: function call" methods)
|
||||
//
|
||||
#endif
|
75
src/DDF/DDF_Transaction.cdl
Executable file
75
src/DDF/DDF_Transaction.cdl
Executable file
@@ -0,0 +1,75 @@
|
||||
-- File: DDF_Transaction.cdl
|
||||
-- -------------------
|
||||
-- Author: DAUTRY Philippe
|
||||
-- <fid@fox.paris1.matra-dtv.fr>
|
||||
---Copyright: MATRA DATAVISION 1997
|
||||
|
||||
---Version: 0.0
|
||||
---History: Version Date Purpose
|
||||
-- 0.0 Nov 4 1997 Creation
|
||||
|
||||
class Transaction from DDF
|
||||
inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class encapsulates TDF_Transaction.
|
||||
|
||||
uses
|
||||
|
||||
Data from TDF,
|
||||
Delta from TDF,
|
||||
Transaction from TDF
|
||||
|
||||
raises
|
||||
|
||||
DomainError, NullObject from Standard
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns Transaction from DDF;
|
||||
---Purpose: Creates an empty transaction context, unable to be
|
||||
-- opened.
|
||||
|
||||
Create(aDF : Data from TDF)
|
||||
returns Transaction from DDF;
|
||||
---Purpose: Creates a transaction context on <aDF>, ready to
|
||||
-- be opened.
|
||||
|
||||
Open(me : mutable)
|
||||
returns Integer from Standard;
|
||||
---Purpose: If not yet done, opens a new transaction on
|
||||
-- <myDF>. Returns the index of the just opened
|
||||
-- transaction.
|
||||
--
|
||||
-- It raises DomainError if the transaction is
|
||||
-- already open, and NullObject if there is no
|
||||
-- current Data framework.
|
||||
|
||||
Commit(me : mutable;
|
||||
withDelta : Boolean from Standard = Standard_False)
|
||||
returns Delta from TDF;
|
||||
---Purpose: Commits the transactions until AND including the
|
||||
-- current opened one.
|
||||
|
||||
Abort(me : mutable);
|
||||
---Purpose: Aborts the transactions until AND including the
|
||||
-- current opened one.
|
||||
--
|
||||
---C++: alias ~
|
||||
|
||||
Data(me) returns Data from TDF;
|
||||
---Purpose: Returns the Data from TDF.
|
||||
|
||||
Transaction(me) returns Integer from Standard;
|
||||
---Purpose: Returns the number of the transaction opened by <me>.
|
||||
|
||||
IsOpen(me)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns true if the transaction is open.
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myTransaction : Transaction from TDF;
|
||||
|
||||
end Transaction;
|
88
src/DDF/DDF_Transaction.cxx
Executable file
88
src/DDF/DDF_Transaction.cxx
Executable file
@@ -0,0 +1,88 @@
|
||||
// File: DDF_Transaction.cxx
|
||||
// -------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Nov 4 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF_Transaction.ixx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_Transaction
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_Transaction::DDF_Transaction()
|
||||
: myTransaction( TCollection_AsciiString() )
|
||||
{}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDF_Transaction
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
DDF_Transaction::DDF_Transaction(const Handle(TDF_Data)& aDF)
|
||||
: myTransaction( TCollection_AsciiString() )
|
||||
{ myTransaction.Initialize(aDF); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Open
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer DDF_Transaction::Open()
|
||||
{ return myTransaction.Open(); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Commit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Delta) DDF_Transaction::Commit(const Standard_Boolean withDelta)
|
||||
{ return myTransaction.Commit(withDelta); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Abort
|
||||
//purpose : alias ~
|
||||
//=======================================================================
|
||||
|
||||
void DDF_Transaction::Abort()
|
||||
{ myTransaction.Abort(); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Data
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Data) DDF_Transaction::Data() const
|
||||
{ return myTransaction.Data(); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Transaction
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer DDF_Transaction::Transaction() const
|
||||
{ return myTransaction.Transaction(); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsOpen
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean DDF_Transaction::IsOpen() const
|
||||
{ return myTransaction.IsOpen(); }
|
||||
|
229
src/DDF/DDF_TransactionCommands.cxx
Executable file
229
src/DDF/DDF_TransactionCommands.cxx
Executable file
@@ -0,0 +1,229 @@
|
||||
// File: DDF_TransactionCommands.cxx
|
||||
// ---------------------------
|
||||
// Author: DAUTRY Philippe
|
||||
// <fid@fox.paris1.matra-dtv.fr>
|
||||
// Copyright: Matra Datavision 1997
|
||||
// Version: 0.0
|
||||
// History: Version Date Purpose
|
||||
// 0.0 Sep 30 1997 Creation
|
||||
|
||||
|
||||
|
||||
#include <DDF.hxx>
|
||||
#include <DDF_Data.hxx>
|
||||
#include <DDF_Transaction.hxx>
|
||||
#include <DDF_TransactionStack.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Delta.hxx>
|
||||
#include <TDF_Transaction.hxx>
|
||||
|
||||
static DDF_TransactionStack DDF_TStack;
|
||||
static Handle(TDF_Delta) DDF_LastDelta;
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Transaction commands
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenTran
|
||||
//purpose : Opens a transaction
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer OpenTran (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (DDF::GetDF (a[1], DF)) {
|
||||
Handle(DDF_Transaction) tr = new DDF_Transaction(DF);
|
||||
di<<"Open transaction # "<<tr->Open()<<" # "<<DF->Transaction()<<"\n";
|
||||
DDF_TStack.Push(tr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AbortTran
|
||||
//purpose : Aborts a transaction
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer AbortTran (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (DDF::GetDF (a[1], DF)) {
|
||||
if (DF->Transaction () > 0) {
|
||||
Handle(DDF_Transaction) tr = DDF_TStack.Top();
|
||||
di<<"Abort transaction # "<<tr->Transaction()<<" # "<<DF->Transaction()<<"\n";
|
||||
tr->Abort();
|
||||
DDF_TStack.Pop();
|
||||
}
|
||||
else {
|
||||
di<<"DDF_BasicCommands::AbortTran - No more transaction to abort"<<"\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CommitTran
|
||||
//purpose : Commits a transaction
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer CommitTran (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (DDF::GetDF (a[1], DF)) {
|
||||
if (DF->Transaction () > 0) {
|
||||
Handle(DDF_Transaction) tr = DDF_TStack.Top();
|
||||
di<<"Commit transaction # "<<tr->Transaction()<<" # "<<DF->Transaction()<<"\n";
|
||||
Standard_Boolean withDelta = Standard_False;
|
||||
if (n > 2) withDelta = (atoi(a[2]) != 0);
|
||||
DDF_LastDelta = tr->Commit(withDelta);
|
||||
DDF_TStack.Pop();
|
||||
}
|
||||
else {
|
||||
di<<"DDF_BasicCommands::CommitTran - No more transaction to commit"<<"\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CurrentTran
|
||||
//purpose : Current transaction number.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer CurrentTran (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (DDF::GetDF (a[1], DF)) {
|
||||
di<<"# "<<DF->Transaction()<<"\n";
|
||||
if (!DDF_TStack.IsEmpty())
|
||||
if (DF->Transaction() != DDF_TStack.Top()->Transaction())
|
||||
di<<"Transaction object said # "<<DDF_TStack.Top()->Transaction()<<"\n";
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Delta commands
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Undo
|
||||
//purpose : Undo
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer Undo (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (DDF::GetDF (a[1], DF)) {
|
||||
Standard_Boolean withDelta = Standard_False;
|
||||
if (n > 2) withDelta = (atoi(a[2]) != 0);
|
||||
if (!DDF_LastDelta.IsNull()) {
|
||||
if (DF->IsApplicable(DDF_LastDelta)) {
|
||||
Handle(TDF_Delta) tmp = DF->Undo(DDF_LastDelta,withDelta);
|
||||
DDF_LastDelta = tmp;
|
||||
}
|
||||
else {
|
||||
di<<"Undo not applicable HERE and NOW."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
di<<"No undo to apply."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
di<<"Unknown DF."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TransactionCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void DDF::TransactionCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
const char* g = "DF transaction and undo commands";
|
||||
|
||||
// Transaction :
|
||||
// +++++++++++++
|
||||
theCommands.Add
|
||||
("OpenTran",
|
||||
"Opens a transaction on a DF: OpenTran dfname",
|
||||
__FILE__, OpenTran, g);
|
||||
|
||||
theCommands.Add
|
||||
("AbortTran",
|
||||
"Aborts a transaction on a DF: AbortTran dfname",
|
||||
__FILE__, AbortTran, g);
|
||||
|
||||
theCommands.Add
|
||||
("CommitTran",
|
||||
"Commits a transaction on a DF with/without delta generation : CommitTran dfname [withDelta]",
|
||||
__FILE__, CommitTran, g);
|
||||
|
||||
theCommands.Add
|
||||
("CurrentTran",
|
||||
"Returns the current transaction number on a DF : CurrentTran dfname",
|
||||
__FILE__, CurrentTran, g);
|
||||
|
||||
// Undo :
|
||||
// ++++++
|
||||
theCommands.Add
|
||||
("DFUndo",
|
||||
" Undos last DF commit modifications: Undo dfname [withDelta]",
|
||||
__FILE__, Undo, g);
|
||||
|
||||
|
||||
}
|
9
src/DDF/FILES
Executable file
9
src/DDF/FILES
Executable file
@@ -0,0 +1,9 @@
|
||||
DDF_AttributeBrowser.hxx
|
||||
DDF_AttributeBrowser.cxx
|
||||
DDF_BasicCommands.cxx
|
||||
DDF_DataCommands.cxx
|
||||
DDF_TransactionCommands.cxx
|
||||
DDF_BrowserCommands.cxx
|
||||
DDF_IOStream.cxx
|
||||
DDF_IOStream.hxx
|
||||
FILES
|
Reference in New Issue
Block a user