Gui::SelectionSingleton Class Reference

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

#include <Selection.h>

Classes

struct  SelObj
 

Public Types

enum  VisibleState { VisHide = 0, VisShow = 1, VisToggle = -1 }
 Visible state used by setVisible() More...
 
- Public Types inherited from Base::Subject< const SelectionChanges & >
typedef const SelectionChanges & MessageType
 
typedef Observer< const SelectionChanges & > ObserverType
 
typedef Subject< const SelectionChanges & > SubjectType
 

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, const std::vector< SelObj > *pickedList=0, bool clearPreSelect=true)
 Add to selection. More...
 
bool addSelection (const SelectionObject &, bool clearPreSelect=true)
 Add to selection. More...
 
bool addSelection2 (const char *pDocName, const char *pObjectName=0, const char *pSubName=0, float x=0, float y=0, float z=0, const std::vector< SelObj > *pickedList=0)
 
void addSelectionGate (Gui::SelectionGate *gate, int resolve=1)
 add a SelectionGate to control what is selectable More...
 
bool addSelections (const char *pDocName, const char *pObjectName, const std::vector< std::string > &pSubNames)
 Add to selection with several sub-elements. More...
 
void clearCompleteSelection (bool clearPreSelect=true)
 Clear the selection of all documents. More...
 
void clearSelection (const char *pDocName=0, bool clearPreSelect=true)
 Clear the selection of document pDocName. If the document name is not given the selection of the active document is cleared. More...
 
unsigned int countObjectsOfType (const Base::Type &typeId=App::DocumentObject::getClassTypeId(), const char *pDocName=0, int resolve=1) 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). More...
 
unsigned int countObjectsOfType (const char *typeName, const char *pDocName=0, int resolve=1) const
 Does basically the same as the method above unless that it accepts a string literal as first argument. More...
 
int disableCommandLog ()
 
int enableCommandLog (bool silent=false)
 
int getAsPropertyLinkSubList (App::PropertyLinkSubList &prop) const
 getAsPropertyLinkSubList fills PropertyLinkSubList with current selection. More...
 
std::vector< SelObjgetCompleteSelection (int resolve=1) const
 Returns a vector of all selection objects of all documents. More...
 
std::vector< App::DocumentObject * > getObjectsOfType (const Base::Type &typeId, const char *pDocName=0, int resolve=1) const
 Returns a vector of objects of type TypeName selected for the given document name pDocName. More...
 
template<typename T >
std::vector< T * > getObjectsOfType (const char *pDocName=0, int resolve=1) const
 A convenience template-based method that returns an array with the correct types already. More...
 
std::vector< App::DocumentObject * > getObjectsOfType (const char *typeName, const char *pDocName=0, int resolve=1) const
 Does basically the same as the method above unless that it accepts a string literal as first argument. More...
 
const SelectionChangesgetPreselection (void) const
 returns the present preselection More...
 
const char * getSelectedElement (App::DocumentObject *, const char *pSubName) const
 
std::vector< SelObjgetSelection (const char *pDocName=0, int resolve=1, bool single=false) const
 Returns a vector of selection objects. More...
 
std::vector< Gui::SelectionObjectgetSelectionEx (const char *pDocName=0, Base::Type typeId=App::DocumentObject::getClassTypeId(), int resolve=1, bool single=false) const
 Returns a vector of selection objects. More...
 
bool hasPreselection () const
 Check if there is any pre-selection. More...
 
bool hasSelection () const
 Check if there is any selection. More...
 
bool hasSelection (const char *doc, bool resolve=true) const
 Check if there is any selection within a given document. More...
 
bool hasSubSelection (const char *doc=0, bool subElement=false) const
 Check if there is any sub-element selection. More...
 
bool isSelected (App::DocumentObject *, const char *pSubName=0, int resolve=1) const
 Check if selected. More...
 
bool isSelected (const char *pDocName, const char *pObjectName=0, const char *pSubName=0, int resolve=1) const
 Check if selected. More...
 
void rmvPreselect (bool signal=false)
 remove the present preselection More...
 
void rmvSelection (const char *pDocName, const char *pObjectName=0, const char *pSubName=0, const std::vector< SelObj > *pickedList=0)
 Remove from selection (for internal use) More...
 
void rmvSelectionGate (void)
 remove the active SelectionGate More...
 
int setPreselect (const char *pDocName, const char *pObjectName, const char *pSubName, float x=0, float y=0, float z=0, int signal=0)
 set the preselected object (mostly by the 3D view) More...
 
void setPreselectCoord (float x, float y, float z)
 sets different coords for the preselection More...
 
void setSelection (const char *pDocName, const std::vector< App::DocumentObject * > &)
 Set the selection for a document. More...
 
void setVisible (VisibleState visible)
 Set selection object visibility. More...
 
unsigned int size (void) const
 Size of selected entities for all documents. More...
 
bool updateSelection (bool show, const char *pDocName, const char *pObjectName=0, const char *pSubName=0)
 Update a selection. More...
 
Selection stack functions

Selection stack is for storing selection history so that the user can go back and forward to previous selections.

int selStackBackSize () const
 Return the current selection stack size. More...
 
int selStackForwardSize () const
 Return the current forward selection stack size. More...
 
std::vector< Gui::SelectionObjectselStackGet (const char *pDocName=0, int resolve=1, int index=0) const
 Obtain selected objects from stack. More...
 
void selStackGoBack (int count=1)
 Go back selection history. More...
 
void selStackGoForward (int count=1)
 Go forward selection history. More...
 
void selStackPush (bool clearForward=true, bool overwrite=false)
 Save the current selection on to the stack. More...
 
- Public Member Functions inherited from Base::Subject< const SelectionChanges & >
void Attach (Observer< const SelectionChanges & > *ToObserv)
 Attach an Observer Attach an Observer to the list of Observers which get
called when Notify is called. More...
 
void ClearObserver ()
 Clears the list of all registered observers. More...
 
void Detach (Observer< const SelectionChanges & > *ToObserv)
 Detach an Observer Detach an Observer from the list of Observers which get
called when Notify is called. More...
 
Observer< const SelectionChanges & > * Get (const char *Name)
 Get an Observer by name Get a observer by name if the observer reimplements the Name() mthode. More...
 
void Notify (const SelectionChanges & rcReason)
 Notify all Observers Send a message to all Observers attached to this subject. More...
 
 Subject ()
 A constructor. More...
 
virtual ~Subject ()
 A destructor. More...
 

Public Attributes

boost::signals2::signal< void(const SelectionChanges &msg)> signalSelectionChanged
 signal on new object More...
 
boost::signals2::signal< void(const SelectionChanges &msg)> signalSelectionChanged2
 signal on selection change with resolved object More...
 
boost::signals2::signal< void(const SelectionChanges &msg)> signalSelectionChanged3
 signal on selection change with resolved object and sub element map More...
 

Picked list functions

Picked list stores all selected geometry elements that intersects the 3D pick point.

The list population is done by SoFCUnifiedSelection through addSelection() with the pickedList argument.

typedef std::set< App::SubObjectTSelStackItem
 
class SelectionFilter
 
static PyMethodDef Methods []
 
SelectionChanges CurrentPreselection
 
std::deque< SelectionChangesNotificationQueue
 
bool Notifying = false
 
std::string DocName
 
std::string FeatName
 
std::string SubName
 
float hx
 
float hy
 
float hz
 
Gui::SelectionGateActiveGate
 
int gateResolve
 
int logDisabled = 0
 
bool logHasSelection = false
 
bool needPickedList () const
 Check whether picked list is enabled. More...
 
void enablePickedList (bool)
 Turn on or off picked list. More...
 
bool hasPickedList () const
 Check if there is any selection inside picked list. More...
 
std::vector< SelectionSingleton::SelObjgetPickedList (const char *pDocName) const
 Return select objects inside picked list. More...
 
std::vector< Gui::SelectionObjectgetPickedListEx (const char *pDocName=0, Base::Type typeId=App::DocumentObject::getClassTypeId()) const
 Return selected object inside picked list grouped by top level parents. More...
 
static SelectionSingletoninstance (void)
 
static void destruct (void)
 
static PyObjectsAddSelection (PyObject *self, PyObject *args)
 
static PyObjectsUpdateSelection (PyObject *self, PyObject *args)
 
static PyObjectsRemoveSelection (PyObject *self, PyObject *args)
 
static PyObjectsClearSelection (PyObject *self, PyObject *args)
 
static PyObjectsIsSelected (PyObject *self, PyObject *args)
 
static PyObjectsCountObjectsOfType (PyObject *self, PyObject *args)
 
static PyObjectsGetSelection (PyObject *self, PyObject *args)
 
static PyObjectsSetPreselection (PyObject *self, PyObject *args, PyObject *kwd)
 
static PyObjectsGetPreselection (PyObject *self, PyObject *args)
 
static PyObjectsRemPreselection (PyObject *self, PyObject *args)
 
static PyObjectsGetCompleteSelection (PyObject *self, PyObject *args)
 
static PyObjectsGetSelectionEx (PyObject *self, PyObject *args)
 
static PyObjectsGetSelectionObject (PyObject *self, PyObject *args)
 
static PyObjectsAddSelObserver (PyObject *self, PyObject *args)
 
static PyObjectsRemSelObserver (PyObject *self, PyObject *args)
 
static PyObjectsAddSelectionGate (PyObject *self, PyObject *args)
 
static PyObjectsRemoveSelectionGate (PyObject *self, PyObject *args)
 
static PyObjectsGetPickedList (PyObject *self, PyObject *args)
 
static PyObjectsEnablePickedList (PyObject *self, PyObject *args)
 
static PyObjectsPreselect (PyObject *self, PyObject *args)
 
static PyObjectsSetVisible (PyObject *self, PyObject *args)
 
static PyObjectsPushSelStack (PyObject *self, PyObject *args)
 
static PyObjectsHasSelection (PyObject *self, PyObject *args)
 
static PyObjectsHasSubSelection (PyObject *self, PyObject *args)
 
static PyObjectsGetSelectionFromStack (PyObject *self, PyObject *args)
 
static App::DocumentObjectgetObjectOfType (_SelObj &sel, Base::Type type, int resolve, const char **subelement=0)
 
 SelectionSingleton ()
 Construction. More...
 
virtual ~SelectionSingleton ()
 Destruction. More...
 
void slotDeletedObject (const App::DocumentObject &)
 Observer message from the App doc. More...
 
App::DocumentgetDocument (const char *pDocName=0) const
 helper to retrieve document by name More...
 
void slotSelectionChanged (const SelectionChanges &msg)
 
void notify (SelectionChanges &&Chng)
 
void notify (const SelectionChanges &Chng)
 
int checkSelection (const char *pDocName, const char *pObjectName, const char *pSubName, int resolve, _SelObj &sel, const std::list< _SelObj > *selList=0) const
 
std::vector< Gui::SelectionObjectgetObjectList (const char *pDocName, Base::Type typeId, std::list< _SelObj > &objs, int resolve, bool single=false) const
 

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:

  • document (pointer)
  • Object (pointer)
  • list of subelements (list of strings)
  • 3D coordinates where the user clicks to select (Vector3d)

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

Member Typedef Documentation

◆ SelStackItem

Member Enumeration Documentation

◆ VisibleState

Visible state used by setVisible()

Enumerator
VisHide 

Hide the selection.

VisShow 

Show the selection.

VisToggle 

Toggle visibility of the selection.

Constructor & Destructor Documentation

◆ SelectionSingleton()

SelectionSingleton::SelectionSingleton ( )
protected

