Gui::SelectionSingleton Class Reference

The Selection class The selection singleton keeps track of the selection state of the whole application. More...

#include <Selection.h>

Inheritance diagram for Gui::SelectionSingleton:
Base::Subject< const SelectionChanges & >

List of all members.

Classes

struct  _SelObj
struct  SelObj

Public Member Functions

bool addSelection (const char *pDocName, const char *pObjectName=0, const char *pSubName=0, float x=0, float y=0, float z=0)
 Add to selection.
void addSelectionGate (Gui::SelectionGate *gate)
 add a SelectionGate to control what is selectable
void clearCompleteSelection ()
 Clear the selection of all documents.
void clearSelection (const char *pDocName=0)
 Clear the selection of document pDocName. If the document name is not given the selection of the active document is cleared.
unsigned int countObjectsOfType (const char *typeName, const char *pDocName=0) const
 Does basically the same as the method above unless that it accepts a string literal as first argument.
unsigned int countObjectsOfType (const Base::Type &typeId, const char *pDocName=0) const
 Returns the number of selected objects with a special object type It's the convenient way to check if the right objects are selected to perform an operation (GuiCommand).
std::vector< SelObjgetCompleteSelection () const
 Returns a vector of all selection objects of all documents.
template<typename T >
std::vector< T * > getObjectsOfType (const char *pDocName=0) const
 A convenience template-based method that returns an array with the correct types already.
std::vector
< App::DocumentObject * > 
getObjectsOfType (const char *typeName, const char *pDocName=0) const
 Does basically the same as the method above unless that it accepts a string literal as first argument.
std::vector
< App::DocumentObject * > 
getObjectsOfType (const Base::Type &typeId, const char *pDocName=0) const
 Returns a vector of objects of type TypeName selected for the given document name pDocName.
const SelectionChangesgetPreselection (void) const
 returns the present preselection
std::vector< SelObjgetSelection (const char *pDocName=0) const
 Returns a vector of selection objects If no document name is given the objects of the active are returned.
std::vector< Gui::SelectionObjectgetSelectionEx (const char *pDocName=0, Base::Type typeId=App::DocumentObject::getClassTypeId()) const
 Returns a vector of selection objects If no document name is given the objects of the active are returned.
bool hasSelection (const char *doc) const
bool hasSelection () const
bool isSelected (App::DocumentObject *, const char *pSubName=0) const
 Check if selected.
bool isSelected (const char *pDocName, const char *pObjectName=0, const char *pSubName=0) const
 Check if selected.
void rmvPreselect ()
 remove the present preselection
void rmvSelection (const char *pDocName, const char *pObjectName=0, const char *pSubName=0)
 Remove from selection (for internal use).
void rmvSelectionGate (void)
 remove the active SelectionGate
bool setPreselect (const char *pDocName, const char *pObjectName, const char *pSubName, float x=0, float y=0, float z=0)
 set the preselected object (mostly by the 3D view)
void setPreselectCoord (float x, float y, float z)
 sets different coords for the preselection
void setSelection (const char *pDocName, const std::vector< App::DocumentObject * > &)
 Set the selection for a document.
unsigned int size (void) const
 Size of selcted entities for all documents.

Static Public Member Functions

static void destruct (void)
static SelectionSingletoninstance (void)

Public Attributes

boost::signal< void(const
SelectionChanges &msg)> 
signalSelectionChanged
 signal on new object

Static Public Attributes

static PyMethodDef Methods []

Protected Member Functions

App::DocumentgetDocument (const char *pDocName=0) const
 helper to retrieve document by name
 SelectionSingleton ()
 Construction.
void slotDeletedObject (const App::DocumentObject &)
void slotRenamedObject (const App::DocumentObject &)
 Observer message from the App doc.
virtual ~SelectionSingleton ()
 Destruction.

Static Protected Member Functions

