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

0030988: Add possibility to attach multiple files to notes

Implemented
This commit is contained in:
snn
2019-06-13 14:39:29 +03:00
committed by dbv
parent 7b296f0230
commit 9640291ff0
35 changed files with 917 additions and 1002 deletions

View File

@@ -35,8 +35,6 @@
#include <BinMXCAFDoc_MaterialToolDriver.hxx>
#include <BinMXCAFDoc_NoteDriver.hxx>
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <BinMXCAFDoc_NotesToolDriver.hxx>
#include <BinMXCAFDoc_ShapeToolDriver.hxx>
#include <BinMXCAFDoc_ViewDriver.hxx>
@@ -78,8 +76,7 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBalloonDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ViewDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver (theMsgDrv));

View File

@@ -20,14 +20,14 @@
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
#include <XCAFDoc_NoteBalloon.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
{
}
@@ -40,13 +40,52 @@ Handle(TDF_Attribute) BinMXCAFDoc_NoteBalloonDriver::NewEmpty() const
return new XCAFDoc_NoteBalloon();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteBalloonDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aComment;
if (!(theSource >> aComment))
return Standard_False;
aNote->Set(aComment);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
if (!aNote.IsNull())
theTarget << aNote->Get();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -16,20 +16,28 @@
#ifndef _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
#define _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteBalloonDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteCommentDriver
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
Standard_EXPORT Standard_Boolean Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
protected:

View File

@@ -1,96 +0,0 @@
// Created on: 2017-02-13
// Created by: Eugeny NIKONOV
// Copyright (c) 2005-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 <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
#include <XCAFDoc_NoteBinData.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBinDataDriver::BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteBinDataDriver::NewEmpty() const
{
return new XCAFDoc_NoteBinData();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aTitle;
TCollection_AsciiString aMIMEtype;
Standard_Integer nbSize;
if (!(theSource >> aTitle >> aMIMEtype >> nbSize))
return Standard_False;
Handle(TColStd_HArray1OfByte) aData;
if (nbSize > 0)
{
aData.reset(new TColStd_HArray1OfByte(1, nbSize));
theSource.GetByteArray(&aData->ChangeFirst(), nbSize);
}
aNote->Set(aTitle, aMIMEtype, aData);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
if (!aNote.IsNull())
{
theTarget << aNote->Title() << aNote->MIMEtype() << aNote->Size();
if (aNote->Size() > 0)
theTarget.PutByteArray(&aNote->Data()->ChangeFirst(), aNote->Size());
}
}

View File

@@ -1,44 +0,0 @@
// Created on: 2017-02-13
// Created by: Sergey NIKONOV
// Copyright (c) 2005-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 _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
#define _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteBinDataDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteBinDataDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& 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;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
};
#endif // _BinMXCAFDoc_NoteBinDataDriver_HeaderFile

View File

@@ -1,91 +0,0 @@
// Created on: 2017-02-13
// Created by: Eugeny NIKONOV
// Copyright (c) 2005-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 <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <XCAFDoc_NoteComment.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteCommentDriver::NewEmpty() const
{
return new XCAFDoc_NoteComment();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aComment;
if (!(theSource >> aComment))
return Standard_False;
aNote->Set(aComment);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
if (!aNote.IsNull())
theTarget << aNote->Comment();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -1,49 +0,0 @@
// Created on: 2017-02-13
// Created by: Sergey NIKONOV
// Copyright (c) 2005-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 _BinMXCAFDoc_NoteCommentDriver_HeaderFile
#define _BinMXCAFDoc_NoteCommentDriver_HeaderFile
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteCommentDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteCommentDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& 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;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
protected:
BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName);
};
#endif // _BinMXCAFDoc_NoteCommentDriver_HeaderFile

View File

@@ -22,6 +22,24 @@
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
{
return new XCAFDoc_Note();
}
//=======================================================================
//function :
//purpose :

View File

@@ -35,6 +35,10 @@ class BinMXCAFDoc_NoteDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& 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

@@ -39,10 +39,6 @@ BinMXCAFDoc_NoteDriver.cxx
BinMXCAFDoc_NoteDriver.hxx
BinMXCAFDoc_NoteBalloonDriver.cxx
BinMXCAFDoc_NoteBalloonDriver.hxx
BinMXCAFDoc_NoteCommentDriver.cxx
BinMXCAFDoc_NoteCommentDriver.hxx
BinMXCAFDoc_NoteBinDataDriver.cxx
BinMXCAFDoc_NoteBinDataDriver.hxx
BinMXCAFDoc_NotesToolDriver.cxx
BinMXCAFDoc_NotesToolDriver.hxx
BinMXCAFDoc_ShapeToolDriver.cxx

View File

@@ -13,6 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <TDF_Tool.hxx>
#include <XCAFDoc_AssemblyItemId.hxx>
XCAFDoc_AssemblyItemId::XCAFDoc_AssemblyItemId()
@@ -122,3 +123,15 @@ XCAFDoc_AssemblyItemId::ToString() const
aStr.Remove(1, 1);
return aStr;
}
TDF_Label
XCAFDoc_AssemblyItemId::GetLabel(const Handle(TDF_Data)& aDF) const
{
TDF_Label aLabel;
if (!myPath.IsEmpty())
{
TCollection_AsciiString anEntry = myPath.Last();
TDF_Tool::Label(aDF, anEntry, aLabel, Standard_False);
}
return aLabel;
}

View File

