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));
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;
#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>
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
- Handle(XCAFDoc_NoteBinData) aNoteBinData = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
+ Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
+ if (aNote.IsNull())
+ return Standard_False;
+ TCollection_ExtendedString aTitle;
TCollection_AsciiString aData, aMIMEtype;
- if (!(theSource >> aData >> aMIMEtype))
+ if (!(theSource >> aTitle >> aData >> aMIMEtype))
return Standard_False;
- aNoteBinData->Set(new TCollection_HAsciiString(aData),
- new TCollection_HAsciiString(aMIMEtype));
+ aNote->Set(aTitle, aData, aMIMEtype);
return Standard_True;
}
{
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();
- theTarget
- << (aData ? aData->String() : TCollection_AsciiString(""))
- << (aMIMEtype ? aMIMEtype->String() : TCollection_AsciiString(""))
- ;
+ Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
+ if (!aNote.IsNull())
+ {
+ theTarget
+ << aNote->Title()
+ << aNote->MIMEtype()
+ << aNote->Data()
+ ;
+ }
}
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;
}
{
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();
}
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 :
}
-//=======================================================================
-//function :
-//purpose :
-//=======================================================================
-Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
-{
- return new XCAFDoc_Note();
-}
-
//=======================================================================
//function :
//purpose :
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;
}
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();
}
{
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;
#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()
+Standard_Boolean XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
{
- static Standard_GUID s_ID("FDC0AF06-C4AC-468a-ACFB-4C9388C76D9E");
- return s_ID;
+ return !Get(theLabel).IsNull();
}
-Standard_Boolean XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
+XCAFDoc_Note::XCAFDoc_Note()
{
- 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) XCAFDoc_Note::Get(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Note) aNote;
- if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote))
- {
- aNote = new XCAFDoc_Note();
- aNote->Set(theUserName, theTimeStamp);
- theLabel.AddAttribute(aNote);
- }
+ if (theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNote) ||
+ theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNote))
+ return aNote;
return aNote;
}
-XCAFDoc_Note::XCAFDoc_Note()
-{
-}
-
-void XCAFDoc_Note::Set(const Handle(TCollection_HExtendedString)& theUserName,
- const Handle(TCollection_HExtendedString)& theTimeStamp)
+void XCAFDoc_Note::Set(const TCollection_ExtendedString& theUserName,
+ const TCollection_ExtendedString& theTimeStamp)
{
Backup();
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
+{
+ if (!IsMine(Label()))
+ return Standard_False;
+
+ Handle(XCAFDoc_GraphNode) aFather;
+ return Label().FindAttribute(XCAFDoc::NoteRefGUID(), aFather) &&
+ (aFather->NbChildren() > 0);
+}
+
+void XCAFDoc_Note::Attach(const TDF_LabelSequence& theLabels)
{
- return GetID();
+ 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);
+ }
}
-Handle(TDF_Attribute) XCAFDoc_Note::NewEmpty() const
+void XCAFDoc_Note::Detach(const TDF_LabelSequence& theLabels)
{
- return new XCAFDoc_Note();
+ 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)
{
theOS
<< "Note : "
- << (myUserName ? myUserName->String() : "<anonymous>")
+ << (myUserName.IsEmpty() ? myUserName : "<anonymous>")
<< " on "
- << (myTimeStamp ? myTimeStamp->String() : "<unknown>")
+ << (myTimeStamp.IsEmpty() ? myTimeStamp : "<unknown>")
;
return theOS;
}
#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;
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;
-public:
+ Standard_EXPORT void Attach(const TDF_LabelSequence& theLabels);
- Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+ Standard_EXPORT void Detach(const TDF_LabelSequence& theLabels);
+ Standard_EXPORT void DetachAll();
- Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+public:
Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
protected:
- Handle(TCollection_HExtendedString) myUserName;
- Handle(TCollection_HExtendedString) myTimeStamp;
+ Standard_EXPORT XCAFDoc_Note();
+
+private:
+
+ TCollection_ExtendedString myUserName;
+ TCollection_ExtendedString myTimeStamp;
};
#endif // _XCAFDoc_Note_HeaderFile
return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), anAttr));
}
-Handle(XCAFDoc_NoteBinData) XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
- const Handle(TCollection_HExtendedString)& theUserName,
- const Handle(TCollection_HExtendedString)& theTimeStamp,
- OSD_File& theFile,
- const Handle(TCollection_HAsciiString)& theMIMEtype)
+Handle(XCAFDoc_NoteBinData) XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
+ const TCollection_ExtendedString& theUserName,
+ const TCollection_ExtendedString& theTimeStamp,
+ const TCollection_ExtendedString& theTitle,
+ OSD_File& theFile,
+ 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;
{
}
-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;
}
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;
}
#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)
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,
- OSD_File& theFile,
- const Handle(TCollection_HAsciiString)& theMIMEtype);
+ Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
+ const TCollection_ExtendedString& theUserName,
+ const TCollection_ExtendedString& theTimeStamp,
+ const TCollection_ExtendedString& theTitle,
+ OSD_File& theFile,
+ 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:
protected:
- Handle(TCollection_HAsciiString) myData;
- Handle(TCollection_HAsciiString) myMIMEtype;
+ TCollection_ExtendedString myTitle;
+ TCollection_AsciiString myData;
+ TCollection_AsciiString myMIMEtype;
};
#endif // _XCAFDoc_NoteBinData_HeaderFile
return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), anAttr));
}
-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)
+Handle(XCAFDoc_NoteComment) XCAFDoc_NoteComment::Set(const TDF_Label& theLabel,
+ 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);
{
}
-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;
}
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;
}
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);
+ Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label& theLabel,
+ 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:
protected:
- Handle(TCollection_HExtendedString) myComment;
+ TCollection_ExtendedString myComment;
};
#endif // _XCAFDoc_NoteComment_HeaderFile
#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)
{
}
+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();
}
}
-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
#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;
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:
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
#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>
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));
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));
}
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;
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;
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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
--- /dev/null
+// 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
+{
+}
--- /dev/null
+// 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