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=nullptr, const char *pSubName=nullptr, float x=0, float y=0, float z=0, const std::vector< SelObj > *pickedList=nullptr, 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=nullptr, const char *pSubName=nullptr, float x=0, float y=0, float z=0, const std::vector< SelObj > *pickedList=nullptr)
 
void addSelectionGate (Gui::SelectionGate *gate, ResolveMode resolve=ResolveMode::OldStyleElement)
 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=nullptr, 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) 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 (ResolveMode resolve=ResolveMode::OldStyleElement) const
 Returns a vector of all selection objects of all documents. More...
 
std::vector< App::DocumentObject * > getObjectsOfType (const Base::Type &typeId, const char *pDocName=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement, bool single=false) const
 Returns a vector of selection objects. More...
 
std::vector< Gui::SelectionObjectgetSelectionEx (const char *pDocName=nullptr, Base::Type typeId=App::DocumentObject::getClassTypeId(), ResolveMode resolve=ResolveMode::OldStyleElement, 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, ResolveMode resolve=ResolveMode::OldStyleElement) const
 Check if there is any selection within a given document. More...
 
bool hasSubSelection (const char *doc=nullptr, bool subElement=false) const
 Check if there is any sub-element selection. More...
 
bool isSelected (App::DocumentObject *, const char *pSubName=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) const
 Check if selected. More...
 
bool isSelected (const char *pDocName, const char *pObjectName=nullptr, const char *pSubName=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement) const
 Check if selected. More...
 
void rmvPreselect (bool signal=false)
 remove the present preselection More...
 
void rmvSelection (const char *pDocName, const char *pObjectName=nullptr, const char *pSubName=nullptr, const std::vector< SelObj > *pickedList=nullptr)
 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, SelectionChanges::MsgSource signal=SelectionChanges::MsgSource::Any)
 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=nullptr, const char *pSubName=nullptr)
 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=nullptr, ResolveMode resolve=ResolveMode::OldStyleElement, 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
 
ResolveMode 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=nullptr, 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, ResolveMode resolve, const char **subelement=nullptr)
 
 SelectionSingleton ()
 Construction. More...
 
virtual ~SelectionSingleton ()
 Destruction. More...
 
void slotDeletedObject (const App::DocumentObject &)
 Observer message from the App doc. More...
 
App::DocumentgetDocument (const char *pDocName=nullptr) 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, ResolveMode resolve, _SelObj &sel, const std::list< _SelObj > *selList=nullptr) const
 
std::vector< Gui::SelectionObjectgetObjectList (const char *pDocName, Base::Type typeId, std::list< _SelObj > &objs, ResolveMode 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

◆ ~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 = nullptr,
const char *  pSubName = nullptr,
float  x = 0,
float  y = 0,
float  z = 0,
const std::vector< SelObj > *  pickedList = nullptr,
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, draftfunctions.move::move(), Gui::NoResolve, Gui::SelectionGate::notAllowedReason, notify(), Gui::SelectionChanges::pDocName, Gui::SelectionChanges::PickedListChanged, Gui::SelectionChanges::pObjectName, Gui::SelectionChanges::pSubName, rmvPreselect(), Gui::MDIView::setOverrideCursor(), Gui::MainWindow::showMessage(), draftguitools.gui_setstyle::translate, 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(), PartDesignGui::TaskFeaturePick::onDoubleClick(), PartDesignGui::TaskFeaturePick::onItemSelectionChanged(), Gui::TreeWidget::onSelectDependents(), Gui::ElementColors::Private::onSelectionChanged(), DrawSketchHandlerGenConstraint::releaseButton(), DrawSketchHandlerCoincident::releaseButton(), SketcherGui::DrawSketchHandlerFillet::releaseButton(), sAddSelection(), Gui::PropertyEditor::LinkSelection::select(), PartGui::TaskMeasureLinear::selection1Slot(), PartGui::TaskMeasureAngular::selection1Slot(), PartGui::TaskMeasureLinear::selection2Slot(), PartGui::TaskMeasureAngular::selection2Slot(), selStackGoBack(), selStackGoForward(), TechDrawGui::ViewProviderViewPart::setEdit(), PartDesignGui::ViewProviderSubShapeBinder::setEdit(), PartDesignGui::TaskDressUpParameters::setSelection(), FemGui::TaskFemConstraint::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 = nullptr,
const char *  pSubName = nullptr,
float  x = 0,
float  y = 0,
float  z = 0,
const std::vector< SelObj > *  pickedList = nullptr 
)

◆ addSelectionGate()

◆ addSelections()

◆ checkSelection()

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

◆ clearCompleteSelection()

◆ clearSelection()