Construction.

A constructor.

A more elaborate description of the constructor.

References ActiveGate, gateResolve, App::GetApplication(), hx, hy, hz, App::Application::signalDeletedObject, signalSelectionChanged, slotDeletedObject(), and slotSelectionChanged().

Referenced by instance().

◆ ~SelectionSingleton()

SelectionSingleton::~SelectionSingleton ( )
protectedvirtual

Destruction.

A destructor.

A more elaborate description of the destructor.

Member Function Documentation

◆ addSelection() [1/2]

bool SelectionSingleton::addSelection ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0,
float  x = 0,
float  y = 0,
float  z = 0,
const std::vector< SelObj > *  pickedList = 0,
bool  clearPreSelect = true 
)

Add to selection.

References Gui::Application::activeDocument(), ActiveGate, Gui::SelectionChanges::AddSelection, Gui::SelectionGate::allow(), checkSelection(), gateResolve, Gui::Document::getActiveView(), Base::Persistence::getClassTypeId(), Gui::getMainWindow(), getObjectOfType(), Gui::Application::Instance, isSelected(), logDisabled, Gui::SelectionGate::notAllowedReason, notify(), Gui::SelectionChanges::pDocName, Gui::SelectionChanges::PickedListChanged, Gui::SelectionChanges::pObjectName, Gui::SelectionChanges::pSubName, rmvPreselect(), Gui::MDIView::setOverrideCursor(), Gui::MainWindow::showMessage(), and Gui::MainWindow::updateActions().

Referenced by StdCmdLinkMakeGroup::activated(), StdCmdLinkMake::activated(), StdCmdLinkMakeRelative::activated(), StdCmdLinkSelectLinked::activated(), PartGui::FaceColors::Private::addFacesToSelection(), addSelection(), Gui::DAG::Model::contextMenuEvent(), Gui::Dialog::DlgPropertyLink::detachObserver(), Gui::TreeWidget::dropEvent(), Gui::SoFCSelection::handleEvent(), Gui::TreeWidget::itemSearch(), Gui::DAG::Model::mousePressEvent(), SketcherGui::TaskSketcherConstrains::on_listWidgetConstraints_itemSelectionChanged(), SketcherGui::TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(), PartDesignGui::TaskFeaturePick::onItemSelectionChanged(), Gui::ElementColors::Private::onSelectionChanged(), DrawSketchHandlerGenConstraint::releaseButton(), DrawSketchHandlerCoincident::releaseButton(), DrawSketchHandlerFillet::releaseButton(), sAddSelection(), Gui::PropertyEditor::LinkSelection::select(), PartGui::TaskMeasureLinear::selection1Slot(), PartGui::TaskMeasureAngular::selection1Slot(), PartGui::TaskMeasureLinear::selection2Slot(), PartGui::TaskMeasureAngular::selection2Slot(), selStackGoBack(), selStackGoForward(), PartDesignGui::ViewProviderSubShapeBinder::setEdit(), TechDrawGui::ViewProviderViewPart::setEdit(), FemGui::TaskFemConstraint::setSelection(), PartDesignGui::TaskDressUpParameters::setSelection(), TechDrawGui::MDIViewPage::setTreeToSceneSelect(), PartDesignGui::ViewProvider::unsetEdit(), and SketcherGui::ViewProviderSketch::unsetEdit().

◆ addSelection() [2/2]

bool SelectionSingleton::addSelection ( const SelectionObject obj,
bool  clearPreSelect = true 
)

◆ addSelection2()

bool Gui::SelectionSingleton::addSelection2 ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0,
float  x = 0,
float  y = 0,
float  z = 0,
const std::vector< SelObj > *  pickedList = 0 
)

◆ addSelectionGate()

◆ addSelections()

bool SelectionSingleton::addSelections ( const char *  pDocName,
const char *  pObjectName,
const std::vector< std::string > &  pSubNames 
)

◆ checkSelection()

int SelectionSingleton::checkSelection ( const char *  pDocName,
const char *  pObjectName,
const char *  pSubName,
int  resolve,
_SelObj &  sel,
const std::list< _SelObj > *  selList = 0 
) const
protected

◆ clearCompleteSelection()

◆ clearSelection()

void SelectionSingleton::clearSelection ( const char *  pDocName = 0,
bool  clearPreSelect = true 
)

Clear the selection of document pDocName. If the document name is not given the selection of the active document is cleared.

References Gui::MacroManager::addLine(), clearCompleteSelection(), Gui::SelectionChanges::ClrSelection, Gui::MacroManager::Cmt, DocName, getDocument(), Gui::getMainWindow(), App::Document::getName(), Gui::Application::Instance, logDisabled, Gui::Application::macroManager(), notify(), Gui::SelectionChanges::PickedListChanged, rmvPreselect(), and Gui::MainWindow::updateActions().

