SAMSON Class Reference

This class is the main interface. More...

Time

static SBCTime getTime ()
 Returns SAMSON's internal time.
 
static void startTimer ()
 Starts a new performance timer.
 
static void stopTimer (SBQuantity::second &elapsedTime)
 Stops the top performance timer.
 
static void stopTimer (SBQuantity::second &elapsedTime, SBQuantity::second &totalTime)
 Stops the top performance timer.
 

Directories

static std::string getSAMSONPath ()
 Returns the path where SAMSON is installed.
 
static std::string getSAMSONElementsPath ()
 Returns the path where SAMSON Elements are installed.
 
static std::string getUserDataPath ()
 Returns the path where user data is installed.
 
static std::string getScratchPath ()
 Returns the path to scratch data.
 

Documents

static SBDDocumentgetActiveDocument ()
 Returns a pointer to SAMSON's active document.
 
static SBDDocumentCameragetActiveCamera ()
 Returns a pointer to the active camera.
 
static SBStructuralModelgetActiveStructuralModel ()
 Returns a pointer to the active structural model.
 
static void setActiveStructuralModel (SBStructuralModel *structuralModel)
 Sets the active structural model.
 

Apps

static SBAppgetApp (const SBUUID &appUUID, const SBUUID &elementUUID=SBUUID())
 Returns the app corresponding to a specific appUUID and elementUUID.
 
static SBPointerIndexer< SBApp > const * getAppIndexer ()
 Returns the app indexer.
 

Editors

static SBEditorgetActiveEditor ()
 Returns a pointer to the current editor.
 
static void setActiveEditor (SBEditor *editor)
 Sets the current editor.
 
static SBEditorgetEditor (const SBUUID &editorUUID, const SBUUID &elementUUID=SBUUID())
 Returns the editor corresponding to a specific editorUUID and elementUUID.
 
static SBIndexer< SBEditor * > const * getEditorIndexer ()
 Returns the editor indexer.
 

Picking

static SBAtomgetAtom (int x, int y)
 Returns the atom at location (x,y) in the viewport. More...
 
static SBAtomgetAtom (const QPoint &position)
 Returns the atom at location position in the viewport. More...
 
static SBBondgetBond (int x, int y)
 Returns the bond at location (x,y) in the viewport. More...
 
static SBBondgetBond (const QPoint &position)
 Returns the bond at location position in the viewport. More...
 
static SBNodegetNode (int x, int y, const SBNodePredicate &selectionFilter=SBNode::All())
 Returns the node at location (x,y) in the viewport according to the selectionFilter. More...
 
static SBNodegetNode (const QPoint &position, const SBNodePredicate &selectionFilter=SBNode::All())
 Returns the node at location position in the viewport according to the selectionFilter. More...
 
static SBNodegetNode (int x, int y, SBPosition3 &pickedPosition, const SBNodePredicate &selectionFilter=SBNode::All())
 Returns the node at location (x,y) in the viewport and the pickedPosition according to the selectionFilter. More...
 
static SBNodegetNode (const QPoint &position, SBPosition3 &pickedPosition, const SBNodePredicate &selectionFilter=SBNode::All())
 Returns the node at location position in the viewport and the pickedPosition according to the selectionFilter. More...
 
static void getNodes (SBNodeIndexer &nodeIndexer, int x, int y, int width, int height, const SBNodePredicate &selectionFilter=SBNode::All())
 Stores the nodes found inside the viewport rectangle (x,y,width,height) into nodeIndexer according to the selectionFilter. More...
 
static void getNodes (SBNodeIndexer &nodeIndexer, const QPoint &topLeftCorner, int width, int height, const SBNodePredicate &selectionFilter=SBNode::All())
 Stores the nodes found inside the viewport rectangle (topLeftCorner,width,height) into nodeIndexer according to the selectionFilter. More...
 
static void getNodes (SBNodeIndexer &nodeIndexer, const SBVector< QPoint > &selectionLasso, const SBNodePredicate &selectionFilter=SBNode::All())
 Returns the nodes insde the selection lasso with contour selectionLasso into nodeIndexer according to the selectionFilter. More...
 
static const SBNodePredicategetActiveSelectionFilter ()
 Returns the active selection filter.
 

Viewport

static int getViewportWidth ()
 Returns the viewport width.
 
static int getViewportHeight ()
 Returns the viewport height.
 
static QPoint getMousePositionInViewport ()
 Returns the current mouse position in viewport coordinates.
 
static SBVector3 getViewportPositionFromWorldPosition (const SBPosition3 &position)
 Returns the projection in the viewport of a given world position.
 
static SBPosition3 getWorldPositionFromViewportPosition (int x, int y)
 Returns the 3D position that corresponds to the viewport location (x,y)
 
static SBPosition3 getWorldPositionFromViewportPosition (int x, int y, const SBPosition3 &pointInPlane)
 Returns the 3D position that corresponds to the viewport location (x,y) in the plane containing pointInPlane.
 
static SBPosition3 getWorldPositionFromViewportPosition (const QPoint &position)
 Returns the 3D position that corresponds to the viewport location (x,y)
 
static SBPosition3 getWorldPositionFromViewportPosition (const QPoint &position, const SBPosition3 &pointInPlane)
 Returns the 3D position that corresponds to the viewport location (x,y) in the plane containing pointInPlane.
 
static QImage captureViewport (int width, int height, bool transparentBackground=false)
 Captures the viewport.
 
static void captureViewport (const std::string &fileName, int width, int height, bool transparentBackground=false)
 Captures the viewport.
 
static void requestViewportUpdate ()
 Requests a viewport update. More...
 
static void setViewportCursor (const QCursor &cursor)
 Sets the viewport cursor.
 
static void setViewportCursor (Qt::CursorShape cursorShape)
 Sets the viewport cursor.
 
static void unsetViewportCursor ()
 Unsets the viewport cursor.
 

Light

static const float * getLightDirection (unsigned int lightIndex)
 Returns the light direction of light lightIndex.
 
static float getLightIntensity (unsigned int lightIndex)
 Returns the light intensity of light lightIndex.
 
static const float * getLightColor (unsigned int lightIndex)
 Returns the light color of light lightIndex.
 
static float getSpecularIntensity (unsigned int lightIndex)
 Returns the specular intensity of light lightIndex.
 
static float getSpecularPower (unsigned int lightIndex)
 Returns the specular power of light lightIndex.
 
static float getAmbientLight ()
 Returns the ambient light.
 
static const float * getFresnelColor ()
 Returns the fresnel color.
 
static float getFresnelPower ()
 Returns the fresnel power.
 
static float getFresnelIntensity ()
 Returns the fresnel power.
 

Version number

static SBCContainerVersionNumber getVersionNumber ()
 Returns the version number of SAMSON.
 

Periodic table

static const SBElementgetElement (SBMElement::Type element)
 Returns the periodic table element corresponding to a given type.
 
static SBMElement *const * getElementVector ()
 Returns the complete periodic table element vector.
 
static unsigned int getNumberOfElements ()
 Returns the number of defined periodic table elements.
 
static std::string getElementName (SBMElement::Type element)
 Returns the name of the periodic table element corresponding to a given type.
 
static std::string getElementSymbol (SBMElement::Type element)
 Returns the symbol of the periodic table element corresponding to a given type.
 
static std::string getPeriod (SBMElement::Type element)
 Returns the period of periodic table element element.
 
static unsigned int getGroup (SBMElement::Type element)
 Returns the group of periodic table element element.
 
static std::string getBlock (SBMElement::Type element)
 Returns the block of periodic table element element.
 
static SBQuantity::mass getAtomicWeight (SBMElement::Type element)
 Returns the atomic weight of periodic table element element.
 
static SBQuantity::length getCovalentRadius (SBMElement::Type element)
 Returns the covalent radius of periodic table element element.
 
static SBQuantity::length getVanDerWaalsRadius (SBMElement::Type element)
 Returns the van der Waals radius of periodic table element element.
 
static SBQuantity::dimensionless getElectronegativity (SBMElement::Type element)
 Returns the electronegativity of periodic table element element.
 
static SBElement::Type getElementTypeByName (char *elementName)
 Returns the periodic table element type corresponding to a given name.
 
static SBElement::Type getElementTypeByName (const std::string &elementName)
 Returns the periodic table element type corresponding to a given name.
 
static SBElement::Type getElementTypeBySymbol (char *elementSymbol)
 Returns the periodic table element type corresponding to a given symbol.
 
static SBElement::Type getElementTypeBySymbol (const std::string &elementSymbol)
 Returns the periodic table element type corresponding to a given symbol.
 

GUI

static SBGWindowaddDialog (SBGWindowDialog *dialog)
 Adds a SAMSON dialog to the user interface.
 
static SBGWindowaddDialog (QDialog *dialog, QString name="", int format=SBGWindow::NoOptions, QPixmap logo=QPixmap(), SBUUID uuid=SBUUID(""))
 Adds a Qt dialog to the user interface.
 
static SBGWindowaddWidget (SBGWindowWidget *widget)
 Adds a SAMSON widget to the user interface.
 
static SBGWindowaddWidget (QWidget *widget, QString name="", int format=SBGWindow::NoOptions, QPixmap logo=QPixmap(), SBUUID uuid=SBUUID(""))
 Adds a Qt widget to the user interface.
 
static void removeDialog (SBGWindowDialog *dialog)
 Removes a SAMSON dialog from the user interface.
 
static void removeDialog (QDialog *dialog)
 Removes a Qt dialog from the user interface.
 
static void removeWidget (SBGWindowWidget *widget)
 Removes a SAMSON widget from the user interface.
 
static void removeWidget (QWidget *widget)
 Removes a Qt widget from the user interface.
 
static void removeWindow (SBGWindow *window)
 Removes a window from the user interface.
 
static void setBusy (bool b)
 Notifies the user that SAMSON is busy.
 
static void setStatusMessage (const QString &message, int time=0)
 Shows a message in the status bar.
 
static void informUser (const QString &dialogTitle, const QString &dialogText)
 Informs the user with a message in a modal pop-up dialog. More...
 
static void informUser (SBGWindowWidget *widget)
 Informs the user with a widget in a modal pop-up dialog. More...
 
static bool askUser (const QString &dialogTitle, const QString &dialogText, QDialogButtonBox *buttonBox=0)
 Asks a question to the user with a message in a modal pop-up dialog. More...
 
static bool askUser (SBGWindowWidget *widget, QDialogButtonBox *buttonBox=0)
 Asks a question to the user with a widget in a modal pop-up dialog. More...
 
static bool askUser (QWidget *widget, QDialogButtonBox *buttonBox=0)
 Asks a question to the user with a widget in a modal pop-up dialog. More...
 
static bool getColorFromUser (const QString &dialogTitle, SBDColor &result)
 Gets a color from the user in a modal pop-up dialog.
 
static bool getDoubleFromUser (const QString &dialogTitle, double &result, double minimum, double maximum, double singleStep=1.0, const QString &prefix="", const QString &suffix="", int decimals=2)
 Gets a number from the user in a modal pop-up dialog.
 
static bool getFontFromUser (const QString &dialogTitle, QFont &result)
 Gets a font from the user in a modal pop-up dialog.
 
static bool getIntegerFromUser (const QString &dialogTitle, int &result, int minimum, int maximum, int singleStep=1, const QString &prefix="", const QString &suffix="")
 Gets a number from the user in a modal pop-up dialog.
 
static bool getPathFromUser (const QString &dialogTitle, QString &result)
 Gets a path from the user in a modal pop-up dialog.
 
static bool getFileNameFromUser (const QString &dialogTitle, QString &result, const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=Q_NULLPTR, QFileDialog::Options options=QFileDialog::Options())
 Gets a filename from the user in a modal pop-up dialog.
 
static bool getStringFromUser (const QString &dialogTitle, QString &result)
 Gets a string from the user in a modal pop-up dialog.
 
static void showProgressBar (const QString &name="", int minimum=0, int maximum=0, const SBQuantity::second &minimumDuration=SBQuantity::second(2.0), bool isCancellable=true, const QString &cancelButtonText="Cancel")
 Shows the progress bar.
 
static void setProgressBarValue (int value)
 Sets the value of the progress bar.
 
static void hideProgressBar ()
 Hides the progress bar.
 
static bool isProgressBarStopped ()
 Returns true when the progress bar is stopped.
 
static SBActiongetAction (const SBUUID &actionUUID)
 Returns the action with the given actionUUID.
 
static SBActionWidgetgetActionWidget (const SBUUID &actionWidgetUUID)
 Returns the action widget with the given actionWidgetUUID.
 

Undo

static bool isHolding ()
 Returns true when SAMSON is holding.
 
static void beginHolding (const std::string &name)
 Begins holding.
 
static void disableHolding ()
 Pauses holding.
 
static void enableHolding ()
 Resumes holding.
 
static void endHolding ()
 Ends holding.
 
static void hold (void *object)
 Holds an object.
 
static void hold (SBNode *node)
 Holds a node and its descendants.
 
static void hold (SBUndoCommand *undoCommand)
 Holds a command.
 