void SelectionSingleton::clearSelection ( const char *  pDocName = nullptr,
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(), Gui::Application::Instance, logDisabled, Gui::Application::macroManager(), notify(), Gui::SelectionChanges::PickedListChanged, rmvPreselect(), and Gui::MainWindow::updateActions().

Referenced by MeshGui::TaskDecimating::accept(), SketcherCopy::activate(), StdCmdAlignment::activated(), CmdSketcherConstrainHorizontal::activated(), CmdSketcherConstrainVertical::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(), CmdSketcherConstrainRadiam::activated(), CmdSketcherConstrainAngle::activated(), CmdSketcherConstrainEqual::activated(), CmdSketcherConstrainSymmetric::activated(), CmdSketcherConstraint::activated(), Gui::ElementColors::Private::apply(), CmdSketcherConstrainPerpendicular::applyConstraint(), CmdSketcherConstrainTangent::applyConstraint(), CmdSketcherConstrainRadius::applyConstraint(), CmdSketcherConstrainDiameter::applyConstraint(), CmdSketcherConstrainRadiam::applyConstraint(), CmdSketcherConstrainSymmetric::applyConstraint(), PartGui::ViewProviderPartExt::changeFaceColors(), SketcherGui::ConstraintView::contextMenuEvent(), Gui::DAG::Model::contextMenuEvent(), Gui::Dialog::DlgPropertyLink::detachObserver(), PartDesignGui::TaskDressUpParameters::doubleClicked(), TechDrawGui::execHoleCircle(), PartDesignGui::TaskDressUpParameters::exitSelectionMode(), PartGui::goDimensionAngularRoot(), PartGui::goDimensionLinearRoot(), Gui::SoFCSelection::handleEvent(), Gui::TreeWidget::itemSearch(), SketcherGui::ViewProviderSketch::mouseButtonPressed(), Gui::DAG::Model::mousePressEvent(), SketcherGui::TaskSketcherConstraints::on_listWidgetConstraints_itemSelectionChanged(), SketcherGui::TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(), PartDesignGui::TaskTransformedParameters::onButtonAddFeature(), PartDesignGui::TaskDressUpParameters::onButtonRefAdd(), FemGui::TaskFemConstraint::onButtonReference(), PartDesignGui::TaskDressUpParameters::onButtonRefRemove(), PartDesignGui::TaskTransformedParameters::onButtonRemoveFeature(), FemGui::TaskFemConstraintOnBoundary::onButtonToggled(), PartDesignGui::TaskDlgPipeParameters::onButtonToggled(), SketcherGui::ViewProviderSketch::onDelete(), PartDesignGui::TaskFeaturePick::onItemSelectionChanged(), FemGui::TaskFemConstraintBearing::onSelectionChanged(), FemGui::TaskFemConstraintGear::onSelectionChanged(), PartDesignGui::TaskChamferParameters::onSelectionChanged(), PartDesignGui::TaskDraftParameters::onSelectionChanged(), PartDesignGui::TaskFilletParameters::onSelectionChanged(), PartDesignGui::TaskThicknessParameters::onSelectionChanged(), SketcherGui::DrawSketchHandlerCarbonCopy::onSelectionChanged(), SketcherGui::DrawSketchHandlerExternal::onSelectionChanged(), PartDesignGui::TaskSketchBasedParameters::onSelectReference(), SurfaceGui::FillingPanel::open(), SurfaceGui::FillingEdgePanel::open(), SurfaceGui::FillingVertexPanel::open(), SurfaceGui::GeomFillSurface::open(), SurfaceGui::SectionsPanel::open(), MeshGui::ParametersDialog::ParametersDialog(), TechDrawGui::MDIViewPage::print(), Gui::NavigationStyle::processEvent(), SketcherGui::ViewProviderSketch::purgeHandler(), DrawSketchHandlerGenConstraint::releaseButton(), DrawSketchHandlerCoincident::releaseButton(), SketcherGui::DrawSketchHandlerFillet::releaseButton(), MeshGui::RemoveComponents::RemoveComponents(), Gui::ElementColors::Private::reset(), PartGui::TaskMeasureLinear::resetDialogSlot(), PartGui::TaskMeasureAngular::resetDialogSlot(), DrawSketchHandlerGenConstraint::resetOngoingSequences(), TechDrawGui::QGSPage::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(), FemGui::ViewProviderFemConstraintBearing::setEdit(), FemGui::ViewProviderFemConstraintContact::setEdit(), FemGui::ViewProviderFemConstraintDisplacement::setEdit(), FemGui::ViewProviderFemConstraintFixed::setEdit(), FemGui::ViewProviderFemConstraintFluidBoundary::setEdit(), FemGui::ViewProviderFemConstraintForce::setEdit(), FemGui::ViewProviderFemConstraintGear::setEdit(), FemGui::ViewProviderFemConstraintHeatflux::setEdit(), FemGui::ViewProviderFemConstraintInitialTemperature::setEdit(), FemGui::ViewProviderFemConstraintPlaneRotation::setEdit(), FemGui::ViewProviderFemConstraintPressure::setEdit(), FemGui::ViewProviderFemConstraintPulley::setEdit(), FemGui::ViewProviderFemConstraintSpring::setEdit(), FemGui::ViewProviderFemConstraintTemperature::setEdit(), FemGui::ViewProviderFemConstraintTransform::setEdit(), FemGui::ViewProviderFemMeshShapeNetgen::setEdit(), PartGui::ViewProviderOffset::setEdit(), PartGui::ViewProviderThickness::setEdit(), PartDesignGui::ViewProviderHole::setEdit(), PartDesignGui::ViewProviderPrimitive::setEdit(), TechDrawGui::ViewProviderBalloon::setEdit(), TechDrawGui::ViewProviderDimension::setEdit(), TechDrawGui::ViewProviderLeader::setEdit(), TechDrawGui::ViewProviderProjGroup::setEdit(), TechDrawGui::ViewProviderRichAnno::setEdit(), TechDrawGui::ViewProviderViewPart::setEdit(), TechDrawGui::ViewProviderViewSection::setEdit(), TechDrawGui::ViewProviderWeld::setEdit(), Gui::ViewProviderLink::setEdit(), PartDesignGui::ViewProvider::setEdit(), PartDesignGui::ViewProviderBoolean::setEdit(), PartDesignGui::ViewProviderDatum::setEdit(), PartDesignGui::ViewProviderShapeBinder::setEdit(), PartDesignGui::ViewProviderSubShapeBinder::setEdit(), SketcherGui::ViewProviderSketch::setEdit(), TechDrawGui::ViewProviderGeomHatch::setEdit(), TechDrawGui::ViewProviderHatch::setEdit(), PartDesignGui::TaskDressUpParameters::setSelection(), FemGui::TaskFemConstraint::setSelection(), TechDrawGui::MDIViewPage::setTreeToSceneSelect(), PartGui::DlgFilletEdges::setupFillet(), CmdSketcherConstrainTangent::substituteConstraintCombinations(), CmdSketcherConstrainPointOnObject::substituteConstraintCombinations(), CmdSketcherConstrainCoincident::substituteConstraintCombinations(), 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 = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) 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 StdCmdMeasurementSimple::activated(), countObjectsOfType(), StdCmdPlacement::isActive(), StdCmdTransformManip::isActive(), StdCmdAlignment::isActive(), SketcherGui::isCommandActive(), sCountObjectsOfType(), and PartDesignGui::Workbench::setupContextMenu().

