SBDDocument Class Reference

This class describes a document. More...

Constructors and destructors

 SBDDocument ()
 Constructs a document.
 
 SBDDocument (const std::string &fileName)
 Constructs a document with name name.
 
virtual ~SBDDocument ()
 Destructs the document.
 

Serialization

bool isSerializable () const
 Returns true.
 
virtual void serialize (SBCSerializer *serializer, const SBNodeIndexer &nodeIndexer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber &classVersionNumber=SBVersionNumber(1, 0, 0)) const
 Serializes the document.
 
virtual void unserialize (SBCSerializer *serializer, const SBNodeIndexer &nodeIndexer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber &classVersionNumber=SBVersionNumber(1, 0, 0))
 Unserializes the document.
 

Topology

virtual SBNodegetParent () const
 Returns the null pointer. More...
 
virtual bool addChild (SBNode *node, SBNode *nextNode=0)
 Adds a child to the node.
 
virtual bool removeChild (SBNode *node)
 Removes a child from the node.
 
SBDDocumentgetNextDocument () const
 Returns the next document.
 
SBDDocumentgetPreviousDocument () const
 Returns the previous document.
 
virtual SBDDocumentclone ()
 Returns a copy of the node and its descendants.
 

Identity

virtual SBNode::Type getType () const
 Returns the data graph node type.
 

File management

std::string getFileName () const
 Returns the name of the file associated to the document.
 
void setFileName (const std::string &name)
 Sets the name of the file associated to the document.
 

Layer

SBDDocumentLayergetActiveLayer () const
 Returns the active document layer.
 
void setActiveLayer (SBDDocumentLayer *documentLayer)
 Sets the active document layer.
 
SBPointerList< SBDDocumentLayer > const * getLayerList () const
 Returns the list of document layers.
 

Camera

SBDDocumentCameragetActiveCamera () const
 Returns the active camera.
 
void setActiveCamera (SBDDocumentCamera *documentCamera)
 Sets the active camera.
 
SBPointerList< SBDDocumentCamera > const * getCameraList () const
 Returns the list of cameras.
 

Groups

SBNodeGroupcreateGroup (const std::string &name, const SBNodePredicate &selectionPredicate=SBDDataGraphNode::All(), const SBNodePredicate &visitPredicate=SBDDataGraphNode::All())
 Create a group with name name based on a selectionPredicate and a visitPredicate.
 
SBNodeGroupgroupSelection (const std::string &name)
 Stores the selected nodes into a group with name name. More...
 
SBNodeGroupgetGroup (const std::string &name) const
 Returns the group with name name.
 
SBPointerList< SBNodeGroup > const * getGroupList () const
 Returns the list of groups.
 

Conformations

SBPointerList< SBMStructuralModelConformation > const * getConformationList () const
 Returns the list of conformations.
 

Paths

SBPointerList< SBMStructuralModelPath > const * getPathList () const
 Returns the list of paths.
 

Selection

void clearSelection ()
 Clears the selection.
 
void addNodeToSelection (SBNode *node)
 Adds a node to the selection.
 
void removeNodeFromSelection (SBNode *node)
 Removes a node from the selection.
 
SBPointerIndexer< SBNode > const * getSelectedNodes () const
 Returns the index of selected nodes.
 
void selectGroupNodes (SBNodeGroup *group) const
 Clears the document selection and select the group nodes.
 
void addGroupNodesToSelection (SBNodeGroup *group) const
 Adds the group nodes to the document selection.
 
void removeGroupNodesFromSelection (SBNodeGroup *group) const
 Removes the group nodes from the document selection.
 
void intersectGroupNodesWithSelection (SBNodeGroup *group) const
 Keeps in the document selection only the nodes stored in this group.
 
virtual void getNodes (SBNodeIndexer &nodeIndexer, const SBNodePredicate &selectionPredicate=SBDDataGraphNode::All(), const SBNodePredicate &visitPredicate=SBDDataGraphNode::All(), bool includeDependencies=false)
 Returns some nodes.
 

Visitor

virtual void forEachNodeDepthFirst (void(*action)(SBNode *node))
 Performs action action on each node of this document.
 
virtual void forEachNodeDepthFirst (SBCClass *object, void(SBCClass::*action)(SBNode *node))
 Performs action action of object object on each node of this document.
 

Messaging

void connectDocumentSignalToSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBDocumentEvent *), SBCReferenceTarget *nextReferenceTarget=0, void(SBCReferenceTarget::*nextFunctionPointer)(SBDocumentEvent *)=0)
 Connects the document signal to a slot.
 
bool documentSignalIsConnectedToSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBDocumentEvent *)) const
 Returns true if and only if the document signal is connected to the slot.
 
void disconnectDocumentSignalFromSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBDocumentEvent *))
 Disconnects the document signal from a slot.
 

Debugging

virtual void print (unsigned int offset=0) const
 Prints the document.
 