Referenced by MeshGui::TaskDecimating::accept(), SketcherCopy::activate(), CmdSketcherConstrainHorizontal::activated(), CmdSketcherConstrainVertical::activated(), StdCmdAlignment::activated(), CmdSketcherConstrainLock::activated(), CmdSketcherConstrainBlock::activated(), CmdSketcherConstrainCoincident::activated(), CmdSketcherConstrainDistance::activated(), CmdSketcherConstrainPointOnObject::activated(), CmdSketcherConstrainDistanceX::activated(), CmdSketcherConstrainDistanceY::activated(), CmdSketcherConstrainParallel::activated(), CmdSketcherConstrainPerpendicular::activated(), CmdSketcherConstrainTangent::activated(), CmdSketcherConstrainRadius::activated(), CmdSketcherConstrainDiameter::activated(), CmdSketcherConstrainAngle::activated(), DrawSketchHandlerTrimming::activated(), DrawSketchHandlerExtend::activated(), CmdSketcherConstrainEqual::activated(), DrawSketchHandlerExternal::activated(), CmdSketcherConstrainSymmetric::activated(), DrawSketchHandlerCarbonCopy::activated(), Gui::ElementColors::Private::apply(), CmdSketcherConstrainPerpendicular::applyConstraint(), CmdSketcherConstrainTangent::applyConstraint(), CmdSketcherConstrainRadius::applyConstraint(), CmdSketcherConstrainDiameter::applyConstraint(), CmdSketcherConstrainSymmetric::applyConstraint(), Gui::DAG::Model::contextMenuEvent(), Gui::Dialog::DlgPropertyLink::detachObserver(), PartDesignGui::TaskDressUpParameters::doubleClicked(), PartDesignGui::TaskDressUpParameters::exitSelectionMode(), PartGui::goDimensionAngularRoot(), PartGui::goDimensionLinearRoot(), Gui::SoFCSelection::handleEvent(), Gui::TreeWidget::itemSearch(), SketcherGui::ViewProviderSketch::mouseButtonPressed(), Gui::DAG::Model::mousePressEvent(), SketcherGui::TaskSketcherConstrains::on_listWidgetConstraints_itemSelectionChanged(), SketcherGui::TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(), PartDesignGui::TaskTransformedParameters::onButtonAddFeature(), PartDesignGui::TaskDressUpParameters::onButtonRefAdd(), FemGui::TaskFemConstraint::onButtonReference(), PartDesignGui::TaskDressUpParameters::onButtonRefRemove(), PartDesignGui::TaskTransformedParameters::onButtonRemoveFeature(), SketcherGui::ViewProviderSketch::onDelete(), PartDesignGui::TaskFeaturePick::onItemSelectionChanged(), PartDesignGui::TaskFilletParameters::onSelectionChanged(), PartDesignGui::TaskChamferParameters::onSelectionChanged(), PartDesignGui::TaskThicknessParameters::onSelectionChanged(), PartDesignGui::TaskDraftParameters::onSelectionChanged(), FemGui::TaskFemConstraintBearing::onSelectionChanged(), FemGui::TaskFemConstraintGear::onSelectionChanged(), DrawSketchHandlerExternal::onSelectionChanged(), DrawSketchHandlerCarbonCopy::onSelectionChanged(), PartDesignGui::TaskSketchBasedParameters::onSelectReference(), SurfaceGui::FillingVertexPanel::open(), SurfaceGui::FillingUnboundPanel::open(), SurfaceGui::GeomFillSurface::open(), SurfaceGui::FillingPanel::open(), MeshGui::ParametersDialog::ParametersDialog(), TechDrawGui::MDIViewPage::print(), Gui::NavigationStyle::processEvent(), SketcherGui::ViewProviderSketch::purgeHandler(), DrawSketchHandlerGenConstraint::releaseButton(), DrawSketchHandlerCoincident::releaseButton(), DrawSketchHandlerFillet::releaseButton(), MeshGui::RemoveComponents::RemoveComponents(), Gui::ElementColors::Private::reset(), PartGui::TaskMeasureLinear::resetDialogSlot(), PartGui::TaskMeasureAngular::resetDialogSlot(), DrawSketchHandlerGenConstraint::resetOngoingSequences(), TechDrawGui::QGVPage::saveSvg(), sClearSelection(), ReverseEngineeringGui::SegmentationManual::SegmentationManual(), Gui::PropertyEditor::LinkSelection::select(), Gui::TreeWidget::selectAll(), PartGui::TaskMeasureLinear::selection1Slot(), PartGui::TaskMeasureAngular::selection1Slot(), PartGui::TaskMeasureLinear::selection2Slot(), PartGui::TaskMeasureAngular::selection2Slot(), PartGui::TaskMeasureLinear::selectionClearDelayedSlot(), PartGui::TaskMeasureAngular::selectionClearDelayedSlot(), TechDrawGui::ViewProviderHatch::setEdit(), TechDrawGui::ViewProviderGeomHatch::setEdit(), TechDrawGui::ViewProviderRichAnno::setEdit(), TechDrawGui::ViewProviderLeader::setEdit(), FemGui::ViewProviderFemConstraintPressure::setEdit(), PartDesignGui::ViewProviderShapeBinder::setEdit(), FemGui::ViewProviderFemConstraintBearing::setEdit(), PartDesignGui::ViewProviderHole::setEdit(), FemGui::ViewProviderFemConstraintPulley::setEdit(), FemGui::ViewProviderFemConstraintFixed::setEdit(), FemGui::ViewProviderFemConstraintForce::setEdit(), FemGui::ViewProviderFemConstraintGear::setEdit(), FemGui::ViewProviderFemConstraintFluidBoundary::setEdit(), FemGui::ViewProviderFemMeshShapeNetgen::setEdit(), FemGui::ViewProviderFemConstraintPlaneRotation::setEdit(), FemGui::ViewProviderFemConstraintHeatflux::setEdit(), FemGui::ViewProviderFemConstraintTemperature::setEdit(), FemGui::ViewProviderFemConstraintContact::setEdit(), PartDesignGui::ViewProviderPrimitive::setEdit(), FemGui::ViewProviderFemConstraintInitialTemperature::setEdit(), FemGui::ViewProviderFemConstraintDisplacement::setEdit(), FemGui::ViewProviderFemConstraintTransform::setEdit(), PartDesignGui::ViewProviderSubShapeBinder::setEdit(), PartDesignGui::ViewProvider::setEdit(), PartDesignGui::ViewProviderBoolean::setEdit(), TechDrawGui::ViewProviderWeld::setEdit(), TechDrawGui::ViewProviderViewSection::setEdit(), TechDrawGui::ViewProviderBalloon::setEdit(), TechDrawGui::ViewProviderProjGroup::setEdit(), TechDrawGui::ViewProviderViewPart::setEdit(), PartDesignGui::ViewProviderDatum::setEdit(), PartGui::ViewProviderPartExt::setEdit(), PartGui::ViewProviderOffset::setEdit(), PartGui::ViewProviderThickness::setEdit(), SketcherGui::ViewProviderSketch::setEdit(), Gui::ViewProviderLink::setEdit(), FemGui::TaskFemConstraint::setSelection(), PartDesignGui::TaskDressUpParameters::setSelection(), TechDrawGui::MDIViewPage::setTreeToSceneSelect(), PartGui::DlgFilletEdges::setupFillet(), MeshGui::TaskSmoothing::TaskSmoothing(), FemGui::ViewProviderFemConstraint::unsetEdit(), PartDesignGui::ViewProvider::unsetEdit(), SketcherGui::ViewProviderSketch::unsetEdit(), PartDesignGui::TaskChamferParameters::~TaskChamferParameters(), PartGui::TaskCheckGeometryResults::~TaskCheckGeometryResults(), PartDesignGui::TaskDraftParameters::~TaskDraftParameters(), PartDesignGui::TaskFilletParameters::~TaskFilletParameters(), PartGui::TaskMeasureAngular::~TaskMeasureAngular(), PartGui::TaskMeasureLinear::~TaskMeasureLinear(), and PartDesignGui::TaskThicknessParameters::~TaskThicknessParameters().