◆ countObjectsOfType() [2/2]

unsigned int SelectionSingleton::countObjectsOfType ( const char *  typeName,
const char *  pDocName = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) 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 ( ResolveMode  resolve = ResolveMode::OldStyleElement) const

Returns a vector of all selection objects of all documents.

References getSelection().

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

◆ getDocument()

◆ getObjectList()

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

◆ getObjectOfType()

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

◆ getObjectsOfType() [1/3]

vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const Base::Type typeId,
const char *  pDocName = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) const

◆ getObjectsOfType() [2/3]

template<typename T >
std::vector< T * > Gui::SelectionSingleton::getObjectsOfType ( const char *  pDocName = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) const

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

References draftutils.utils::getObjectsOfType.

◆ getObjectsOfType() [3/3]

std::vector< App::DocumentObject * > SelectionSingleton::getObjectsOfType ( const char *  typeName,
const char *  pDocName = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) 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 = nullptr,
Base::Type  typeId = App::DocumentObject::getClassTypeId() 
) const

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

References getObjectList(), and Gui::NoResolve.

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 = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement,
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::NoResolve, 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(), StdCmdMeasurementSimple::activated(), Gui::PropertyEditor::PropertyEditor::contextMenuEvent(), PartGui::evaluateAngularPreSelection(), PartGui::evaluateLinearPreSelection(), getCompleteSelection(), PartGui::TaskCheckGeometryResults::goCheck(), 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 = nullptr,
Base::Type  typeId = App::DocumentObject::getClassTypeId(),
ResolveMode  resolve = ResolveMode::OldStyleElement,
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 PartGui::SweepWidget::accept(), SketcherCopy::activate(), StdCmdDelete::activated(), StdCmdTreeSelectAllInstances::activated(), CmdSketcherConstrainHorizontal::activated(), CmdSketcherConstrainVertical::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(), CmdSketcherConstrainRadiam::activated(), CmdSketcherConstrainAngle::activated(), CmdSketcherConstrainEqual::activated(), CmdSketcherConstrainSymmetric::activated(), SketcherGui::ConstraintView::deleteSelectedItems(), SketcherGui::ElementView::deleteSelectedItems(), getAsPropertyLinkSubList(), TechDrawGui::TaskAlignViews::getSelectedEdges(), 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,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) 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 = nullptr,
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 = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) const

◆ isSelected() [2/2]

bool SelectionSingleton::isSelected ( const char *  pDocName,
const char *  pObjectName = nullptr,
const char *  pSubName = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement 
) 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()

void SelectionSingleton::rmvSelection ( const char *  pDocName,
const char *  pObjectName = nullptr,
const char *  pSubName = nullptr,
const std::vector< SelObj > *  pickedList = nullptr 
)

◆ rmvSelectionGate()

void SelectionSingleton::rmvSelectionGate ( void  )

remove the active SelectionGate

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

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

◆ 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 = nullptr,
ResolveMode  resolve = ResolveMode::OldStyleElement,
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(), getObjectList(), and Gui::NoResolve.

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(), draftfunctions.move::move(), 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(), draftfunctions.move::move(), 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

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

◆ size()

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

◆ 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

ResolveMode 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: