ModuleBase_IPrefMgr.h
ModuleBase_IPropertyPanel.h
ModuleBase_ISelection.h
+ ModuleBase_ISelectionActivate.h
ModuleBase_IViewWindow.h
ModuleBase_IViewer.h
ModuleBase_IWidgetCreator.h
#include <GeomAPI_Shape.h>
#include <GeomAPI_ICustomPrs.h>
+#include <SelectMgr_ListOfFilter.hxx>
+
#include <QString>
#include <QObject>
#include <QMap>
virtual ~ModuleBase_IModule() {}
- /// Add default selection filters of the module to the current viewer
- virtual void activateSelectionFilters() {}
-
- /// Remove default selection filters of the module from the current viewer
- virtual void deactivateSelectionFilters() {}
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const {}
- /// Update selection filters depending on the module active controls
- virtual void updateActiveSelectionFilters() {}
+ /// Returns current selection modes that should be used in 3D viewer
+ /// \param theModes container of modes
+ virtual void selectionModes(QIntList& theModes) const {}
/// Stores the current selection
virtual void storeSelection() {}
virtual void activeSelectionModes(QIntList& theModes) {}
/// Appends specific selection modes for the module to the list of types
- /// \param theTypes a selection modes to be extended
- virtual void customSubShapesSelectionModes(QIntList& theTypes) {}
+ /// \param theModes a selection modes to be extended
+ virtual void customSubShapesSelectionModes(QIntList& theModes) {}
/// Return true if the custom presentation is activated
/// \param theFlag a flag of level of customization, which means that only part of sub-elements
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ISelectionActivate_H
+#define ModuleBase_ISelectionActivate_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_IWorkshop.h"
+
+#include <SelectMgr_ListOfFilter.hxx>
+
+class ModuleBase_ModelWidget;
+
+
+/// \ingroup GUI
+/// A class which provides interface of activation/deactivate selection modes
+/// and using selection filters.
+class ModuleBase_ISelectionActivate
+{
+public:
+ /// Constructor
+ ModuleBase_ISelectionActivate(ModuleBase_IWorkshop* theWorkshop) : myWorkshop(theWorkshop) {}
+
+ /// Destructor
+ ~ModuleBase_ISelectionActivate() {}
+
+ /// Updates active selection modes in the viewer depending on the application state
+ MODULEBASE_EXPORT virtual void updateSelectionModes() = 0;
+
+ /// Updates active selection filters in the viewer depending on the application state
+ MODULEBASE_EXPORT virtual void updateSelectionFilters() = 0;
+
+ /// Activates parameter filters in the workshop, deactivate active out of the container
+ /// Please find a possibility to use updateSelectionFilters instead of direct call this method.
+ /// \param theSelectionFilters a filtes
+ MODULEBASE_EXPORT virtual void activateSelectionFilters
+ (const SelectMgr_ListOfFilter& theSelectionFilters) = 0;
+
+ /// Activate or deactivate selection and selection filters like the widget is active
+ /// \param theWidget a source widget of selection modes/filters
+ MODULEBASE_EXPORT virtual void activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget) = 0;
+
+protected:
+ ModuleBase_IWorkshop* myWorkshop; ///< active workshop
+};
+
+#endif
class ModuleBase_IPropertyPanel;
class ModuleBase_IErrorMgr;
class ModuleBase_Operation;
+class ModuleBase_ISelectionActivate;
class ModuleBase_ViewerPrs;
class QMainWindow;
/// Return current selection instance
virtual ModuleBase_ISelection* selection() const = 0;
- /// Activate sub-shapes selection (opens local context)
- /// Types has to be defined according to TopAbs_ShapeEnum
- virtual void activateSubShapesSelection(const QIntList& theTypes) = 0;
-
- /// Activate objects in the module selection modes(opens local context)
- virtual void activateModuleSelectionModes() = 0;
-
- /// Deactivate sub-shapes selection (closes local context)
- virtual void deactivateSubShapesSelection() = 0;
-
//! Returns instance of loaded module
virtual ModuleBase_IModule* module() const = 0;
/// \return a filter
Handle(ModuleBase_FilterValidated) validatorFilter();
+ /// A selection activate in 3D View handler
+ virtual ModuleBase_ISelectionActivate* selectionActivate() const = 0;
+
//! Returns currently active operation
virtual ModuleBase_Operation* currentOperation() const = 0;
//#define DEBUG_WIDGET_INSTANCE
//#define DEBUG_ENABLE_SKETCH_INPUT_FIELDS
+//**************************************************************
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
const Config_WidgetAPI* theData)
: QWidget(theParent),
connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
}
+//**************************************************************
ModuleBase_ModelWidget::~ModuleBase_ModelWidget()
{
#ifdef DEBUG_WIDGET_INSTANCE
#endif
}
+//**************************************************************
bool ModuleBase_ModelWidget::reset()
{
bool aResult = resetCustom();
return aResult;
}
+//**************************************************************
bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
{
return theObject->data()->attribute(attributeID())->isInitialized();
}
+//**************************************************************
+void ModuleBase_ModelWidget::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+ isAdditional = true;
+ if (myWidgetValidator)
+ myWidgetValidator->selectionModes(theModes, isAdditional);
+}
+
+//**************************************************************
+void ModuleBase_ModelWidget::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ if (myWidgetValidator)
+ myWidgetValidator->selectionFilters(theSelectionFilters);
+}
+
+//**************************************************************
bool ModuleBase_ModelWidget::isValueEnabled() const
{
bool anEnabled = true;
return anEnabled;
}
+//**************************************************************
void ModuleBase_ModelWidget::processValueState()
{
if (myState == ModifiedInPP || myState == ModifiedInViewer)
storeValue();
}
+//**************************************************************
Events_InfoMessage ModuleBase_ModelWidget::getValueStateError() const
{
Events_InfoMessage aMessage;
return aMessage;
}
+//**************************************************************
QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
{
QString anError;
return anError;
}
+//**************************************************************
void ModuleBase_ModelWidget::enableFocusProcessing()
{
QList<QWidget*> aMyControls = getControls();
}
}
+//**************************************************************
void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
{
QList<QWidget*> aWidgetList = getControls();
}
}
+//**************************************************************
void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue,
const bool isUpdateFlushed)
{
myFlushUpdateBlocked = false;
}
+//**************************************************************
bool ModuleBase_ModelWidget::focusTo()
{
#ifdef DEBUG_WIDGET_INSTANCE
return isFocusAccepted;
}
+//**************************************************************
void ModuleBase_ModelWidget::activate()
{
#ifdef DEBUG_WIDGET_INSTANCE
if (anAttribute.get() != NULL && !anAttribute->isInitialized())
initializeValueByActivate();
}
-
- if (myWidgetValidator)
- myWidgetValidator->activateFilters(true);
-
activateCustom();
}
+//**************************************************************
void ModuleBase_ModelWidget::deactivate()
{
#ifdef DEBUG_WIDGET_INSTANCE
myIsValueStateBlocked = false;
myState = Stored;
if (myWidgetValidator)
- myWidgetValidator->activateFilters(false);
+ myWidgetValidator->clearValidatedCash();
}
+//**************************************************************
void ModuleBase_ModelWidget::initializeValueByActivate()
{
if (isComputedDefault()) {
}
}
+//**************************************************************
QWidget* ModuleBase_ModelWidget::getControlAcceptingFocus(const bool isFirst)
{
QWidget* aControl = 0;
return aControl;
}
+//**************************************************************
void ModuleBase_ModelWidget::setDefaultValue(const std::string& theValue)
{
myDefaultValue = theValue;
}
+//**************************************************************
bool ModuleBase_ModelWidget::storeValue()
{
setValueState(Stored);
return isDone;
}
#ifdef DEBUG_VALUE_STATE
+
+//**************************************************************
std::string getDebugInfo(const ModuleBase_ModelWidget::ValueState& theState)
{
std::string anInfo;
}
return anInfo;
}
-
#endif
+
+//**************************************************************
ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState
(const ModuleBase_ModelWidget::ValueState& theState)
{
return aState;
}
+//**************************************************************
bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
{
bool isBlocked = myIsValueStateBlocked;
return isBlocked;
}
+//**************************************************************
bool ModuleBase_ModelWidget::restoreValue()
{
emit beforeValuesRestored();
return isDone;
}
+//**************************************************************
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
{
if (!myFlushUpdateBlocked) {
}
}
+//**************************************************************
bool ModuleBase_ModelWidget::canProcessAction(ModuleBase_ActionType theActionType,
bool& isActionEnabled)
{
case ActionEnter: return false;
case ActionEscape: return false;
case ActionDelete: return true;
+ case ActionSelection: return true;
case ActionUndo:
case ActionRedo:
default:
}
}
+//**************************************************************
bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
const ActionParamPtr& theParam)
{
return processEscape();
case ActionDelete:
return processDelete();
+ case ActionSelection:
+ processSelection();
case ActionUndo:
case ActionRedo:
default:
}
}
+//**************************************************************
bool ModuleBase_ModelWidget::processEnter()
{
return false;
}
+//**************************************************************
bool ModuleBase_ModelWidget::processEscape()
{
return false;
}
+//**************************************************************
bool ModuleBase_ModelWidget::processDelete()
{
// we consider that model objects eats delete key in order to
return true;
}
+//**************************************************************
+bool ModuleBase_ModelWidget::processSelection()
+{
+ return false;
+}
+
+//**************************************************************
bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
{
QWidget* aWidget = qobject_cast<QWidget*>(theObject);
#include <ModuleBase.h>
#include <ModuleBase_ActionType.h>
+#include <ModuleBase_Definitions.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ActionInfo.h>
#include <ModuleBase_ActionParameter.h>
#include <ModelAPI_Feature.h>
+#include <SelectMgr_ListOfFilter.hxx>
+
#include <QWidget>
#include <memory>
/// \return the boolean result
bool isInitialized(ObjectPtr theObject) const;
+ /// Fills given container with selection modes if the widget has it
+ /// \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
/// Returns true, if default value of the widget should be computed
/// on operation's execute, like radius for circle's constraint (can not be zero)
bool isComputedDefault() const { return myIsComputedDefault; }
//// Returns true if the event is processed. The default implementation is empty, returns false.
virtual bool processDelete();
-protected slots:
+ /// Returns true if envent is processed. It applyes workshop selection for the widget attribute.
+ virtual bool processSelection();
+
+ protected slots:
/// Processing of values changed in model widget by store the current value to the feature
void onWidgetValuesChanged();
}
//********************************************************************
-void ModuleBase_WidgetFeatureSelector::deactivate()
+void ModuleBase_WidgetFeatureSelector::selectionModes(QIntList& theModes, bool& isAdditional)
{
- ModuleBase_ModelWidget::deactivate();
- activateFilters(false);
- myWorkshop->deactivateSubShapesSelection();
-}
-
-//********************************************************************
-bool ModuleBase_WidgetFeatureSelector::processAction(ModuleBase_ActionType theActionType,
- const ActionParamPtr& theParam)
-{
- if (theActionType == ActionSelection)
- onSelectionChanged();
- else
- return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
-
- return true;
+ theModes.push_back(ModuleBase_ResultPrs::Sel_Result);
+ isAdditional = true;
}
//********************************************************************
void ModuleBase_WidgetFeatureSelector::activateCustom()
{
- activateFilters(true);
-
- QIntList aShapeTypes;
- aShapeTypes.push_back(ModuleBase_ResultPrs::Sel_Result);
- myWorkshop->activateSubShapesSelection(aShapeTypes);
-
// Restore selection in the viewer by the attribute selection list
// it should be postponed to have current widget as active to validate restored selection
//static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
}
//********************************************************************
-void ModuleBase_WidgetFeatureSelector::onSelectionChanged()
+bool ModuleBase_WidgetFeatureSelector::processSelection()
{
QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
ModuleBase_ISelection::AllControls);
bool isDone = setSelection(aSelected, true/*false*/);
updateOnSelectionChanged(isDone);
+
+ return isDone;
}
//********************************************************************
virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
+ /// Fills given container with selection modes if the widget has it
+ /// \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
/// \param thePrs a selected owner
virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
- /// The method called when widget is deactivated
- virtual void deactivate();
-
- /// Processes Selection action.
- virtual bool processAction(ModuleBase_ActionType theActionType,
- const ActionParamPtr& theParam = ActionParamPtr());
-
protected:
/// The method called when widget is activated
virtual void activateCustom();
virtual void updateOnSelectionChanged(const bool theDone);
protected:
- /// Called on selection changed event
- virtual void onSelectionChanged();
+ /// Returns true if envent is processed.
+ virtual bool processSelection();
//----------- Class members -------------
protected:
#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_ActionIntParameter.h>
#include <ModuleBase_Definitions.h>
#include <ModuleBase_Events.h>
#include <ModuleBase_IconFactory.h>
#include <ModuleBase_IModule.h>
#include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ListView.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_WidgetShapeSelector.h>
-#include <ModuleBase_ActionIntParameter.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
}
break;
default:
+ aCanProcess = ModuleBase_WidgetSelector::canProcessAction(theActionType, isActionEnabled);
break;
}
return aCanProcess;
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::activateSelectionAndFilters(bool toActivate)
+void ModuleBase_WidgetMultiSelector::activateSelectionAndFilters(bool toActivate)
{
myWorkshop->updateCommandStatus(); // update enable state of Undo/Redo application actions
- return ModuleBase_WidgetSelector::activateSelectionAndFilters(toActivate);
+ ModuleBase_WidgetSelector::activateSelectionAndFilters(toActivate);
}
//********************************************************************
void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
{
activateSelectionAndFilters(true);
+ myWorkshop->selectionActivate()->updateSelectionModes();
if (!myFeature)
return;
}
//********************************************************************
-void ModuleBase_WidgetMultiSelector::onSelectionChanged()
+bool ModuleBase_WidgetMultiSelector::processSelection()
{
if (!myIsNeutralPointClear) {
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
Events_Loop::loop()->flush(anEvent);
- return;
+ return true;
}
}
}
appendFirstSelectionInHistory();
- ModuleBase_WidgetSelector::onSelectionChanged();
+ bool aDone = ModuleBase_WidgetSelector::processSelection();
appendSelectionInHistory();
+ return aDone;
}
void ModuleBase_WidgetMultiSelector::appendFirstSelectionInHistory()
aShapeTypeName = myTypeCombo->itemText(idx);
int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
- bool aWasActivated = activateSelectionAndFilters(false);
+ activateSelectionAndFilters(false);
bool isBlocked = myTypeCombo->blockSignals(true);
myTypeCombo->setCurrentIndex(idx);
myTypeCombo->blockSignals(isBlocked);
- if (aWasActivated)
- activateSelectionAndFilters(true);
+ activateSelectionAndFilters(true);
break;
}
}
const ActionParamPtr& theParam = ActionParamPtr());
/// Activate or deactivate selection and selection filters
- /// \return true if the selection filter of the widget is activated in viewer context
- virtual bool activateSelectionAndFilters(bool toActivate);
+ virtual void activateSelectionAndFilters(bool toActivate);
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// Slot is called on selection type changed
void onSelectionTypeChanged();
- /// Slot which is called on selection event. Redefined to process XML state about
- /// clear selection in neutral point
- virtual void onSelectionChanged();
+protected:
+ /// Returns true if envent is processed.
+ /// Redefined to process XML state about clear selection in neutral point
+ virtual bool processSelection();
protected slots:
/// Slot for delete command in a list pop-up menu
#include <ModuleBase_WidgetSelector.h>
+#include <ModuleBase_Events.h>
+#include <ModuleBase_IModule.h>
#include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_Tools.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetFactory.h>
-#include <ModuleBase_IModule.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_Tools.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Events.h>
+#include <ModuleBase_WidgetFactory.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_Events.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultConstruction.h>
#include <TopoDS_Iterator.hxx>
}
//********************************************************************
-void ModuleBase_WidgetSelector::onSelectionChanged()
+bool ModuleBase_WidgetSelector::processSelection()
{
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
// equal vertices should not be used here
bool isDone = setSelection(aSelected, true/*false*/);
updateOnSelectionChanged(isDone);
+
+ return isDone;
}
//********************************************************************
}
//********************************************************************
-bool ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate)
+void ModuleBase_WidgetSelector::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+ theModes.append(getShapeTypes());
+ isAdditional = true;
+}
+
+//********************************************************************
+void ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate)
{
updateSelectionName();
- if (toActivate) {
- myWorkshop->activateSubShapesSelection(getShapeTypes());
- } else {
- myWorkshop->deactivateSubShapesSelection();
- }
- return activateFilters(toActivate);
+ myWorkshop->selectionActivate()->updateSelectionFilters();
+ myWorkshop->selectionActivate()->updateSelectionModes();
+
+ if (!toActivate)
+ clearValidatedCash();
}
//********************************************************************
void ModuleBase_WidgetSelector::activateCustom()
{
- connect(myWorkshop, SIGNAL(selectionChanged()), this,
- SLOT(onSelectionChanged()), Qt::UniqueConnection);
-
- activateSelectionAndFilters(true);
-
// Restore selection in the viewer by the attribute selection list
// it should be postponed to have current widget as active to validate restored selection
static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
//********************************************************************
void ModuleBase_WidgetSelector::deactivate()
{
- ModuleBase_ModelWidget::deactivate();
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- activateSelectionAndFilters(false);
-
+ ModuleBase_WidgetValidated::deactivate();
/// clear temporary cash
AttributePtr anAttribute = attribute();
if (!anAttribute.get())
virtual ~ModuleBase_WidgetSelector();
+ /// Fills given container with selection modes if the widget has it
+ /// \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
/// Defines if it is supposed that the widget should interact with the viewer.
virtual bool isViewerSelector() { return true; }
/// Activate or deactivate selection and selection filters
- /// \return true if the selection filter of the widget is activated in viewer context
- virtual bool activateSelectionAndFilters(bool toActivate);
+ virtual void activateSelectionAndFilters(bool toActivate);
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// a shape. If the attribute do not uses the shape, it is empty
virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
-protected slots:
- /// Slot which is called on selection event
- virtual void onSelectionChanged();
-
protected:
+ /// Returns true if envent is processed. The default implementation is empty, returns false.
+ virtual bool processSelection();
+
/// Emits model changed info, updates the current control by selection change
/// \param theDone a state whether the selection is set
virtual void updateOnSelectionChanged(const bool theDone);
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <ModuleBase_WidgetSelectorStore.h>
#include <ModuleBase_ViewerPrs.h>
return myPresentedObject;
}
+//********************************************************************
+void ModuleBase_WidgetValidated::deactivate()
+{
+ clearValidatedCash();
+}
+
//********************************************************************
void ModuleBase_WidgetValidated::clearValidatedCash()
{
// the widget validator filter should be active, but during check by preselection
// it is not yet activated, so we need to activate/deactivate it manually
bool isActivated = isFilterActivated();
- if (!isActivated)
- activateFilters(true);
+ if (!isActivated) {
+ SelectMgr_ListOfFilter aSelectionFilters;
+ selectionFilters(aSelectionFilters);
+ /// after validation, the selection filters should be restored
+ myWorkshop->selectionActivate()->activateSelectionFilters(aSelectionFilters);
+ }
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull()) {
}
}
if (!isActivated)
- activateFilters(false);
+ {
+ myWorkshop->selectionActivate()->updateSelectionFilters();
+ clearValidatedCash();
+ }
}
// removes created owner
return aFactory->validate(theAttribute, aValidatorID, anError);
}
+//********************************************************************
bool ModuleBase_WidgetValidated::isFilterActivated() const
{
bool isActivated = false;
return aViewer->hasSelectionFilter(aSelFilter);
}
-bool ModuleBase_WidgetValidated::activateFilters(const bool toActivate)
+//********************************************************************
+void ModuleBase_WidgetValidated::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
{
- ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-
- Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter();
- bool aHasSelectionFilter = aViewer->hasSelectionFilter(aSelFilter);
-
- if (toActivate)
- aViewer->addSelectionFilter(aSelFilter);
- else {
- aViewer->removeSelectionFilter(aSelFilter);
- clearValidatedCash();
- }
-
- return aHasSelectionFilter;
+ theSelectionFilters.Append(myWorkshop->validatorFilter());
}
//********************************************************************
//! Returns data object by AIS
ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
+ /// The method called when widget is deactivated
+ virtual void deactivate();
+
//! Clear all validated cash in the widget
void clearValidatedCash();
/// \return boolean value
bool isFilterActivated() const;
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
/// Block the model flush of update and intialization of attribute
/// \param theAttribute an attribute of blocking
/// \param theFeature a feature
/// \return a list of presentations
QList<std::shared_ptr<ModuleBase_ViewerPrs>> getFilteredSelected();
- /// It obtains selection filters from the workshop and activates them in the active viewer
- /// \param toActivate a flag about activation or deactivation the filters
- /// \return true if the selection filter of the widget is activated in viewer context
- bool activateFilters(const bool toActivate);
-
/// Block the model flush of update and intialization of attribute
/// \param theAttribute an attribute of blocking
/// \param theToBlock flag whether the model is blocked or unblocked
delete myAttributeStore;
}
+//********************************************************************
+void ModuleBase_WidgetValidator::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ theSelectionFilters.Append(myWorkshop->validatorFilter());
+}
+
//********************************************************************
bool ModuleBase_WidgetValidator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
{
return aValid;
}
-bool ModuleBase_WidgetValidator::activateFilters(const bool toActivate)
-{
- ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-
- Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter();
- bool aHasSelectionFilter = aViewer->hasSelectionFilter(aSelFilter);
-
- if (toActivate)
- aViewer->addSelectionFilter(aSelFilter);
- else {
- aViewer->removeSelectionFilter(aSelFilter);
- clearValidatedCash();
- }
-
- return aHasSelectionFilter;
-}
-
void ModuleBase_WidgetValidator::storeAttributeValue(const AttributePtr& theAttribute)
{
myIsInValidate = true;
#ifndef ModuleBase_WidgetValidator_H_
#define ModuleBase_WidgetValidator_H_
-#include <ModuleBase.h>
+#include "ModuleBase.h"
+
+#include "ModuleBase_Definitions.h"
+
+#include <SelectMgr_ListOfFilter.hxx>
#include <QList>
#include <memory>
ModuleBase_IWorkshop* theWorkshop);
virtual ~ModuleBase_WidgetValidator();
+ /// Fills given container with selection modes if the widget has it
+ /// \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional) {}
+
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
/// Returns true if the validation is activated
bool isInValidate() const { return myIsInValidate; }
/// \return a boolean value
virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
- /// It obtains selection filters from the workshop and activates them in the active viewer
- /// \param toActivate a flag about activation or deactivation the filters
- /// \return true if the selection filter of the widget is activated in viewer context
- bool activateFilters(const bool toActivate);
-
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// parameters of the current attribute
/// \return true if all validators return that the attribute is valid
bool isValidAttribute(const std::shared_ptr<ModelAPI_Attribute>& theAttribute) const;
+ //! Clear all validated cash in the widget
+ void clearValidatedCash();
+
private:
/// Returns true if the workshop validator filter has been already activated
/// \return boolean value
bool isFilterActivated() const;
- //! Clear all validated cash in the widget
- void clearValidatedCash();
-
/// Gets the validity state of the presentation in an internal map.
/// Returns true if the valid state of value is stored
/// \param theValue a viewer presentation
#include <XGUI_Tools.h>
#include <XGUI_Displayer.h>
#include <XGUI_Workshop.h>
+#include <XGUI_SelectionActivate.h>
#include <XGUI_SelectionMgr.h>
PartSet_ExternalPointsMgr::PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
myPresentations[aPrs->object()] = aList;
foreach(AISObjectPtr anAIS, aList) {
aDisplayer->displayAIS(anAIS, false);
- aDisplayer->activateAIS(anAIS->impl<Handle(AIS_InteractiveObject)>(), TopAbs_VERTEX, false);
+ aWorkshop->selectionActivate()->activateAIS(anAIS->impl<Handle(AIS_InteractiveObject)>(),
+ TopAbs_VERTEX, false);
}
}
}
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <ModuleBase_WidgetChoice.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_WidgetValidated.h>
return new PartSet_Module(theWshop);
}
+//******************************************************
PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
: ModuleBase_IModule(theWshop),
myVisualLayerId(0),
"0.8");
}
+//******************************************************
PartSet_Module::~PartSet_Module()
{
SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
delete myOverconstraintListener;
}
-void PartSet_Module::activateSelectionFilters()
-{
- SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
- for (; aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = aIt.Value();
- if (!aFilter.IsNull())
- myWorkshop->viewer()->addSelectionFilter(aFilter);
- }
-}
-
-void PartSet_Module::deactivateSelectionFilters()
-{
- SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
- for (; aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = aIt.Value();
- if (!aFilter.IsNull())
- myWorkshop->viewer()->removeSelectionFilter(aFilter);
- }
-}
-
-void PartSet_Module::updateActiveSelectionFilters()
-{
- XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(workshop());
- XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
-
- if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
- sketchMgr()->deactivateSelectionFilters();
- else
- sketchMgr()->activateSelectionFilters();
-}
-
+//******************************************************
void PartSet_Module::storeSelection()
{
// cash is used only to restore selection, so it should be filled in storeSelection and
sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
}
+//******************************************************
void PartSet_Module::restoreSelection()
{
// cash is used only to restore selection, so it should be filled in storeSelection and
myCurrentSelection.clear();
}
+//******************************************************
void PartSet_Module::registerValidators()
{
//Registering of validators
aFactory->registerValidator("PartSet_ProjectionSelection", new PartSet_ProjectionSelection);
}
+//******************************************************
void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget,
const bool isToConnect)
{
mySketchMgr->connectToPropertyPanel(theWidget, isToConnect);
}
+//******************************************************
void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
{
if (sketchMgr()->isNestedSketchOperation(theOperation)) {
}
}
+//******************************************************
void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
{
/// Restart sketcher operations automatically
overconstraintListener()->setActive(false);
}
+//******************************************************
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
}
}
+//******************************************************
void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
{
if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
}
}
+//******************************************************
void PartSet_Module::updatePresentationsOnStart(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation =
}
}
+//******************************************************
void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
{
ModuleBase_IModule::operationResumed(theOperation);
}
}
+//******************************************************
void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
bool isModifiedArgs = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeArguments, false);
}
}
+//******************************************************
ModuleBase_Operation* PartSet_Module::currentOperation() const
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
return anOpMgr->currentOperation();
}
+//******************************************************
bool PartSet_Module::canUndo() const
{
bool aCanUndo = false;
return aCanUndo;
}
+//******************************************************
bool PartSet_Module::canRedo() const
{
bool aCanRedo = false;
return aCanRedo;
}
+//******************************************************
bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const
{
bool aValid = true;
return aValid;
}
+//******************************************************
bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const
{
// the sketch manager put the restriction to the objects erase
return mySketchMgr->canEraseObject(theObject);
}
+//******************************************************
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
// the sketch manager put the restriction to the objects display
return mySketchMgr->canDisplayObject(theObject);
}
+//******************************************************
bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
const QString& theStartedOperationKind)
{
mySketchMgr->processHiddenObject(theObjects);
}*/
+//******************************************************
bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
{
bool aCanActivate = ModuleBase_IModule::canActivateSelection(theObject);
return aCanActivate;
}
+//******************************************************
+void PartSet_Module::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
+{
+ for (SelectMgr_ListOfFilter::Iterator aFiltersIt(mySelectionFilters); aFiltersIt.More();
+ aFiltersIt.Next())
+ theSelectionFilters.Append(aFiltersIt.Value());
+
+ if (mySketchMgr->activeSketch())
+ mySketchMgr->selectionFilters(theSelectionFilters);
+}
+
+//******************************************************
bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
QWidget* theParent,
QMap<int, QAction*>& theMenuActions) const
return myMenuMgr->addViewerMenu(theStdActions, theParent, theMenuActions);
}
+//******************************************************
void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
{
myMenuMgr->updateViewerMenu(theStdActions);
}
+//******************************************************
bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
{
bool isEnabledFixed = false;
return isEnabledFixed;
}
+//******************************************************
QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
{
QString anError = ModuleBase_IModule::getFeatureError(theFeature);
return anError;
}
+//******************************************************
void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation,
QStringList& theIds) const
{
}
}
+//******************************************************
void PartSet_Module::activeSelectionModes(QIntList& theModes)
{
- theModes.clear();
if (mySketchMgr->activeSketch().get())
- PartSet_SketcherMgr::sketchSelectionModes(theModes);
+ PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
+ else
+ theModes = XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes();
}
-void PartSet_Module::customSubShapesSelectionModes(QIntList& theTypes)
+//******************************************************
+void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes)
{
- if (theTypes.contains(TopAbs_FACE))
- theTypes.append(SketcherPrs_Tools::Sel_Sketch_Face);
- if (theTypes.contains(TopAbs_WIRE))
- theTypes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
+ if (theModes.contains(TopAbs_FACE))
+ theModes.append(SketcherPrs_Tools::Sel_Sketch_Face);
+ if (theModes.contains(TopAbs_WIRE))
+ theModes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
+
+ if (mySketchMgr->activeSketch().get())
+ PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
}
+//******************************************************
void PartSet_Module::getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelected,
ObjectPtr& theObject, AttributePtr& theAttribute)
{
theObject = anObject;
}
+//******************************************************
bool PartSet_Module::isMouseOverWindow()
{
return mySketchMgr->isMouseOverWindow();
}
+//******************************************************
bool PartSet_Module::isSketchNeutralPointActivated() const
{
bool isNeutralPoint = true;
return isNeutralPoint;
}
+//******************************************************
void PartSet_Module::closeDocument()
{
myActivePartIndex = QModelIndex();
}
+//******************************************************
void PartSet_Module::clearViewer()
{
myCustomPrs->clearPrs();
XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
- aDisplayer->deactivateSelectionFilters();
+ aDisplayer->deactivateSelectionFilters(false);
}
+//******************************************************
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation =
aPanel->activateWidget(aPanel->modelWidgets().first());
}
+//******************************************************
bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
QList<ModuleBase_ModelWidget*>& theWidgets) const
{
return aProcessed;
}
+//******************************************************
void PartSet_Module::onSelectionChanged()
{
ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
}
}
+//******************************************************
void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
anOpMgr->onKeyReleased(theWnd->viewPort(), theEvent);
}
+//******************************************************
ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType,
QWidget* theParent,
Config_WidgetAPI* theWidgetApi)
return aWgt;
}
+//******************************************************
ModuleBase_ModelWidget* PartSet_Module::activeWidget() const
{
ModuleBase_ModelWidget* anActiveWidget = 0;
return anActiveWidget;
}
+//******************************************************
bool PartSet_Module::deleteObjects()
{
bool isProcessed = false;
return isProcessed;
}
+//******************************************************
void PartSet_Module::editFeature(FeaturePtr theFeature)
{
storeConstraintsState(theFeature->getKind());
ModuleBase_IModule::editFeature(theFeature);
}
+//******************************************************
bool PartSet_Module::canCommitOperation() const
{
return true;
}
+//******************************************************
void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
{
myIsOperationIsLaunched = true;
myIsOperationIsLaunched = false;
}
+//******************************************************
void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind)
{
if (myWorkshop->currentOperation() &&
}
}
+//******************************************************
void PartSet_Module::updateConstraintsState(const std::string& theFeatureKind)
{
if (PartSet_SketcherMgr::constraintsIdList().contains(theFeatureKind.c_str()) ||
}
}
+//******************************************************
void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
{
Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
}
}
+//******************************************************
void PartSet_Module::onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS)
{
// this is obsolete
// myCustomPrs->redisplay(theObject, false);
}
+//******************************************************
void PartSet_Module::onViewTransformed(int theTrsfType)
{
// Set length of arrows constant in pixel size
}
}
+//******************************************************
bool PartSet_Module::isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const
{
return myCustomPrs->isActive(theFlag);
}
+//******************************************************
void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature,
const ModuleBase_CustomizeFlag& theFlag,
const bool theUpdateViewer)
myCustomPrs->activate(theFeature, theFlag, theUpdateViewer);
}
+//******************************************************
void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
const bool theUpdateViewer)
{
myCustomPrs->deactivate(theFlag, theUpdateViewer);
}
+//******************************************************
bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
{
return aCustomized;
}
+//******************************************************
bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
AISObjectPtr thePrs,
GeomCustomPrsPtr theCustomPrs)
return aCustomized;
}
+//******************************************************
bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
const bool theUpdateViewer)
{
return isRedisplayed;
}
+//******************************************************
void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
{
XGUI_ObjectsBrowser* aOB = dynamic_cast<XGUI_ObjectsBrowser*>(theObjectBrowser);
}
}
+//******************************************************
void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
{
SessionPtr aMgr = ModelAPI_Session::get();
aMenu.exec(aHeader->mapToGlobal(thePnt));
}
+//******************************************************
Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult)
{
return mySketchMgr->createPresentation(theResult);
}
-
+//******************************************************
ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
{
ObjectPtr anObject;
return anObject;
}
+//******************************************************
bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
{
bool aCanBeShaged = true;
return aCanBeShaged;
}
+//******************************************************
void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
{
QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
}
}
+//******************************************************
#define EXPAND_PARENT(OBJ) \
QModelIndex aObjIndex = aDataModel->objectIndex(OBJ); \
if (aObjIndex.isValid()) { \
aTreeView->setExpanded(aParent, true); \
}
-
+//******************************************************
void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
{
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
}
}
+//******************************************************
void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
{
if (myWorkshop->currentOperation()) // Do not change activation of parts if an operation active
}
}
-
+//******************************************************
void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
{
// z layer is created for all started operations in order to visualize operation AIS presentation
}
// if there is an active operation with validated widget,
// the filters of this widget should be activated in the created view
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
- if (aOperation) {
- ModuleBase_ModelWidget* anActiveWidget = activeWidget();
- if (anActiveWidget) {
- ModuleBase_WidgetSelector* aWSelector =
- dynamic_cast<ModuleBase_WidgetSelector*>(anActiveWidget);
- if (aWSelector)
- aWSelector->activateSelectionAndFilters(true);
- }
- }
+ myWorkshop->selectionActivate()->updateSelectionFilters();
+ myWorkshop->selectionActivate()->updateSelectionModes();
}
//******************************************************
mySketchMgr->widgetStateChanged(thePreviousState);
}
+//******************************************************
bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID)
{
return mySketchReentrantMgr->processEnter(thePreviousAttributeID);
PartSet_Module(ModuleBase_IWorkshop* theWshop);
virtual ~PartSet_Module();
- // Add default selection filters of the module to the current viewer
- virtual void activateSelectionFilters();
- // Remove default selection filters of the module from the current viewer
- virtual void deactivateSelectionFilters();
- /// Update selection filters depending on the module active controls
- virtual void updateActiveSelectionFilters();
-
// Stores the current selection
virtual void storeSelection();
/// \param theObject a model object
virtual bool canActivateSelection(const ObjectPtr& theObject) const;
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const;
+
/// Add menu atems for object browser into the given menu
/// \param theMenu a popup menu to be shown in the object browser
virtual void addObjectBrowserMenu(QMenu* theMenu) const;
virtual void activeSelectionModes(QIntList& theModes);
/// Appends specific selection modes for the module to the list of types
- /// \param theTypes a selection modes to be extended
- virtual void customSubShapesSelectionModes(QIntList& theTypes);
+ /// \param theModes a selection modes to be extended
+ virtual void customSubShapesSelectionModes(QIntList& theModes);
/// Returns whether the mouse enter the viewer's window
/// \return true if items are added and there is no necessity to provide standard menu
#include <XGUI_Workshop.h>
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Selection.h>
+#include <XGUI_SelectionActivate.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
return aConstraintIds;
}
-void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
+void PartSet_SketcherMgr::sketchSelectionModes(const CompositeFeaturePtr& theSketch,
+ QIntList& theModes)
{
- theModes.clear();
+ if (!theSketch.get() || !PartSet_Tools::sketchPlane(theSketch).get())
+ return;
theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
myPlaneFilter->setPlane(aPln);
- activateSelectionFilters();
+ workshop()->selectionActivate()->updateSelectionFilters();
+ workshop()->selectionActivate()->updateSelectionModes();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- // all displayed objects should be activated in current selection modes according to switched
- // plane filter
- if (aPln.get())
- aConnector->activateModuleSelectionModes();
myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
}
Events_Loop::loop()->flush(aDispEvent);
}
- deactivateSelectionFilters();
-
- // restore the module selection modes, which were changed on startSketch
- aConnector->activateModuleSelectionModes();
+ workshop()->selectionActivate()->updateSelectionFilters();
+ workshop()->selectionActivate()->updateSelectionModes();
}
void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
}
}
-void PartSet_SketcherMgr::activateSelectionFilters()
-{
- myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
-}
-
-void PartSet_SketcherMgr::deactivateSelectionFilters()
+void PartSet_SketcherMgr::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
{
- myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
+ theSelectionFilters.Append(myCirclePointFilter);
+ theSelectionFilters.Append(myPlaneFilter);
}
void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
myPlaneFilter->setPlane(thePln);
+ workshop()->selectionActivate()->updateSelectionModes();
}
bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation,
#include <ModuleBase_ModelWidget.h>
#include <GeomAPI_Pln.h>
+
#include <SelectMgr_IndexedMapOfOwner.hxx>
+#include <SelectMgr_ListOfFilter.hxx>
+
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
/// \param theOperation a committed operation
void commitNestedSketch(ModuleBase_Operation* theOperation);
- /// Append the sketch selection filters in 3D viewer (plane and circle pointer)
- void activateSelectionFilters();
-
- // Remove sketch selection filter from the current viewer
- virtual void deactivateSelectionFilters();
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const;
/// Append the sketch plane filter into the current viewer
/// \param toActivate state whether the filter should be activated/deactivated
static const QStringList& constraintsIdList();
/// Returns a list of modes, where the AIS objects should be activated
+ /// \param theSketch a sketch object, modes are empty if sketch plane is not defined yet
/// \param theModes a list of modes
- static void sketchSelectionModes(QIntList& theModes);
+ static void sketchSelectionModes(const CompositeFeaturePtr& theSketch, QIntList& theModes);
/// Create specific for the module presentation
/// \param theResult an object for presentation
#include "GeomDataAPI_Point2D.h"
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ModelWidget.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_OperationDescription.h>
#include "ModuleBase_ToolBox.h"
#include "ModuleBase_ISelection.h"
+#include "ModuleBase_ISelectionActivate.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Line.h>
ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
if (aFirstWidget != aPanel->activeWidget()) {
ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
- if (aWSelector)
- aWSelector->activateSelectionAndFilters(true);
+ if (aWSelector) {
+ myWorkshop->selectionActivate()->activateSelectionAndFilters(aWSelector);
+ }
}
}
ModuleBase_WidgetSelector* aWSelector =
dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
if (aWSelector)
- aWSelector->activateSelectionAndFilters(false);
+ myWorkshop->selectionActivate()->activateSelectionAndFilters(aWSelector);
myInternalActiveWidget = 0;
}
delete myInternalWidget;
}
//********************************************************************
-bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActivate)
+void PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActivate)
{
#ifdef HIGHLIGHT_STAYS_PROBLEM
Handle(AIS_InteractiveContext) aContext =
#endif
- return ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
+ ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
}
//********************************************************************
/// Activate or deactivate selection and selection filters
/// \return true if the selection filter of the widget is activated in viewer context
- virtual bool activateSelectionAndFilters(bool toActivate);
+ virtual void activateSelectionAndFilters(bool toActivate);
/// Set sketcher
/// \param theSketch a sketcher object
return aControls;
}
+//********************************************************************
+void PartSet_WidgetPoint2D::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+ theModes << TopAbs_VERTEX;
+ theModes << TopAbs_EDGE;
+ isAdditional = true;
+}
+//********************************************************************
void PartSet_WidgetPoint2D::activateCustom()
{
- QIntList aModes;
- aModes << TopAbs_VERTEX;
- aModes << TopAbs_EDGE;
- myWorkshop->activateSubShapesSelection(aModes);
-
if (!isEditingMode()) {
FeaturePtr aFeature = feature();
if (aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID())
storeValue();
ModuleBase_ModelWidget::deactivate();
- myWorkshop->deactivateSubShapesSelection();
}
bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
/// Destructor
virtual ~PartSet_WidgetPoint2D();
+ /// Fills given container with selection modes if the widget has it
+ /// \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
/// Checks if the selection presentation is valid in widget
/// \param theValue a selected presentation in the view
/// \return a boolean value
}
//********************************************************************
-bool PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
+void PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
{
- bool aHasSelectionFilter = ModuleBase_WidgetShapeSelector::activateSelectionAndFilters
- (toActivate);
+ ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
if (!myUseSketchPlane) {
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(aWorkshop->module());
bool isUsePlaneFilterOnly = !toActivate;
aModule->sketchMgr()->activatePlaneFilter(isUsePlaneFilterOnly);
}
- return aHasSelectionFilter;
}
//********************************************************************
/// Activate or deactivate selection and selection filters
/// \param toActivate boolean state whether it should be activated/deactivated
- virtual bool activateSelectionAndFilters(bool toActivate);
+ virtual void activateSelectionAndFilters(bool toActivate);
protected:
/// Checks the widget validity. By default, it returns true.
}
//********************************************************************
-void PartSet_WidgetSketchCreator::onSelectionChanged()
+bool PartSet_WidgetSketchCreator::processSelection()
{
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
bool isDone = setSelection(aSelected, true/*false*/);
+
+ return isDone;
}
//********************************************************************
/// \param theDone a state whether the selection is set
void updateOnSelectionChanged(const bool theDone);
-protected slots:
- /// Slot which is called on selection event
- virtual void onSelectionChanged();
+protected:
+ /// Returns true if envent is processed.
+ virtual bool processSelection();
private:
/// Returns true if the selection mode is active. This is when composition feature has no
#include "SketchPlugin_SketchEntity.h"
-#include <XGUI_Workshop.h>
+#include <XGUI_ActionsMgr.h>
#include <XGUI_Displayer.h>
-#include <XGUI_SelectionMgr.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_SelectionActivate.h>
#include <XGUI_Selection.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ActionsMgr.h>
+#include <XGUI_SelectionMgr.h>
#include <XGUI_Tools.h>
-#include <XGUI_ModuleConnector.h>
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_Workshop.h>
+
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Tools.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IModule.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_Tools.h>
-
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomDataAPI_Point.h>
return aResult;
}
-void PartSet_WidgetSketchLabel::onSelectionChanged()
+bool PartSet_WidgetSketchLabel::processSelection()
{
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
if (aPlane.get())
- return;
+ return false;
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
if (aSelected.empty())
- return;
+ return false;
ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
bool aDone = setSelectionInternal(aSelected, false);
if (aDone) {
updateByPlaneSelected(aPrs);
updateObject(myFeature);
}
+
+ return aDone;
}
void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn)
//myLabel->setText("");
//myLabel->setToolTip("");
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
- // 4. deactivate face selection filter
- activateFilters(false);
// 5. Clear selection mode and define sketching mode
emit planeSelected(plane());
// after the plane is selected in the sketch, the sketch selection should be activated
// it can not be performed in the sketch label widget because, we don't need to switch off
// the selection by any label deactivation, but need to switch it off by stop the sketch
- activateSelection(true);
+ myWorkshop->selectionActivate()->updateSelectionFilters();
+ myWorkshop->selectionActivate()->updateSelectionModes();
// 6. Update sketcher actions
XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
return aCanFillSketch;
}
-//********************************************************************
-bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType,
- const ActionParamPtr& theParam)
-{
- if (theActionType == ActionSelection)
- onSelectionChanged();
- else
- return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
-
- return true;
-}
-
bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool isOwnerSet = false;
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
if (aPlane.get()) {
myStackWidget->setCurrentIndex(1);
- activateSelection(true);
return;
}
// Clear previous selection mode It is necessary for correct activation of preview planes
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
XGUI_Displayer* aDisp = aWorkshop->displayer();
- aDisp->activateObjects(QIntList(), aDisp->displayedObjects(), false);
+ aWorkshop->selectionActivate()->activateObjects(QIntList(), aDisp->displayedObjects(), false);
if (!aBodyIsVisualized) {
// We have to select a plane before any operation
}
else
mySizeOfViewWidget->setVisible(false);
-
- activateSelection(true);
- activateFilters(true);
}
void PartSet_WidgetSketchLabel::deactivate()
{
- ModuleBase_ModelWidget::deactivate();
+ ModuleBase_WidgetValidated::deactivate();
bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
myPreviewPlanes->erasePreviewPlanes(myWorkshop);
- activateSelection(false);
- activateFilters(false);
if (aHidePreview)
myWorkshop->viewer()->update();
}
-void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
+void PartSet_WidgetSketchLabel::selectionModes(QIntList& theModes, bool& isAdditional)
{
- if (toActivate) {
- QIntList aModes;
- std::shared_ptr<GeomAPI_Pln> aPlane = plane();
- if (aPlane.get()) {
- myWorkshop->module()->activeSelectionModes(aModes);
- }
- else {
- aModes << TopAbs_FACE;
- }
- myWorkshop->activateSubShapesSelection(aModes);
- } else {
- myWorkshop->deactivateSubShapesSelection();
- }
+ std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+ if (!aPlane.get())
+ theModes << TopAbs_FACE;
+ isAdditional = true;
}
+void PartSet_WidgetSketchLabel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+ if (aPlane.get())
+ return;
+ return ModuleBase_WidgetValidated::selectionFilters(theSelectionFilters);
+}
std::shared_ptr<GeomAPI_Dir>
PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
+ /// Fills given container with selection modes if the widget has it
+ // \param theModes [out] a container of modes
+ /// \param isAdditional if true, the modes are combinated with the module ones
+ virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
+ /// Using widget selection filter only if plane is not defined.
+ /// \param [out] selection filters
+ virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
/// \param thePrs a presentation
static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
- /// Processes Selection action.
- virtual bool processAction(ModuleBase_ActionType theActionType,
- const ActionParamPtr& theParam);
-
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
bool& isAttributeSetInitializedBlocked,
bool& isAttributeSendUpdatedBlocked);
+ /// Returns true if envent is processed.
+ virtual bool processSelection();
+
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// The method is called by the current operation to process the operation preselection.
/// \param thePrs a presentation
bool fillSketchPlaneBySelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
- protected:
- /// Activate or deactivate selection
- void activateSelection(bool toActivate);
-
- private:
- /// Slot on change selection
- void onSelectionChanged();
-
private slots:
/// A slot called on set sketch plane view
void onSetPlaneView();
/// \param theOn a flag show constraints or not
void onShowConstraint(bool theOn);
- private:
+private:
/// Set sketch plane by shape
/// \param theShape a planar face
std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
#include <XGUI_Displayer.h>
#include <XGUI_MenuMgr.h>
#include <XGUI_FacesPanel.h>
+#include <XGUI_SelectionActivate.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_Preferences.h>
{
if (!mySelector) {
mySelector = createSelector(theMgr);
- myWorkshop->module()->activateSelectionFilters();
+ myWorkshop->selectionActivate()->updateSelectionFilters();
+ myWorkshop->selectionActivate()->updateSelectionModes();
myWorkshop->synchronizeViewer();
}
}
TARGET_LINK_LIBRARIES(SamplePanelPlugin ${PROJECT_LIBRARIES})
INCLUDE_DIRECTORIES(
+ ${CAS_INCLUDE_DIRS}
../Config
../Events
../ModelAPI
XGUI_QtEvents.h
XGUI_SalomeConnector.h
XGUI_Selection.h
+ XGUI_SelectionActivate.h
XGUI_SelectionMgr.h
XGUI_Tools.h
XGUI_TransparencyWidget.h
XGUI_QtEvents.cpp
XGUI_SalomeConnector.cpp
XGUI_Selection.cpp
+ XGUI_SelectionActivate.cpp
XGUI_SelectionMgr.cpp
XGUI_Tools.cpp
XGUI_TransparencyWidget.cpp
// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
//
-#include <XGUI_ActiveControlMgr.h>
-#include <XGUI_ActiveControlSelector.h>
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
+#include "XGUI_SelectionActivate.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Workshop.h"
+
#include <ModuleBase_IModule.h>
#include <ModuleBase_IWorkshop.h>
myActiveSelector->setActive(false);
activateSelector(aSelector);
+ XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes();
+ XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters();
}
//********************************************************************
myActiveSelector = NULL;
aSelector->setActive(false);
- myWorkshop->module()->updateActiveSelectionFilters();
XGUI_ActiveControlSelector* aSelectorToBeActivated = 0;
for (int i = 0, aCount = mySelectors.count(); i < aCount; i++)
}
if (aSelectorToBeActivated)
activateSelector(aSelectorToBeActivated);
+
+ XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes();
+ XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters();
}
//********************************************************************
{
myActiveSelector = theSelector;
theSelector->setActive(true);
-
- myWorkshop->module()->updateActiveSelectionFilters();
}
#include "XGUI_SelectionMgr.h"
#include "XGUI_Displayer.h"
#include "XGUI_ViewerProxy.h"
-#include "XGUI_Selection.h"
#include "XGUI_SalomeConnector.h"
+#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
#include "XGUI_DataModel.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_Tools.h"
#endif
// Update selection menu
- QIntList aModes = aDisplayer->activeSelectionModes();
+ QIntList aModes = myWorkshop->selectionActivate()->activeSelectionModes();
action("SELECT_VERTEX_CMD")->setEnabled(true);
action("SELECT_EDGE_CMD")->setEnabled(true);
action("SELECT_FACE_CMD")->setEnabled(true);
// Create selection menu
XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
- QIntList aModes;
- myWorkshop->module()->activeSelectionModes(aModes);
- if ((!aOpMgr->hasOperation()) && aModes.isEmpty()) {
+ if (!aOpMgr->hasOperation() &&
+ myWorkshop->selectionActivate()->activeSelectionPlace() == XGUI_SelectionActivate::Workshop) {
QMenu* aSelMenu = new QMenu(tr("Selection mode"), theMenu);
aSelMenu->addAction(action("SELECT_VERTEX_CMD"));
aSelMenu->addAction(action("SELECT_EDGE_CMD"));
// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
//
-#include "XGUI_CustomPrs.h"
#include "XGUI_Displayer.h"
+
+#include "XGUI_CustomPrs.h"
#include "XGUI_FacesPanel.h"
#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_Workshop.h"
#include <AIS_Point.hxx>
#endif
#include <AIS_Selection.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <SelectMgr_ListOfFilter.hxx>
-#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
+#include <SelectMgr_ListOfFilter.hxx>
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#include <SelectMgr_SelectionManager.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
/// defines the local context mouse selection sensitivity
const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
-//#define DEBUG_ACTIVATE_OBJECTS
-//#define DEBUG_DEACTIVATE
-//#define DEBUG_ACTIVATE_AIS
-//#define DEBUG_DEACTIVATE_AIS
-
//#define DEBUG_DISPLAY
//#define DEBUG_FEATURE_REDISPLAY
//#define DEBUG_SELECTION_FILTERS
#define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+//**************************************************************
void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
{
// Get from null point
return anInfo.join(theSeparator);
}
-void deselectPresentation(const Handle(AIS_InteractiveObject) theObject,
- const Handle(AIS_InteractiveContext)& theContext)
-{
- NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
-
- for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) {
- Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
- if (anOwner.IsNull()) // TODO: check why it is possible
- continue;
- if (anOwner->Selectable() == theObject && anOwner->IsSelected())
- aResultOwners.Append(anOwner);
- }
- NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
- Handle(SelectMgr_EntityOwner) anOwner;
- for (; anOwnersIt.More(); anOwnersIt.Next()) {
- anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
- if (!anOwner.IsNull())
- theContext->AddOrRemoveSelected(anOwner, false);
- }
-}
-
+//**************************************************************
XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
- : myWorkshop(theWorkshop), myNeedUpdate(false),
- myIsTrihedronActive(true), myViewerBlockedRecursiveCount(0),
- myIsFirstAISContextUse(true)
+: myWorkshop(theWorkshop), myNeedUpdate(false),
+ myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true)
{
myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
}
+//**************************************************************
XGUI_Displayer::~XGUI_Displayer()
{
}
+//**************************************************************
bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
{
return myResult2AISObjectMap.contains(theObject);
}
+//**************************************************************
bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
{
bool aDisplayed = false;
return aDisplayed;
}
+//**************************************************************
bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
{
Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
return false;
}
+//**************************************************************
bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
bool isShading, bool theUpdateViewer)
{
aDisplayed = true;
emit objectDisplayed(theObject, theAIS);
- activate(anAISIO, myActiveSelectionModes, theUpdateViewer);
+ selectionActivate()->activate(anAISIO, theUpdateViewer);
}
if (theUpdateViewer)
updateViewer();
return aDisplayed;
}
+//**************************************************************
bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
{
bool aErased = false;
return aErased;
}
+//**************************************************************
bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
{
bool aRedisplayed = false;
myWorkshop->module()->storeSelection();
#ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
- deselectPresentation(aAISIO, aContext);
+ myWorkshop->selector()->deselectPresentation(aAISIO);
#endif
aContext->Redisplay(aAISIO, false);
return aRedisplayed;
}
+//**************************************************************
void XGUI_Displayer::redisplayObjects()
{
// redisplay objects visualized in the viewer
Events_Loop::loop()->flush(EVENT_DISP);
}
-void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer)
-{
-#ifdef DEBUG_DEACTIVATE
- QString anInfoStr = ModuleBase_Tools::objectInfo(theObject);
- qDebug(QString("deactivate: myActiveSelectionModes[%1]: %2, objects = ").
- arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
- arg(anInfoStr).
- toStdString().c_str());
-#endif
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull() && isVisible(theObject)) {
- AISObjectPtr anObj = myResult2AISObjectMap[theObject];
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-
- deactivateAIS(anAIS);
- // the selection from the previous activation modes should be cleared manually (#26172)
-#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
- deselectPresentation(anAIS, aContext);
-#endif
- if (theUpdateViewer)
- updateViewer();
- }
-}
-
+//**************************************************************
void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
const bool theUpdateViewer)
{
QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
for (; anIt != aLast; anIt++) {
- deactivate(*anIt, false);
+ selectionActivate()->deactivate(*anIt, false);
}
//VSV It seems that there is no necessity to update viewer on deactivation
//if (theUpdateViewer)
// updateViewer();
}
-void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext.IsNull() || !isVisible(theObject))
- return;
-
- AISObjectPtr aAISObj = getAISObject(theObject);
-
- if (aAISObj.get() != NULL) {
- Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
- TColStd_ListOfInteger aTColModes;
- aContext->ActivatedModes(anAISIO, aTColModes);
- TColStd_ListIteratorOfListOfInteger itr( aTColModes );
- for (; itr.More(); itr.Next() ) {
- theModes.append(itr.Value());
- }
- }
-}
-
-int XGUI_Displayer::getSelectionMode(int theShapeType)
-{
- return (theShapeType > TopAbs_SHAPE) ? theShapeType :
- AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
-}
-
+//**************************************************************
bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
{
bool aVisible = false;
return aVisible;
}
-#ifdef DEBUG_ACTIVATE_OBJECTS
-QString getModeInfo(const int theMode)
-{
- QString anInfo = "Undefined";
- switch(theMode) {
- case 0: anInfo = "SHAPE(0)"; break;
- case 1: anInfo = "VERTEX(1)"; break;
- case 2: anInfo = "EDGE(2)"; break;
- case 3: anInfo = "WIRE(3)"; break;
- case 4: anInfo = "FACE(4)"; break;
- case 5: anInfo = "SHELL(5)"; break;
- case 6: anInfo = "SOLID(6)"; break;
- case 7: anInfo = "COMPSOLID(7)"; break;
- case 8: anInfo = "COMPOUND(8)"; break;
- case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
- case 101: anInfo = "Sel_Constraint(101)"; break;
- case 102: anInfo = "Sel_Dimension_All(102)"; break;
- case 103: anInfo = "Sel_Dimension_Line(103)"; break;
- case 104: anInfo = "Sel_Dimension_Text(104)"; break;
- default: break;
- }
- return anInfo;
-}
-
-QString getModesInfo(const QIntList& theModes)
-{
- QStringList aModesInfo;
- for (int i = 0, aSize = theModes.size(); i < aSize; i++)
- aModesInfo.append(getModeInfo(theModes[i]));
- return QString("[%1] = %2").arg(aModesInfo.size()).arg(aModesInfo.join(", "));
-}
-#endif
-
-void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
- const bool theUpdateViewer)
-{
- // Convert shape types to selection types
- QIntList aModes;
- foreach(int aType, theModes) {
- aModes.append(getSelectionMode(aType));
- }
-
-#ifdef DEBUG_ACTIVATE_OBJECTS
- QStringList anInfo;
- QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
- for (; anIt != aLast; ++anIt) {
- anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
- }
- QString anInfoStr = anInfo.join(", ");
-
- qDebug(QString("activateObjects: new modes%1, active modes%2, objects[%3] = %4").
- arg(getModesInfo(aModes)).
- arg(getModesInfo(myActiveSelectionModes)).
- arg(theObjList.size()).
- arg(anInfoStr).
- toStdString().c_str());
-#endif
- // In order to avoid doblications of selection modes
- QIntList aNewModes;
- foreach (int aMode, aModes) {
- if (!aNewModes.contains(aMode))
- aNewModes.append(aMode);
- }
- myActiveSelectionModes = aNewModes;
- Handle(AIS_InteractiveContext) aContext = AISContext();
- // Open local context if there is no one
- if (aContext.IsNull())
- return;
-
- //aContext->UseDisplayedObjects();
- //myUseExternalObjects = true;
-
- Handle(AIS_InteractiveObject) anAISIO;
- AIS_ListOfInteractive aPrsList;
- //if (aObjList.isEmpty())
- // return;
- //else {
- foreach(ObjectPtr aObj, theObjList) {
- if (myResult2AISObjectMap.contains(aObj))
- aPrsList.Append(myResult2AISObjectMap[aObj]->impl<Handle(AIS_InteractiveObject)>());
- }
- //}
-
- // Add trihedron because it has to partisipate in selection
- Handle(AIS_InteractiveObject) aTrihedron;
- if (isTrihedronActive()) {
- aTrihedron = getTrihedron();
- if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
- aPrsList.Append(aTrihedron);
- }
- if (aPrsList.Extent() == 0)
- return;
-
- AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
- bool isActivationChanged = false;
- for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
- anAISIO = aLIt.Value();
- if (activate(anAISIO, myActiveSelectionModes, false))
- isActivationChanged = true;
- }
-}
-
-bool XGUI_Displayer::isActive(ObjectPtr theObject) const
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext.IsNull() || !isVisible(theObject))
- return false;
-
- AISObjectPtr anObj = myResult2AISObjectMap[theObject];
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-
- TColStd_ListOfInteger aModes;
- aContext->ActivatedModes(anAIS, aModes);
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->ActivatedModes(anAIS, aModes);
- #endif
-
- return aModes.Extent() > 0;
-}
-
-
+//**************************************************************
void XGUI_Displayer::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues,
bool theUpdateViewer)
{
updateViewer();
}
+//**************************************************************
void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
+//**************************************************************
bool XGUI_Displayer::eraseAll(const bool theUpdateViewer)
{
bool aErased = false;
return aErased;
}
-void deactivateObject(Handle(AIS_InteractiveContext) theContext,
- Handle(AIS_InteractiveObject) theObject
-#ifdef TINSPECTOR
- , Handle(VInspectorAPI_CallBack) theCallBack
-#endif
- )
-{
- if (!theObject.IsNull()) {
- theContext->Deactivate(theObject);
- #ifdef TINSPECTOR
- if (theCallBack) theCallBack->Deactivate(theObject);
- #endif
- }
-}
-
-void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const
-{
- Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
- Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
- deactivateObject(aContext, aTrie
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
-
- /// #1136 hidden axis are selected in sketch
-#ifdef BEFORE_TRIHEDRON_PATCH
- deactivateObject(aContext, aTrie->XAxis()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
- deactivateObject(aContext, aTrie->YAxis()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
- deactivateObject(aContext, aTrie->Axis()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
- deactivateObject(aContext, aTrie->Position()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
-
- deactivateObject(aContext, aTrie->XYPlane()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
- deactivateObject(aContext, aTrie->XZPlane()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
- deactivateObject(aContext, aTrie->YZPlane()
- #ifdef TINSPECTOR
- , getCallBack()
- #endif
- );
-#endif
- if (theUpdateViewer)
- updateViewer();
- }
-}
-
-Handle(AIS_InteractiveObject) XGUI_Displayer::getTrihedron() const
-{
- return myWorkshop->viewer()->trihedron();
-}
-
-/*void XGUI_Displayer::openLocalContext()
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- // Open local context if there is no one
- if (!aContext.IsNull() && !aContext->HasOpenedContext()) {
- // Preserve selected objects
- //AIS_ListOfInteractive aAisList;
- //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
- // aAisList.Append(aContext->Current());
-
- // get the filters from the global context and append them to the local context
- // a list of filters in the global context is not cleared and should be cleared here
- SelectMgr_ListOfFilter aFilters;
- aFilters.Assign(aContext->Filters());
- // it is important to remove the filters in the global context, because there is a code
- // in the closeLocalContex, which restore the global context filters
- aContext->RemoveFilters();
-
- //aContext->ClearCurrents();
- aContext->OpenLocalContext();
- //deactivateTrihedron();
- //aContext->NotUseDisplayedObjects();
-
- //myUseExternalObjects = false;
-
- SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
- for (;aIt.More(); aIt.Next()) {
- aContext->AddFilter(aIt.Value());
- }
- // Restore selection
- //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
- //for(; aIt2.More(); aIt2.Next()) {
- // aContext->SetSelected(aIt2.Value(), false);
- //}
- }
-}*/
-
-/*void XGUI_Displayer::closeLocalContexts(const bool theUpdateViewer)
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull() && aContext->HasOpenedContext()) {
- // Preserve selected objects
- //AIS_ListOfInteractive aAisList;
- //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
- // aAisList.Append(aContext->SelectedInteractive());
-
- // get the filters from the local context and append them to the global context
- // a list of filters in the local context is cleared
- SelectMgr_ListOfFilter aFilters;
- aFilters.Assign(aContext->Filters());
-
- //aContext->ClearSelected();
- aContext->CloseAllContexts(false);
-
- // From the moment when the AIS_DS_Displayed flag is used in the Display of AIS object,
- // this code is obsolete. It is temporaty commented and should be removed after
- // the test campaign.
- // Redisplay all object if they were displayed in localContext
- /*Handle(AIS_InteractiveObject) aAISIO;
- foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
- aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
- if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
- aContext->Display(aAISIO, false);
- aContext->SetDisplayMode(aAISIO, Shading, false);
- }
- }*+/
-
- // Append the filters from the local selection in the global selection context
- SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
- for (;aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = aIt.Value();
- aContext->AddFilter(aFilter);
- }
-
- if (theUpdateViewer)
- updateViewer();
- //myUseExternalObjects = false;
-
- // Restore selection
- //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
- //for(; aIt2.More(); aIt2.Next()) {
- // if (aContext->IsDisplayed(aIt2.Value()))
- // aContext->SetCurrentObject(aIt2.Value(), false);
- //}
- }
-}*/
+//**************************************************************
AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
{
AISObjectPtr anIO;
return anIO;
}
+//**************************************************************
ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
{
Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
return getObject(aRefAIS);
}
+//**************************************************************
ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
{
ObjectPtr anObject;
return anObject;
}
+//**************************************************************
bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
{
bool aWasEnabled = isUpdateEnabled();
return aWasEnabled;
}
+//**************************************************************
bool XGUI_Displayer::isUpdateEnabled() const
{
return myViewerBlockedRecursiveCount == 0;
}
+//**************************************************************
void XGUI_Displayer::updateViewer() const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
-void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
- const int theMode, const bool theUpdateViewer) const
-{
- Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
- if (!theIO.IsNull() && theIO == getTrihedron()) {
- if (theMode != AIS_Shape::SelectionType(TopAbs_EDGE) &&
- theMode != AIS_Shape::SelectionType(TopAbs_VERTEX))
- return;
- }
- if (!aContext.IsNull()) {
- if (myWorkshop->module()) {
- int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
- aContext->Activate(theIO, theMode, false);
- } else
- aContext->Activate(theIO, theMode, false);
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->Activate(theIO, theMode);
- #endif
-
- // the fix from VPA for more suitable selection of sketcher lines
- if (theIO->Width() > 1) {
- double aPrecision = theIO->Width() + 2;
- if (theMode == getSelectionMode(TopAbs_VERTEX))
- aPrecision = ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
- "point-selection-sensitivity",
- 12);
- else if ((theMode == getSelectionMode(TopAbs_EDGE)) ||
- (theMode == getSelectionMode(TopAbs_WIRE)))
- aPrecision = theIO->Width() +
- ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
- "edge-selection-sensitivity", 2);
- aContext->SetSelectionSensitivity(theIO, theMode, aPrecision);
- }
-
-#ifdef DEBUG_ACTIVATE_AIS
- ObjectPtr anObject = getObject(theIO);
- anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
- qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode)
- .arg(anInfo).toStdString().c_str());
-#endif
- if (theUpdateViewer)
- updateViewer();
- }
-}
-
-void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
- const int theMode) const
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull()) {
- if (theMode == -1) {
- aContext->Deactivate(theIO);
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->Deactivate(theIO);
- #endif
- }
- else {
- aContext->Deactivate(theIO, theMode);
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->Deactivate(theIO, theMode);
- #endif
- }
-
-#ifdef DEBUG_DEACTIVATE_AIS
- ObjectPtr anObject = getObject(theIO);
- anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
- qDebug(QString("deactivateAIS: theMode = %1, object = %2").arg(theMode)
- .arg(anInfo).toStdString().c_str());
-#endif
- }
-}
-
+//**************************************************************
Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
{
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull() && myIsFirstAISContextUse/*&& !aContext->HasOpenedContext()*/) {
XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this;
aDisplayer->myIsFirstAISContextUse = false;
- //aContext->OpenLocalContext();
- if (!isTrihedronActive())
- deactivateTrihedron(true);
+ if (!myWorkshop->selectionActivate()->isTrihedronActive())
+ selectionActivate()->deactivateTrihedron(true);
aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
}
return aContext;
}
+//**************************************************************
Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
{
Handle(AIS_InteractiveContext) aContext = AISContext();
return myAndFilter;
}
+//**************************************************************
bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
const Standard_Integer theDisplayMode, bool theUpdateViewer)
{
#ifdef TINSPECTOR
if (getCallBack()) getCallBack()->Load(anAISIO);
#endif
- if (toActivateInSelectionModes) {
- if (myActiveSelectionModes.size() == 0)
- activateAIS(anAISIO, 0, theUpdateViewer);
- else {
- foreach(int aMode, myActiveSelectionModes) {
- activateAIS(anAISIO, aMode, theUpdateViewer);
- }
- }
- }
+ if (toActivateInSelectionModes)
+ myWorkshop->selectionActivate()->activateOnDisplay(anAISIO, theUpdateViewer);
+
if (theUpdateViewer)
updateViewer();
}
return aDisplayed;
}
+//**************************************************************
bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer)
{
bool aErased = false;
return aErased;
}
-
+//**************************************************************
void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer)
{
if (theMode == NoMode)
updateViewer();
}
+//**************************************************************
XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
}
-void XGUI_Displayer::deactivateSelectionFilters()
+//**************************************************************
+void XGUI_Displayer::deactivateSelectionFilters(const bool theAddFilterOnly)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (!myAndFilter.IsNull()) {
}
}
+//**************************************************************
void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
+//**************************************************************
void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
+//**************************************************************
bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
{
bool aFilterFound = false;
return aFilterFound;
}
+//**************************************************************
void XGUI_Displayer::removeFilters()
{
Handle(AIS_InteractiveContext) aContext = AISContext();
aCompositeFilter->Clear();
}
+//**************************************************************
void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
{
QObjectPtrList aDispList = myResult2AISObjectMap.keys();
updateViewer();
}
+//**************************************************************
bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
{
if (!isVisible(theObject))
return ::canBeShaded(anAIS, myWorkshop->module());
}
-bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
- const QIntList& theModes,
- const bool theUpdateViewer) const
-{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext.IsNull() || theIO.IsNull())
- return false;
-
- bool isActivationChanged = false;
- // deactivate object in all modes, which are not in the list of activation
- // It seems that after the IO deactivation the selected state of the IO's owners
- // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
- // By this reason, the number of the IO deactivate is decreased and the object is deactivated
- // only if there is a difference in the current modes and the parameters modes.
- // If the selection problem happens again, it is possible to write a test scenario and create
- // a bug. The bug steps are the following:
- // Create two IO, activate them in 5 modes, select the first IO, deactivate 3 modes for both,
- // with clicked SHIFT select the second object.
- // The result is the selection of the first IO is lost.
- TColStd_ListOfInteger aTColModes;
- aContext->ActivatedModes(theIO, aTColModes);
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->ActivatedModes(theIO, aTColModes);
- #endif
- TColStd_ListIteratorOfListOfInteger itr( aTColModes );
- QIntList aModesActivatedForIO;
- bool isDeactivated = false;
- bool aHasValidMode = false;
- for (; itr.More(); itr.Next() ) {
- Standard_Integer aMode = itr.Value();
- aHasValidMode = aHasValidMode || aMode != -1;
- int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
- if (!theModes.contains(aMode)) {
- deactivateAIS(theIO, aMode);
- isDeactivated = true;
- }
- else {
- aModesActivatedForIO.append(aMode);
- }
- }
- if (isDeactivated) {
- // the selection from the previous activation modes should be cleared manually (#26172)
- //theIO->ClearSelected();
- //#ifdef TINSPECTOR
- //if (getCallBack()) getCallBack()->ClearSelected(theIO);
- //#endif
-#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
- deselectPresentation(theIO, aContext);
-#endif
- // For performance issues
- //if (theUpdateViewer)
- // updateViewer();
- isActivationChanged = true;
- }
-
- // loading the interactive object allowing the decomposition
- if (aTColModes.IsEmpty() || !aHasValidMode) {
- aContext->Load(theIO, -1, true);
- Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
- if (!aTrihedron.IsNull()) {
- // Workaround for Trihedron. It should be loaded using the next Load method to
- // add this object to myGlobal map of selection manager
- // it is important to activate trihedron in two selection modes: edges and vertices
- aContext->SelectionManager()->Load(theIO);
- }
-
- #ifdef TINSPECTOR
- if (getCallBack()) getCallBack()->Load(theIO);
- #endif
- }
-
- // trihedron AIS check should be after the AIS loading.
- // If it is not loaded, it is steel selectable in the viewer.
- Handle(AIS_Trihedron) aTrihedron;
- if (!isTrihedronActive())
- aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
- if (aTrihedron.IsNull()) {
- // In order to clear active modes list
- if (theModes.size() == 0) {
- activateAIS(theIO, 0, theUpdateViewer);
- } else {
- foreach(int aMode, theModes) {
- if (!aModesActivatedForIO.contains(aMode)) {
- activateAIS(theIO, aMode, theUpdateViewer);
- isActivationChanged = true;
- }
- }
- }
- }
- return isActivationChanged;
-}
-
+//**************************************************************
bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
{
AISObjectPtr anAISObj = getAISObject(theObject);
return isCustomized;
}
-
+//**************************************************************
QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
const QColor& theColor,
bool theUpdateViewer)
return QColor(aR, aG, aB);
}
+//**************************************************************
void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS)
{
myResult2AISObjectMap[theObject] = theAIS;
}
#ifdef _DEBUG
+//**************************************************************
std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
{
QStringList aContent;
}
#endif
+//**************************************************************
void XGUI_Displayer::getPresentations(const ObjectPtr& theObject,
NCollection_Map<Handle(AIS_InteractiveObject)>& thePresentations)
{
}
}
-void XGUI_Displayer::activateTrihedron(bool theIsActive)
-{
- myIsTrihedronActive = theIsActive;
- if (!myIsTrihedronActive) {
- deactivateTrihedron(true);
- }
-}
-
+//**************************************************************
void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
+ XGUI_SelectionActivate* aSelectionActive = selectionActivate();
if (theToDisplay) {
if (!aContext->IsDisplayed(aTrihedron))
aContext->Display(aTrihedron,
if (getCallBack()) getCallBack()->Display(aTrihedron);
#endif
- if (!isTrihedronActive())
- deactivateTrihedron(false);
+ if (!aSelectionActive->isTrihedronActive())
+ aSelectionActive->deactivateTrihedron(false);
else
- activate(aTrihedron, myActiveSelectionModes, false);
+ aSelectionActive->activate(aTrihedron, false);
} else {
- deactivateTrihedron(false);
+ aSelectionActive->deactivateTrihedron(false);
aContext->Erase(aTrihedron, Standard_True);
#ifdef TINSPECTOR
updateViewer();
}
-QIntList XGUI_Displayer::activeSelectionModes() const
-{
- QIntList aModes;
- foreach (int aMode, myActiveSelectionModes) {
- // aMode < 9 is a Shape Enum values
- aModes << ((aMode < 9)? AIS_Shape::SelectionType(aMode) : aMode);
- }
- return aModes;
-}
-
+//**************************************************************
void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
const NCollection_DataMap<TopoDS_Shape,
NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected)
theContext->AddOrRemoveSelected(anIt.Value(), Standard_False);
}
}
+
+//**************************************************************
+XGUI_SelectionActivate* XGUI_Displayer::selectionActivate() const
+{
+ return myWorkshop->selectionActivate();
+}
#include "XGUI.h"
#include <GeomAPI_AISObject.h>
-#include <TopoDS_Shape.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <NCollection_Map.hxx>
-#include <NCollection_DataMap.hxx>
+#include <GeomAPI_ICustomPrs.h>
#include <ModelAPI_Result.h>
#include <ModuleBase_Definitions.h>
-#include <GeomAPI_ICustomPrs.h>
-
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
#include <SelectMgr_AndFilter.hxx>
+#include <TopoDS_Shape.hxx>
-#include <QString>
+#include <QColor>
#include <QMap>
#include <QObject>
-#include <QColor>
+#include <QString>
class ModuleBase_ViewerPrs;
class ModelAPI_Feature;
+class XGUI_SelectionActivate;
class XGUI_Workshop;
#ifdef TINSPECTOR
public:
/// \enum DisplayMode display mode
enum DisplayMode {
- /// Mode is not defined
- NoMode = -1,
- /// Wireframe display mode
- Wireframe,
- /// Shading display mode
- Shading
+ NoMode = -1, ///< Mode is not defined
+ Wireframe, ///< Wireframe display mode
+ Shading ///< Shading display mode
};
/// Constructor
/// \return true if the object visibility state is changed
bool eraseAll(const bool theUpdateViewer = true);
- /// Deactivates selection of sub-shapes
- /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
- //void closeLocalContexts(const bool theUpdateViewer = true);
-
/// Remove default selection filters of the module from the current viewer
- void deactivateSelectionFilters();
+ /// \param theAddFilterOnly if is not 'true' it will deactivate all fiters in viewer
+ void deactivateSelectionFilters(const bool theAddFilterOnly = true);
/// \brief Add selection filter
/// \param theFilter a filter instance
/// Updates the viewer
void updateViewer() const;
- /// Activate interactive context
- /// \param theIO an interactive object
- /// \param theMode activation mode
- /// \param theUpdateViewer update viewer flag
- void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode,
- const bool theUpdateViewer) const;
-
- /// Activate interactive context. It is necessary to call ClearOutdatedSelection
- /// after deactivation
- /// \param theIO an interactive object
- /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated
- void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode = -1) const;
-
/// Searches the interactive object by feature
/// \param theObject the object or presentable feature
/// \return theIO an interactive object
void deactivateObjects(const QObjectPtrList& theObjList,
const bool theUpdateViewer = true);
- /// Returns the modes of activation
- /// \param theObject the feature or NULL if it not visualized
- /// \param theModes - modes on which it is activated (can be empty)
- void getModesOfActivation(ObjectPtr theObject, QIntList& theModes);
-
- /// Returns true if the given object can be selected
- /// \param theObject object to check
- bool isActive(ObjectPtr theObject) const;
-
- /// Activates in local context displayed outside of the context.
- /// \param theModes - modes on which it has to be activated (can be empty)
- /// \param theObjList - list of objects which has to be activated.
- /// \param theUpdateViewer an update viewer flag
- void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
- const bool theUpdateViewer = true);
-
/// Sets display mode for the given object if this object is displayed
void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer = true);
/// \return previously defined color on the object
QColor setObjectColor(ObjectPtr theObject, const QColor& theColor, bool theUpdateViewer = true);
- /// Returns Trihedron object if it is displayed
- Handle(AIS_InteractiveObject) getTrihedron() const;
-
- /// Set trihedron active (used in selection) or non active
- void activateTrihedron(bool theIsActive);
-
/// Displays/erases thrihedron in current modes. It will be activated or deactivated
/// depending on the trihedron visible state and displayer active trihedron state
void displayTrihedron(bool theToDisplay) const;
- /// Returns true if the trihedron should be activated in current selection modes
- bool isTrihedronActive() const { return myIsTrihedronActive; }
-
- /// Returns list of currently active selection modes
- /// Selection modes will be returned according to TopAbs_ShapeEnum
- QIntList activeSelectionModes() const;
-
#ifdef TINSPECTOR
void setCallBack(const Handle(VInspectorAPI_CallBack)& theCallBack)
{ myVCallBack = theCallBack; }
Handle(VInspectorAPI_CallBack) getCallBack() const { return myVCallBack; }
#endif
- /// Converts shape type (TopAbs_ShapeEnum) to selection mode
- /// \param theShapeType a shape type from TopAbs_ShapeEnum
- static int getSelectionMode(int theShapeType);
/// Return true if the object is visible. If the object is feature, it returns true
/// if all results of the feature are shown
bool theUpdateViewer = true);
private:
- /// Activates the interactive object in the local context.
- /// \param theIO an interactive object
- /// \param theModes - modes on which it has to be activated (can be empty)
- /// \return a flag is object activated or not
- bool activate(const Handle(AIS_InteractiveObject)& theIO, const QIntList& theModes,
- const bool theUpdateViewer) const;
-
- /// Deactivates the given object (not allow selection)
- /// \param theObject object to deactivate
- void deactivate(ObjectPtr theObject, const bool theUpdateViewer);
-
- /// Find a trihedron in a list of displayed presentations and deactivate it.
- /// \param theUpdateViewer an update viewer flag
- void deactivateTrihedron(const bool theUpdateViewer) const;
-
/// Update the object presentable properties such as color, lines width and other
/// If the object is result with the color attribute value set, it is used,
/// otherwise the customize is applyed to the object's feature if it is a custom prs
/// owner is selected if it is found there.
/// Only first owner is processed(according to OCCT logic)
static void AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
- const NCollection_DataMap<TopoDS_Shape,
- NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
+ const NCollection_DataMap<TopoDS_Shape,
+ NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
- protected:
- /// Reference to workshop
- XGUI_Workshop* myWorkshop;
+protected:
+ XGUI_SelectionActivate* selectionActivate() const;
+
+protected:
+ XGUI_Workshop* myWorkshop; ///< Reference to workshop
#ifdef TINSPECTOR
Handle(VInspectorAPI_CallBack) myVCallBack;
#endif
- /// A container for selection filters
- Handle(SelectMgr_AndFilter) myAndFilter;
+ Handle(SelectMgr_AndFilter) myAndFilter; ///< A container for selection filters
/// A default custom presentation, which is used if the displayed feature is not
/// a custom presentation
/// Definition of a type of map which defines correspondance between objects and presentations
typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
+ ResultToAISMap myResult2AISObjectMap; ///< A map of displayed objects
- /// A map of displayed objects
- ResultToAISMap myResult2AISObjectMap;
-
- /// Selection modes installed for external objects in local context
- QIntList myActiveSelectionModes;
-
- /// Number of blocking of the viewer update. The viewer is updated only if it equals zero
+ /// Number of blocking of the viewer update. The viewer is updated only if it is zero
int myViewerBlockedRecursiveCount;
- /// Flag: first asking of AIS context: trihedron activation
- bool myIsFirstAISContextUse;
-
- /// Flag: use trihedgon for selection or not
- bool myIsTrihedronActive;
-
- /// A flag that update was requested but not done
- mutable bool myNeedUpdate;
+ bool myIsFirstAISContextUse; ///< Flag: first asking of AIS context: trihedron activation
+ mutable bool myNeedUpdate; ///< A flag that update was requested but not done
};
#endif
myLastItemIndex = 0; // it should be after redisplay as flag used in customize
}
+//********************************************************************
+void XGUI_FacesPanel::selectionModes(QIntList& theModes)
+{
+ theModes.append(TopAbs_FACE);
+}
+
//********************************************************************
bool XGUI_FacesPanel::eventFilter(QObject* theObject, QEvent *theEvent)
{
myIsActive = theIsActive;
if (myIsActive)
- {
emit activated();
- // selection should be activated after emit signal, that deactivates current widget(selection)
- activateSelection(theIsActive);
- }
else
- {
- // selection should be activated after emit signal, that deactivates current widget(selection)
- activateSelection(theIsActive);
emit deactivated();
- }
}
//********************************************************************
emit closed();
}
-//********************************************************************
-void XGUI_FacesPanel::activateSelection(bool toActivate)
-{
- QIntList aShapeTypes;
- aShapeTypes.append(TopAbs_FACE);
-
- if (toActivate) {
- myWorkshop->activateSubShapesSelection(aShapeTypes);
- } else {
- myWorkshop->deactivateSubShapesSelection();
- }
- if (toActivate)
- activateSelectionFilters();
- else
- deactivateSelectionFilters();
-}
-
//********************************************************************
QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs)
{
#include <ModelAPI_Object.h>
#include <ModuleBase_ActionType.h>
+#include <ModuleBase_Definitions.h>
#include <ModuleBase_ViewerPrs.h>
+#include <SelectMgr_ListOfFilter.hxx>
+
#include <QDockWidget>
#include <QObject>
#include <QMap>
/// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
virtual void reset(const bool isToFlushRedisplay);
+ /// Fills container with the panel selection mode: FACE
+ // \param theModes [out] a container of modes
+ void selectionModes(QIntList& theModes);
+
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) {}
+
/// Returns whether the panel is active or not
bool isActivePanel() const { return myIsActive; }
bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject,
const std::shared_ptr<GeomAPI_AISObject>& thePresentation);
-protected:
- /// Add panel selection filters to the current viewer
- virtual void activateSelectionFilters() {}
-
- /// Remove panel selection filters from the current viewer
- virtual void deactivateSelectionFilters() {}
-
protected:
/// Reimplementation to emit a signal about the panel close
virtual void closeEvent(QCloseEvent* theEvent);
void closed();
private:
- /// Activate or deactivate selection and selection filters
- void activateSelection(bool toActivate);
-
/// Redisplay objects.
/// \param theObjects container of objects
/// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
#include "XGUI_ModuleConnector.h"
#include "XGUI_Workshop.h"
#include "XGUI_ViewerProxy.h"
-#include "XGUI_SelectionMgr.h"
#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
+#include "XGUI_SelectionMgr.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_Displayer.h"
#include "XGUI_PropertyPanel.h"
return myWorkshop->errorMgr();
}
+ModuleBase_ISelectionActivate* XGUI_ModuleConnector::selectionActivate() const
+{
+ return myWorkshop->selectionActivate();
+}
+
ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
{
return myWorkshop->operationMgr()->currentOperation();
return aActiveOPbjects;
}
-void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
-{
- QIntList aTypes = theTypes;
-
- XGUI_Displayer* aDisp = myWorkshop->displayer();
- myWorkshop->module()->customSubShapesSelectionModes(aTypes);
- aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects()));
-}
-
-void XGUI_ModuleConnector::deactivateSubShapesSelection()
-{
- // Clear selection modes
- activateModuleSelectionModes();
-}
-
-void XGUI_ModuleConnector::activateModuleSelectionModes()
-{
- XGUI_Displayer* aDisp = myWorkshop->displayer();
- myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
-}
-
AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
//! Returns list of currently selected data objects
virtual ModuleBase_ISelection* selection() const;
- /// Activate sub-shapes selection (opens local context if it was not opened)
- /// Types has to be dined according to TopAbs_ShapeEnum
- virtual void activateSubShapesSelection(const QIntList& theTypes);
-
- /// Activate objects in the module selection modes(opens local context)
- virtual void activateModuleSelectionModes();
-
- /// Deactivate sub-shapes selection (closes local context)
- virtual void deactivateSubShapesSelection();
-
//! Returns instance of loaded module
virtual ModuleBase_IModule* module() const;
//! Returns error manager
virtual ModuleBase_IErrorMgr* errorMgr() const;
+ /// A selection activate in 3D View handler
+ virtual ModuleBase_ISelectionActivate* selectionActivate() const;
+
//! Returns currently active operation
virtual ModuleBase_Operation* currentOperation() const;
#include <XGUI_ActionsMgr.h>
#include <XGUI_ActiveControlMgr.h>
+#include <XGUI_SelectionActivate.h>
#include <XGUI_ActiveControlSelector.h>
#include <XGUI_PropertyPanel.h>
#include <XGUI_PropertyPanelSelector.h>
myWidgets.clear();
myPanelPage->clearPage();
myActiveWidget = NULL;
+ emit propertyPanelDeactivated();
+ myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
+ myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
#ifdef DEBUG_ACTIVE_WIDGET
std::cout << "myActiveWidget = NULL" << std::endl;
#endif
theWidget->activate();
}
myActiveWidget = theWidget;
+ myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
+ myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
+
#ifdef DEBUG_ACTIVE_WIDGET
std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
#endif
/// \param theObject a sender of the event
void enterClicked(QObject* theObject);
+ /// Emits on clear content
+ void propertyPanelDeactivated();
+
protected:
/// Makes the widget active, deactivate the previous, activate and hightlight the given one
/// \param theWidget a widget
: myPanel(thePanel), myWidgetToBeActivated (NULL)
{
connect(myPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, SIGNAL(activated()));
+ connect(myPanel, SIGNAL(propertyPanelDeactivated()), this, SIGNAL(deactivated()));
}
//********************************************************************
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "XGUI_SelectionActivate.h"
+
+#include "ModelAPI_Object.h"
+
+#include "ModuleBase_IModule.h"
+#include "ModuleBase_IViewer.h"
+#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_Preferences.h"
+
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_FacesPanel.h"
+#include "XGUI_FacesPanelSelector.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Workshop.h"
+
+#include <SUIT_ResourceMgr.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_Trihedron.hxx>
+
+#include <SelectMgr_SelectionManager.hxx>
+
+//#define DEBUG_ACTIVATE_OBJECTS
+//#define DEBUG_DEACTIVATE
+//#define DEBUG_ACTIVATE_AIS
+//#define DEBUG_DEACTIVATE_AIS
+
+#define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+
+//**************************************************************
+XGUI_SelectionActivate::XGUI_SelectionActivate(ModuleBase_IWorkshop* theWorkshop)
+ : ModuleBase_ISelectionActivate(theWorkshop), myIsTrihedronActive(true)
+{
+}
+
+//**************************************************************
+XGUI_SelectionActivate::SelectionPlace XGUI_SelectionActivate::activeSelectionPlace() const
+{
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
+ XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
+ if (!anActiveSelector)
+ return Workshop;
+
+ if (anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ return FacesPanel;
+ else
+ return PropertyPanel;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::updateSelectionModes()
+{
+ QIntList aModes;
+ switch (activeSelectionPlace()) {
+ case Workshop:
+ myWorkshop->module()->activeSelectionModes(aModes);
+ break;
+ case PropertyPanel: {
+ ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
+ if (anActiveWidget)
+ getSelectionModes(anActiveWidget, aModes);
+ else
+ myWorkshop->module()->activeSelectionModes(aModes); //using module modes
+ }
+ break;
+ case FacesPanel: {
+ XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionModes(aModes);
+ myWorkshop->module()->customSubShapesSelectionModes(aModes); // avoid wire selection
+ }
+ break;
+ default: break;
+ }
+ activateObjects(aModes, getDisplayer()->displayedObjects(), true);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::updateSelectionFilters()
+{
+ SelectMgr_ListOfFilter aSelectionFilters;
+ switch (activeSelectionPlace()) {
+ case Workshop:
+ XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
+ break;
+ case PropertyPanel: {
+ ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
+ getSelectionFilters(anActiveWidget, aSelectionFilters);
+ }
+ break;
+ case FacesPanel: {
+ //XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
+ XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters);
+ }
+ break;
+ default: break;
+ }
+ activateSelectionFilters(aSelectionFilters);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget)
+{
+ // activate selection modes
+ QIntList aModes;
+ getSelectionModes(theWidget, aModes);
+ activateObjects(aModes, getDisplayer()->displayedObjects(), true);
+
+ // activate selection filters
+ SelectMgr_ListOfFilter aSelectionFilters;
+ getSelectionFilters(theWidget, aSelectionFilters);
+ activateSelectionFilters(aSelectionFilters);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateSelectionFilters
+ (const SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ XGUI_Displayer* aDisplayer = getDisplayer();
+ aDisplayer->deactivateSelectionFilters(false);
+
+ SelectMgr_ListIteratorOfListOfFilter aIt(theSelectionFilters);
+ for (; aIt.More(); aIt.Next()) {
+ Handle(SelectMgr_Filter) aFilter = aIt.Value();
+ if (aFilter.IsNull())
+ continue;
+ aDisplayer->addSelectionFilter(aFilter);
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::getSelectionModes(ModuleBase_ModelWidget* theWidget,
+ QIntList& theModes)
+{
+ if (!theWidget)
+ return;
+
+ bool isAdditional = false;
+ theWidget->selectionModes(theModes, isAdditional);
+ if (isAdditional) {
+ myWorkshop->module()->customSubShapesSelectionModes(theModes);
+ //theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes());
+ //myWorkshop->module()->activeSelectionModes(theModes);
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::getSelectionFilters(ModuleBase_ModelWidget* theWidget,
+ SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ XGUI_Tools::workshop(myWorkshop)->selectionFilters(theSelectionFilters);
+
+ if (theWidget)
+ theWidget->selectionFilters(theSelectionFilters);
+}
+
+//**************************************************************
+QIntList XGUI_SelectionActivate::activeSelectionModes() const
+{
+ QIntList aModes;
+ foreach (int aMode, myActiveSelectionModes) {
+ // aMode < 9 is a Shape Enum values
+ aModes << ((aMode < 9)? AIS_Shape::SelectionType(aMode) : aMode);
+ }
+ return aModes;
+}
+
+//**************************************************************
+bool XGUI_SelectionActivate::isActive(ObjectPtr theObject) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull() || !getDisplayer()->isVisible(theObject))
+ return false;
+
+ AISObjectPtr anObj = getDisplayedAISObject(theObject);
+ Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+ TColStd_ListOfInteger aModes;
+ aContext->ActivatedModes(anAIS, aModes);
+
+ return aModes.Extent() > 0;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateObjects(const QIntList& theModes,
+ const QObjectPtrList& theObjList, const bool theUpdateViewer)
+{
+ setSelectionModes(theModes);
+
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (aContext.IsNull())
+ return;
+
+ //aContext->UseDisplayedObjects();
+ //myUseExternalObjects = true;
+
+ Handle(AIS_InteractiveObject) anAISIO;
+ AIS_ListOfInteractive aPrsList;
+ AIS_ListOfInteractive aPrsListToBeDeactivated;
+ //if (aObjList.isEmpty())
+ // return;
+ //else {
+ foreach(ObjectPtr anObject, theObjList) {
+ AISObjectPtr anAISObject = getDisplayedAISObject(anObject);
+ if (!anAISObject.get())
+ continue;
+
+ Handle(AIS_InteractiveObject) aPrs = anAISObject->impl<Handle(AIS_InteractiveObject)>();
+ if (myWorkshop->module()->canActivateSelection(anObject))
+ aPrsList.Append(aPrs);
+ else
+ aPrsListToBeDeactivated.Append(aPrs);
+ }
+ //}
+
+ // Add trihedron because it has to partisipate in selection
+ Handle(AIS_InteractiveObject) aTrihedron;
+ if (isTrihedronActive()) {
+ aTrihedron = getTrihedron();
+ if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
+ aPrsList.Append(aTrihedron);
+ }
+ if (aPrsList.Extent() == 0 && aPrsListToBeDeactivated.Extent() == 0)
+ return;
+
+ AIS_ListIteratorOfListOfInteractive aLIt;
+ bool isActivationChanged = false;
+ for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()) {
+ anAISIO = aLIt.Value();
+ if (activate(anAISIO, false))
+ isActivationChanged = true;
+ }
+
+ for(aLIt.Initialize(aPrsListToBeDeactivated); aLIt.More(); aLIt.Next()) {
+ anAISIO = aLIt.Value();
+ deactivateAIS(anAISIO);
+ isActivationChanged = true;
+ }
+}
+
+#ifdef DEBUG_ACTIVATE_OBJECTS
+//**************************************************************
+QString getModeInfo(const int theMode)
+{
+ QString anInfo = "Undefined";
+ switch(theMode) {
+ case 0: anInfo = "SHAPE(0)"; break;
+ case 1: anInfo = "VERTEX(1)"; break;
+ case 2: anInfo = "EDGE(2)"; break;
+ case 3: anInfo = "WIRE(3)"; break;
+ case 4: anInfo = "FACE(4)"; break;
+ case 5: anInfo = "SHELL(5)"; break;
+ case 6: anInfo = "SOLID(6)"; break;
+ case 7: anInfo = "COMPSOLID(7)"; break;
+ case 8: anInfo = "COMPOUND(8)"; break;
+ case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
+ case 101: anInfo = "Sel_Constraint(101)"; break;
+ case 102: anInfo = "Sel_Dimension_All(102)"; break;
+ case 103: anInfo = "Sel_Dimension_Line(103)"; break;
+ case 104: anInfo = "Sel_Dimension_Text(104)"; break;
+ default: break;
+ }
+ return anInfo;
+}
+
+//**************************************************************
+QString getModesInfo(const QIntList& theModes)
+{
+ QStringList aModesInfo;
+ for (int i = 0, aSize = theModes.size(); i < aSize; i++)
+ aModesInfo.append(getModeInfo(theModes[i]));
+ return QString("[%1] = %2").arg(aModesInfo.size()).arg(aModesInfo.join(", "));
+}
+#endif
+
+//**************************************************************
+void XGUI_SelectionActivate::setSelectionModes(const QIntList& theModes)
+{
+ // Convert shape types to selection types
+ QIntList aModes;
+ foreach(int aType, theModes) {
+ aModes.append(getSelectionMode(aType));
+ }
+
+#ifdef DEBUG_ACTIVATE_OBJECTS
+ QStringList anInfo;
+ QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
+ for (; anIt != aLast; ++anIt) {
+ anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+ }
+ QString anInfoStr = anInfo.join(", ");
+
+ qDebug(QString("activateObjects: new modes%1, active modes%2, objects[%3] = %4").
+ arg(getModesInfo(aModes)).
+ arg(getModesInfo(myActiveSelectionModes)).
+ arg(theObjList.size()).
+ arg(anInfoStr).
+ toStdString().c_str());
+#endif
+ // In order to avoid doblications of selection modes
+ QIntList aNewModes;
+ foreach (int aMode, aModes) {
+ if (!aNewModes.contains(aMode))
+ aNewModes.append(aMode);
+ }
+ myActiveSelectionModes = aNewModes;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateOnDisplay(const Handle(AIS_InteractiveObject)& theIO,
+ const bool theUpdateViewer)
+{
+ if (myActiveSelectionModes.size() == 0)
+ activateAIS(theIO, 0, theUpdateViewer);
+ else {
+ foreach(int aMode, myActiveSelectionModes) {
+ activateAIS(theIO, aMode, theUpdateViewer);
+ }
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
+ const int theMode, const bool theUpdateViewer) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!theIO.IsNull() && theIO == getTrihedron()) {
+ if (theMode != AIS_Shape::SelectionType(TopAbs_EDGE) &&
+ theMode != AIS_Shape::SelectionType(TopAbs_VERTEX))
+ return;
+ }
+ if (!aContext.IsNull()) {
+ if (myWorkshop->module()) {
+ int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
+ aContext->Activate(theIO, theMode, false);
+ } else
+ aContext->Activate(theIO, theMode, false);
+
+ // the fix from VPA for more suitable selection of sketcher lines
+ if (theIO->Width() > 1) {
+ double aPrecision = theIO->Width() + 2;
+ if (theMode == getSelectionMode(TopAbs_VERTEX))
+ aPrecision = ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
+ "point-selection-sensitivity", 12);
+ else if ((theMode == getSelectionMode(TopAbs_EDGE)) ||
+ (theMode == getSelectionMode(TopAbs_WIRE)))
+ aPrecision = theIO->Width() + ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
+ "edge-selection-sensitivity", 2);
+ aContext->SetSelectionSensitivity(theIO, theMode, aPrecision);
+ }
+
+#ifdef DEBUG_ACTIVATE_AIS
+ ObjectPtr anObject = getObject(theIO);
+ anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+ qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode)
+ .arg(anInfo).toStdString().c_str());
+#endif
+ if (theUpdateViewer)
+ getDisplayer()->updateViewer();
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
+ const int theMode) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aContext.IsNull()) {
+ if (theMode == -1)
+ aContext->Deactivate(theIO);
+ else
+ aContext->Deactivate(theIO, theMode);
+
+#ifdef DEBUG_DEACTIVATE_AIS
+ ObjectPtr anObject = getObject(theIO);
+ anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+ qDebug(QString("deactivateAIS: theMode = %1, object = %2").arg(theMode)
+ .arg(anInfo).toStdString().c_str());
+#endif
+ }
+}
+
+//**************************************************************
+bool XGUI_SelectionActivate::activate(const Handle(AIS_InteractiveObject)& theIO,
+ const bool theUpdateViewer) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull() || theIO.IsNull())
+ return false;
+
+ bool isActivationChanged = false;
+ // deactivate object in all modes, which are not in the list of activation
+ // It seems that after the IO deactivation the selected state of the IO's owners
+ // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
+ // By this reason, the number of the IO deactivate is decreased and the object is deactivated
+ // only if there is a difference in the current modes and the parameters modes.
+ // If the selection problem happens again, it is possible to write a test scenario and create
+ // a bug. The bug steps are the following:
+ // Create two IO, activate them in 5 modes, select the first IO, deactivate 3 modes for both,
+ // with clicked SHIFT select the second object.
+ // The result is the selection of the first IO is lost.
+ TColStd_ListOfInteger aTColModes;
+ aContext->ActivatedModes(theIO, aTColModes);
+ TColStd_ListIteratorOfListOfInteger itr( aTColModes );
+ QIntList aModesActivatedForIO;
+ bool isDeactivated = false;
+ bool aHasValidMode = false;
+ for (; itr.More(); itr.Next() ) {
+ Standard_Integer aMode = itr.Value();
+ aHasValidMode = aHasValidMode || aMode != -1;
+ int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
+ if (!myActiveSelectionModes.contains(aMode)) {
+ deactivateAIS(theIO, aMode);
+ isDeactivated = true;
+ }
+ else {
+ aModesActivatedForIO.append(aMode);
+ }
+ }
+ if (isDeactivated) {
+ // the selection from the previous activation modes should be cleared manually (#26172)
+ //theIO->ClearSelected();
+#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+ XGUI_Tools::workshop(myWorkshop)->selector()->deselectPresentation(theIO);
+#endif
+ // For performance issues
+ //if (theUpdateViewer)
+ // getDisplayer()->updateViewer();
+ isActivationChanged = true;
+ }
+
+ // loading the interactive object allowing the decomposition
+ if (aTColModes.IsEmpty() || !aHasValidMode) {
+ aContext->Load(theIO, -1, true);
+ Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
+ if (!aTrihedron.IsNull()) {
+ // Workaround for Trihedron. It should be loaded using the next Load method to
+ // add this object to myGlobal map of selection manager
+ // it is important to activate trihedron in two selection modes: edges and vertices
+ aContext->SelectionManager()->Load(theIO);
+ }
+ }
+
+ // trihedron AIS check should be after the AIS loading.
+ // If it is not loaded, it is steel selectable in the viewer.
+ Handle(AIS_Trihedron) aTrihedron;
+ if (!isTrihedronActive())
+ aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
+ if (aTrihedron.IsNull()) {
+ // In order to clear active modes list
+ if (myActiveSelectionModes.size() == 0) {
+ activateAIS(theIO, 0, theUpdateViewer);
+ } else {
+ foreach(int aMode, myActiveSelectionModes) {
+ if (!aModesActivatedForIO.contains(aMode)) {
+ activateAIS(theIO, aMode, theUpdateViewer);
+ isActivationChanged = true;
+ }
+ }
+ }
+ }
+ return isActivationChanged;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivate(const ObjectPtr& theObject, const bool theUpdateViewer)
+{
+#ifdef DEBUG_DEACTIVATE
+ QString anInfoStr = ModuleBase_Tools::objectInfo(theObject);
+ qDebug(QString("deactivate: myActiveSelectionModes[%1]: %2, objects = ").
+ arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
+ arg(anInfoStr).
+ toStdString().c_str());
+#endif
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aContext.IsNull() && getDisplayer()->isVisible(theObject)) {
+ AISObjectPtr anObj = getDisplayedAISObject(theObject);
+ Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+ deactivateAIS(anAIS);
+ // the selection from the previous activation modes should be cleared manually (#26172)
+#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+ XGUI_Tools::workshop(myWorkshop)->selector()->deselectPresentation(anAIS);
+#endif
+ if (theUpdateViewer)
+ getDisplayer()->updateViewer();
+ }
+}
+
+/// #1136 hidden axis are selected in sketch
+#ifdef BEFORE_TRIHEDRON_PATCH
+//**************************************************************
+void deactivateObject(Handle(AIS_InteractiveContext) theContext,
+ Handle(AIS_InteractiveObject) theObject)
+{
+ if (!theObject.IsNull())
+ theContext->Deactivate(theObject);
+}
+#endif
+
+//**************************************************************
+void XGUI_SelectionActivate::activateTrihedron(bool theIsActive)
+{
+ myIsTrihedronActive = theIsActive;
+ if (!myIsTrihedronActive)
+ deactivateTrihedron(true);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivateTrihedron(const bool theUpdateViewer) const
+{
+ Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
+ Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
+ if (!aTrie.IsNull())
+ aContext->Deactivate(aTrie);
+
+ /// #1136 hidden axis are selected in sketch
+#ifdef BEFORE_TRIHEDRON_PATCH
+ deactivateObject(aContext, aTrie->XAxis());
+ deactivateObject(aContext, aTrie->YAxis());
+ deactivateObject(aContext, aTrie->Axis());
+ deactivateObject(aContext, aTrie->Position());
+
+ deactivateObject(aContext, aTrie->XYPlane());
+ deactivateObject(aContext, aTrie->XZPlane());
+ deactivateObject(aContext, aTrie->YZPlane());
+#endif
+ if (theUpdateViewer)
+ getDisplayer()->updateViewer();
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivateTrihedronInSelectionModes()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(getTrihedron());
+ /// deactivate trihedron in selection modes
+ TColStd_ListOfInteger aTColModes;
+ aContext->ActivatedModes(aTrihedron, aTColModes);
+ TColStd_ListIteratorOfListOfInteger itr( aTColModes );
+ for (; itr.More(); itr.Next() ) {
+ Standard_Integer aMode = itr.Value();
+ aContext->Deactivate(aTrihedron, aMode);
+ }
+}
+
+//**************************************************************
+Handle(AIS_InteractiveContext) XGUI_SelectionActivate::AISContext() const
+{
+ return myWorkshop->viewer()->AISContext();
+}
+
+//**************************************************************
+XGUI_Displayer* XGUI_SelectionActivate::getDisplayer() const
+{
+ return XGUI_Tools::workshop(myWorkshop)->displayer();
+}
+
+//**************************************************************
+Handle(AIS_InteractiveObject) XGUI_SelectionActivate::getTrihedron() const
+{
+ return myWorkshop->viewer()->trihedron();
+}
+
+//**************************************************************
+AISObjectPtr XGUI_SelectionActivate::getDisplayedAISObject(ObjectPtr theObject) const
+{
+ return getDisplayer()->getAISObject(theObject);
+}
+
+//**************************************************************
+int XGUI_SelectionActivate::getSelectionMode(int theShapeType)
+{
+ return (theShapeType > TopAbs_SHAPE) ? theShapeType :
+ AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_ISelectionActivate_H
+#define XGUI_ISelectionActivate_H
+
+#include "XGUI.h"
+
+#include "ModuleBase_Definitions.h"
+#include "ModuleBase_ISelectionActivate.h"
+
+#include "SelectMgr_ListOfFilter.hxx"
+
+#include <memory>
+
+class AIS_InteractiveContext;
+class AIS_InteractiveObject;
+class ModelAPI_Object;
+
+class XGUI_Displayer;
+
+/// \ingroup GUI
+/// A class which implements activation/deactivate selection modes and using selection filters.
+class XGUI_SelectionActivate : public ModuleBase_ISelectionActivate
+{
+public:
+ /// Types of the activation place
+ enum SelectionPlace { Workshop, PropertyPanel, FacesPanel };
+
+public:
+ /// Constructor
+ XGUI_EXPORT XGUI_SelectionActivate(ModuleBase_IWorkshop* theWorkshop);
+
+ /// Destructor
+ ~XGUI_SelectionActivate() {}
+
+ /// Returns place of activation modes that now is active
+ /// \return place
+ SelectionPlace activeSelectionPlace() const;
+
+ /// Updates active selection modes in the viewer depending on the application state
+ XGUI_EXPORT virtual void updateSelectionModes();
+
+ /// Updates active selection filters in the viewer depending on the application state
+ XGUI_EXPORT virtual void updateSelectionFilters();
+
+ /// Activates parameter filters in the workshop, deactivate active out of the container
+ /// Please find a possibility to use updateSelectionFilters instead of direct call this method.
+ /// \param theSelectionFilters a filtes
+ XGUI_EXPORT virtual void activateSelectionFilters
+ (const SelectMgr_ListOfFilter& theSelectionFilters);
+
+ /// Activate or deactivate selection and selection filters like the widget is active
+ /// \param theWidget a source widget of selection modes/filters
+ XGUI_EXPORT virtual void activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget);
+
+ /// Returns list of currently active selection modes
+ /// Selection modes will be returned according to TopAbs_ShapeEnum
+ XGUI_EXPORT QIntList activeSelectionModes() const;
+
+ /// Returns true if the given object can be selected
+ /// \param theObject object to check
+ XGUI_EXPORT bool isActive(ObjectPtr theObject) const;
+
+ /// Activates in local context displayed outside of the context.
+ /// \param theModes - modes on which it has to be activated (can be empty)
+ /// \param theObjList - list of objects which has to be activated.
+ /// \param theUpdateViewer an update viewer flag
+ XGUI_EXPORT void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
+ const bool theUpdateViewer = true);
+
+ /// Fill container of current selection modes
+ /// \param theModes selection modes
+ XGUI_EXPORT void setSelectionModes(const QIntList& theModes);
+
+ /// Activate object in the selection modes
+ /// \param theIO an object
+ /// \param theUpdateViewer an update viewer flag
+ XGUI_EXPORT void activateOnDisplay(const Handle(AIS_InteractiveObject)& theIO,
+ const bool theUpdateViewer);
+
+ /// Activate interactive object
+ /// \param theIO an interactive object
+ /// \param theMode activation mode
+ /// \param theUpdateViewer update viewer flag
+ XGUI_EXPORT void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode,
+ const bool theUpdateViewer) const;
+
+ /// Activate interactive object. It is necessary to call ClearOutdatedSelection
+ /// after deactivation
+ /// \param theIO an interactive object
+ /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated
+ XGUI_EXPORT void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
+ const int theMode = -1) const;
+
+ /// Activates the interactive object in the local context.
+ /// \param theIO an interactive object
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ /// \return a flag is object activated or not
+ XGUI_EXPORT bool activate(const Handle(AIS_InteractiveObject)& theIO,
+ const bool theUpdateViewer) const;
+
+ /// Deactivates the given object (not allow selection)
+ /// \param theObject object to deactivate
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ XGUI_EXPORT void deactivate(const std::shared_ptr<ModelAPI_Object>& theObject,
+ const bool theUpdateViewer);
+
+ /// Returns true if the trihedron should be activated in current selection modes
+ bool isTrihedronActive() const { return myIsTrihedronActive; }
+
+ /// Set trihedron active (used in selection) or non active
+ XGUI_EXPORT void activateTrihedron(bool theIsActive);
+
+ /// Find a trihedron in a list of displayed presentations and deactivate it.
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ XGUI_EXPORT void deactivateTrihedron(const bool theUpdateViewer) const;
+
+ /// Get selection modes of trihedron and deactivate it in it.
+ XGUI_EXPORT void deactivateTrihedronInSelectionModes();
+
+protected:
+ /// Returns selection modes of the widget
+ /// \param theWidget model widget
+ /// \param theModes selection modes
+ void getSelectionModes(ModuleBase_ModelWidget* theWidget, QIntList& theModes);
+
+ /// Returns selection filters of the widget
+ /// \param theWidget model widget
+ /// \param theSelectionFilters selection filters
+ void getSelectionFilters(ModuleBase_ModelWidget* theWidget,
+ SelectMgr_ListOfFilter& theSelectionFilters);
+
+ /// Returns Trihedron object if it is displayed
+ Handle(AIS_InteractiveObject) getTrihedron() const;
+
+ /// Returns context of the 3D viewer
+ /// \return context instance
+ Handle(AIS_InteractiveContext) AISContext() const;
+
+ /// Returns displayer
+ /// \return displayer
+ XGUI_Displayer* getDisplayer() const;
+
+ /// Returns AIS object displayed in 3D viewer for the given model object
+ /// \param theObject source object
+ /// \returns interactive object
+ AISObjectPtr getDisplayedAISObject(std::shared_ptr<ModelAPI_Object> theObject) const;
+
+ /// Converts shape type (TopAbs_ShapeEnum) to selection mode
+ /// \param theShapeType a shape type from TopAbs_ShapeEnum
+ static int getSelectionMode(int theShapeType);
+
+protected:
+ QIntList myActiveSelectionModes; ///< Current activated selection modes
+ bool myIsTrihedronActive; ///< Flag: use trihedgon for selection or not
+};
+
+#endif
emit selectionChanged();
}
+//**************************************************************
+void XGUI_SelectionMgr::deselectPresentation(const Handle(AIS_InteractiveObject) theObject)
+{
+ NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+ if (anOwner.IsNull()) // TODO: check why it is possible
+ continue;
+ if (anOwner->Selectable() == theObject && anOwner->IsSelected())
+ aResultOwners.Append(anOwner);
+ }
+ NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
+ Handle(SelectMgr_EntityOwner) anOwner;
+ for (; anOwnersIt.More(); anOwnersIt.Next()) {
+ anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+ if (!anOwner.IsNull())
+ aContext->AddOrRemoveSelected(anOwner, false);
+ }
+}
+
//**************************************************************
void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace)
{
#include <QObject>
#include <QModelIndexList>
+#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <NCollection_List.hxx>
#include <TopoDS_Shape.hxx>
//! \param theValues a container of values to be selected.
void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs> >& theValues);
+ //! Find all selected owners of the object and remove the owners from selection
+ //! \param theObject an interactive object
+ void deselectPresentation(const Handle(AIS_InteractiveObject) theObject);
+
/// Updates selection, which are depend on the selection in the given place
/// \param thePlace a widget where selection has happened.
void updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace);
#include "XGUI_PropertyDialog.h"
#include "XGUI_SalomeConnector.h"
#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Tools.h"
#include "XGUI_ViewerProxy.h"
ModuleBase_IWorkshop* aWorkshop = moduleConnector();
// Has to be defined first in order to get errors and messages from other components
myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+ mySelectionActivate = new XGUI_SelectionActivate(aWorkshop);
SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
#ifndef HAVE_SALOME
//******************************************************
void XGUI_Workshop::activateModule()
{
- myModule->activateSelectionFilters();
+ selectionActivate()->updateSelectionFilters();
connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
//******************************************************
void XGUI_Workshop::deactivateModule()
{
- myModule->deactivateSelectionFilters();
-
// remove internal displayer filter
- displayer()->deactivateSelectionFilters();
+ displayer()->deactivateSelectionFilters(false);
disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
XGUI_Displayer* aDisplayer = displayer();
QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
aDisplayer->deactivateObjects(aDisplayed, true);
- Handle(AIS_InteractiveContext) aContext = viewer()->AISContext();
- Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
- /// deactivate trihedron in selection modes
- TColStd_ListOfInteger aTColModes;
- aContext->ActivatedModes(aTrihedron, aTColModes);
- TColStd_ListIteratorOfListOfInteger itr( aTColModes );
- for (; itr.More(); itr.Next() ) {
- Standard_Integer aMode = itr.Value();
- aContext->Deactivate(aTrihedron, aMode);
- }
+ selectionActivate()->deactivateTrihedronInSelectionModes();
+
#ifdef BEFORE_TRIHEDRON_PATCH
+ //Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
/// Trihedron problem: objects stayed in the viewer, should be removed manually
/// otherwise in SALOME happens crash by HideAll in the viewer
aContext->Remove(aTrihedron->Position(), true);
void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer)
{
if (!myModule->canActivateSelection(theObject)) {
- if (myDisplayer->isActive(theObject)) {
+ if (selectionActivate()->isActive(theObject)) {
QObjectPtrList anObjects;
anObjects.append(theObject);
myDisplayer->deactivateObjects(anObjects, theUpdateViewer);
}
}
+//******************************************************
+void XGUI_Workshop::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+ module()->selectionFilters(theSelectionFilters);
+}
+
//******************************************************
void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
{
myModule->operationResumed(theOperation);
}
-
//******************************************************
void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
{
QObjectPtrList anObjects;
FeaturePtr aFeature = aFOperation->feature();
if (aFeature.get()) { // feature may be not created (plugin load fail)
- if (myDisplayer->isVisible(aFeature) && !myDisplayer->isActive(aFeature))
+ if (myDisplayer->isVisible(aFeature) && !selectionActivate()->isActive(aFeature))
anObjects.append(aFeature);
std::list<ResultPtr> aResults;
ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
ResultPtr anObject = *aIt;
- if (myDisplayer->isVisible(anObject) && !myDisplayer->isActive(anObject)) {
+ if (myDisplayer->isVisible(anObject) && !selectionActivate()->isActive(anObject)) {
anObjects.append(anObject);
}
}
#ifdef DEBUG_WITH_MESSAGE_REPORT
Handle(Message_Report) aContextReport = aContext->GetReport();
- aContextReport->SetActive (Standard_True);
+ aContext->SetReportActive (Standard_True);
aContextReport->SetLimit (1000);
if (!aContextReport.IsNull())
aParameters.Append(aContextReport);
//**************************************************************
void XGUI_Workshop::setViewerSelectionMode(int theMode)
{
- XGUI_ActiveControlSelector* anActiveSelector = activeControlMgr()->activeSelector();
- if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
- facesPanel()->setActivePanel(false);
-
if (theMode == -1)
myViewerSelMode.clear();
else {
else
myViewerSelMode.append(theMode);
}
- activateObjectsSelection(myDisplayer->displayedObjects());
+ selectionActivate()->updateSelectionModes();
}
//**************************************************************
module()->activeSelectionModes(aModes);
if (aModes.isEmpty() && (myViewerSelMode.length() > 0))
aModes.append(myViewerSelMode);
- myDisplayer->activateObjects(aModes, theList);
+ selectionActivate()->activateObjects(aModes, theList);
}
//**************************************************************
#include <ModuleBase_ActionType.h>
#include <ModuleBase_Definitions.h>
+#include <SelectMgr_ListOfFilter.hxx>
+
#include <QIcon>
#include <QObject>
#include <QKeySequence>
class XGUI_PropertyPanel;
class XGUI_SalomeConnector;
class XGUI_SalomeViewer;
+class XGUI_SelectionActivate;
class XGUI_SelectionMgr;
class XGUI_ViewerProxy;
class XGUI_WorkshopListener;
/// Returns selection manager object
XGUI_SelectionMgr* selector() const { return mySelector; }
+ /// Returns selection activating object
+ XGUI_SelectionActivate* selectionActivate() const { return mySelectionActivate; }
+
/// Returns displayer
XGUI_Displayer* displayer() const { return myDisplayer; }
/// Returns defailt selection mode in 3d viewer
QIntList viewerSelectionModes() const { return myViewerSelMode; }
+ /// Appends into container of workshop selection filters
+ /// \param [out] selection filters
+ void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
/// Highlights result objects in Object Browser according to
/// features found in the given list
void highlightResults(const QObjectPtrList& theObjects);
XGUI_PropertyPanel* myPropertyPanel; ///< container of feature attributes widgets
XGUI_FacesPanel* myFacesPanel; ///< panel for hide object faces
XGUI_SelectionMgr* mySelector; ///< handler of selection processing
+ XGUI_SelectionActivate* mySelectionActivate; /// manager of selection activating
XGUI_Displayer* myDisplayer; ///< handler of objects display
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
XGUI_ActionsMgr* myActionsMgr; ///< manager of workshop actions