◆ countObjectsOfType() [1/2]

unsigned int SelectionSingleton::countObjectsOfType ( const Base::Type typeId = App::DocumentObject::getClassTypeId(),
const char *  pDocName = 0,
int  resolve = 1 
) 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.

Set 'resolve' to true to resolve any sub object inside selection SubName field

References getDocument(), and getObjectOfType().

Referenced by countObjectsOfType(), StdCmdTransformManip::isActive(), StdCmdAlignment::isActive(), sCountObjectsOfType(), and PartDesignGui::Workbench::setupContextMenu().

◆ countObjectsOfType() [2/2]

unsigned int SelectionSingleton::countObjectsOfType ( const char *  typeName,
const char *  pDocName = 0,
int  resolve = 1 
) 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.

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

◆ destruct()

void SelectionSingleton::destruct ( void  )
static

◆ disableCommandLog()

int SelectionSingleton::disableCommandLog ( )

◆ enableCommandLog()

◆ enablePickedList()

void SelectionSingleton::enablePickedList ( bool  enable)

Turn on or off picked list.

References notify(), and Gui::SelectionChanges::PickedListChanged.

Referenced by sEnablePickedList().

◆ getAsPropertyLinkSubList()

int SelectionSingleton::getAsPropertyLinkSubList ( App::PropertyLinkSubList prop) const

getAsPropertyLinkSubList fills PropertyLinkSubList with current selection.

Parameters
prop(output). The property object to receive links
Returns
the number of items written to the link

References Gui::SelectionObject::getObject(), getSelectionEx(), Gui::SelectionObject::getSubNames(), and App::PropertyLinkSubList::setValues().

Referenced by SketcherGui::SuggestAutoMapMode().

◆ getCompleteSelection()

std::vector< SelectionSingleton::SelObj > SelectionSingleton::getCompleteSelection ( int  resolve = 1) const

Returns a vector of all selection objects of all documents.

References getSelection().

Referenced by StdCmdEdit::activated(), StdCmdDelete::isActive(), Gui::Document::setEdit(), and sGetCompleteSelection().

◆ getDocument()

◆ getObjectList()

std::vector< SelectionObject > SelectionSingleton::getObjectList ( const char *  pDocName,
Base::Type  typeId,
std::list< _SelObj > &  objs,
int  resolve,
bool  single = false 
) const
protected

◆ getObjectOfType()

App::DocumentObject * SelectionSingleton::getObjectOfType ( _SelObj &  sel,
Base::Type  type,
int  resolve,
const char **  subelement = 0 
)
staticprotected

◆ getObjectsOfType() [1/3]

vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const Base::Type typeId,
const char *  pDocName = 0,
int  resolve = 1 
) const

Returns a vector of objects of type TypeName selected for the given document name pDocName.

If no document name is specified the objects from the active document are regarded. If no objects of this document are selected an empty vector is returned.

Note
The vector reflects the sequence of selection.

References getDocument(), and getObjectOfType().

Referenced by DrawingGui::TaskProjection::accept(), ReenGui::FitBSplineSurfaceWidget::accept(), MeshGui::TaskDecimating::accept(), StdCmdToggleSelectability::activated(), StdCmdPlacement::activated(), StdCmdTransformManip::activated(), StdCmdAlignment::activated(), Gui::Application::exportTo(), getObjectsOfType(), Gui::MainWindow::insertFromMimeData(), MeshInfoWatcher::onSelectionChanged(), MeshGui::TaskDecimating::TaskDecimating(), and DrawingGui::TaskOrthoViews::TaskOrthoViews().

◆ getObjectsOfType() [2/3]

template<typename T >
std::vector< T * > Gui::SelectionSingleton::getObjectsOfType ( const char *  pDocName = 0,
int  resolve = 1 
) const

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

◆ getObjectsOfType() [3/3]

std::vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const char *  typeName,
const char *  pDocName = 0,
int  resolve = 1 
) 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.

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

◆ getPickedList()

◆ getPickedListEx()

std::vector< SelectionObject > SelectionSingleton::getPickedListEx ( const char *  pDocName = 0,
Base::Type  typeId = App::DocumentObject::getClassTypeId() 
) const

Return selected object inside picked list grouped by top level parents.

References getObjectList().

Referenced by sGetPickedList().

◆ getPreselection()

const SelectionChanges & SelectionSingleton::getPreselection ( void  ) const

returns the present preselection

References CurrentPreselection.

Referenced by sGetPreselection().

◆ getSelectedElement()

const char * SelectionSingleton::getSelectedElement ( App::DocumentObject obj,
const char *  pSubName 
) const

◆ getSelection()

std::vector< SelectionSingleton::SelObj > SelectionSingleton::getSelection ( const char *  pDocName = 0,
int  resolve = 1,
bool  single = false 
) const

Returns a vector of selection objects.

Parameters
pDocNamedocument name. If no document name is given the objects of the active are returned. If nothing for this Document is selected an empty vector is returned. If document name is "*", then all document is considered.
resolvesub-object resolving mode 0 no resolve, 1 resolve sub-object with old style element name 2 resolve sub-object with new style element name
singleif set to true, then it will return an empty vector if there is more than one selections.
Returns
The returned vector reflects the sequence of selection.

References Gui::SelectionSingleton::SelObj::DocName, Gui::SelectionSingleton::SelObj::FeatName, Base::Persistence::getClassTypeId(), getDocument(), getObjectOfType(), Gui::SelectionSingleton::SelObj::pDoc, Gui::SelectionSingleton::SelObj::pObject, Gui::SelectionSingleton::SelObj::pResolvedObject, Gui::SelectionSingleton::SelObj::SubName, Gui::SelectionSingleton::SelObj::TypeName, Gui::SelectionSingleton::SelObj::x, Gui::SelectionSingleton::SelObj::y, and Gui::SelectionSingleton::SelObj::z.

Referenced by StdCmdLinkSelectAllLinks::activated(), PartGui::evaluateAngularPreSelection(), PartGui::evaluateLinearPreSelection(), getCompleteSelection(), StdCmdLinkSelectAllLinks::isActive(), TechDrawGui::MDIViewPage::onSelectionChanged(), Gui::DAG::Model::selectionChanged(), Gui::DocumentItem::selectItems(), Gui::View3DInventorViewer::setDocument(), femguiutils.selection_widgets._Selector::setHelpText(), PartDesignGui::Workbench::setupContextMenu(), and sGetSelection().

◆ getSelectionEx()

std::vector< SelectionObject > SelectionSingleton::getSelectionEx ( const char *  pDocName = 0,
Base::Type  typeId = App::DocumentObject::getClassTypeId(),
int  resolve = 1,
bool  single = false 
) const

Returns a vector of selection objects.

Parameters
pDocNamedocument name. If no document name is given the objects of the active are returned. If nothing for this Document is selected an empty vector is returned. If document name is "*", then all document is considered.
typeIdspecify the type of object to be returned.
resolvesub-object resolving mode. 0 no resolve, 1 resolve sub-object with old style element name 2 resolve sub-object with new style element name
singleif set to true, then it will return an empty vector if there is more than one selections.
Returns
The returned vector reflects the sequence of selection.

References getObjectList().

Referenced by SketcherCopy::activate(), CmdSketcherConstrainHorizontal::activated(), StdCmdDelete::activated(), CmdSketcherConstrainVertical::activated(), CmdSketcherConstrainLock::activated(), CmdSketcherConstrainBlock::activated(), CmdSketcherConstrainCoincident::activated(), CmdSketcherConstrainDistance::activated(), CmdSketcherConstrainPointOnObject::activated(), StdCmdTreeSelectAllInstances::activated(), CmdSketcherConstrainDistanceX::activated(), CmdSketcherConstrainDistanceY::activated(), CmdSketcherConstrainParallel::activated(), CmdSketcherConstrainPerpendicular::activated(), CmdSketcherConstrainTangent::activated(), CmdSketcherConstrainRadius::activated(), CmdSketcherConstrainDiameter::activated(), CmdSketcherConstrainAngle::activated(), CmdSketcherConstrainEqual::activated(), CmdSketcherConstrainSymmetric::activated(), SketcherGui::ViewProviderSketch::deleteSelected(), SketcherGui::ElementView::deleteSelectedItems(), SketcherGui::ConstraintView::deleteSelectedItems(), getAsPropertyLinkSubList(), StdCmdTreeSelectAllInstances::isActive(), Gui::SelectionFilter::match(), SketcherGui::ViewProviderSketch::mouseButtonPressed(), Gui::PropertyView::onTimer(), Gui::Dialog::Placement::Placement(), TechDrawGui::MDIViewPage::sceneSelectionChanged(), SketcherGui::SketchSelection::setUp(), and sGetSelectionEx().

◆ hasPickedList()

bool SelectionSingleton::hasPickedList ( ) const

Check if there is any selection inside picked list.

◆ hasPreselection()

bool SelectionSingleton::hasPreselection ( ) const

Check if there is any pre-selection.

References CurrentPreselection, App::DocumentObjectT::getObjectName(), and Gui::SelectionChanges::Object.

◆ hasSelection() [1/2]

bool SelectionSingleton::hasSelection ( ) const

◆ hasSelection() [2/2]

bool SelectionSingleton::hasSelection ( const char *  doc,
bool  resolve = true 
) const

Check if there is any selection within a given document.

Parameters
docspecify the document to check for selection. If NULL, then check the current active document.
resolvewhether to resolve the selected sub-object

If resolve is true, then the selection is first resolved before matching its owner document. So in case the selected sub-object is linked from an external document, it may not match the input doc. If resolve is false, then the match is only done with the top level parent object.

References Base::Persistence::getClassTypeId(), getDocument(), and getObjectOfType().

◆ hasSubSelection()

bool SelectionSingleton::hasSubSelection ( const char *  doc = 0,
bool  subElement = false 
) const

Check if there is any sub-element selection.

Parameters
docoptional document to check for selection
subElementwhether to count sub-element only selection

Example sub selections are face, edge or vertex. If subElement is false, then sub-object (i.e. a group child object) selection is also counted even if it selects the whole sub-object.

References getDocument().

Referenced by StdCmdLinkMakeRelative::isActive(), and sHasSubSelection().

◆ instance()

SelectionSingleton & SelectionSingleton::instance ( void  )
static

References SelectionSingleton().

