1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

XCAF: notes Bin/XML drivers

# Conflicts:
#	src/XmlMXCAFDoc/XmlMXCAFDoc.hxx
This commit is contained in:
snn 2017-02-14 17:32:19 +03:00
parent b87a2fa42c
commit e66ddc4bab
25 changed files with 912 additions and 179 deletions

View File

@ -74,7 +74,6 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
theDriverTable->AddDriver( new BinMXCAFDoc_DimensionDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
theDriverTable->AddDriver (new BinMXCAFDoc_ViewDriver (theMsgDrv));

View File

@ -34,6 +34,9 @@ class BinMXCAFDoc_GeomToleranceDriver;
class BinMXCAFDoc_DimensionDriver;
class BinMXCAFDoc_DimTolDriver;
class BinMXCAFDoc_MaterialDriver;
class BinMXCAFDoc_NoteCommentDriver;
class BinMXCAFDoc_NoteBinDataDriver;
class BinMXCAFDoc_NotesToolDriver;
class BinMXCAFDoc_ColorToolDriver;
class BinMXCAFDoc_DocumentToolDriver;
class BinMXCAFDoc_LayerToolDriver;

View File

@ -17,7 +17,8 @@
#include <CDM_MessageDriver.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
#include <XCAFDoc_NoteBinData.hxx>
@ -52,14 +53,16 @@ Standard_Boolean BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteBinData) aNoteBinData = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
TCollection_AsciiString aData, aMIMEtype;
if (!(theSource >> aData >> aMIMEtype))
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
aNoteBinData->Set(new TCollection_HAsciiString(aData),
new TCollection_HAsciiString(aMIMEtype));
TCollection_ExtendedString aTitle;
TCollection_AsciiString aData, aMIMEtype;
if (!(theSource >> aTitle >> aData >> aMIMEtype))
return Standard_False;
aNote->Set(aTitle, aData, aMIMEtype);
return Standard_True;
}
@ -74,12 +77,13 @@ void BinMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBinData) aNoteBinData = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
Handle(TCollection_HAsciiString) aData = aNoteBinData->Data();
Handle(TCollection_HAsciiString) aMIMEtype = aNoteBinData->MIMEtype();
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
if (!aNote.IsNull())
{
theTarget
<< (aData ? aData->String() : TCollection_AsciiString(""))
<< (aMIMEtype ? aMIMEtype->String() : TCollection_AsciiString(""))
<< aNote->Title()
<< aNote->MIMEtype()
<< aNote->Data()
;
}
}

View File

@ -51,13 +51,15 @@ Standard_Boolean BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteComment) aNoteComment = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aComment;
if (!(theSource >> aComment))
return Standard_False;
aNoteComment->Set(new TCollection_HExtendedString(aComment));
aNote->Set(aComment);
return Standard_True;
}
@ -72,10 +74,7 @@ void BinMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteComment) aNoteComment = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
Handle(TCollection_HExtendedString) aComment = aNoteComment->TimeStamp();
theTarget
<< (aComment ? aComment->String() : TCollection_ExtendedString(""))
;
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
if (!aNote.IsNull())
theTarget << aNote->Comment();
}

View File

@ -22,15 +22,6 @@
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
{
}
//=======================================================================
//function :
//purpose :
@ -42,15 +33,6 @@ BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)&
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
{
return new XCAFDoc_Note();
}
//=======================================================================
//function :
//purpose :
@ -60,13 +42,14 @@ Standard_Boolean BinMXCAFDoc_NoteDriver::Paste(const BinObjMgt_Persistent& theS
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aUserName, aTimeStamp;
if (!(theSource >> aUserName >> aTimeStamp))
return Standard_False;
aNote->Set(new TCollection_HExtendedString(aUserName),
new TCollection_HExtendedString(aTimeStamp));
aNote->Set(aUserName, aTimeStamp);
return Standard_True;
}
@ -80,10 +63,6 @@ void BinMXCAFDoc_NoteDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_SRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theSource);
Handle(TCollection_HExtendedString) aUserName = aNote->UserName();
Handle(TCollection_HExtendedString) aTimeStamp = aNote->TimeStamp();
theTarget
<< (aUserName ? aUserName->String() : TCollection_ExtendedString(""))
<< (aTimeStamp ? aTimeStamp->String() : TCollection_ExtendedString(""))
;
if (!aNote.IsNull())
theTarget << aNote->UserName() << aNote->TimeStamp();
}

View File

@ -35,10 +35,6 @@ class BinMXCAFDoc_NoteDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;

View File