static void hold (SBPointerTarget *pointerTarget)
 Holds a pointer target allocated on the heap.
 
static void holdArray (void *array)
 Holds an array allocated on the heap.
 
static void undo ()
 Undo one command.
 
static void redo ()
 Redo one command.
 
static bool isUndoing ()
 Returns true while undoing.
 
static bool isRedoing ()
 Returns true while redoing.
 

Files

static void importFromFile (const std::string &fileName, const SBList< std::string > *parameters=0, SBDDocumentFolder *preferredFolder=0, SBIFileImporter *importer=0)
 Import a file from the disk.
 
static void exportToFile (const SBNodeIndexer &nodeIndexer, const std::string &fileName, const SBList< std::string > *parameters=0, SBIFileExporter *exporter=0)
 Export a selection of nodes to a file.
 

Display

static void displayCylinders (unsigned int nCylinders, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *radiusData, const unsigned int *capData, const float *colorData, const unsigned int *flagData, bool shadowPassFlag=false)
 Displays cylinders. More...
 
static void displayCylindersSelection (unsigned int nCylinders, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *radiusData, const unsigned int *capData, const unsigned int *nodeIndexData)
 Displays cylinders for selection.
 
static void displayLines (unsigned int nLines, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *colorData, const unsigned int *flagData, bool shadowPassFlag=false)
 Displays 3D lines.
 
static void displayLinesOrtho (unsigned int nLinesOrtho, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *colorData)
 Displays 2D lines.
 
static void displayLinesSelection (unsigned int nLines, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const unsigned int *nodeIndexData)
 Displays 3D lines for selection.
 
static void displayLineSweptSpheres (unsigned int nLineSweptSpheres, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *radiusData, const float *colorData, unsigned int *flagData, bool shadowPassFlag=false)
 Displays line-swept spheres.
 
static void displayLineSweptSpheresSelection (unsigned int nLineSweptSpheres, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *radiusData, const unsigned int *nodeIndexData)
 Displays line-swept spheres for selection.
 
static void displaySpheres (unsigned int nSpheres, const float *positionData, const float *radiusData, const float *colorData, const unsigned int *flagData, bool shadowPassFlag=false)
 Displays spheres.
 
static void displaySpheresSelection (unsigned int nSpheres, const float *positionData, const float *radiusData, const unsigned int *nodeIndexData)
 Displays spheres for selection.
 
static void displayText (std::string text, const SBPosition3 &position, const QFont &font, float *color)
 Displays text.
 
static void displayTextSelection (std::string text, const SBPosition3 &position, const QFont &font)
 Displays text for selection.
 
static void displayTriangles (unsigned int nTriangles, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *normalData, const float *colorData, const unsigned int *flagData, bool shadowPassFlag=false, bool transparency=false)
 Displays 3D triangles.
 
static void displayTrianglesOrtho (unsigned int nTriangles, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const float *colorData)
 Displays 2D triangles.
 
static void displayTrianglesSelection (unsigned int nTriangles, unsigned int nPositions, const unsigned int *indexData, const float *positionData, const unsigned int *nodeIndexData)
 Displays 3D triangles for selection.
 
static void displayTubes (float *ovalCenter, float *normal, float *binormal, float *width, float *height, unsigned int *nodeIndex, unsigned int *sectionIndex, unsigned int *detailIndex, unsigned int *flags, unsigned int sectionsNumber, unsigned int sectionsDetail, unsigned int ovalDetail, unsigned int triangleReduction, float *color)
 Displays tubes.
 
static void displayTubesSelection (float *ovalCenter, float *normal, float *binormal, float *width, float *height, unsigned int *nodeIndex, unsigned int *sectionIndex, unsigned int *detailIndex, unsigned int sectionsNumber, unsigned int sectionsDetail, unsigned int ovalDetail, unsigned int triangleReduction, float *color)
 Displays tubes for selection.
 
static const SBQuantity::lengthgetAtomRadius ()
 Get the radius of atoms in the default representation of structural models.
 
static const SBQuantity::lengthgetBondRadius ()
 Get the radius of bonds in the default representation of structural models.
 

Introspection

Access proxies of registered classes

static SBProxygetProxy (const std::string &className, const SBUUID &elementUUID=SBUUID())
 Returns the proxy of a class.
 
static SBIndexer< SBProxy * > const * getProxyIndexer (SBCClass::Type classType)
 Returns all proxies corresponding to a given class type classType.
 

Factory

static SBNodePredicatemakeNodePredicate (const std::string &selectionString)
 Make a node predicate based on a selectionString. More...
 
static SBControllermakeController (const std::string &controllerClassName, const SBUUID &controllerElementUUID=SBUUID())
 Make a controller.
 
static SBInteractionModelParticleSystemmakeInteractionModel (SBParticleSystem *dynamicalModel, const std::string &interactionModelClassName, const SBUUID &interactionModelElementUUID=SBUUID())
 Make an interaction model.
 
static SBSNeighborSearchParticleSystemmakeNeigborSearch (SBParticleSystem *dynamicalModel, const SBQuantity::length &cutoffDistance, const std::string &neighborSearchClassName, const SBUUID &neighborSearchElementUUID=SBUUID())
 Make a neighbor search algorithm.
 
static SBStateUpdaterParticleSystemmakeStateUpdater (SBParticleSystem *dynamicalModel, SBInteractionModelParticleSystem *interactionModel, const std::string &stateUpdaterClassName, const SBUUID &stateUpdaterElementUUID=SBUUID())
 Make a state updater.
 
static SBSimulatorParticleSystemmakeSimulator (const SBNodeIndexer &nodeIndexer, const std::string &interactionModelClassName, const SBUUID &interactionModelElementUUID, const std::string &stateUpdaterClassName, const SBUUID &stateUpdaterElementUUID=SBUUID())
 Make a simulator.
 
static SBVisualModelmakeVisualModel (const SBNodeIndexer &nodeIndexer, const std::string &visualModelClassName, const SBUUID &visualModelElementUUID=SBUUID())
 Make a visual model.
 
static SBPropertyModelmakePropertyModel (const SBNodeIndexer &nodeIndexer, const std::string &propertyModelClassName, const SBUUID &propertyModelElementUUID=SBUUID())
 Make a property model.
 

Selection

static void getNodes (SBNodeIndexer &nodeIndexer, const std::string &selectionString)
 Returns some nodes based on a selectionString. More...
 

Simulation

static void startSimulation ()
 Starts interactive simulation. More...
 
static void stopSimulation ()
 Stops interactive simulation. More...
 
static void toggleSimulation ()
 Toggles interactive simulation on and off. More...
 