◆ isSelected() [1/2]

bool SelectionSingleton::isSelected ( App::DocumentObject pObject,
const char *  pSubName = 0,
int  resolve = 1 
) const

◆ isSelected() [2/2]

bool SelectionSingleton::isSelected ( const char *  pDocName,
const char *  pObjectName = 0,
const char *  pSubName = 0,
int  resolve = 1 
) const

◆ needPickedList()

bool SelectionSingleton::needPickedList ( ) const

Check whether picked list is enabled.

Referenced by Gui::View3DInventorViewer::checkGroupOnTop().

◆ notify() [1/2]

void Gui::SelectionSingleton::notify ( const SelectionChanges Chng)
protected

References notify().

Referenced by notify().

◆ notify() [2/2]

◆ rmvPreselect()

◆ rmvSelection()

◆ rmvSelectionGate()

void SelectionSingleton::rmvSelectionGate ( void  )

remove the active SelectionGate

References Gui::Application::activeDocument(), ActiveGate, Gui::Application::Instance, and Gui::MDIView::restoreOverrideCursor().

Referenced by SurfaceGui::FillingUnboundPanel::accept(), SurfaceGui::GeomFillSurface::accept(), SurfaceGui::FillingPanel::accept(), DrawSketchHandlerGenConstraint::activated(), DrawSketchHandlerCoincident::activated(), DrawSketchHandlerFillet::activated(), DrawSketchHandlerTrimming::activated(), DrawSketchHandlerExtend::activated(), DrawSketchHandlerExternal::activated(), DrawSketchHandlerCarbonCopy::activated(), addSelectionGate(), Gui::SelectionObserver::detachSelection(), PartDesignGui::TaskDressUpParameters::exitSelectionMode(), PartDesignGui::TaskTransformedParameters::exitSelectionMode(), FemGui::TaskCreateNodeSet::onSelectionChanged(), SurfaceGui::FillingPanel::onSelectionChanged(), PartDesignGui::TaskSketchBasedParameters::onSelectReference(), SketcherGui::DrawSketchHandler::quit(), SurfaceGui::FillingUnboundPanel::reject(), SurfaceGui::GeomFillSurface::reject(), SurfaceGui::FillingPanel::reject(), sRemoveSelectionGate(), PartGui::DlgExtrusion::~DlgExtrusion(), PartGui::DlgFilletEdges::~DlgFilletEdges(), PartGui::DlgProjectionOnSurface::~DlgProjectionOnSurface(), PartGui::DlgRevolution::~DlgRevolution(), DrawSketchHandlerCarbonCopy::~DrawSketchHandlerCarbonCopy(), DrawSketchHandlerCoincident::~DrawSketchHandlerCoincident(), DrawSketchHandlerExtend::~DrawSketchHandlerExtend(), DrawSketchHandlerExternal::~DrawSketchHandlerExternal(), DrawSketchHandlerFillet::~DrawSketchHandlerFillet(), DrawSketchHandlerGenConstraint::~DrawSketchHandlerGenConstraint(), DrawSketchHandlerTrimming::~DrawSketchHandlerTrimming(), Gui::ElementColors::~ElementColors(), PartGui::FaceColors::~FaceColors(), SurfaceGui::FillingUnboundPanel::~FillingUnboundPanel(), SurfaceGui::FillingVertexPanel::~FillingVertexPanel(), PartGui::ShapeBuilderWidget::~ShapeBuilderWidget(), PartDesignGui::TaskChamferParameters::~TaskChamferParameters(), PartDesignGui::TaskDatumParameters::~TaskDatumParameters(), PartDesignGui::TaskDraftParameters::~TaskDraftParameters(), PartDesignGui::TaskDressUpParameters::~TaskDressUpParameters(), PartDesignGui::TaskFilletParameters::~TaskFilletParameters(), PartDesignGui::TaskThicknessParameters::~TaskThicknessParameters(), and PartDesignGui::TaskTransformedParameters::~TaskTransformedParameters().

◆ sAddSelection()

◆ sAddSelectionGate()

PyObject * SelectionSingleton::sAddSelectionGate ( PyObject self,
PyObject args 
)
staticprotected

◆ sAddSelObserver()

PyObject * SelectionSingleton::sAddSelObserver ( PyObject self,
PyObject args 
)
staticprotected

◆ sClearSelection()

PyObject * SelectionSingleton::sClearSelection ( PyObject self,
PyObject args 
)
staticprotected

◆ sCountObjectsOfType()

PyObject * SelectionSingleton::sCountObjectsOfType ( PyObject self,
PyObject args 
)
staticprotected

◆ selStackBackSize()

int Gui::SelectionSingleton::selStackBackSize ( ) const

Return the current selection stack size.

Referenced by StdCmdSelBack::isActive().

◆ selStackForwardSize()

int Gui::SelectionSingleton::selStackForwardSize ( ) const

Return the current forward selection stack size.

Referenced by StdCmdSelForward::isActive().

◆ selStackGet()

std::vector< SelectionObject > SelectionSingleton::selStackGet ( const char *  pDocName = 0,
int  resolve = 1,
int  index = 0 
) const

Obtain selected objects from stack.

Parameters
pDocNameoptional filtering document, NULL for current active document
resolvesub-object resolving mode. 0 no resolve, 1 resolve sub-object with old style element name 2 resolve sub-object with new style element name
indexoptional position in the stack

References checkSelection(), Base::Persistence::getClassTypeId(), and getObjectList().

Referenced by sGetSelectionFromStack().

◆ selStackGoBack()

void SelectionSingleton::selStackGoBack ( int  count = 1)

Go back selection history.

Parameters
countoptional number of steps to go back

This function pops the selection stack, and populate the current selection with the content of the last pop'd entry

References addSelection(), clearCompleteSelection(), Gui::getMainWindow(), selStackPush(), and Gui::MainWindow::updateActions().