@ -15,42 +15,33 @@
#include <Standard_GUID.hxx>
#include <TDF_Label.hxx>
#include <XCAFDoc_Note.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_NoteComment.hxx>
#include <XCAFDoc_NoteBinData.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
const Standard_GUID& XCAFDoc_Note::GetID()
{
static Standard_GUID s_ID("FDC0AF06-C4AC-468a-ACFB-4C9388C76D9E");
return s_ID;
}
Standard_Boolean XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Note) anAttr;
return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_Note::GetID(), anAttr));
}
Handle(XCAFDoc_Note) XCAFDoc_Note::Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp)
{
Handle(XCAFDoc_Note) aNote;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote))
{
aNote = new XCAFDoc_Note();
aNote->Set(theUserName, theTimeStamp);
theLabel.AddAttribute(aNote);
}
return aNote;
return !Get(theLabel).IsNull();
}
XCAFDoc_Note::XCAFDoc_Note()
{
}
void XCAFDoc_Note::Set(const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp)
Handle(XCAFDoc_Note) XCAFDoc_Note::Get(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Note) aNote;
if (theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNote) ||
theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNote))
return aNote;
return aNote;
}
void XCAFDoc_Note::Set(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp)
{
Backup();
@ -58,24 +49,85 @@ void XCAFDoc_Note::Set(const Handle(TCollection_HExtendedString)& theUserName,
myTimeStamp = theTimeStamp;
}
Handle(TCollection_HExtendedString) XCAFDoc_Note::UserName() const
const TCollection_ExtendedString& XCAFDoc_Note::UserName() const
{
return myUserName;
}
Handle(TCollection_HExtendedString) XCAFDoc_Note::TimeStamp() const
const TCollection_ExtendedString& XCAFDoc_Note::TimeStamp() const
{
return myTimeStamp;
}
const Standard_GUID& XCAFDoc_Note::ID() const
Standard_Boolean XCAFDoc_Note::IsAttached() const
{
return GetID();
if (!IsMine(Label()))
return Standard_False;
Handle(XCAFDoc_GraphNode) aFather;
return Label().FindAttribute(XCAFDoc::NoteRefGUID(), aFather) &&
(aFather->NbChildren() > 0);
}
Handle(TDF_Attribute) XCAFDoc_Note::NewEmpty() const
void XCAFDoc_Note::Attach(const TDF_LabelSequence& theLabels)
{
return new XCAFDoc_Note();
if (!IsMine(Label()) || theLabels.Length() == 0)
return;
Handle(XCAFDoc_GraphNode) aFather = XCAFDoc_GraphNode::Set(Label(), XCAFDoc::NoteRefGUID());
for (Standard_Integer i = theLabels.Lower(); i <= theLabels.Upper(); i++)
{
Handle(XCAFDoc_GraphNode) aChild = XCAFDoc_GraphNode::Set(theLabels.Value(i), XCAFDoc::NoteRefGUID());
aChild->SetFather(aFather);
aFather->SetChild(aChild);
}
}
void XCAFDoc_Note::Detach(const TDF_LabelSequence& theLabels)
{
if (!IsMine(Label()) || theLabels.Length() == 0)
return;
Handle(XCAFDoc_GraphNode) aFather;
if (Label().FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
{
for (Standard_Integer i = theLabels.Lower(); i <= theLabels.Upper(); i++)
{
Handle(XCAFDoc_GraphNode) aChild;
if (theLabels.Value(i).FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
{
Standard_Integer iFather = aChild->FatherIndex(aFather);
if (iFather > 0)
aChild->UnSetFather(iFather);
if (aChild->NbFathers() == 0)
theLabels.Value(i).ForgetAttribute(aChild);
}
}
if (aFather->NbChildren() == 0)
Label().ForgetAttribute(aFather);
}
}
void XCAFDoc_Note::DetachAll()
{
if (!IsMine(Label()))
return;
Handle(XCAFDoc_GraphNode) aFather;
if (Label().FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
{
Standard_Integer nbChildren = aFather->NbChildren();
for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild)
{
Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild);
aFather->UnSetChild(iChild);
if (aChild->NbFathers() == 0)
aChild->Label().ForgetAttribute(aChild);
}
if (aFather->NbChildren() == 0)
Label().ForgetAttribute(aFather);
}
}
void XCAFDoc_Note::Restore(const Handle(TDF_Attribute)& theAttr)
@ -94,9 +146,9 @@ Standard_OStream& XCAFDoc_Note::Dump(Standard_OStream& theOS) const
{
theOS
<< "Note : "
<< (myUserName ? myUserName->String() : "<anonymous>")
<< (myUserName.IsEmpty() ? myUserName : "<anonymous>")
<< " on "
<< (myTimeStamp ? myTimeStamp->String() : "<unknown>")
<< (myTimeStamp.IsEmpty() ? myTimeStamp : "<unknown>")
;
return theOS;
}

View File

@ -18,9 +18,10 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TCollection_HExtendedString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_File.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_LabelSequence.hxx>
class Standard_GUID;
class TDF_RelocationTable;
@ -34,29 +35,26 @@ public:
DEFINE_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
Standard_EXPORT static Handle(XCAFDoc_Note) Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp);
Standard_EXPORT static Handle(XCAFDoc_Note) Get(const TDF_Label& theLabel);
Standard_EXPORT XCAFDoc_Note();
Standard_EXPORT void Set(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp);
Standard_EXPORT void Set(const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp);
Standard_EXPORT const TCollection_ExtendedString& UserName() const;
Standard_EXPORT Handle(TCollection_HExtendedString) UserName() const;
Standard_EXPORT const TCollection_ExtendedString& TimeStamp() const;
Standard_EXPORT Handle(TCollection_HExtendedString) TimeStamp() const;
Standard_EXPORT Standard_Boolean IsAttached() const;
Standard_EXPORT void Attach(const TDF_LabelSequence& theLabels);
Standard_EXPORT void Detach(const TDF_LabelSequence& theLabels);
Standard_EXPORT void DetachAll();
public:
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theAttrInto,
@ -66,8 +64,12 @@ public:
protected:
Handle(TCollection_HExtendedString) myUserName;
Handle(TCollection_HExtendedString) myTimeStamp;
Standard_EXPORT XCAFDoc_Note();
private:
TCollection_ExtendedString myUserName;
TCollection_ExtendedString myTimeStamp;
};
#endif // _XCAFDoc_Note_HeaderFile

View File

@ -34,17 +34,18 @@ Standard_Boolean XCAFDoc_NoteBinData::IsMine(const TDF_Label& theLabel)
}
Handle(XCAFDoc_NoteBinData) XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const Handle(TCollection_HAsciiString)& theMIMEtype)
const TCollection_AsciiString& theMIMEtype)
{
Handle(XCAFDoc_NoteBinData) aNoteBinData;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNoteBinData))
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNoteBinData))
{
aNoteBinData = new XCAFDoc_NoteBinData();
aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
aNoteBinData->Set(theFile, theMIMEtype);
aNoteBinData->Set(theTitle, theFile, theMIMEtype);
theLabel.AddAttribute(aNoteBinData);
}
return aNoteBinData;
@ -54,36 +55,44 @@ XCAFDoc_NoteBinData::XCAFDoc_NoteBinData()
{
}
void XCAFDoc_NoteBinData::Set(OSD_File& theFile,
const Handle(TCollection_HAsciiString)& theMIMEtype)
void XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const TCollection_AsciiString& theMIMEtype)
{
if (!theFile.IsOpen() || !theFile.IsReadable())
return;
TCollection_AsciiString aStr;
theFile.Read(aStr, theFile.Size());
Backup();
myData.reset(new TCollection_HAsciiString(aStr));
TCollection_AsciiString myData;
theFile.Read(myData, theFile.Size());
myTitle = theTitle;
myMIMEtype = theMIMEtype;
}
void XCAFDoc_NoteBinData::Set(const Handle(TCollection_HAsciiString)& theData,
const Handle(TCollection_HAsciiString)& theMIMEtype)
void XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theData,
const TCollection_AsciiString& theMIMEtype)
{
Backup();
myData = theData;
myTitle = theTitle;
myMIMEtype = theMIMEtype;
}
Handle(TCollection_HAsciiString) XCAFDoc_NoteBinData::Data() const
const TCollection_ExtendedString& XCAFDoc_NoteBinData::Title() const
{
return myTitle;
}
const TCollection_AsciiString& XCAFDoc_NoteBinData::Data() const
{
return myData;
}
Handle(TCollection_HAsciiString) XCAFDoc_NoteBinData::MIMEtype() const
const TCollection_AsciiString& XCAFDoc_NoteBinData::MIMEtype() const
{
return myMIMEtype;
}
@ -95,34 +104,40 @@ const Standard_GUID& XCAFDoc_NoteBinData::ID() const
Handle(TDF_Attribute) XCAFDoc_NoteBinData::NewEmpty() const
{
return new XCAFDoc_Note();
return new XCAFDoc_NoteBinData();
}
void XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr)
{
XCAFDoc_Note::Restore(theAttr);
myData = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr)->myData;
myMIMEtype = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr)->myMIMEtype;
Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr);
if (!aMine.IsNull())
{
myData = aMine->myData;
myTitle = aMine->myTitle;
myMIMEtype = aMine->myMIMEtype;
}
}
void XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)& theAttrInto,
const Handle(TDF_RelocationTable)& theRT) const
{
XCAFDoc_Note::Paste(theAttrInto, theRT);
Handle(XCAFDoc_NoteBinData)::DownCast(theAttrInto)->Set(myData, myMIMEtype);
Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttrInto);
if (!aMine.IsNull())
aMine->Set(myTitle, myData, myMIMEtype);
}
Standard_OStream& XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const
{
XCAFDoc_Note::Dump(theOS);
theOS
<< "\n"
<< "MIME type : "
<< (myMIMEtype ? myMIMEtype->String() : "<none>")
<< "\n"
<< "<BEGIN>"
<< (myData ? myData->String() : "")
<< "<END>"
theOS << "\n"
<< "Title : " << (!myTitle.IsEmpty() ? myMIMEtype : "<untitled>") << "\n"
<< "MIME type : " << (!myMIMEtype.IsEmpty() ? myMIMEtype : "<none>") << "\n"
<< "Size : " << myData.Length() << " bytes" << "\n"
<< myData
;
return theOS;
}