static PyObjectsAddSelection (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsaddSelectionGate (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsAddSelObserver (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsClearSelection (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsGetSelection (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsGetSelectionEx (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsIsSelected (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsRemoveSelection (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsremoveSelectionGate (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsRemSelObserver (PyObject *self, PyObject *args, PyObject *kwd)

Protected Attributes

std::list< _SelObj_SelList
Gui::SelectionGateActiveGate
SelectionChanges CurrentPreselection
std::string DocName
std::string FeatName
float hx
float hy
float hz
std::string SubName

Static Protected Attributes

static SelectionSingleton_pcSingleton = NULL

Friends

class SelectionFilter

Detailed Description

The Selection class The selection singleton keeps track of the selection state of the whole application.

It gets messages from all entities which can alter the selection (e.g. tree view and 3D-view) and sends messages to entities which need to keep track on the selection state.

The selection consists mainly out of following information per selected object:

Also the preselection is managed. That means you can add a filter to prevent selection of unwanted objects or subelements.

Definition at line 198 of file Selection.h.


Constructor & Destructor Documentation

SelectionSingleton::SelectionSingleton (  )  [protected]
SelectionSingleton::~SelectionSingleton (  )  [protected, virtual]

Destruction.

A destructor.

A more elaborate description of the destructor.

Definition at line 912 of file Selection.cpp.


Member Function Documentation

bool SelectionSingleton::addSelection ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0,
float  x = 0,
float  y = 0,
float  z = 0 
)
void SelectionSingleton::addSelectionGate ( Gui::SelectionGate gate  ) 

add a SelectionGate to control what is selectable

Definition at line 601 of file Selection.cpp.

References ActiveGate, and rmvSelectionGate().

Referenced by saddSelectionGate().

void SelectionSingleton::clearCompleteSelection (  ) 
void SelectionSingleton::clearSelection ( const char *  pDocName = 0  ) 
unsigned int SelectionSingleton::countObjectsOfType ( const char *  typeName,
const char *  pDocName = 0 
) const

Does basically the same as the method above unless that it accepts a string literal as first argument.

typeName must be a registered type, otherwise 0 is returned.

Definition at line 448 of file Selection.cpp.

References Base::Type::badType(), countObjectsOfType(), and Base::Type::fromName().

unsigned int SelectionSingleton::countObjectsOfType ( const Base::Type typeId,
const char *  pDocName = 0 
) const

Returns the number of selected objects with a special object type It's the convenient way to check if the right objects are selected to perform an operation (GuiCommand).

The check also detects base types. E.g. "Part" also fits on "PartImport" or PartTransform types. If no document name is given the active document is assumed.

Definition at line 429 of file Selection.cpp.

References _SelList, getDocument(), App::PropertyContainer::getTypeId(), and Base::Type::isDerivedFrom().

Referenced by CmdRobotInsertWaypoint::activated(), StdCmdMeasurementSimple::activated(), CmdRobotExportKukaFull::activated(), CmdRobotExportKukaCompact::activated(), CmdRaytracingExportProject::activated(), CmdPartDesignRevolution::activated(), CmdPartDesignPocket::activated(), CmdPartDesignPad::activated(), CmdPartSection::activated(), CmdPartFuse::activated(), CmdPartCommon::activated(), CmdPartCut::activated(), CmdMeshDemolding::activated(), CmdMeshTransform::activated(), CmdDrawingExportPage::activated(), countObjectsOfType(), StdCmdExport::isActive(), CmdPointsPolyCut::isActive(), CmdPointsTransform::isActive(), CmdPointsExport::isActive(), CmdPartSection::isActive(), CmdPartFuse::isActive(), CmdPartCommon::isActive(), CmdPartCut::isActive(), CmdMeshFillupHoles::isActive(), CmdMeshBoundingBox::isActive(), CmdMeshFlipNormals::isActive(), CmdMeshHarmonizeNormals::isActive(), CmdMeshSmoothing::isActive(), CmdMeshEvaluateSolid::isActive(), CmdMeshToolMesh::isActive(), CmdMeshVertexCurvature::isActive(), CmdMeshFromGeometry::isActive(), CmdMeshExport::isActive(), CmdMeshIntersection::isActive(), CmdMeshDifference::isActive(), CmdMeshUnion::isActive(), CmdMeshDemolding::isActive(), and CmdMeshTransform::isActive().

void SelectionSingleton::destruct ( void   )  [static]

Definition at line 926 of file Selection.cpp.

References _pcSingleton.

Referenced by Gui::Application::~Application().

std::vector< SelectionSingleton::SelObj > SelectionSingleton::getCompleteSelection (  )  const
App::Document * SelectionSingleton::getDocument ( const char *  pDocName = 0  )  const [protected]
template<typename T >
std::vector< T * > Gui::SelectionSingleton::getObjectsOfType ( const char *  pDocName = 0  )  const [inline]

A convenience template-based method that returns an array with the correct types already.

Definition at line 356 of file Selection.h.

References getObjectsOfType(), and Py::type().

std::vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const char *  typeName,
const char *  pDocName = 0 
) const

Does basically the same as the method above unless that it accepts a string literal as first argument.

typeName must be a registered type otherwise an empty array is returned.

Definition at line 421 of file Selection.cpp.

References Base::Type::badType(), Base::Type::fromName(), and getObjectsOfType().

vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const Base::Type typeId,
const char *  pDocName = 0 
) const
const SelectionChanges & SelectionSingleton::getPreselection ( void   )  const

returns the present preselection

Definition at line 595 of file Selection.cpp.

References CurrentPreselection.

Referenced by CmdRobotInsertWaypointPreselect::activated().

std::vector< SelectionSingleton::SelObj > SelectionSingleton::getSelection ( const char *  pDocName = 0  )  const
std::vector< SelectionObject > SelectionSingleton::getSelectionEx ( const char *  pDocName = 0,
Base::Type  typeId = App::DocumentObject::getClassTypeId() 
) const
bool SelectionSingleton::hasSelection ( const char *  doc  )  const

Definition at line 325 of file Selection.cpp.

References _SelList, and getDocument().

bool SelectionSingleton::hasSelection (  )  const

Definition at line 273 of file Selection.cpp.

References _SelList.

Referenced by StdCmdDDuplicateSelection::isActive(), and StdCmdCopy::isActive().

SelectionSingleton & SelectionSingleton::instance ( void   )  [static]

Definition at line 919 of file Selection.cpp.

References _pcSingleton.

Referenced by Gui::Selection().

bool SelectionSingleton::isSelected ( App::DocumentObject obj,
const char *  pSubName = 0 
) const

Check if selected.

Definition at line 853 of file Selection.cpp.

References _SelList.

bool SelectionSingleton::isSelected ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0 
) const
void SelectionSingleton::rmvPreselect (  ) 
void SelectionSingleton::rmvSelection ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0 
)
void SelectionSingleton::rmvSelectionGate ( void   ) 

remove the active SelectionGate

Definition at line 611 of file Selection.cpp.

References ActiveGate.

Referenced by addSelectionGate(), and sremoveSelectionGate().

PyObject * SelectionSingleton::sAddSelection ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * SelectionSingleton::saddSelectionGate ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 1119 of file Selection.cpp.

References addSelectionGate(), PY_CATCH, Py_Return, PY_TRY, and Gui::Selection().

PyObject * SelectionSingleton::sAddSelObserver ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * SelectionSingleton::sClearSelection ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
bool SelectionSingleton::setPreselect ( const char *  pDocName,
const char *  pObjectName,
const char *  pSubName,
float  x = 0,
float  y = 0,
float  z = 0 
)
void SelectionSingleton::setPreselectCoord ( float  x,
float  y,
float  z 
)
void SelectionSingleton::setSelection ( const char *  pDocName,
const std::vector< App::DocumentObject * > &  sel 
)
PyObject * SelectionSingleton::sGetSelection ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * SelectionSingleton::sGetSelectionEx ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * SelectionSingleton::sIsSelected ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
unsigned int Gui::SelectionSingleton::size ( void   )  const [inline]

Size of selcted entities for all documents.

Definition at line 293 of file Selection.h.

Referenced by StdCmdSetAppearance::isActive().

void SelectionSingleton::slotDeletedObject ( const App::DocumentObject Obj  )  [protected]
void SelectionSingleton::slotRenamedObject ( const App::DocumentObject Obj  )  [protected]

Observer message from the App doc.

Definition at line 878 of file Selection.cpp.

References _SelList, App::DocumentObject::getDocument(), and App::Document::getName().

Referenced by SelectionSingleton().

PyObject * SelectionSingleton::sRemoveSelection ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * SelectionSingleton::sremoveSelectionGate ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 1132 of file Selection.cpp.

References PY_CATCH, Py_Return, PY_TRY, rmvSelectionGate(), and Gui::Selection().

PyObject * SelectionSingleton::sRemSelObserver ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Friends And Related Function Documentation

friend class SelectionFilter [friend]

Definition at line 299 of file Selection.h.


Member Data Documentation

Definition at line 342 of file Selection.h.

Referenced by destruct(), and instance().

std::string Gui::SelectionSingleton::DocName [protected]

Definition at line 344 of file Selection.h.

Referenced by getSelectionEx(), rmvPreselect(), and setPreselect().

std::string Gui::SelectionSingleton::FeatName [protected]

Definition at line 345 of file Selection.h.

Referenced by rmvPreselect(), and setPreselect().

float Gui::SelectionSingleton::hx [protected]

Definition at line 347 of file Selection.h.

Referenced by rmvPreselect(), and setPreselect().

float Gui::SelectionSingleton::hy [protected]

Definition at line 347 of file Selection.h.

Referenced by rmvPreselect(), and setPreselect().

float Gui::SelectionSingleton::hz [protected]

Definition at line 347 of file Selection.h.

Referenced by rmvPreselect(), and setPreselect().

PyMethodDef SelectionSingleton::Methods [static]

Definition at line 302 of file Selection.h.

Referenced by Gui::Application::Application().

std::string Gui::SelectionSingleton::SubName [protected]

Definition at line 346 of file Selection.h.

Referenced by rmvPreselect(), and setPreselect().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:02:02 2011 for FreeCAD by  doxygen 1.6.1