static bool getSimulationFlag ()
 Returns true when interactive simulation is on. More...
 
static void setSimulationFlag (bool simulationFlag)
 Sets the interactive simulation flag. More...
 

Properties

static bool showProperties (SBNode *node)
 Shows the properties widget of a node.
 

Jobs

static SBUUID createJob (const QString &name, double fixedCost, double hourlyCost, QString priceCurrency, long estimatedDuration, const QString &endpoint, const QJsonObject &metadata)
 Creates a job named name with fixed cost fixedCost, hourly cost hourlyCost, price currency priceCurrency, estimated duration estimatedDuration, end point endPoint, and meta data metadata; returns the job's UUID.
 
static bool getJob (const SBUUID &jobUUID, QJsonObject &response)
 Returns a job.
 
static bool getJobs (QJsonObject &response)
 Returns all the jobs of the current user.
 
static bool getJobStatus (const SBUUID &jobUUID, QJsonObject &response)
 Returns a job status.
 
static bool startJob (const SBUUID &jobUUID, QJsonObject &response)
 Starts a job.
 
static bool pauseJob (const SBUUID &jobUUID, QJsonObject &response)
 Pauses a job.
 
static bool stopJob (const SBUUID &jobUUID, QJsonObject &response)
 Stops a job.
 
static bool eraseJob (const SBUUID &jobUUID, QJsonObject &response)
 Erases a job.
 

Debugging

static void printMemoryUsage ()
 Prints memory usage.
 
static void printFullMemoryUsage ()
 Prints full memory usage.
 
static void printDataGraphState ()
 Prints the data graph state.
 
static void printRendererState ()
 Prints the renderer state.
 
static void printUndoStack ()
 Prints the undo stack.
 

Detailed Description

This class is the main interface of SAMSON. It acts as a facade that centralizes and exposes other functions from the SAMSON API to make it easy for developers to interact with SAMSON, the data graph, etc. All functions in this class are static, e.g:

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

Time

SAMSON may be used to get the current internal time (in ticks)

SBTime currentTime = SAMSON::getTime();

as well as analyze the performance of algorithms using timers. Internally, SAMSON uses a stack of timers, so that calling SAMSON::stopTimer stops the timer that was started last :

SAMSON::startTimer(); // Starts the first timer
... // Do task 1
SAMSON::startTimer(); // Starts the second timer (the first is still running)
... // Do task 2
SBQuantity::second timeTask2(0.0);
SAMSON::stopTimer(timeTask2); // timeTask2 contains the time taken by task 2
SBQuantity::second totalTime(0.0);
SAMSON::stopTimer(totalTime); // totalTime contains the time taken by both tasks
See also
getTime
startTimer
stopTimer(SBQuantity::second&)
stopTimer(SBQuantity::second&, SBQuantity::second&)
Units

Directories

A few functions are provided to easily access key file locations from within a SAMSON Element. For example, the path to the scratch folder, where SAMSON Elements may write temporary data, may be obtained with:

std::string scratchPath = SAMSON::getScratchPath();

Furthermore, the SB_ELEMENT_PATH macro provides a std::string containing the installation path of the specific SAMSON Element whose code is being executed. This may be used for example to access the resources associated to the SAMSON Element:

return QPixmap(QString::fromStdString(SB_ELEMENT_PATH + "/Resource/icons/logo.png"));
See also
getSAMSONPath
getSAMSONElementsPath
getUserDataPath
getScratchPath
The SB_ELEMENT_PATH macro

Documents

The SAMSON interface is the main entry point to documents. In particular, the active document is retrieved with:

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

For example, a new structural model may be added to the active document with:

SAMSON::beginHolding("Add structural model"); // turn the undo system on
SBPointer<SBStructuralModel> newStructuralModel = new SBStructuralModel();
SAMSON::hold(newStructuralModel()); // hold the model in memory
newStructuralModel->create();
SAMSON::getActiveDocument()->addChild(newStructuralModel());
SAMSON::endHolding(); // turn the undo system off
See also
getActiveDocument
getActiveCamera
getActiveStructuralModel

Editors

In SAMSON, editors are used to modify the data graph. There is always one (and only one) active editor at any given time. Two functions control the active editor.

See also
Editors
getActiveEditor
setActiveEditor

Picking

When editors, for example, want to select data graph nodes based on the display viewport, they may perform picking operations.

For example, if an editor needs to determine which node was under the mouse cursor when the mouse button was pressed, the getNode(int, int, const SBNodePredicate&) function may be used:

SBNode* pickedNode = SAMSON::getNode(event->pos().x(), event->pos().y());

Some picking functions are convenience functions that attempt to pick specific node types, e.g. getAtom(int, int) and getBond(int, int).

Furthermore, two functions pick nodes in regions of the viewport, instead of at a specific location (x, y):

Note that picking in SAMSON is performed through rendering. As a result, picking functions cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getAtom(int, int)
getAtom(const QPoint&)
getBond(int, int)
getBond(const QPoint&)
getNode(int, int, const SBNodePredicate&)
getNode(const QPoint&, const SBNodePredicate&)
getNode(int, int, SBPosition3&, const SBNodePredicate&)
getNode(const QPoint&, SBPosition3&, const SBNodePredicate&)
getNodes(SBNodeIndexer&, int, int, int, int, const SBNodePredicate&)
getNodes(SBNodeIndexer&, const QPoint&, int, int, const SBNodePredicate&)
getNodes(SBNodeIndexer&, const SBVector<QPoint>&, const SBNodePredicate&)

Viewport

The SAMSON class is also the main entry point to the viewport, which displays a visual representation of the data graph.

The viewport dimensions may be retrieved with:

and the mouse position in viewport coordinates can be obtained with:

QPoint mousePosition = SAMSON::getMousePositionInViewport();

Typically, editors that allow users to visually interact with the data graph need to convert back and forth between two-dimensional viewport coordinates (integers) and three-dimensional world coordinates (lengths).

For example, the getWorldPositionFromViewportPosition(const QPoint&) function returns a 3D world position that corresponds to a given viewport position:

SBPosition3 worldPosition;
worldPosition = SAMSON::getWorldPositionFromViewportPosition(mousePosition);

Note that, since a given viewport position actually corresponds to an infinite line of world positions (all positions that would project to the same pixel), functions that return a world position based on a viewport position typically return the point that belongs to the plane containing the camera target. If another plane should be used, then a variant should be used:

worldPosition =
SAMSON::getWorldPositionFromViewportPosition(mousePosition, pointInPlane);

Conversely, projecting a world position in the viewport may be achieved with:

SBVector3 viewportPosition;
viewportPosition = SAMSON::getViewportPositionFromWorldPosition(worldPosition);

Note that the returned viewport position is a dimensionless physical vector. The first two components are the viewport coordinates with subpixel accuracy, and the third component is the depth in the camera frustum.

See also
getViewportWidth
getViewportHeight
getMousePositionInViewport
getViewportPositionFromWorldPosition
getWorldPositionFromViewportPosition(int, int)
getWorldPositionFromViewportPosition(int, int, const SBPosition3&)
getWorldPositionFromViewportPosition(const QPoint&)
getWorldPositionFromViewportPosition(const QPoint&, const SBPosition3&)

Lights

Developers of SAMSON Elements who need to develop their own shaders can retrieve the parameters of the lighting model used by SAMSON's internal renderer. In particular, two directional lights are used:

// get parameters of directional light 0
const float* lightDirection0 = SAMSON::getLightDirection(0);
const float* lightColor0 = SAMSON::getLightColor(0);
float lightIntensity0 = SAMSON::getLightIntensity(0);
float lightSpecularIntensity0 = SAMSON::getSpecularIntensity(0);
float lightSpecularPower0 = SAMSON::getSpecularPower(0);
// get parameters of directional light 1
const float* lightDirection1 = SAMSON::getLightDirection(1);
const float* lightColor1 = SAMSON::getLightColor(1);
float lightIntensity1 = SAMSON::getLightIntensity(1);
float lightSpecularIntensity1 = SAMSON::getSpecularIntensity(1);
float lightSpecularPower1 = SAMSON::getSpecularPower(1);

Global lighting parameters may also be accessed:

float ambientLight = SAMSON::getAmbientLight();
float fresnelPower = SAMSON::getFresnelPower();
float fresnelIntensity = SAMSON::getFresnelIntensity();
const float* fresnelColor = SAMSON::getFresnelColor();
See also
Rendering

Version number

The version number of SAMSON may be retrieved from the SAMSON class:

Please refer to the versioning chapter for more information about the versioning scheme used for SAMSON and SAMSON Elements.

See also
SBVersionNumber
Versioning

Periodic table

The SAMSON class also exposes functions from the periodic table, which collects periodic table elements:

Note that convenience functions exist in atoms to access the properties of their element:

SBQuantity::length r = atom->getCovalentRadius();
See also
getElement
getElementVector
getNumberOfElements
getElementName
getElementSymbol
getPeriod
getGroup
getBlock
getAtomicWeight
getCovalentRadius
getVanDerWaalsRadius
getElectronegativity
getElementTypeByName(char*)
getElementTypeByName(const std::string&)
getElementTypeBySymbol(char*)
getElementTypeBySymbol(const std::string&)

GUI

Dialogs and windows

The SAMSON class gives access to the Graphical User Interface (GUI) of SAMSON, and makes it possible for SAMSON Elements to add SAMSON widgets to the interface:

// MyCustomWidget derives from SBGWindowWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
SBGWindow* window = SAMSON::addWidget(myCustomWidget);

The function returns a pointer to the embedding SAMSON window which gives the SAMSON style to the SAMSON widget.

Note that Qt widgets may also be added to the SAMSON GUI (and given the SAMSON style), provided the information normally held in a SAMSON widget is supplied:

// MyCustomWidget derives from QWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
std::string title = "My widget";
QPixmap logo(QString::fromStdString(SB_ELEMENT_PATH + "/Resource/logo.png"));
SBUUID UUID("7EC7B88F-A357-C32A-1FD2-FEE401F6CC61");
SBGWindow* window = SAMSON::addWidget(myCustomWidget, title, format, logo, UUID);

SAMSON dialogs may be added in a similar fashion with the addDialog functions.

See also
addDialog(SBGWindowDialog*)
addDialog(QDialog*, QString, int, QPixmap, SBUUID)
addWidget(SBGWindowWidget*)
addWidget(QWidget*, QString, int, QPixmap, SBUUID)
removeDialog(SBGWindowDialog*)
removeDialog(QDialog*)
removeWidget(SBGWindowWidget*)
removeWidget(QWidget*)
removeWindow(SBGWindow*)

Notifications

The SAMSON class may be used to set the message in the status bar:

SAMSON::setStatusMessage("Operation complete", 0);

as well as inform the user through modal dialogs, either via a simple string:

SAMSON::informUser("Information", "This operation will be applied to all atoms");

or via a SAMSON widget:

// MyCustomWidget derives from SBGWindowWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
SAMSON::informUser(myCustomWidget);

When a question should be asked to the user, the askUser function may be used, either with a string:

bool result = SAMSON::askUser("Mutate all", "Do you want to proceed?");

or with a SAMSON widget:

// MyCustomWidget derives from SBGWindowWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
bool result = SAMSON::askUser(myCustomWidget);
See also
setStatusMessage
informUser(const QString&, const QString&)
informUser(SBGWindowWidget*)
askUser(const QString&, const QString&)
askUser(SBGWindowWidget*)

Asking for strings and numbers

Some convenience functions make it easy to request a string or a number from the user:

std::string groupName;
bool result = SAMSON::getStringFromUser("Enter group name", groupName);

where result is true if the user did not cancel the request and actually provided a string.

See also
getDoubleFromUser
getIntegerFromUser
getStringFromUser

Progress bar

When SAMSON Elements need to lock the user interface for a long period of time, they may communicate the progress made through a progress bar:

SAMSON::showProgressBar("Updating atoms", 0, numberOfAtoms);
for (unsigned int i = 0; i < numberOfAtoms; i++) {
// do something
...
}
See also
showProgressBar
isProgressBarStopped
setProgressBarValue
hideProgressBar

Undo and redo

SAMSON Elements may turn the undo and redo mechanism via the SAMSON class:

SBCamera* camera = SAMSON::getActiveCamera(); // get the active camera
SAMSON::beginHolding("Change camera name"); // turn the Undo system on
camera->setName("New camera name"); // change the camera name
SAMSON::endHolding(); // turn the Undo system off
SAMSON::undo(); // undo the name change
See also
Undo and redo
isHolding
beginHolding
disableHolding
enableHolding
endHolding
hold
undo
redo
isUndoing
isRedoing

Files

SAMSON may be used to import and export files. For example, the instruction:

requests SAMSON to look into the importers loaded at startup to see if one of them matches the extension of the file. If this is the case, the file is imported.

See also
importFromFile
exportToFile

Display