View File

@ -19,7 +19,8 @@
#include <XCAFDoc_Note.hxx>
class OSD_File;
class TCollection_HAsciiString;
class TCollection_AsciiString;
class TCollection_ExtendedString;
class XCAFDoc_NoteBinData;
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, XCAFDoc_Note)
@ -35,21 +36,25 @@ public:
Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const Handle(TCollection_HAsciiString)& theMIMEtype);
const TCollection_AsciiString& theMIMEtype);
Standard_EXPORT XCAFDoc_NoteBinData();
Standard_EXPORT void Set(OSD_File& theFile,
const Handle(TCollection_HAsciiString)& theMIMEtype);
Standard_EXPORT void Set(const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const TCollection_AsciiString& theMIMEtype);
Standard_EXPORT void Set(const Handle(TCollection_HAsciiString)& theData,
const Handle(TCollection_HAsciiString)& theMIMEtype);
Standard_EXPORT void Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theData,
const TCollection_AsciiString& theMIMEtype);
Standard_EXPORT Handle(TCollection_HAsciiString) Data() const;
Standard_EXPORT Handle(TCollection_HAsciiString) MIMEtype() const;
Standard_EXPORT const TCollection_ExtendedString& Title() const;
Standard_EXPORT const TCollection_AsciiString& Data() const;
Standard_EXPORT const TCollection_AsciiString& MIMEtype() const;
public:
@ -66,8 +71,9 @@ public:
protected:
Handle(TCollection_HAsciiString) myData;
Handle(TCollection_HAsciiString) myMIMEtype;
TCollection_ExtendedString myTitle;
TCollection_AsciiString myData;
TCollection_AsciiString myMIMEtype;
};
#endif // _XCAFDoc_NoteBinData_HeaderFile

View File

@ -32,12 +32,12 @@ Standard_Boolean XCAFDoc_NoteComment::IsMine(const TDF_Label& theLabel)
}
Handle(XCAFDoc_NoteComment) XCAFDoc_NoteComment::Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp,
const Handle(TCollection_HExtendedString)& theComment)
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment)
{
Handle(XCAFDoc_NoteComment) aNoteComment;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNoteComment))
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNoteComment))
{
aNoteComment = new XCAFDoc_NoteComment();
aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp);
@ -51,14 +51,14 @@ XCAFDoc_NoteComment::XCAFDoc_NoteComment()
{
}
void XCAFDoc_NoteComment::Set(const Handle(TCollection_HExtendedString)& theComment)
void XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment)
{
Backup();
myComment = theComment;
}
Handle(TCollection_HExtendedString) XCAFDoc_NoteComment::Comment() const
const TCollection_ExtendedString& XCAFDoc_NoteComment::Comment() const
{
return myComment;
}
@ -70,29 +70,33 @@ const Standard_GUID& XCAFDoc_NoteComment::ID() const
Handle(TDF_Attribute) XCAFDoc_NoteComment::NewEmpty() const
{
return new XCAFDoc_Note();
return new XCAFDoc_NoteComment();
}
void XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr)
{
XCAFDoc_Note::Restore(theAttr);
myComment = Handle(XCAFDoc_NoteComment)::DownCast(theAttr)->myComment;
Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttr);
if (!aMine.IsNull())
myComment = aMine->myComment;
}
void XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto,
const Handle(TDF_RelocationTable)& theRT) const
{
XCAFDoc_Note::Paste(theAttrInto, theRT);
Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto)->Set(myComment);
Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto);
if (!aMine.IsNull())
aMine->Set(myComment);
}
Standard_OStream& XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const
{
XCAFDoc_Note::Dump(theOS);
theOS
<< "\n"
<< "Comment : "
<< (myComment ? myComment->String() : "<empty>")
theOS << "\n"
<< "Comment : " << (!myComment.IsEmpty() ? myComment : "<empty>")
;
return theOS;
}

View File

@ -32,15 +32,15 @@ public:
Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label& theLabel,
const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp,
const Handle(TCollection_HExtendedString)& theComment);
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment);
Standard_EXPORT XCAFDoc_NoteComment();
Standard_EXPORT void Set(const Handle(TCollection_HExtendedString)& theComment);
Standard_EXPORT void Set(const TCollection_ExtendedString& theComment);
Standard_EXPORT Handle(TCollection_HExtendedString) Comment() const;
Standard_EXPORT const TCollection_ExtendedString& Comment() const;
public:
@ -57,7 +57,7 @@ public:
protected:
Handle(TCollection_HExtendedString) myComment;
TCollection_ExtendedString myComment;
};
#endif // _XCAFDoc_NoteComment_HeaderFile

View File

@ -20,7 +20,8 @@
#include <XCAFDoc.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_NotesTool.hxx>
#include <XCAFDoc_Note.hxx>
#include <XCAFDoc_NoteComment.hxx>
#include <XCAFDoc_NoteBinData.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NotesTool, TDF_Attribute)
@ -45,6 +46,20 @@ XCAFDoc_NotesTool::XCAFDoc_NotesTool()
{
}
Standard_Integer XCAFDoc_NotesTool::NbNotes() const
{
Standard_Integer nbNotes = 0;
for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next())
{
const TDF_Label aLabel = anIter.Value();
if (XCAFDoc_Note::IsMine(aLabel))
{
++nbNotes;
}
}
return nbNotes;
}
void XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const
{
theNoteLabels.Clear();
@ -58,13 +73,117 @@ void XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const
}
}
Handle(XCAFDoc_Note) XCAFDoc_NotesTool::AddNote(const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp)
Handle(XCAFDoc_Note)
XCAFDoc_NotesTool::AddComment(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment)
{
TDF_Label aNoteLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(Label());
return XCAFDoc_Note::Set(aNoteLabel, theUserName, theTimeStamp);
return XCAFDoc_NoteComment::Set(aNoteLabel, theUserName, theTimeStamp, theComment);
}
Handle(XCAFDoc_Note)
XCAFDoc_NotesTool::AddBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const TCollection_AsciiString& theMIMEtype)
{
TDF_Label aNoteLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(Label());
return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theFile, theMIMEtype);
}
Standard_Boolean XCAFDoc_NotesTool::HasAttachedNotes(const TDF_Label& theLabel) const
{
Handle(XCAFDoc_GraphNode) aChild;
return !theLabel.IsNull() &&
theLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild) &&
(aChild->NbFathers() > 0);
}
void XCAFDoc_NotesTool::GetAttachedNotes(const TDF_Label& theLabel,
TDF_LabelSequence& theNoteLabels) const
{
theNoteLabels.Clear();
Handle(XCAFDoc_GraphNode) aChild;
if (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
{
Standard_Integer nbNotes = aChild->NbFathers();
for (Standard_Integer iNote = 1; iNote <= nbNotes; ++iNote)
{
Handle(XCAFDoc_GraphNode) aNote = aChild->GetFather(iNote);
if (XCAFDoc_Note::IsMine(aNote->Label()))
theNoteLabels.Append(aNote->Label());
}
}
}
Standard_Integer XCAFDoc_NotesTool::DetachAllNotes(const TDF_Label& theLabel) const
{
Standard_Integer nbNotes = 0;
Handle(XCAFDoc_GraphNode) aChild;
if (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
{
Standard_Integer nbNotes = aChild->NbFathers();
for (Standard_Integer iNote = 1; iNote <= nbNotes; ++iNote)
{
aChild->UnSetFather(iNote);
++nbNotes;
}
}
theLabel.ForgetAttribute(aChild);
return nbNotes;
}
Standard_Boolean XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel)
{
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(theNoteLabel);
if (!aNote.IsNull())
{
aNote->DetachAll();
theNoteLabel.ForgetAllAttributes(Standard_True);
return Standard_True;
}
return Standard_False;
}
Standard_Integer XCAFDoc_NotesTool::RemoveNotes(TDF_LabelSequence& theNoteLabels)
{
Standard_Integer nbNotes = 0;
for (TDF_LabelSequence::Iterator anIter(theNoteLabels); anIter.More(); anIter.Next())
{
if (RemoveNote(anIter.Value()))
++nbNotes;
}
return nbNotes;
}
Standard_Integer XCAFDoc_NotesTool::RemoveDetachedNotes()
{
Standard_Integer nbNotes = 0;
for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next())
{
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(anIter.Value());
if (!aNote.IsNull() && !aNote->IsAttached() && RemoveNote(anIter.Value()))
++nbNotes;
}
return nbNotes;
}
Standard_Integer XCAFDoc_NotesTool::RemoveAllNotes()
{
Standard_Integer nbNotes = 0;
for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next())
{
if (RemoveNote(anIter.Value()))
++nbNotes;
}
return nbNotes;
}
const Standard_GUID& XCAFDoc_NotesTool::ID() const

View File

@ -21,8 +21,10 @@
#include <TDF_Attribute.hxx>
#include <TDF_LabelSequence.hxx>
class OSD_File;
class Standard_GUID;
class TCollection_HExtendedString;
class TCollection_AsciiString;
class TCollection_ExtendedString;
class TDF_RelocationTable;
class XCAFDoc_Note;
@ -37,18 +39,34 @@ public:
Standard_EXPORT static const Standard_GUID& GetID();
//! Create (if not exist) NotesTool from XCAFDoc on <L>.
Standard_EXPORT static Handle(XCAFDoc_NotesTool) Set(const TDF_Label& theLabel);
//! Creates an empty tool
Standard_EXPORT XCAFDoc_NotesTool();
//! Returns a sequence of note labels currently stored in the tool table
Standard_EXPORT Standard_Integer NbNotes() const;
Standard_EXPORT void GetNotes(TDF_LabelSequence& theNoteLabels) const;
//! Adds a new note and returns a handle to it
Standard_EXPORT Handle(XCAFDoc_Note) AddNote(const Handle(TCollection_HExtendedString)& theUserName,
const Handle(TCollection_HExtendedString)& theTimeStamp);
Standard_EXPORT Handle(XCAFDoc_Note) AddComment(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment);
Standard_EXPORT Handle(XCAFDoc_Note) AddBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
OSD_File& theFile,
const TCollection_AsciiString& theMIMEtype);
Standard_EXPORT Standard_Boolean HasAttachedNotes(const TDF_Label& theLabel) const;
Standard_EXPORT void GetAttachedNotes(const TDF_Label& theLabel,
TDF_LabelSequence& theNoteLabels) const;
Standard_EXPORT Standard_Integer DetachAllNotes(const TDF_Label& theLabel) const;
Standard_EXPORT Standard_Boolean RemoveNote(const TDF_Label& theNoteLabel);
Standard_EXPORT Standard_Integer RemoveNotes(TDF_LabelSequence& theNoteLabels);
Standard_EXPORT Standard_Integer RemoveDetachedNotes();
Standard_EXPORT Standard_Integer RemoveAllNotes();
public:

View File

@ -29,6 +29,14 @@ XmlMXCAFDoc_MaterialDriver.cxx
XmlMXCAFDoc_MaterialDriver.hxx
XmlMXCAFDoc_MaterialToolDriver.cxx
XmlMXCAFDoc_MaterialToolDriver.hxx
XmlMXCAFDoc_NoteDriver.cxx
XmlMXCAFDoc_NoteDriver.hxx
XmlMXCAFDoc_NoteCommentDriver.cxx
XmlMXCAFDoc_NoteCommentDriver.hxx
XmlMXCAFDoc_NoteBinDataDriver.cxx
XmlMXCAFDoc_NoteBinDataDriver.hxx
XmlMXCAFDoc_NotesToolDriver.cxx
XmlMXCAFDoc_NotesToolDriver.hxx
XmlMXCAFDoc_ShapeToolDriver.cxx
XmlMXCAFDoc_ShapeToolDriver.hxx
XmlMXCAFDoc_ViewToolDriver.cxx

View File

@ -32,6 +32,9 @@
#include <XmlMXCAFDoc_LayerToolDriver.hxx>
#include <XmlMXCAFDoc_LocationDriver.hxx>
#include <XmlMXCAFDoc_MaterialDriver.hxx>
#include <XmlMXCAFDoc_NotesToolDriver.hxx>
#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
#include <XmlMXCAFDoc_MaterialToolDriver.hxx>
#include <XmlMXCAFDoc_ShapeToolDriver.hxx>
#include <XmlMXCAFDoc_ViewToolDriver.hxx>
@ -66,6 +69,8 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
aDriverTable -> AddDriver (new XmlMXCAFDoc_DatumDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteCommentDriver(anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBinDataDriver(anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ColorToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_DocumentToolDriver (anMsgDrv));
@ -73,6 +78,7 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
aDriverTable -> AddDriver (new XmlMXCAFDoc_ShapeToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NotesToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ViewToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ClippingPlaneToolDriver(anMsgDrv));
}

View File

@ -32,6 +32,11 @@ class XmlMXCAFDoc_VolumeDriver;
class XmlMXCAFDoc_DatumDriver;
class XmlMXCAFDoc_DimTolDriver;
class XmlMXCAFDoc_MaterialDriver;
class XmlMXCAFDoc_NotesToolDriver;
class XmlMXCAFDoc_NoteDriver;
class XmlMXCAFDoc_NoteCommentDriver;
class XmlMXCAFDoc_NoteBinDataDriver;
class XmlMXCAFDoc_ClippingPlaneToolDriver;
class XmlMXCAFDoc_ColorToolDriver;
class XmlMXCAFDoc_DocumentToolDriver;
class XmlMXCAFDoc_LayerToolDriver;
@ -77,6 +82,7 @@ friend class XmlMXCAFDoc_VolumeDriver;
friend class XmlMXCAFDoc_DatumDriver;
friend class XmlMXCAFDoc_DimTolDriver;
friend class XmlMXCAFDoc_MaterialDriver;
friend class XmlMXCAFDoc_ClippingPlaneToolDriver;
friend class XmlMXCAFDoc_ColorToolDriver;
friend class XmlMXCAFDoc_DocumentToolDriver;
friend class XmlMXCAFDoc_LayerToolDriver;

View File

@ -0,0 +1,92 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <CDM_MessageDriver.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_NoteBinData.hxx>
#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
IMPLEMENT_DOMSTRING(Title, "title")
IMPLEMENT_DOMSTRING(MIMEtype, "mime_type")
IMPLEMENT_DOMSTRING(Data, "data")
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteBinDataDriver::XmlMXCAFDoc_NoteBinDataDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
: XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_NoteBinDataDriver::NewEmpty() const
{
return new XCAFDoc_NoteBinData();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_NoteBinDataDriver::Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const
{
XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
const XmlObjMgt_Element& anElement = theSource;
XmlObjMgt_DOMString aTitle = anElement.getAttribute(::Title());
XmlObjMgt_DOMString aMIMEtype = anElement.getAttribute(::MIMEtype());
XmlObjMgt_DOMString aData = anElement.getAttribute(::Data());
if (aTitle == NULL || aMIMEtype == NULL || aData == NULL)
return Standard_False;
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
aNote->Set(aTitle.GetString(), aData.GetString(), aMIMEtype.GetString());
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const
{
XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
XmlObjMgt_DOMString aTitle(TCollection_AsciiString(aNote->Title()).ToCString());
XmlObjMgt_DOMString aMIMEtype(aNote->MIMEtype().ToCString());
XmlObjMgt_DOMString aData(aNote->Data().ToCString());
theTarget.Element().setAttribute(::Title(), aTitle);
theTarget.Element().setAttribute(::MIMEtype(), aMIMEtype);
theTarget.Element().setAttribute(::Data(), aData);
}

View File

@ -0,0 +1,45 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile
#define _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile
#include <XmlMXCAFDoc_NoteDriver.hxx>
class XmlMXCAFDoc_NoteBinDataDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
//! Attribute Driver.
class XmlMXCAFDoc_NoteBinDataDriver : public XmlMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT XmlMXCAFDoc_NoteBinDataDriver(const Handle(CDM_MessageDriver)& theMessageDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
};
#endif // _XmlMXCAFDoc_NoteBinDataDriver_HeaderFile

View File

@ -0,0 +1,84 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <CDM_MessageDriver.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_NoteComment.hxx>
#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
IMPLEMENT_DOMSTRING(Comment, "comment")
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteCommentDriver::XmlMXCAFDoc_NoteCommentDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
: XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_NoteCommentDriver::NewEmpty() const
{
return new XCAFDoc_NoteComment();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_NoteCommentDriver::Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const
{
XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
const XmlObjMgt_Element& anElement = theSource;
XmlObjMgt_DOMString aComment = anElement.getAttribute(::Comment());
if (aComment == NULL)
return Standard_False;
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
aNote->Set(aComment.GetString());
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const
{
XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
XmlObjMgt_DOMString aComment(TCollection_AsciiString(aNote->TimeStamp()).ToCString());
theTarget.Element().setAttribute(::Comment(), aComment);
}

View File

@ -0,0 +1,45 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_NoteCommentDriver_HeaderFile
#define _XmlMXCAFDoc_NoteCommentDriver_HeaderFile
#include <XmlMXCAFDoc_NoteDriver.hxx>
class XmlMXCAFDoc_NoteCommentDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
//! Attribute Driver.
class XmlMXCAFDoc_NoteCommentDriver : public XmlMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT XmlMXCAFDoc_NoteCommentDriver(const Handle(CDM_MessageDriver)& theMessageDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteCommentDriver, XmlMXCAFDoc_NoteDriver)
};
#endif // _XmlMXCAFDoc_NoteCommentDriver_HeaderFile

View File

@ -0,0 +1,78 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <CDM_MessageDriver.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_Note.hxx>
#include <XmlMXCAFDoc_NoteDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)
IMPLEMENT_DOMSTRING(UserName, "user_name")
IMPLEMENT_DOMSTRING(TimeStamp, "time_stamp")
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteDriver::XmlMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver,
Standard_CString theName)
: XmlMDF_ADriver(theMsgDriver, theName)
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_NoteDriver::Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& /*theRelocTable*/) const
{
const XmlObjMgt_Element& anElement = theSource;
XmlObjMgt_DOMString aUserName = anElement.getAttribute(::UserName());
XmlObjMgt_DOMString aTimeStamp = anElement.getAttribute(::TimeStamp());
if (aUserName == NULL || aTimeStamp == NULL)
return Standard_False;
Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
aNote->Set(aUserName.GetString(), aTimeStamp.GetString());
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_NoteDriver::Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theSource);
if (aNote.IsNull())
return;
XmlObjMgt_DOMString aUserName(TCollection_AsciiString(aNote->UserName()).ToCString());
XmlObjMgt_DOMString aTimeStamp(TCollection_AsciiString(aNote->TimeStamp()).ToCString());
theTarget.Element().setAttribute(::UserName(), aUserName);
theTarget.Element().setAttribute(::TimeStamp(), aTimeStamp);
}

View File

@ -0,0 +1,56 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_NoteDriver_HeaderFile
#define _XmlMXCAFDoc_NoteDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <XmlMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlObjMgt_SRelocationTable.hxx>
class CDM_MessageDriver;
class TDF_Attribute;
class XmlObjMgt_Persistent;
class XmlMXCAFDoc_NoteDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)
//! Attribute Driver.
class XmlMXCAFDoc_NoteDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)
protected:
Standard_EXPORT XmlMXCAFDoc_NoteDriver(const Handle(CDM_MessageDriver)& theMsgDriver,
Standard_CString theName);
};
#endif // _XmlMXCAFDoc_NoteDriver_HeaderFile