Additional Inherited Members

- Public Types inherited from SBDDataGraphNode
enum  Type {
  Undefined,
  StructuralModel,
  StructuralModelNode,
  StructuralModelConformation,
  Conformation,
  StructuralModelPath,
  Path,
  StructuralModelNodeGroup,
  StructuralGroup,
  StructuralModelNodeRoot,
  Root,
  StructuralModelNodeParticle,
  StructuralParticle,
  StructuralModelNodeAtom,
  Atom,
  StructuralModelNodePseudoAtom,
  PseudoAtom,
  StructuralModelNodeBond,
  Bond,
  StructuralModelNodeResidue,
  Residue,
  StructuralModelNodeSegment,
  Segment,
  StructuralModelNodeProtein,
  Protein,
  StructuralModelNodeChain,
  Chain,
  StructuralModelNodeMolecule,
  Molecule,
  StructuralModelNodeBackbone,
  Backbone,
  StructuralModelNodeSideChain,
  SideChain,
  VisualModel,
  DynamicalModel,
  DynamicalModelParticleSystem,
  ParticleSystem,
  DynamicalModelRigidBodySystem,
  RigidBodySystem,
  DynamicalModelArticulatedBodySystem,
  ArticulatedBodySystem,
  DynamicalModelNode,
  DynamicalNode,
  DynamicalModelNodeGroup,
  DynamicalGroup,
  DynamicalModelNodeRoot,
  DynamicalRoot,
  DynamicalModelNodeParticle,
  DynamicalParticle,
  DynamicalModelNodeRigidBody,
  RigidBody,
  DynamicalModelNodeArticulatedBody,
  ArticulatedBody,
  InteractionModel,
  InteractionModelParticleSystem,
  InteractionModelRigidBodySystem,
  InteractionModelArticulatedBodySystem,
  PropertyModel,
  PropertyModelFunction,
  Simulator,
  SimulatorParticleSystem,
  SimulatorRigidBodySystem,
  SimulatorArticulatedBodySystem,
  StateUpdater,
  StateUpdaterParticleSystem,
  StateUpdaterRigidBodySystem,
  StateUpdaterArticulatedBodySystem,
  DocumentManager,
  Document,
  DocumentLayer,
  Layer,
  DocumentCamera,
  Camera,
  DocumentLabel,
  Label,
  DataGraphNodeGroup,
  NodeGroup,
  Controller,
  ControllerNode
}
 The type of the data graph node. More...
 
- Public Member Functions inherited from SBDDataGraphNode
SBDDataGraphNodegetThisNode () const
 Returns the pointer to this node. More...
 
virtual bool addChild (SBDDataGraphNode *node, SBDDataGraphNode *nextNode=0)
 Adds a child to the node. More...
 
virtual bool removeChild (SBDDataGraphNode *node)
 Removes a child from the node. More...
 
bool hasOneOf (const SBNodeIndexer &nodeIndexer) const
 Returns true if and only if this node is one of the nodes of the nodeIndexer, or is the ancestor of one of them. More...
 
bool isIn (SBDDataGraphNode *node) const
 Returns true if and only if this node is node, or descends from it. More...
 
bool isIn (const SBNodeIndexer &nodeIndexer) const
 Returns true if and only if this node is one of the nodes of the nodeIndexer, or descends from one of them. More...
 
bool isOneOf (const SBNodeIndexer &nodeIndexer) const
 Returns true if and only if this node is one of the nodes of the nodeIndexer. More...
 
SBDDataGraphNodegetRoot () const
 Returns the root of the hierarchy the node belongs to. More...
 
unsigned int getNodeIndex () const
 Returns the node index (unique in the whole data graph, but non-persistent) More...
 
bool isCreated () const
 Returns true if and only if the node is created. More...
 
void create ()
 Creates the node. More...
 
bool isErased () const
 Returns true if and only if the node is erased. More...
 
void erase ()
 Erases the node. More...
 
unsigned int getFlags () const
 Returns the flags. More...
 
unsigned int getInheritedFlags () const
 Returns the inherited flags. More...
 
bool isSelected () const
 Returns whether the node is selected. More...
 
bool getSelected () const
 Returns whether the node is visible.
 
bool getSelectionFlag () const
 Returns the selection flag. More...
 
void setSelectionFlag (bool flag)
 Sets the selection flag. More...
 
bool isVisible () const
 Returns whether the node is visible. More...
 
bool getVisible () const
 Returns whether the node is visible.
 
bool getVisibilityFlag () const
 Returns the visibility flag. More...
 
void setVisibilityFlag (bool flag)
 Sets the visibility flag. More...
 
bool isHighlighted () const
 Returns whether the node is highlighted. More...
 
bool getHighlightingFlag () const
 Returns the highlighting flag. More...
 
void setHighlightingFlag (bool flag)
 Sets the highlighting flag. More...
 
void connectBaseSignalToSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBBaseEvent *), SBCReferenceTarget *nextReferenceTarget=0, void(SBCReferenceTarget::*nextFunctionPointer)(SBBaseEvent *)=0)
 Connects the base signal to a slot. More...
 
bool baseSignalIsConnectedToSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBBaseEvent *)) const
 Returns true when the base signal is connected to a slot.
 
void disconnectBaseSignalFromSlot (SBCReferenceTarget *referenceTarget, void(SBCReferenceTarget::*functionPointer)(SBBaseEvent *))
 Disconnects the base signal from a slot.
 
unsigned int countNodes (const SBNodePredicate &selectionPredicate=SBDDataGraphNode::All(), const SBNodePredicate &visitPredicate=SBDDataGraphNode::All(), bool includeDependencies=false)
 Collects nodes into nodeIndexer, based on a selectionPredicate and a visitPredicate, with our without dependencies. More...
 
virtual void forEachNodeDepthFirst (void(*action)(SBDDataGraphNode *node))
 Performs an action on each node.
 
virtual void forEachNodeDepthFirst (SBCClass *object, void(SBCClass::*action)(SBDDataGraphNode *node))
 Performs an action on each node.
 
bool addMaterial (SBDDataGraphNodeMaterial *material)
 Adds a material. More...
 
bool removeMaterial ()
 Removes the material. More...
 
SBDDataGraphNodeMaterialgetMaterial () const
 Returns the material. More...
 
SBDDataGraphNodegetMaterialOwner () const
 Returns the node whose material is inherited. More...
 
- Public Member Functions inherited from SBCReferenceTarget
 SBCReferenceTarget ()
 
virtual ~SBCReferenceTarget ()
 
unsigned int getMemoryFootprint () const
 
void printReferencesToOwners () const
 
- Static Public Member Functions inherited from SBDDataGraphNode
static SBDDataGraphNodegetNode (unsigned int nodeIndex)
 Returns the unique node corresponding to the node index nodeIndex. More...
 
static std::string getTypeString (Type type)
 Returns a string describing the type of the data graph node. More...
 
static void forEachNodeInSelection (SBNodeIndexer &nodeIndexer, void(*action)(SBDDataGraphNode *node))
 Performs an action for each node in a selection.
 
static void forEachNodeInSelection (SBNodeIndexer &nodeIndexer, SBCClass *object, void(SBCClass::*action)(SBDDataGraphNode *node))
 Performs an action for each node in a selection.
 
- Protected Member Functions inherited from SBDDataGraphNode
 SBDDataGraphNode ()
 Builds a data graph node. More...
 
 SBDDataGraphNode (SBDDataGraphNodeData *dataPointer)
 Builds a data graph node.
 
virtual ~SBDDataGraphNode ()
 Destroys the node. More...
 

Detailed Description

This class describes a document. A document may contain layers, cameras, groups, conformations and paths.

There is always at least one (possibly empty) layer in a document, and always one active layer. This active layer is the layer preferably used when performing actions on the document (adding a model, a simulator, etc.).

SAMSON Elements access the active document through SAMSON:

SBPointer<SBDocument> activeDocument=SAMSON::getActiveDocument();

The set of selected nodes is accessible from the document:

SBPointerIndexer<SBNode> const* selectedNodes=activeDocument->getSelectedNodes();

The index cannot be modified, because SAMSON needs to perform bookkeeping when managing selected nodes, so the selection is manipulated either by modifying the selection flag of a node:

atom->setSelectionFlag(true); // the atom is selected
atom->setSelectionFlag(false); // the atom is deselected

or by modyfing the document selection itself:

document->addNodeToSelection(atom); // the atom is selected
document->removeNodeFromSelection(atom); // the atom is deselected

Whenever the selection flag of a node changes, through either one of these methods, a SelectionFlagChanged base signal is emitted by the node and the document (thus, adding a node twice to a selection, for example, emits a signal only once).

Note that you should always turn the Undo system on when modifying the selection:

SAMSON::beginHolding("Modify selection"); // turn the undo system on
SAMSON::getActiveDocument()->clearSelection(); // clear the selection
atom->setSelectionFlag(true); // the atom is selected
SAMSON::endHolding(); // turn the undo system off
SAMSON::undo(); // go back to before clearing

Short name: SBDocument

See also
SBDDocumentLayer
SBDDocumentCamera
SBDDataGraphNodeGroup
SBMStructuralModelConformation
SBMStructuralModelPath
Signals and slots

Member Function Documentation

◆ getParent()

SBDDataGraphNode * SBDDocument::getParent ( ) const
virtual

This function always returns the null pointer.

Reimplemented from SBDDataGraphNode.

◆ groupSelection()

SBNodeGroup * SBDDocument::groupSelection ( const std::string &  name)

This function is undoable

See also
SBDDataGraphNodeGroup