Referenced by StdCmdSelBack::activated().

◆ selStackGoForward()

void SelectionSingleton::selStackGoForward ( int  count = 1)

Go forward selection history.

Parameters
countoptional number of steps to go back

This function pops the selection stack, and populate the current selection with the content of the last pop'd entry

References addSelection(), clearCompleteSelection(), Gui::getMainWindow(), selStackPush(), and Gui::MainWindow::updateActions().

Referenced by StdCmdSelForward::activated().

◆ selStackPush()

◆ sEnablePickedList()

PyObject * SelectionSingleton::sEnablePickedList ( PyObject self,
PyObject args 
)
staticprotected

◆ setPreselect()

◆ setPreselectCoord()

◆ setSelection()

◆ setVisible()

◆ sGetCompleteSelection()

PyObject * SelectionSingleton::sGetCompleteSelection ( PyObject self,
PyObject args 
)
staticprotected

◆ sGetPickedList()

PyObject * SelectionSingleton::sGetPickedList ( PyObject self,
PyObject args 
)
staticprotected

◆ sGetPreselection()

PyObject * SelectionSingleton::sGetPreselection ( PyObject self,
PyObject args 
)
staticprotected

◆ sGetSelection()

PyObject * SelectionSingleton::sGetSelection ( PyObject self,
PyObject args 
)
staticprotected

References getSelection(), and Gui::Selection().

◆ sGetSelectionEx()

PyObject * SelectionSingleton::sGetSelectionEx ( PyObject self,
PyObject args 
)
staticprotected

◆ sGetSelectionFromStack()

PyObject * SelectionSingleton::sGetSelectionFromStack ( PyObject self,
PyObject args 
)
staticprotected

References Gui::Selection(), and selStackGet().

◆ sGetSelectionObject()

◆ sHasSelection()

PyObject * SelectionSingleton::sHasSelection ( PyObject self,
PyObject args 
)
staticprotected

References hasSelection(), and Gui::Selection().

◆ sHasSubSelection()

PyObject * SelectionSingleton::sHasSubSelection ( PyObject self,
PyObject args 
)
staticprotected

◆ sIsSelected()

PyObject * SelectionSingleton::sIsSelected ( PyObject self,
PyObject args 
)
staticprotected

◆ size()

unsigned int Gui::SelectionSingleton::size ( void  ) const

Size of selected entities for all documents.

Referenced by PathScripts.PostUtils.GCodeEditorDialog::done(), and StdCmdSetAppearance::isActive().

◆ slotDeletedObject()

◆ slotSelectionChanged()

◆ sPreselect()

static PyObject* Gui::SelectionSingleton::sPreselect ( PyObject self,
PyObject args 
)
staticprotected

◆ sPushSelStack()

PyObject * SelectionSingleton::sPushSelStack ( PyObject self,
PyObject args 
)
staticprotected

References Gui::Selection(), and selStackPush().

◆ sRemoveSelection()

◆ sRemoveSelectionGate()

PyObject * SelectionSingleton::sRemoveSelectionGate ( PyObject self,
PyObject args 
)
staticprotected

◆ sRemPreselection()

PyObject * SelectionSingleton::sRemPreselection ( PyObject self,
PyObject args 
)
staticprotected

References rmvPreselect(), and Gui::Selection().

◆ sRemSelObserver()

PyObject * SelectionSingleton::sRemSelObserver ( PyObject self,
PyObject args 
)
staticprotected

◆ sSetPreselection()

◆ sSetVisible()

PyObject * SelectionSingleton::sSetVisible ( PyObject self,
PyObject args 
)
staticprotected

◆ sUpdateSelection()

◆ updateSelection()

Friends And Related Function Documentation

◆ SelectionFilter

friend class SelectionFilter
friend

Member Data Documentation

◆ ActiveGate

Gui::SelectionGate* Gui::SelectionSingleton::ActiveGate
protected

◆ CurrentPreselection

SelectionChanges Gui::SelectionSingleton::CurrentPreselection
protected

◆ DocName

◆ FeatName

std::string Gui::SelectionSingleton::FeatName
protected

◆ gateResolve

int Gui::SelectionSingleton::gateResolve
protected

◆ hx

float Gui::SelectionSingleton::hx
protected

◆ hy

float Gui::SelectionSingleton::hy
protected

◆ hz

float Gui::SelectionSingleton::hz
protected

◆ logDisabled

int Gui::SelectionSingleton::logDisabled = 0
protected

◆ logHasSelection

bool Gui::SelectionSingleton::logHasSelection = false
protected

◆ Methods

PyMethodDef SelectionSingleton::Methods
static

◆ NotificationQueue

std::deque<SelectionChanges> Gui::SelectionSingleton::NotificationQueue
protected

Referenced by notify().

◆ Notifying

bool Gui::SelectionSingleton::Notifying = false
protected

Referenced by notify().

◆ signalSelectionChanged

boost::signals2::signal<void (const SelectionChanges& msg)> Gui::SelectionSingleton::signalSelectionChanged

signal on new object

Referenced by Gui::SelectionObserver::attachSelection(), notify(), and SelectionSingleton().

◆ signalSelectionChanged2

boost::signals2::signal<void (const SelectionChanges& msg)> Gui::SelectionSingleton::signalSelectionChanged2

signal on selection change with resolved object

Referenced by Gui::SelectionObserver::attachSelection(), and slotSelectionChanged().

◆ signalSelectionChanged3

boost::signals2::signal<void (const SelectionChanges& msg)> Gui::SelectionSingleton::signalSelectionChanged3

signal on selection change with resolved object and sub element map

Referenced by Gui::SelectionObserver::attachSelection(), and slotSelectionChanged().

◆ SubName

std::string Gui::SelectionSingleton::SubName
protected

The documentation for this class was generated from the following files:
  • src/Gui/Selection.h
  • src/Gui/Selection.cpp