Several types of SAMSON classes have virtual display functions that may be overloaded to render objects in the viewport. For example, a visual model has a display function called at each frame by SAMSON's internal renderer. Furthermore, rendering is also used to perform node picking, by rendering unique indices instead of colors (see the chapter about rendering in SAMSON). To perform rendering, SAMSON uses, and requires from developers of SAMSON Elements to use, core-profile OpenGL functionality. For example, shaders are used to display e.g.atoms, bonds, etc. This implies that legacy OpenGL function calls(e.g. glBegin, glEnd, etc.) are not supported and should not be used in SAMSON Elements.

Because using core OpenGL functionality is sometimes cumbersome, especially when rendering simple objects, SAMSON provides several utility functions to render geometric primitives in batches, especially when implementing display functions of data graph nodes. For example, the displayTriangles function makes it easy to display triangles in a SAMSON viewport.

Some utility functions also facilitate the use of the renderer to perform node selection. For example, the displayTrianglesSelection makes it easy to render triangles for selection purposes, by passing to SAMSON indices instead of colors.

Please refer to the chapter about rendering in SAMSON for more information, as well as the documentations of the specific display functions listed below.

See also
Rendering
displayCylinders
displayCylindersSelection
displayLines
displayLinesOrtho
displayLineSweptSpheres
displayLineSweptSpheresSelection
displaySpheres
displaySpheresSelection
displayText
displayTextSelection
displayTriangles
displayTrianglesOrtho
displayTrianglesSelection
displayTubes
displayTubesSelection

Introspection

SAMSON Elements expose their functionality to SAMSON and to other SAMSON Elements thanks to an introspection mechanism. Exposition is achieved thanks to descriptor files that contain the list of exposed classes and functions, and that are compiled along with the SAMSON Element. One of the major benefits of the introspection mechanism is the ability to share and combine functionality without the need for providing any type of source code or header code. It is thanks to this introspection mechanism that SAMSON Elements form more than a collection of independent modules.

The functionality of an exposed class is accessible through its class proxy, which gathers the class factory (its collection of constructors) and the class interface (its collection of member functions).

The class proxy of an exposed class is retrieved using SAMSON:

SBProxy* classProxy = SAMSON::getProxy("SEElementMyApp");

In case there is a risk that several SAMSON Elements might provide a class called SEElementMyApp, it is possible to specify the name and the UUID of the SAMSON Element:

SBProxy* classProxy = SAMSON::getProxy("SEElementMyApp", "SEElement",
"C8EC88EA-38CE-70F4-2A74-C71F2C86A692");

The SAMSON Element UUID is guaranteed to be unique if the SAMSON Element has been installed from SAMSON Connect.

In general, creating instances of exposed classes, and calling their functions, is performed through class proxies.

For exposed classes that derive from some classes from the SDK, SAMSON provides convenience factory functions to create instances.

Assume for example a SAMSON Element provides a particle interaction model:

class InteractionModel : public class SBMInteractionModelParticleSystem {
InteractionModel(SBMDyamicalModelParticleSystem* dynamicalModel);
~InteractionModel();
...
virtual void updateInteractions();
...
};

Then, an instance of this class can be created as follows:

SAMSON::makeInteractionModel(dynamicalModel, "InteractionModel");

where dynamicalModel is the argument that would be passed to the constructor of the interaction model.

If only the reimplemented virtual functions of the interaction model should be used (e.g. updateInteractions), then the interactionModel pointer is sufficient, even though interactionModel is a pointer to a SBMInteractionModelParticleSystem and not a pointer to an InteractionModel.

For more information, please refer to the chapter about introspection.

See also
Introspection
makeNeigborSearch
makeStateUpdater
makeVisualModel
makeInteractionModel
makeController

Properties

If a data graph node has an associated property window, it is possible to make it appear with:

bool shown = SAMSON::showProperties(dataGraphNode);
See also
Data Graph
showProperties

Member Function Documentation

◆ askUser() [1/3]

bool SAMSON::askUser ( const QString &  dialogTitle,
const QString &  dialogText,
QDialogButtonBox *  buttonBox = 0 
)
static

This static function asks the user a question with a message in a modal pop-up dialog. This is a convenience function which makes it easy to program questions to the user with the SAMSON style. The function creates a modal pop-up dialog that blocks all other user interaction until the user pushes the Cancel button or the OK button. The function returns true if the user presses the OK button, or false if the user presses the Cancel button or closes the dialog. This function exposes the function with the same name in SBGWindowDialog.

bool userReply = SAMSON::askUser("Information", "This operation will be applied to
all atoms in the document. Would you like to continue?");
See also
informUser

◆ askUser() [2/3]

bool SAMSON::askUser ( SBGWindowWidget widget,
QDialogButtonBox *  buttonBox = 0 
)
static

This static function asks the user a question with a widget in a modal pop-up dialog. This is a convenience function which makes it easy to program questions to the user with the SAMSON style. The function creates a modal pop-up dialog that blocks all other user interaction until the user pushes the Cancel button or the OK button. The function returns true if the user presses the OK button, or false if the user presses the Cancel button or closes the dialog. The dialog title and icon are taken from the widget. Note that the OK button and the Cancel button are created by this function, and the widget does not have to contain some. This function exposes the function with the same name in SBGWindowDialog.

// MyCustomWidget derives from SBGWindowWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
bool userReply = SAMSON::askUser(myCustomWidget);
// do something based on the user reply
...
delete myCustomwidget;
See also
informUser

◆ askUser() [3/3]

bool SAMSON::askUser ( QWidget *  widget,
QDialogButtonBox *  buttonBox = 0 
)
static

This static function asks the user a question with a widget in a modal pop-up dialog. This is a convenience function which makes it easy to progam questions to the user with the SAMSON style. The function creates a modal pop-up dialog that blocks all other user interaction until the user pushes the Cancel button or the OK button. The function returns true if the user presses the OK button, or false if the user presses the Cancel button or closes the dialog. The dialog title and icon are taken from the widget. Note that the OK button and the Cancel button are created by this function, and the widget does not have to contain some. This function exposes the function with the same name in SBGWindowDialog.

// MyCustomWidget derives from QWidget
QWidget* myCustomWidget = new QWidget();
bool userReply = SAMSON::askUser(myCustomWidget);
// do something based on the user reply
...
delete myCustomwidget;
See also
informUser

◆ displayCylinders()

void SAMSON::displayCylinders ( unsigned int  nCylinders,
unsigned int  nPositions,
const unsigned int *  indexData,
const float *  positionData,
const float *  radiusData,
const unsigned int *  capData,
const float *  colorData,
const unsigned int *  flagData,
bool  shadowPassFlag = false 
)
static
Parameters
nCylindersThe number of cylinders
nPositionsThe number of positions used to describe cylinders
indexDataThe array of indices of positions (two unsigned ints per cylinder)
positionDataThe array of positions (three floats per position)
radiusDataThe array of radiuses (one float per position)
capDataThe array of capping flags (one unsigned int per position)
colorDataThe array of colors (four floats per position)
flagDataThe array of flags (one unsigned int per position)
shadowPassFlagA boolean to signal a shadow pass

This function displays cylinders in the viewport thanks to ray-tracing shaders that avoid the use of triangles. For increased efficiency, cylinders are described by providing an array of vertex positions and an array of pairs of indices of vertices. As a result, the number of vertex positions passed to the graphics hardware is often much smaller than twice the number of cylinders. Furthermore, all passed properties are vertex-based and not cylinder-based, and properties are interpolated along the cylinder. For example, if a cylinder connects two vertices which have different associated radiuses, then the shader renders a cone. Similarly, if the two vertices have different colors, then the cylinder color is a gradient that interpolates the two colors. Each vertex has the following properties:

  • a position: three floats with units of length
  • a radius: one float with units of length
  • a capping flag: one unsigned int which determines if the cylinder is capped at the vertex (0 for no capping)
  • a color: four floats between 0 and 1 (the red, green, blue and alpha channels)
  • a flag: one unsigned int representing a node flag
See also
Rendering

◆ getAtom() [1/2]

SBAtom * SAMSON::getAtom ( int  x,
int  y 
)
static
Parameters
xThe first viewport coordinate of the picking location
yThe second viewport coordinate of the picking location

This function returns the atom displayed at coordinates x and y in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which atom was under the mouse cursor when the mouse button was pressed:

SBAtom* pickedAtom = SAMSON::getAtom(event->pos().x(), event->pos().y());

If no atom is present at coordinates x and y, the function returns 0.

This function is a convenience function that calls getNode(int, int, const SBNodePredicate&) and checks whether the picked node, if any, is an atom. If it is the case, the function returns a pointer to the picked atom. If a node of another type (e.g. a bond) is present at coordinates x and y, the function returns 0. If picking should be able to return any type of node, the function getNode(int, int, const SBNodePredicate&) should be used instead.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(int, int)

◆ getAtom() [2/2]

SBAtom * SAMSON::getAtom ( const QPoint &  position)
static
Parameters
positionThe viewport coordinates of the picking location

This function returns the atom displayed at a given position in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which atom was under the mouse cursor when the mouse button was pressed:

SBAtom* pickedAtom = SAMSON::getAtom(event->pos());

If no atom is present at the specified position, the function returns 0.

This function is a convenience function that calls getNode(const QPoint&, const SBNodePredicate&) and checks whether the picked node, if any, is an atom. If it is the case, the function returns a pointer to the picked atom. If a node of another type (e.g. a bond) is present at the specified position, the function returns 0. If picking should be able to return any type of node, the function getNode(const QPoint&, const SBNodePredicate&) should be used instead.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(const QPoint&)

◆ getBond() [1/2]

SBBond * SAMSON::getBond ( int  x,
int  y 
)
static
Parameters
xThe first viewport coordinate of the picking location
yThe second viewport coordinate of the picking location

This function returns the bond displayed at coordinates x and y in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which bond was under the mouse cursor when the mouse button was pressed:

SBBond* pickedBond = SAMSON::getBond(event->pos().x(), event->pos().y());

If no bond is present at coordinates x and y, the function returns 0.

This function is a convenience function that calls getNode(int, int, const SBNodePredicate&) and checks whether the picked node, if any, is a bond. If it is the case, the function returns a pointer to the picked bond. If a node of another type (e.g. an atom) is present at coordinates x and y, the function returns 0. If picking should be able to return any type of node, the function getNode(int, int, const SBNodePredicate&) should be used instead.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(int, int)

◆ getBond() [2/2]

SBBond * SAMSON::getBond ( const QPoint &  position)
static
Parameters
positionThe viewport coordinates of the picking location

This function returns the bond displayed at a given position in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which bond was under the mouse cursor when the mouse button was pressed:

SBBond* pickedBond = SAMSON::getBond(event->pos());

If no bond is present at the specified position, the function returns 0.

This function is a convenience function that calls getNode(const QPoint&, const SBNodePredicate&) and checks whether the picked node, if any, is a bond. If it is the case, the function returns a pointer to the picked bond. If a node of another type (e.g. an atom) is present at the specified position, the function returns 0. If picking should be able to return any type of node, the function getNode(const QPoint&, const SBNodePredicate&) should be used instead.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(const QPoint&)

◆ getNode() [1/4]

SBNode * SAMSON::getNode ( int  x,
int  y,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
xThe first viewport coordinate of the picking location
yThe second viewport coordinate of the picking location
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the node displayed at coordinates x and y in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which node was under the mouse cursor when the mouse button was pressed:

SBNode* node = SAMSON::getNode(event->pos().x(), event->pos().y());

If no node is present at coordinates x and y, the function returns 0.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(int, int, SBPosition3&)

◆ getNode() [2/4]

SBNode * SAMSON::getNode ( const QPoint &  position,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
positionThe viewport coordinates of the picking location
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the node displayed at a given position in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which node was under the mouse cursor when the mouse button was pressed:

SBNode* node = SAMSON::getNode(event->pos());

If no node is present at the specified position, the function returns 0.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(const QPoint&, SBPosition3&)

◆ getNode() [3/4]

SBNode * SAMSON::getNode ( int  x,
int  y,
SBPosition3 pickedPosition,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
xThe first viewport coordinate of the picking location
yThe second viewport coordinate of the picking location
pickedPositionReturns the 3D coordinates of the picked point
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the node displayed at coordinates x and y in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which node was under the mouse cursor when the mouse button was pressed:

SBPosition3 pickedPosition;
SBNode* node = SAMSON::getNode(event->pos().x(), event->pos().y(), pickedPosition);

If no node is present at coordinates x and y, the function returns 0.

When the function returns, and if node is not 0, pickedPosition contains the 3D coordinates of the picked point.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(int, int)

◆ getNode() [4/4]

SBNode * SAMSON::getNode ( const QPoint &  position,
SBPosition3 pickedPosition,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
positionThe viewport coordinates of the picking location
pickedPositionReturns the 3D coordinates of the picked point
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the node displayed at a given position in the viewport. It is typically used by editors when reacting to mouse press events, in order to determine which node was under the mouse cursor when the mouse button was pressed:

SBPosition3 pickedPosition;
SBNode* node = SAMSON::getNode(event->pos(), pickedPosition);

If no node is present at coordinates x and y, the function returns 0.

When the function returns, and if node is not 0, pickedPosition contains the 3D coordinates of the picked point.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(const QPoint&)

◆ getNodes() [1/4]

void SAMSON::getNodes ( SBNodeIndexer nodeIndexer,
int  x,
int  y,
int  width,
int  height,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
nodeIndexerThe indexer which stores picked nodes
xThe first viewport coordinate of the top left corner of the picking rectangle
yThe second viewport coordinate of the top left corner of the picking rectangle
widthThe width of the picking rectangle
heightThe height of the picking rectangle
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the nodes displayed in the viewport rectangle (x,y,width,height). It is typically used by editors when reacting to mouse events:

SBNodeIndexer nodeIndexer;
SAMSON::getNodes(nodeIndexer, x, y, width, height);

Picked nodes are appended to the vector nodeVector.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(SBNodeIndexer&, const QPoint&, int, int)

◆ getNodes() [2/4]

void SAMSON::getNodes ( SBNodeIndexer nodeIndexer,
const QPoint &  topLeftCorner,
int  width,
int  height,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
nodeIndexerThe indexer which stores picked nodes
topLeftCornerThe viewport coordinates of the top left corner of the picking rectangle
widthThe width of the picking rectangle
heightThe height of the picking rectangle
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the nodes displayed in the viewport rectangle (x,y,width,height). It is typically used by editors when reacting to mouse events:

SBNodeIndexer nodeIndexer;
SAMSON::getNodes(nodeIndexer, topLeftCorner, width, height);

Picked nodes are appended to the vector nodeVector.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

See also
getNode(SBNodeIndexer&, int, int, int, int)

◆ getNodes() [3/4]

void SAMSON::getNodes ( SBNodeIndexer nodeIndexer,
const SBVector< QPoint > &  selectionLasso,
const SBNodePredicate selectionFilter = SBNode::All() 
)
static
Parameters
nodeIndexerThe indexer which stores picked nodes
selectionLassoThe vector of viewport coordinates that form the selection lasso
selectionFilterA node predicate for the selection filter; by default, it is equal to SBDDataGraphNode::All()

This function returns the nodes displayed in a given selection lasso. It is typically used by editors when reacting to mouse events:

SBNodeIndexer nodeIndexer;
SAMSON::getNodes(nodeIndexer, selectionLasso);

Picked nodes are appended to the vector nodeVector.

Note that picking in SAMSON is performed through rendering. As a result, this function cannot be called from within a display function (e.g. from a SBMVisualModel::display function).

◆ getNodes() [4/4]

void SAMSON::getNodes ( SBNodeIndexer nodeIndexer,
const std::string &  selectionString 
)
static

This function fills the nodeIndexer passed in reference with nodes from the active document, based on a selectionString formulated in SAMSON's node specification language. For example:

SBNodeIndexer nodeIndexer;
SAMSON::getNodes(nodeIndexer, "node.type residue within 4A of S");

selects all residue nodes from the active document that are within 4 angstrom of any sulfur atom (note that the selection string may be abbreviated to "n.t r w 4A of S").

See also
Node Specification Language

◆ getSimulationFlag()

bool SAMSON::getSimulationFlag ( )
static

This function returns true when interactive simulation is on. When interactive simulation is started, all active simulators in the active document periodically perform a time step.

See also
startSimulation
stopSimulation
toggleSimulation
setSimulationFlag

◆ informUser() [1/2]

void SAMSON::informUser ( const QString &  dialogTitle,
const QString &  dialogText 
)
static

This static function informs the user with a message in a modal pop-up dialog. This is a convenience function which makes it easy to program messages to the user with the SAMSON style. The function creates a modal pop-up dialog that blocks all other user interaction until the user pushes the OK button. This function exposes the function with the same name in SBGWindowDialog.

SAMSON::informUser("Information", "This operation will be applied to all atoms.");
See also
askUser

◆ informUser() [2/2]

void SAMSON::informUser ( SBGWindowWidget widget)
static

This static function informs the user with a widget in a modal pop-up dialog. This is a convenience function which makes it easy to program messages to the user with the SAMSON style. The function creates a modal pop-up dialog that blocks all other user interaction until the user pushes the OK button. The dialog title and icon are taken from the widget. Note that the OK button is created by this function, and the widget does not have to contain one. This function exposes the function with the same name in SBGWindowDialog.

// MyCustomWidget derives from SBGWindowWidget
MyCustomWidget* myCustomWidget = new MyCustomWidget();
SAMSON::informUser(myCustomWidget);
delete myCustomwidget;
See also
askUser

◆ makeNodePredicate()

SBNodePredicate * SAMSON::makeNodePredicate ( const std::string &  selectionString)
static

This function makes a node predicate based on a selectionString formulated in SAMSON's node specification language. For example:

SBNodePredicate* nodePredicate = SAMSON::makeNodePredicate("H linking O");

makes a predicate that is true if and only if the node is a hydrogen atom bonded to an oxygen atom. This function may be used when a predicate should be stored. Ownership is passed to the caller, who should delete the predicate when it's done using it.

See also
Node Specification Language

◆ requestViewportUpdate()

void SAMSON::requestViewportUpdate ( )
static

This function allows SAMSON Elements to request an update of the viewport. This may be useful, for example, when an editor is displaying an interface (e.g. a rectangle selection editor draws a rectangle on top of the viewport), or temporary objects in the viewport (e.g. a carbon nanotube editor renders a transparent nanotube while the user is choosing its endpoints and radius). Requesting a viewport update ensures that SAMSON will call the appropriate display functions of the editor even when the camera is not moving and no other SAMSON Element is requesting a viewport update.

◆ setSimulationFlag()

void SAMSON::setSimulationFlag ( bool  simulationFlag)
static

This function sets the interactive simulation flag. Set the flag to true to start interactive simulation. When interactive simulation is started, all active simulators in the active document periodically perform a time step.

See also
startSimulation
stopSimulation
toggleSimulation
getSimulationFlag

◆ startSimulation()

void SAMSON::startSimulation ( )
static

This function starts interactive simulation. When interactive simulation is started, all active simulators in the active document periodically perform a time step. Calling this function is equivalent to:

See also
stopSimulation
toggleSimulation
getSimulationFlag
setSimulationFlag

◆ stopSimulation()

void SAMSON::stopSimulation ( )
static

This function stops interactive simulation. When interactive simulation is started, all active simulators in the active document periodically perform a time step. Calling this function is equivalent to:

See also
startSimulation
toggleSimulation
getSimulationFlag
setSimulationFlag

◆ toggleSimulation()

void SAMSON::toggleSimulation ( )
static

This function toggles interactive simulation on and off. When interactive simulation is started, all active simulators in the active document periodically perform a time step.

See also
startSimulation
stopSimulation
getSimulationFlag
setSimulationFlag