View File

@ -0,0 +1,62 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <CDM_MessageDriver.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_NotesTool.hxx>
#include <XmlMXCAFDoc_NotesToolDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NotesToolDriver, XmlMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NotesToolDriver::XmlMXCAFDoc_NotesToolDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
: XmlMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NotesTool)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_NotesToolDriver::NewEmpty() const
{
return new XCAFDoc_NotesTool();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_NotesToolDriver::Paste(const XmlObjMgt_Persistent& /*theSource*/,
const Handle(TDF_Attribute)& /*theTarget*/,
XmlObjMgt_RRelocationTable& /*theRelocTable*/) const
{
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_NotesToolDriver::Paste(const Handle(TDF_Attribute)& /*theSource*/,
XmlObjMgt_Persistent& /*theTarget*/,
XmlObjMgt_SRelocationTable& /*theRelocTable*/) const
{
}

View File

@ -0,0 +1,55 @@
// Created on: 2017-02-14
// Created by: Sergey NIKONOV
// Copyright (c) 2008-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_NotesToolDriver_HeaderFile
#define _XmlMXCAFDoc_NotesToolDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <XmlMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlObjMgt_SRelocationTable.hxx>
class CDM_MessageDriver;
class TDF_Attribute;
class XmlObjMgt_Persistent;
class XmlMXCAFDoc_NotesToolDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NotesToolDriver, XmlMDF_ADriver)
//! Attribute Driver.
class XmlMXCAFDoc_NotesToolDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT XmlMXCAFDoc_NotesToolDriver(const Handle(CDM_MessageDriver)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NotesToolDriver, XmlMDF_ADriver)
};
#endif // _XmlMXCAFDoc_NotesToolDriver_HeaderFile