@@ -18,6 +18,7 @@
#include <Standard_GUID.hxx>
#include <TColStd_ListOfAsciiString.hxx>
#include <TDF_Label.hxx>
//! Unique item identifier in the hierarchical product structure.
//! A full path to an assembly component in the "part-of" graph starting from
@@ -77,6 +78,9 @@ public:
//! Returns the full pass as a formatted string.
Standard_EXPORT TCollection_AsciiString ToString() const;
//! Returns the last label in the path
Standard_EXPORT TDF_Label GetLabel(const Handle(TDF_Data)& aDF) const;
struct Hasher
{

View File

@@ -176,6 +176,12 @@ XCAFDoc_AssemblyItemRef::GetItem() const
return myItemId;
}
TDF_Label
XCAFDoc_AssemblyItemRef::GetItemLabel() const
{
return !Label().IsNull() ? myItemId.GetLabel(Label().Data()) : TDF_Label();
}
Standard_GUID
XCAFDoc_AssemblyItemRef::GetGUID() const
{

View File

@@ -102,6 +102,9 @@ public:
//! Returns the assembly item ID that the reference points to.
Standard_EXPORT const XCAFDoc_AssemblyItemId& GetItem() const;
//! Returns the last label in the item's path
Standard_EXPORT TDF_Label GetItemLabel() const;
//! @name Set reference data functions.
//! @{

View File

@@ -29,14 +29,6 @@
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
enum ChildLab
{
ChildLab_PntText = 1,
ChildLab_Plane,
ChildLab_Pnt,
ChildLab_Presentation
};
// =======================================================================
// function : IsMine
// purpose :
@@ -44,7 +36,18 @@ enum ChildLab
Standard_Boolean
XCAFDoc_Note::IsMine(const TDF_Label& theLabel)
{
return !Get(theLabel).IsNull();
return !theLabel.IsNull() && !Get(theLabel).IsNull();
}
// =======================================================================
// function : GetID
// purpose :
// =======================================================================
const Standard_GUID&
XCAFDoc_Note::GetID()
{
static Standard_GUID s_ID("A379384E-8412-4e34-BC26-097D503E2622");
return s_ID;
}
// =======================================================================
@@ -63,11 +66,25 @@ Handle(XCAFDoc_Note)
XCAFDoc_Note::Get(const TDF_Label& theLabel)
{
Handle(XCAFDoc_Note) aNote;
for (TDF_AttributeIterator anIt(theLabel); anIt.More(); anIt.Next())
theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote);
return aNote;
}
// =======================================================================
// function : Set
// purpose :
// =======================================================================
Handle(XCAFDoc_Note)
XCAFDoc_Note::Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp)
{
Handle(XCAFDoc_Note) aNote;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_Note::GetID(), aNote))
{
aNote = Handle(XCAFDoc_Note)::DownCast(anIt.Value());
if (!aNote.IsNull())
break;
aNote = new XCAFDoc_Note();
aNote->XCAFDoc_Note::Set(theUserName, theTimeStamp);
theLabel.AddAttribute(aNote);
}
return aNote;
}
@@ -157,10 +174,11 @@ void XCAFDoc_Note::SetObject (const Handle(XCAFNoteObjects_NoteObject)& theObjec
{
Backup();
for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next())
{
anIter.Value().ForgetAllAttributes();
}
TDF_Label aChLabel;
aChLabel = Label().FindChild(ChildLab_PntText, Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
aChLabel = Label().FindChild(ChildLab_Plane, Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
aChLabel = Label().FindChild(ChildLab_Pnt, Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
aChLabel = Label().FindChild(ChildLab_Presentation, Standard_False); if (!aChLabel.IsNull()) aChLabel.ForgetAllAttributes();
if (theObject->HasPoint())
{
@@ -191,6 +209,26 @@ void XCAFDoc_Note::SetObject (const Handle(XCAFNoteObjects_NoteObject)& theObjec
}
}
// =======================================================================
// function : ID
// purpose :
// =======================================================================
const Standard_GUID&
XCAFDoc_Note::ID() const
{
return GetID();
}
// =======================================================================
// function : NewEmpty
// purpose :
// =======================================================================
Handle(TDF_Attribute)
XCAFDoc_Note::NewEmpty() const
{
return new XCAFDoc_Note();
}
// =======================================================================
// function : Restore
// purpose :

View File

@@ -37,9 +37,23 @@ public:
//! Checks if the given label represents a note.
Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
//! Returns default attribute GUID
Standard_EXPORT static const Standard_GUID& GetID();
//! Finds a reference attribute on the given label and returns it, if it is found
Standard_EXPORT static Handle(XCAFDoc_Note) Get(const TDF_Label& theLabel);
//! Create (if not exist) a note on the given label.
//! \param [in] theLabel - note label.
//! \param [in] theUserName - the name of the user, who created the note.
//! \param [in] theTimeStamp - creation timestamp of the note.
Standard_EXPORT static Handle(XCAFDoc_Note) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp);
//! Creates an empty note.
Standard_EXPORT XCAFDoc_Note();
//! Sets the user name and the timestamp of the note.
//! \param [in] theUserName - the user associated with the note.
//! \param [in] theTimeStamp - timestamp of the note.
@@ -62,19 +76,27 @@ public:
//! Updates auxiliary data
Standard_EXPORT void SetObject(const Handle(XCAFNoteObjects_NoteObject)& theObject);
//!
enum ChildLab
{
ChildLab_PntText = 1,
ChildLab_Plane,
ChildLab_Pnt,
ChildLab_Presentation,
ChildLab_BinDataContainer,
ChildLab_Custom
};
public:
// Overrides TDF_Attribute virtuals
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,
const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
protected:
//! Creates an empty note.
Standard_EXPORT XCAFDoc_Note();
private:
TCollection_ExtendedString myUserName; ///< Name of the user, who created the note.

View File

@@ -15,7 +15,7 @@
#include <TDF_Label.hxx>
#include <XCAFDoc_NoteBalloon.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_Note)
// =======================================================================
// function : GetID
@@ -55,7 +55,7 @@ XCAFDoc_NoteBalloon::Set(const TDF_Label& theLabel,
{
aNoteBalloon = new XCAFDoc_NoteBalloon();
aNoteBalloon->XCAFDoc_Note::Set(theUserName, theTimeStamp);
aNoteBalloon->XCAFDoc_NoteComment::Set(theComment);
aNoteBalloon->Set(theComment);
theLabel.AddAttribute(aNoteBalloon);
}
return aNoteBalloon;
@@ -69,6 +69,18 @@ XCAFDoc_NoteBalloon::XCAFDoc_NoteBalloon()
{
}
// =======================================================================
// function : Set
// purpose :
// =======================================================================
void
XCAFDoc_NoteBalloon::Set(const TCollection_ExtendedString& theComment)
{
Backup();
myComment = theComment;
}
// =======================================================================
// function : ID
// purpose :

View File

@@ -14,15 +14,15 @@
#ifndef _XCAFDoc_NoteBalloon_HeaderFile
#define _XCAFDoc_NoteBalloon_HeaderFile
#include <XCAFDoc_NoteComment.hxx>
#include <XCAFDoc_Note.hxx>
//! A comment note attribute.
//! Contains a textual comment.
class XCAFDoc_NoteBalloon : public XCAFDoc_NoteComment
class XCAFDoc_NoteBalloon : public XCAFDoc_Note
{
public:
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBalloon, XCAFDoc_Note)
//! Returns default attribute GUID
Standard_EXPORT static const Standard_GUID& GetID();
@@ -43,12 +43,22 @@ public:
//! Creates an empty comment note.
Standard_EXPORT XCAFDoc_NoteBalloon();
//! Sets the comment text.
Standard_EXPORT void Set(const TCollection_ExtendedString& theComment);
//! Returns the comment text.
const TCollection_ExtendedString& Get() const { return myComment; }
public:
// Overrides TDF_Attribute virtuals
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
private:
TCollection_ExtendedString myComment;
};
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBalloon, XCAFDoc_NoteComment)

View File

@@ -12,23 +12,185 @@
// commercial license or contractual agreement.
#include <OSD_File.hxx>
#include <Standard_GUID.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_ReferenceList.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <XCAFDoc_Note.hxx>
#include <XCAFDoc_NoteBinData.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinDataContainer, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, Standard_Transient)
// =======================================================================
// function : GetID
// function : getID
// purpose :
// =======================================================================
const Standard_GUID&
XCAFDoc_NoteBinData::GetID()
const Standard_GUID&
XCAFDoc_NoteBinDataContainer::getID()
{
static Standard_GUID s_ID("E9055501-F0FC-4864-BE4B-284FDA7DDEAC");
static Standard_GUID s_ID("91CFB5D9-737C-4ab9-933A-15E28DBBD1CF");
return s_ID;
}
// =======================================================================
// function : XCAFDoc_NoteBinDataContainer
// purpose :
// =======================================================================
XCAFDoc_NoteBinDataContainer::XCAFDoc_NoteBinDataContainer(const Handle(TDataStd_ReferenceList)& theList)
: myList(theList)
{
}
// =======================================================================
// function : Get
// purpose :
// =======================================================================
Handle(XCAFDoc_NoteBinDataContainer)
XCAFDoc_NoteBinDataContainer::Get(const TDF_Label& theLabel)
{
if (!XCAFDoc_Note::IsMine(theLabel))
{
return NULL;
}
TDF_Label aLabel = theLabel.FindChild(XCAFDoc_Note::ChildLab_BinDataContainer, Standard_False);
Handle(TDataStd_ReferenceList) aList;
if (!aLabel.IsNull() && aLabel.FindAttribute(getID(), aList) && !aList.IsNull())
{
return new XCAFDoc_NoteBinDataContainer(aList);
}
return NULL;
}
// =======================================================================
// function : Set
// purpose :
// =======================================================================
Handle(XCAFDoc_NoteBinDataContainer)
XCAFDoc_NoteBinDataContainer::Set(const TDF_Label& theLabel)
{
if (!XCAFDoc_Note::IsMine(theLabel))
{
return NULL;
}
TDF_Label aLabel = theLabel.FindChild(XCAFDoc_Note::ChildLab_BinDataContainer);
return new XCAFDoc_NoteBinDataContainer(TDataStd_ReferenceList::Set(aLabel, getID()));
}
// =======================================================================
// function : Size
// purpose :
// =======================================================================
Standard_Integer
XCAFDoc_NoteBinDataContainer::Size() const
{
return myList->List().Size();
}
// =======================================================================
// function : Content
// purpose :
// =======================================================================
const TDF_LabelList&
XCAFDoc_NoteBinDataContainer::Content() const
{
return myList->List();
}
// =======================================================================
// function : Add
// purpose :
// =======================================================================
Handle(XCAFDoc_NoteBinData)
XCAFDoc_NoteBinDataContainer::Add(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile)
{
TDF_Label aLabel;
for (TDF_ChildIterator anIt(myList->Label()); anIt.More(); anIt.Next())
{
if (!anIt.Value().HasAttribute())
{
aLabel = anIt.Value();
break;
}
}
if (aLabel.IsNull())
{
aLabel = myList->Label().NewChild();
}
myList->Append(aLabel);
return XCAFDoc_NoteBinData::Set(aLabel, theTitle, theMIMEtype, theFile);
}
// =======================================================================
// function : Add
// purpose :
// =======================================================================
Handle(XCAFDoc_NoteBinData)
XCAFDoc_NoteBinDataContainer::Add(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData)
{
TDF_Label aLabel;
for (TDF_ChildIterator anIt(myList->Label()); anIt.More(); anIt.Next())
{
if (!anIt.Value().HasAttribute())
{
aLabel = anIt.Value();
break;
}
}
if (aLabel.IsNull())
{
aLabel = myList->Label().NewChild();
}
myList->Append(aLabel);
return XCAFDoc_NoteBinData::Set(aLabel, theTitle, theMIMEtype, theData);
}
// =======================================================================
// function : Remove
// purpose :
// =======================================================================
Standard_Boolean
XCAFDoc_NoteBinDataContainer::Remove(TDF_Label& theLabel)
{
theLabel.ForgetAllAttributes();
return myList->Remove(theLabel);
}
// =======================================================================
// function : Clear
// purpose :
// =======================================================================
void
XCAFDoc_NoteBinDataContainer::Clear()
{
const TDF_LabelList& aList = myList->List();
for (TDF_LabelList::Iterator anIt(aList); anIt.More(); anIt.Next())
{
anIt.ChangeValue().ForgetAllAttributes();
}
myList->Clear();
}
// =======================================================================
// function : Label
// purpose :
// =======================================================================
TDF_Label
XCAFDoc_NoteBinDataContainer::Label() const
{
return !myList.IsNull() ? myList->Label() : TDF_Label();
}
// =======================================================================
// function : Get
// purpose :
@@ -36,9 +198,19 @@ XCAFDoc_NoteBinData::GetID()
Handle(XCAFDoc_NoteBinData)
XCAFDoc_NoteBinData::Get(const TDF_Label& theLabel)
{
Handle(XCAFDoc_NoteBinData) aThis;
theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aThis);
return aThis;
if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
!XCAFDoc_Note::IsMine(theLabel.Father().Father()))
return NULL;
Handle(TDataStd_Name) aTitle;
Handle(TDataStd_AsciiString) aMIMEType;
Handle(TDataStd_ByteArray) aData;
if (!theLabel.FindAttribute(TDataStd_Name::GetID(), aTitle) ||
!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), aMIMEType) ||
!theLabel.FindAttribute(TDataStd_ByteArray::GetID(), aData))
return NULL;
return new XCAFDoc_NoteBinData(aTitle, aMIMEType, aData);
}
// =======================================================================
@@ -47,23 +219,29 @@ XCAFDoc_NoteBinData::Get(const TDF_Label& theLabel)
// =======================================================================
Handle(XCAFDoc_NoteBinData)
XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile)
{
Handle(XCAFDoc_NoteBinData) aNoteBinData;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNoteBinData))
if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
!XCAFDoc_Note::IsMine(theLabel.Father().Father()))
return NULL;
if (!theFile.IsOpen() || !theFile.IsReadable() || theFile.Size() > (Standard_Size)IntegerLast())
return NULL;
Handle(TDataStd_ByteArray) aData = TDataStd_ByteArray::Set(theLabel, 1, (Standard_Integer)theFile.Size());
Standard_Integer nbReadBytes = 0;
theFile.Read((Standard_Address)&aData->InternalArray()->First(), aData->Length(), nbReadBytes);
if (nbReadBytes < aData->Length())
{
aNoteBinData = new XCAFDoc_NoteBinData();
aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
if (aNoteBinData->Set(theTitle, theMIMEtype, theFile))
theLabel.AddAttribute(aNoteBinData);
else
aNoteBinData.Nullify();
theLabel.ForgetAttribute(aData);
return NULL;
}
return aNoteBinData;
return new XCAFDoc_NoteBinData(TDataStd_Name::Set(theLabel, theTitle),
TDataStd_AsciiString::Set(theLabel, theMIMEtype),
aData);
}
// =======================================================================
@@ -72,28 +250,31 @@ XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
// =======================================================================
Handle(XCAFDoc_NoteBinData)
XCAFDoc_NoteBinData::Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData)
{
Handle(XCAFDoc_NoteBinData) aNoteBinData;
if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNoteBinData))
{
aNoteBinData = new XCAFDoc_NoteBinData();
aNoteBinData->XCAFDoc_Note::Set(theUserName, theTimeStamp);
aNoteBinData->Set(theTitle, theMIMEtype, theData);
theLabel.AddAttribute(aNoteBinData);
}
return aNoteBinData;
if (theLabel.IsNull() || theLabel.Father().IsNull() || theLabel.Father().Father().IsNull() ||
!XCAFDoc_Note::IsMine(theLabel.Father().Father()))
return NULL;
Handle(TDataStd_ByteArray) aData = TDataStd_ByteArray::Set(theLabel, 1, 2);
aData->ChangeArray(theData);
return new XCAFDoc_NoteBinData(TDataStd_Name::Set(theLabel, theTitle),
TDataStd_AsciiString::Set(theLabel, theMIMEtype),
aData);
}
// =======================================================================
// function : XCAFDoc_NoteBinData
// purpose :
// =======================================================================
XCAFDoc_NoteBinData::XCAFDoc_NoteBinData()
XCAFDoc_NoteBinData::XCAFDoc_NoteBinData(const Handle(TDataStd_Name)& theTitle,
const Handle(TDataStd_AsciiString)& theMIMEType,
const Handle(TDataStd_ByteArray)& theData)
: myTitle(theTitle)
, myMIMEtype(theMIMEType)
, myData(theData)
{
}
@@ -106,22 +287,18 @@ XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile)
{
if (!theFile.IsOpen() || !theFile.IsReadable())
if (!theFile.IsOpen() || !theFile.IsReadable() || theFile.Size() > (Standard_Size)IntegerLast())
return Standard_False;
Backup();
if (theFile.Size() > (Standard_Size)IntegerLast())
return Standard_False;
myData.reset(new TColStd_HArray1OfByte(1, (Standard_Integer)theFile.Size()));
Handle(TColStd_HArray1OfByte) aData(new TColStd_HArray1OfByte(1, (Standard_Integer)theFile.Size()));
Standard_Integer nbReadBytes = 0;
theFile.Read((Standard_Address)&myData->First(), myData->Length(), nbReadBytes);
if (nbReadBytes < myData->Length())
theFile.Read((Standard_Address)&aData->First(), aData->Length(), nbReadBytes);
if (nbReadBytes < aData->Length())
return Standard_False;
myTitle = theTitle;
myMIMEtype = theMIMEtype;
myData->ChangeArray(aData);
myTitle->Set(theTitle);
myMIMEtype->Set(theMIMEtype);
return Standard_True;
}
@@ -135,83 +312,57 @@ XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData)
{
Backup();
myData = theData;
myTitle = theTitle;
myMIMEtype = theMIMEtype;
myTitle->Set(theTitle);
myMIMEtype->Set(theMIMEtype);
myData->ChangeArray(theData);
}
// =======================================================================
// function : ID
// function : Title
// purpose :
// =======================================================================
const
Standard_GUID& XCAFDoc_NoteBinData::ID() const
const TCollection_ExtendedString&
XCAFDoc_NoteBinData::Title() const
{
return GetID();
return myTitle->Get();
}
// =======================================================================
// function : NewEmpty
// function : MIMEtype
// purpose :
// =======================================================================
Handle(TDF_Attribute)
XCAFDoc_NoteBinData::NewEmpty() const
const TCollection_AsciiString&
XCAFDoc_NoteBinData::MIMEtype() const
{
return new XCAFDoc_NoteBinData();
return myMIMEtype->Get();
}
// =======================================================================
// function : Restore
// function : Size
// purpose :
// =======================================================================
void
XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr)
Standard_Integer
XCAFDoc_NoteBinData::Size() const
{
XCAFDoc_Note::Restore(theAttr);
Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttr);
if (!aMine.IsNull())
{
myTitle = aMine->myTitle;
myMIMEtype = aMine->myMIMEtype;
myData = aMine->myData;
}
return myData->Length();
}
// =======================================================================
// function : Paste
// function : Data
// purpose :
// =======================================================================
void
XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)& theAttrInto,
const Handle(TDF_RelocationTable)& theRT) const
const Handle(TColStd_HArray1OfByte)&
XCAFDoc_NoteBinData::Data() const
{
XCAFDoc_Note::Paste(theAttrInto, theRT);
Handle(XCAFDoc_NoteBinData) aMine = Handle(XCAFDoc_NoteBinData)::DownCast(theAttrInto);
if (!aMine.IsNull())
aMine->Set(myTitle, myMIMEtype, myData);
return myData->InternalArray();
}
// =======================================================================
// function : Dump
// function : Label
// purpose :
// =======================================================================
Standard_OStream&
XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const
TDF_Label
XCAFDoc_NoteBinData::Label() const
{
XCAFDoc_Note::Dump(theOS);
theOS << "\n"
<< "Title : " << (!myTitle.IsEmpty() ? myMIMEtype : "<untitled>") << "\n"
<< "MIME type : " << (!myMIMEtype.IsEmpty() ? myMIMEtype : "<none>") << "\n"
<< "Size : " << Size() << " bytes" << "\n"
;
if (!myData.IsNull())
{
for (Standard_Integer i = myData->Lower(); i <= myData->Upper(); ++i)
theOS << myData->Value(i);
}
return theOS;
return !myData.IsNull() ? myData->Label() : TDF_Label();
}

View File

@@ -14,78 +14,87 @@
#ifndef _XCAFDoc_NoteBinData_HeaderFile
#define _XCAFDoc_NoteBinData_HeaderFile
#include <XCAFDoc_Note.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelList.hxx>
class OSD_File;
class Standard_GUID;
class TColStd_HArray1OfByte;
class TDataStd_AsciiString;
class TDataStd_ByteArray;
class TDataStd_Name;
class TDataStd_ReferenceList;
class XCAFDoc_NoteBinData;
class XCAFDoc_NoteBinData : public XCAFDoc_Note
class XCAFDoc_NoteBinDataContainer : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinDataContainer, Standard_Transient)
//! Returns default attribute GUID
Standard_EXPORT static const Standard_GUID& GetID();
//! Finds a reference attribute on the given label and returns a proxy instance if it is found
Standard_EXPORT static Handle(XCAFDoc_NoteBinDataContainer) Get(const TDF_Label& theLabel);
//! Create (if not exist) a binary data container on the given note label.
//! \param [in] theLabel - note label.
Standard_EXPORT static Handle(XCAFDoc_NoteBinDataContainer) Set(const TDF_Label& theLabel);
Standard_EXPORT Standard_Integer Size() const;
Standard_EXPORT const TDF_LabelList& Content() const;
Standard_EXPORT Handle(XCAFDoc_NoteBinData) Add(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile);
Standard_EXPORT Handle(XCAFDoc_NoteBinData) Add(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData);
Standard_EXPORT Standard_Boolean Remove(TDF_Label& theLabel);
Standard_EXPORT void Clear();
Standard_EXPORT TDF_Label Label() const;
private:
XCAFDoc_NoteBinDataContainer(const Handle(TDataStd_ReferenceList)& theList);
static const Standard_GUID& getID();
Handle(TDataStd_ReferenceList) myList;
};
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinDataContainer, Standard_Transient)
class XCAFDoc_NoteBinData : public Standard_Transient
{
friend class XCAFDoc_NoteBinDataContainer;
public:
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, Standard_Transient)
//! Finds a binary data attribute on the given label and returns it, if it is found
Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Get(const TDF_Label& theLabel);
//! @name Set attribute functions.
//! @{
//! Create (if not exist) a binary note with data loaded from a binary file.
//! \param [in] theLabel - label to add the attribute.
//! \param [in] theUserName - the name of the user, who created the note.
//! \param [in] theTimeStamp - creation timestamp of the note.
//! \param [in] theTitle - file title.
//! \param [in] theMIMEtype - MIME type of the file.
//! \param [in] theFile - input binary file.
//! \return A handle to the attribute instance.
Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile);
//! Create (if not exist) a binary note byte data array.
//! \param [in] theLabel - label to add the attribute.
//! \param [in] theUserName - the name of the user, who created the note.
//! \param [in] theTimeStamp - creation timestamp of the note.
//! \param [in] theTitle - data title.
//! \param [in] theMIMEtype - MIME type of data.
//! \param [in] theData - byte data array.
//! \return A handle to the attribute instance.
Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData);
//! @}
//! Creates an empty binary data note.
Standard_EXPORT XCAFDoc_NoteBinData();
//! @name Set attribute data functions.
//! @{
//! Sets title, MIME type and data from a binary file.
//! \param [in] theTitle - file title.
//! \param [in] theMIMEtype - MIME type of the file.
//! \param [in] theFile - input binary file.
//! \param [in] theTitle - file title.
//! \param [in] theMIMEtype - MIME type of the file.
//! \param [in] theFile - input binary file.
Standard_EXPORT Standard_Boolean Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile);
//! Sets title, MIME type and data from a byte array.
//! \param [in] theTitle - data title.
//! \param [in] theMIMEtype - MIME type of data.
//! \param [in] theData - byte data array.
//! \param [in] theTitle - data title.
//! \param [in] theMIMEtype - MIME type of data.
//! \param [in] theData - byte data array.
Standard_EXPORT void Set(const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData);
@@ -93,35 +102,44 @@ public:
//! @}
//! Returns the note title.
const TCollection_ExtendedString& Title() const { return myTitle; }
Standard_EXPORT const TCollection_ExtendedString& Title() const;
//! Returns data MIME type.
const TCollection_AsciiString& MIMEtype() const { return myMIMEtype; }
Standard_EXPORT const TCollection_AsciiString& MIMEtype() const;
//! Size of data in bytes.
Standard_Integer Size() const { return (!myData.IsNull() ? myData->Length() : 0); }
Standard_EXPORT Standard_Integer Size() const;
//! Returns byte data array.
const Handle(TColStd_HArray1OfByte)& Data() const { return myData; }
Standard_EXPORT const Handle(TColStd_HArray1OfByte)& Data() const;
public:
//! Returns label
Standard_EXPORT TDF_Label Label() const;
// Overrides TDF_Attribute virtuals
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,
const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
private:
protected:
XCAFDoc_NoteBinData(const Handle(TDataStd_Name)& theTitle,
const Handle(TDataStd_AsciiString)& theMIMEType,
const Handle(TDataStd_ByteArray)& theData);
TCollection_ExtendedString myTitle; ///< Note title.
TCollection_AsciiString myMIMEtype; ///< MIME type of data.
Handle(TColStd_HArray1OfByte) myData; ///< Byte data array.
static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile);
static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData);
private:
Handle(TDataStd_Name) myTitle; ///< Data title.
Handle(TDataStd_AsciiString) myMIMEtype; ///< MIME type of data.
Handle(TDataStd_ByteArray) myData; ///< Byte data array.
};
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, XCAFDoc_Note)
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, Standard_Transient)
#endif // _XCAFDoc_NoteBinData_HeaderFile

View File

@@ -12,21 +12,11 @@
// commercial license or contractual agreement.
#include <Standard_GUID.hxx>
#include <TDF_Label.hxx>
#include <TDataStd_Comment.hxx>
#include <XCAFDoc_Note.hxx>
#include <XCAFDoc_NoteComment.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
// =======================================================================
// function : GetID
// purpose :
// =======================================================================
const Standard_GUID&
XCAFDoc_NoteComment::GetID()
{
static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4");
return s_ID;
}
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, Standard_Transient)
// =======================================================================
// function : Get
@@ -35,9 +25,14 @@ XCAFDoc_NoteComment::GetID()
Handle(XCAFDoc_NoteComment)
XCAFDoc_NoteComment::Get(const TDF_Label& theLabel)
{
Handle(XCAFDoc_NoteComment) aThis;
theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aThis);
return aThis;
if (!XCAFDoc_Note::IsMine(theLabel))
return NULL;
Handle(TDataStd_Comment) aComment;
if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), aComment))
return NULL;
return new XCAFDoc_NoteComment(aComment);
}
// =======================================================================
@@ -46,26 +41,20 @@ XCAFDoc_NoteComment::Get(const TDF_Label& theLabel)
// =======================================================================
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_NoteComment::GetID(), aNoteComment))
{
aNoteComment = new XCAFDoc_NoteComment();
aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp);
aNoteComment->Set(theComment);
theLabel.AddAttribute(aNoteComment);
}
return aNoteComment;
return XCAFDoc_Note::IsMine(theLabel)
? new XCAFDoc_NoteComment(TDataStd_Comment::Set(theLabel, theComment))
: NULL
;
}
// =======================================================================
// function : XCAFDoc_NoteComment
// purpose :
// =======================================================================
XCAFDoc_NoteComment::XCAFDoc_NoteComment()
XCAFDoc_NoteComment::XCAFDoc_NoteComment(const Handle(TDataStd_Comment)& theComment)
: myComment(theComment)
{
}
@@ -76,70 +65,26 @@ XCAFDoc_NoteComment::XCAFDoc_NoteComment()
void
XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment)
{
Backup();
myComment = theComment;
if (!myComment.IsNull())
myComment->Set(theComment);
}
// =======================================================================
// function : ID
// function : Get
// purpose :
// =======================================================================
const Standard_GUID&
XCAFDoc_NoteComment::ID() const
const TCollection_ExtendedString&
XCAFDoc_NoteComment::Get() const
{
return GetID();
return myComment->Get();
}
// =======================================================================
// function : NewEmpty
// function : Label
// purpose :
// =======================================================================
Handle(TDF_Attribute)
XCAFDoc_NoteComment::NewEmpty() const
TDF_Label
XCAFDoc_NoteComment::Label() const
{
return new XCAFDoc_NoteComment();
}
// =======================================================================
// function : Restore
// purpose :
// =======================================================================
void
XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr)
{
XCAFDoc_Note::Restore(theAttr);
Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttr);
if (!aMine.IsNull())
myComment = aMine->myComment;
}
// =======================================================================
// function : Paste
// purpose :
// =======================================================================
void
XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto,
const Handle(TDF_RelocationTable)& theRT) const
{
XCAFDoc_Note::Paste(theAttrInto, theRT);
Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto);
if (!aMine.IsNull())
aMine->Set(myComment);
}
// =======================================================================
// function : Dump
// purpose :
// =======================================================================
Standard_OStream&
XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const
{
XCAFDoc_Note::Dump(theOS);
theOS << "\n"
<< "Comment : " << (!myComment.IsEmpty() ? myComment : "<empty>")
;
return theOS;
return !myComment.IsNull() ? myComment->Label() : TDF_Label();
}

View File

@@ -14,57 +14,46 @@
#ifndef _XCAFDoc_NoteComment_HeaderFile
#define _XCAFDoc_NoteComment_HeaderFile
#include <XCAFDoc_Note.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
#include <TDF_Label.hxx>
//! A comment note attribute.
//! Contains a textual comment.
class XCAFDoc_NoteComment : public XCAFDoc_Note
class TDataStd_Comment;
//! Comment note proxy.
//! Handles a textual comment of the note.
class XCAFDoc_NoteComment : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteComment, Standard_Transient)
//! Returns default attribute GUID
Standard_EXPORT static const Standard_GUID& GetID();
//! Finds a reference attribute on the given label and returns it, if it is found
//! Finds a reference attribute on the given label and returns a proxy instance if it is found
Standard_EXPORT static Handle(XCAFDoc_NoteComment) Get(const TDF_Label& theLabel);
//! Create (if not exist) a comment note on the given label.
//! \param [in] theLabel - note label.
//! \param [in] theUserName - the name of the user, who created the note.
//! \param [in] theTimeStamp - creation timestamp of the note.
//! \param [in] theComment - comment text.
//! Create (if not exist) a comment on the given note label.
//! \param [in] theLabel - note label.
//! \param [in] theComment - comment text.
Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label& theLabel,
const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment);
//! Creates an empty comment note.
Standard_EXPORT XCAFDoc_NoteComment();
//! Sets the comment text.
Standard_EXPORT void Set(const TCollection_ExtendedString& theComment);
//! Returns the comment text.
const TCollection_ExtendedString& Comment() const { return myComment; }
Standard_EXPORT const TCollection_ExtendedString& Get() const;
public:
//! Returns label
Standard_EXPORT TDF_Label Label() const;
// Overrides TDF_Attribute virtuals
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,
const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
private:
protected:
XCAFDoc_NoteComment(const Handle(TDataStd_Comment)& theComment);
TCollection_ExtendedString myComment; ///< Comment text.
Handle(TDataStd_Comment) myComment; ///< Comment attribute.
};
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteComment, XCAFDoc_Note)
DEFINE_STANDARD_HANDLE(XCAFDoc_NoteComment, Standard_Transient)
#endif // _XCAFDoc_NoteComment_HeaderFile

View File

@@ -20,12 +20,13 @@
#include <TDF_LabelSequence.hxx>
#include <TDF_Tool.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_NotesTool.hxx>
#include <XCAFDoc_NoteBalloon.hxx>
#include <XCAFDoc_NoteComment.hxx>
#include <XCAFDoc_NoteBinData.hxx>
#include <XCAFDoc_AssemblyItemRef.hxx>
#include <XCAFDoc_GraphNode.hxx>
#include <XCAFDoc_Note.hxx>
#include <XCAFDoc_NotesTool.hxx>
#include <XCAFDoc_NoteComment.hxx>
#include <XCAFDoc_NoteBalloon.hxx>
#include <XCAFDoc_NoteBinData.hxx>
namespace {
@@ -142,11 +143,55 @@ XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const
for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next())
{
const TDF_Label aLabel = anIter.Value();
if (!XCAFDoc_Note::Get(aLabel).IsNull())
if (XCAFDoc_Note::IsMine(aLabel))
theNoteLabels.Append(aLabel);
}
}
// =======================================================================
// function : GetTopNotes
// purpose :
// =======================================================================
void
XCAFDoc_NotesTool::GetTopNotes(TDF_LabelSequence& theNoteLabels) const
{
for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next())
{
const TDF_Label aLabel = anIter.Value();
if (!XCAFDoc_Note::IsMine(aLabel))
continue;
Handle(XCAFDoc_GraphNode) aFather;
if (!aLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) || aFather.IsNull())
{
theNoteLabels.Append(aLabel);
continue;
}
Standard_Integer nbChildren = aFather->NbChildren();
if (nbChildren == 0)
{
theNoteLabels.Append(aLabel);
continue;
}
for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild)
{
Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild);
Handle(XCAFDoc_AssemblyItemRef) anItemRef = XCAFDoc_AssemblyItemRef::Get(aChild->Label());
if (!anItemRef.IsNull())
{
TDF_Label anAnnotatedLabel = anItemRef->GetItemLabel();
if (!anAnnotatedLabel.IsNull() && !XCAFDoc_Note::IsMine(anAnnotatedLabel))
{
theNoteLabels.Append(aLabel);
break;
}
}
}
}
}
// =======================================================================
// function : GetAnnotatedItems
// purpose :
@@ -180,6 +225,16 @@ XCAFDoc_NotesTool::IsAnnotatedItem(const TDF_Label& theItemLabel) const
return IsAnnotatedItem(labeledItem(theItemLabel));
}
// =======================================================================
// function : IsAnnotatedNote
// purpose :
// =======================================================================
Standard_Boolean
XCAFDoc_NotesTool::IsAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const
{
return !theNote.IsNull() && IsAnnotatedItem(theNote->Label());
}
// =======================================================================
// function : FindAnnotatedItem
// purpose :
@@ -264,6 +319,30 @@ XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const TDF_Label& theItemLabel,
return FindAnnotatedItemSubshape(labeledItem(theItemLabel), theSubshapeIndex);
}
// =======================================================================
// function : FindAnnotatedNote
// purpose :
// =======================================================================
TDF_Label
XCAFDoc_NotesTool::FindAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const
{
return !theNote.IsNull() ? FindAnnotatedItem(theNote->Label()) : TDF_Label();
}
// =======================================================================
// function : Create
// purpose :
// =======================================================================
Handle(XCAFDoc_Note)
XCAFDoc_NotesTool::Create(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp)
{
TDF_Label aNoteLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(GetNotesLabel());
return XCAFDoc_Note::Set(aNoteLabel, theUserName, theTimeStamp);
}
// =======================================================================
// function : CreateComment
// purpose :
@@ -273,10 +352,20 @@ XCAFDoc_NotesTool::CreateComment(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment)
{
TDF_Label aNoteLabel;
TDF_Label aLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(GetNotesLabel());
return XCAFDoc_NoteComment::Set(aNoteLabel, theUserName, theTimeStamp, theComment);
aLabel = aTag.NewChild(GetNotesLabel());
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Set(aLabel, theUserName, theTimeStamp);
if (!aNote.IsNull())
{
Handle(XCAFDoc_NoteComment) aComment = XCAFDoc_NoteComment::Set(aLabel, theComment);
if (aComment.IsNull())
{
aLabel.ForgetAllAttributes();
return NULL;
}
}
return aNote;
}
// =======================================================================
@@ -299,33 +388,23 @@ XCAFDoc_NotesTool::CreateBalloon(const TCollection_ExtendedString& theUserName,
// purpose :
// =======================================================================
Handle(XCAFDoc_Note)
XCAFDoc_NotesTool::CreateBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile)
XCAFDoc_NotesTool::CreateBinDataContainer(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp)
{
TDF_Label aNoteLabel;
TDF_Label aLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(GetNotesLabel());
return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theMIMEtype, theFile);
}
// =======================================================================
// function : CreateBinData
// purpose :
// =======================================================================
Handle(XCAFDoc_Note)
XCAFDoc_NotesTool::CreateBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData)
{
TDF_Label aNoteLabel;
TDF_TagSource aTag;
aNoteLabel = aTag.NewChild(GetNotesLabel());
return XCAFDoc_NoteBinData::Set(aNoteLabel, theUserName, theTimeStamp, theTitle, theMIMEtype, theData);
aLabel = aTag.NewChild(GetNotesLabel());
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Set(aLabel, theUserName, theTimeStamp);
if (!aNote.IsNull())
{
Handle(XCAFDoc_NoteBinDataContainer) aBinDataCnt = XCAFDoc_NoteBinDataContainer::Set(aLabel);
if (aBinDataCnt.IsNull())
{
aLabel.ForgetAllAttributes();
return NULL;
}
}
return aNote;
}
// =======================================================================
@@ -354,6 +433,17 @@ XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId,
return theNoteLabels.Length();
}
// =======================================================================
// function : GetNotes
// purpose :
// =======================================================================
Standard_Integer
XCAFDoc_NotesTool::GetNotes(const Handle(XCAFDoc_Note)& theNote,
TDF_LabelSequence& theNoteLabels) const
{
return !theNote.IsNull() ? GetNotes(theNote->Label(), theNoteLabels) : 0;
}
// =======================================================================
// function : GetNotes
// purpose :
@@ -493,6 +583,17 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label& theNoteLabel,
return AddNote(theNoteLabel, labeledItem(theItemLabel));
}
// =======================================================================
// function : AddNote
// purpose :
// =======================================================================
Handle(XCAFDoc_AssemblyItemRef)
XCAFDoc_NotesTool::AddNote(const TDF_Label& theNoteLabel,
const Handle(XCAFDoc_Note)& theAnnotatedNote)
{
return !theAnnotatedNote.IsNull() ? AddNote(theNoteLabel, theAnnotatedNote->Label()) : NULL;
}
// =======================================================================
// function : AddNoteToAttr
// purpose :
@@ -673,6 +774,18 @@ XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel,
return RemoveNote(theNoteLabel, labeledItem(theItemLabel), theDelIfOrphan);
}
// =======================================================================
// function : RemoveNote
// purpose :
// =======================================================================
Standard_Boolean
XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel,
const Handle(XCAFDoc_Note)& theNote,
Standard_Boolean theDelIfOrphan)
{
return !theNote.IsNull() ? RemoveNote(theNoteLabel, theNote->Label(), theDelIfOrphan) : Standard_False;
}
// =======================================================================
// function : RemoveSubshapeNote
// purpose :
@@ -817,6 +930,17 @@ XCAFDoc_NotesTool::RemoveAllNotes(const TDF_Label& theItemLabel,
return RemoveAllNotes(labeledItem(theItemLabel), theDelIfOrphan);
}
// =======================================================================
// function : RemoveAllNotes
// purpose :
// =======================================================================
Standard_Boolean
XCAFDoc_NotesTool::RemoveAllNotes(const Handle(XCAFDoc_Note)& theNote,
Standard_Boolean theDelIfOrphan)
{
return !theNote.IsNull() ? RemoveAllNotes(theNote->Label(), theDelIfOrphan) : Standard_False;
}
// =======================================================================
// function : RemoveAllSubshapeNotes
// purpose :

View File

@@ -105,6 +105,12 @@ public:
//! \param [out] theNoteLabels - sequence of labels.
Standard_EXPORT void GetNotes(TDF_LabelSequence& theNoteLabels) const;
//! Returns all labels corresponding to top notes from the notes hive.
//! A top note annotates any atem excepting other notes.
//! The label sequence isn't cleared beforehand.
//! \param [out] theNoteLabels - sequence of labels.
Standard_EXPORT void GetTopNotes(TDF_LabelSequence& theNoteLabels) const;
//! Returns all labels from the annotated items hive.
//! The label sequence isn't cleared beforehand.
//! \param [out] theNoteLabels - sequence of labels.
@@ -120,6 +126,11 @@ public:
//! \return true if the item is annotated, otherwise - false.
Standard_EXPORT Standard_Boolean IsAnnotatedItem(const TDF_Label& theItemLabel) const;
//! Checks if the given note is annotated.
//! \param [in] theNote - note attribute.
//! \return true if the note is annotated, otherwise - false.
Standard_EXPORT Standard_Boolean IsAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const;
//! @name Find annotated item functions
//! @{
@@ -133,6 +144,11 @@ public:
//! \return annotated item label if it is found, otherwise - null label.
Standard_EXPORT TDF_Label FindAnnotatedItem(const TDF_Label& theItemLabel) const;
//! Finds a label of the given note in the annotated items hive.
//! \param [in] theNote - note attribute.
//! \return annotated note label if it is found, otherwise - null label.
Standard_EXPORT TDF_Label FindAnnotatedItem(const Handle(XCAFDoc_Note)& theNote) const;
//! Finds a label of the given assembly item's attribute in the annotated items hive.
//! \param [in] theItemId - assembly item ID.
//! \param [in] theGUID - assembly item's attribute GUID.
@@ -166,9 +182,16 @@ public:
//! @name Note creation functions
//! @{
//! Create a note.
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
//! \param [in] theUserName - the user associated with the note.
//! \param [in] theTimeStamp - timestamp of the note.
//! \return a handle to the base note attribute.
Standard_EXPORT Handle(XCAFDoc_Note) Create(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp);
//! Create a new comment note.
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment
//! attribute (derived ftom \ref XCAFDoc_Note).
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
//! \param [in] theUserName - the user associated with the note.
//! \param [in] theTimeStamp - timestamp of the note.
//! \param [in] theComment - textual comment.
@@ -188,35 +211,13 @@ public:
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theComment);
//! Create a new note with data loaded from a binary file.
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment
//! attribute (derived ftom \ref XCAFDoc_Note).
//! Create a new note for a binary data container.
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_Note attribute.
//! \param [in] theUserName - the user associated with the note.
//! \param [in] theTimeStamp - timestamp of the note.
//! \param [in] theTitle - file title.
//! \param [in] theMIMEtype - MIME type of the file.
//! \param [in] theFile - input binary file.
//! \return a handle to the base note attribute.
Standard_EXPORT Handle(XCAFDoc_Note) CreateBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
OSD_File& theFile);
//! Create a new note with data loaded from a byte data array.
//! Creates a new label under the notes hive and attaches \ref XCAFDoc_NoteComment
//! attribute (derived ftom \ref XCAFDoc_Note).
//! \param [in] theUserName - the user associated with the note.
//! \param [in] theTimeStamp - timestamp of the note.
//! \param [in] theTitle - data title.
//! \param [in] theMIMEtype - MIME type of the file.
//! \param [in] theData - byte data array.
//! \return a handle to the base note attribute.
Standard_EXPORT Handle(XCAFDoc_Note) CreateBinData(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp,
const TCollection_ExtendedString& theTitle,
const TCollection_AsciiString& theMIMEtype,
const Handle(TColStd_HArray1OfByte)& theData);
Standard_EXPORT Handle(XCAFDoc_Note) CreateBinDataContainer(const TCollection_ExtendedString& theUserName,
const TCollection_ExtendedString& theTimeStamp);
//! @}
@@ -241,6 +242,15 @@ public:
Standard_EXPORT Standard_Integer GetNotes(const TDF_Label& theItemLabel,
TDF_LabelSequence& theNoteLabels) const;
//! Gets all note labels of the note.
//! Notes linked to item's attributes aren't
//! taken into account. The label sequence isn't cleared beforehand.
//! \param [in] theNote - note attribute.
//! \param [out] theNoteLabels - sequence of labels.
//! \return number of added labels.
Standard_EXPORT Standard_Integer GetNotes(const Handle(XCAFDoc_Note)& theNote,
TDF_LabelSequence& theNoteLabels) const;
//! Gets all note labels of the assembly item's attribute.
//! Notes linked to the item itself or to item's subshapes
//! aren't taken into account. The label sequence isn't cleared beforehand.
@@ -293,6 +303,13 @@ public:
Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label& theNoteLabel,
const TDF_Label& theItemLabel);
//! Adds the given note to other note.
//! \param [in] theNoteLabel - note label.
//! \param [in] theAnnotatedNote - other note attribute.
//! \return a handle to the assembly reference attribute.
Standard_EXPORT Handle(XCAFDoc_AssemblyItemRef) AddNote(const TDF_Label& theNoteLabel,
const Handle(XCAFDoc_Note)& theAnnotatedNote);
//! Adds the given note to the assembly item's attribute.
//! \param [in] theNoteLabel - note label.
//! \param [in] theItemId - assembly item ID.
@@ -335,7 +352,7 @@ public:
//! @{
//! Removes the given note from the assembly item.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemId - assembly item ID.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
//! if there are no more assembly items
@@ -346,7 +363,7 @@ public:
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes the given note from the labeled item.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemLabel - item label.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
//! if there are no more labeled items
@@ -356,8 +373,19 @@ public:
const TDF_Label& theItemLabel,
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes the given note from other note.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theNote - note attribute.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
//! if there are no more labeled items
//! linked with the note.
//! \return true if the note is removed, otherwise - false.
Standard_EXPORT Standard_Boolean RemoveNote(const TDF_Label& theNoteLabel,
const Handle(XCAFDoc_Note)& theNote,
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes the given note from the assembly item's subshape.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemId - assembly item ID.
//! \param [in] theSubshapeIndex - assembly item's subshape index.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
@@ -370,7 +398,7 @@ public:
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes the given note from the labeled item's subshape.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemLabel - item label.
//! \param [in] theSubshapeIndex - labeled item's subshape index.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
@@ -383,7 +411,7 @@ public:
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes a note from the assembly item's attribute.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemId - assembly item ID.
//! \param [in] theGUID - assembly item's attribute GUID.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
@@ -396,7 +424,7 @@ public:
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes a note from the labeled item's attribute.
//! \param [in] theNoteLabel - note label.
//! \param [in] theNoteLabel - label of the note to be removed.
//! \param [in] theItemLabel - item label.
//! \param [in] theGUID - labeled item's attribute GUID.
//! \param [in] theDelIfOrphan - deletes the note from the notes hive
@@ -426,6 +454,15 @@ public:
Standard_EXPORT Standard_Boolean RemoveAllNotes(const TDF_Label& theItemLabel,
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes all notes from other note.
//! \param [in] theNote - note attribute.
//! \param [in] theDelIfOrphan - deletes removed notes from the notes
//! hive if there are no more annotated items
//! linked with the notes.
//! \return true if the notes are removed, otherwise - false.
Standard_EXPORT Standard_Boolean RemoveAllNotes(const Handle(XCAFDoc_Note)& theNote,
Standard_Boolean theDelIfOrphan = Standard_False);
//! Removes all notes from the assembly item's subshape.
//! \param [in] theItemId - assembly item ID.
//! \param [in] theSubshapeIndex - assembly item's subshape index.

View File

@@ -16,6 +16,7 @@
#include <DDocStd.hxx>
#include <OSD_File.hxx>
#include <OSD_Protection.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Tool.hxx>
#include <XCAFDoc_AssemblyItemRef.hxx>
@@ -417,11 +418,15 @@ noteCreateBinData(Draw_Interpretor& di, Standard_Integer argc, const char** argv
OSD_Path aPath(aFilename);
OSD_File aFile(aPath);
aFile.Open(OSD_ReadOnly, OSD_Protection());
aNote = aNotesTool->CreateBinData(aUsername, aTimestamp, aTitle, aMIMEtype, aFile);
aNote = aNotesTool->CreateBinDataContainer(aUsername, aTimestamp);
Handle(XCAFDoc_NoteBinDataContainer) aCnt = XCAFDoc_NoteBinDataContainer::Get(aNote->Label());
aCnt->Add(aTitle, aMIMEtype, aFile);
}
else if (aFromData)
{
aNote = aNotesTool->CreateBinData(aUsername, aTimestamp, aTitle, aMIMEtype, aData);
aNote = aNotesTool->CreateBinDataContainer(aUsername, aTimestamp);
Handle(XCAFDoc_NoteBinDataContainer) aCnt = XCAFDoc_NoteBinDataContainer::Get(aNote->Label());
aCnt->Add(aTitle, aMIMEtype, aData);
}
else
{
@@ -1234,15 +1239,15 @@ noteDump(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
di << "Username : " << aNote->UserName() << "\n";
di << "Timestamp : " << aNote->TimeStamp() << "\n";
di << "Type : " << aNote->get_type_name() << "\n";
if (Handle(XCAFDoc_NoteComment) aComment = Handle(XCAFDoc_NoteComment)::DownCast(aNote))
if (Handle(XCAFDoc_NoteComment) aComment = XCAFDoc_NoteComment::Get(aNote->Label()))
{
di << "Comment : " << aComment->Comment() << "\n";
di << "Comment : " << aComment->Get() << "\n";
}
else if (Handle(XCAFDoc_NoteBalloon) aBalloon = Handle(XCAFDoc_NoteBalloon)::DownCast(aNote))
else if (Handle(XCAFDoc_NoteBalloon) aBalloon = XCAFDoc_NoteBalloon::Get(aNote->Label()))
{
di << "Comment : " << aBalloon->Comment() << "\n";
di << "Comment : " << aBalloon->Get() << "\n";
}
else if (Handle(XCAFDoc_NoteBinData) aBinData = Handle(XCAFDoc_NoteBinData)::DownCast(aNote))
else if (Handle(XCAFDoc_NoteBinData) aBinData = XCAFDoc_NoteBinData::Get(aNote->Label()))
{
di << "Title : " << aBinData->Title() << "\n";
di << "MIME type : " << aBinData->MIMEtype() << "\n";

View File

@@ -35,10 +35,6 @@ XmlMXCAFDoc_NoteDriver.cxx
XmlMXCAFDoc_NoteDriver.hxx
XmlMXCAFDoc_NoteBalloonDriver.cxx
XmlMXCAFDoc_NoteBalloonDriver.hxx
XmlMXCAFDoc_NoteCommentDriver.cxx
XmlMXCAFDoc_NoteCommentDriver.hxx
XmlMXCAFDoc_NoteBinDataDriver.cxx
XmlMXCAFDoc_NoteBinDataDriver.hxx
XmlMXCAFDoc_NotesToolDriver.cxx
XmlMXCAFDoc_NotesToolDriver.hxx
XmlMXCAFDoc_ShapeToolDriver.cxx

View File

@@ -33,10 +33,9 @@
#include <XmlMXCAFDoc_LayerToolDriver.hxx>
#include <XmlMXCAFDoc_LocationDriver.hxx>
#include <XmlMXCAFDoc_MaterialDriver.hxx>
#include <XmlMXCAFDoc_NoteDriver.hxx>
#include <XmlMXCAFDoc_NotesToolDriver.hxx>
#include <XmlMXCAFDoc_NoteBalloonDriver.hxx>
#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
#include <XmlMXCAFDoc_MaterialToolDriver.hxx>
#include <XmlMXCAFDoc_ShapeToolDriver.hxx>
#include <XmlMXCAFDoc_ViewToolDriver.hxx>
@@ -73,8 +72,7 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBalloonDriver(anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteCommentDriver(anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBinDataDriver(anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ColorToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_DocumentToolDriver (anMsgDrv));

View File

@@ -20,14 +20,15 @@
#include <XmlMXCAFDoc_NoteBalloonDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
IMPLEMENT_DOMSTRING(Comment, "comment")
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteBalloonDriver::XmlMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
: XmlMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
: XmlMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
{
}
@@ -40,13 +41,55 @@ Handle(TDF_Attribute) XmlMXCAFDoc_NoteBalloonDriver::NewEmpty() const
return new XCAFDoc_NoteBalloon();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_NoteBalloonDriver::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_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
aNote->Set(aComment.GetString());
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const
{
XmlMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
XmlObjMgt_DOMString aComment(TCollection_AsciiString(aNote->TimeStamp()).ToCString());
theTarget.Element().setAttribute(::Comment(), aComment);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteBalloonDriver::XmlMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: XmlMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
: XmlMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -16,13 +16,13 @@
#ifndef _XmlMXCAFDoc_NoteBalloonDriver_HeaderFile
#define _XmlMXCAFDoc_NoteBalloonDriver_HeaderFile
#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
#include <XmlMXCAFDoc_NoteDriver.hxx>
class XmlMXCAFDoc_NoteBalloonDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
//! Attribute Driver.
class XmlMXCAFDoc_NoteBalloonDriver : public XmlMXCAFDoc_NoteCommentDriver
class XmlMXCAFDoc_NoteBalloonDriver : public XmlMXCAFDoc_NoteDriver
{
public:
@@ -30,7 +30,15 @@ public:
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBalloonDriver, XmlMXCAFDoc_NoteCommentDriver)
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_NoteBalloonDriver, XmlMXCAFDoc_NoteDriver)
protected:

View File

@@ -1,121 +0,0 @@
// 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 <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_NoteBinData.hxx>
#include <XmlObjMgt.hxx>
#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <LDOM_OSStream.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteBinDataDriver, XmlMXCAFDoc_NoteDriver)
IMPLEMENT_DOMSTRING(Title, "title")
IMPLEMENT_DOMSTRING(MIMEtype, "mime_type")
IMPLEMENT_DOMSTRING(Size, "size")
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteBinDataDriver::XmlMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& 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 aSize = anElement.getAttribute(::Size());
if (aTitle == NULL || aMIMEtype == NULL || aSize == NULL)
return Standard_False;
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
Standard_Integer nbSize = 0;
if (!aSize.GetInteger(nbSize))
return Standard_False;
XmlObjMgt_DOMString aDataStr = XmlObjMgt::GetStringValue(theSource);
Standard_SStream anSS(aDataStr.GetString());
Handle(TColStd_HArray1OfByte) aData = new TColStd_HArray1OfByte(1, nbSize);
for (Standard_Integer i = 1; i <= nbSize; ++i)
{
Standard_Byte aValue;
anSS >> aValue;
aData->ChangeValue(i) = aValue;
}
aNote->Set(aTitle.GetString(), aMIMEtype.GetString(), aData);
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());
theTarget.Element().setAttribute(::Title(), aTitle);
theTarget.Element().setAttribute(::MIMEtype(), aMIMEtype);
theTarget.Element().setAttribute(::Size(), aNote->Size());
if (aNote->Size() > 0)
{
const Handle(TColStd_HArray1OfByte)& aData = aNote->Data();
LDOM_OSStream anOSS(aNote->Size());
for (Standard_Integer i = aData->Lower(); i <= aData->Upper(); ++i)
{
anOSS << std::hex << aData->Value(i);
}
Standard_Character* dump = (Standard_Character*)anOSS.str(); // copying! Don't forget to delete it.
XmlObjMgt::SetStringValue(theTarget, dump, Standard_True);
delete[] dump;
}
}

View File

@@ -1,45 +0,0 @@
// 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(Message_Messenger)& 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

@@ -1,95 +0,0 @@
// 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 <Message_Messenger.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(Message_Messenger)& 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);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_NoteCommentDriver::XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: XmlMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -1,50 +0,0 @@
// 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(Message_Messenger)& 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)
protected:
XmlMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName);
};
#endif // _XmlMXCAFDoc_NoteCommentDriver_HeaderFile

View File

@@ -24,6 +24,24 @@ 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(Message_Messenger)& theMsgDriver)
: XmlMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_NoteDriver::NewEmpty() const
{
return new XCAFDoc_Note();
}
//=======================================================================
//function :
//purpose :

View File

@@ -36,13 +36,17 @@ class XmlMXCAFDoc_NoteDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT XmlMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& 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;
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;
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver)