we should not remove from list objects hidden in the viewer if selection was done with SHIFT button
/// Returns main window of the application
virtual QMainWindow* desktop() const = 0;
+ /// Returns true if SHIFT is pressed
+ /// \return boolean value
+ virtual bool hasSHIFTPressed() const = 0;
signals:
/// Signal selection changed.
AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- bool aFound = findInSelection(anAttr->context(), anAttr->value(), aGeomSelection);
+ bool aFound = findInSelection(anAttr->context(), anAttr->value(), aGeomSelection,
+ myWorkshop);
if (!aFound)
anIndicesToBeRemoved.insert(i);
}
for (int i = 0; i < aRefListAttr->size(); i++) {
ObjectPtr anObject = aRefListAttr->object(i);
if (anObject.get()) {
- bool aFound = findInSelection(anObject, GeomShapePtr(), aGeomSelection);
+ bool aFound = findInSelection(anObject, GeomShapePtr(), aGeomSelection,
+ myWorkshop);
if (!aFound)
anIndicesToBeRemoved.insert(i);
}
aFound = anAttributes.find(anAttribute) != anAttributes.end();
}
else {
- aFound = findInSelection(aRefAttrListAttr->object(i), GeomShapePtr(), aGeomSelection);
+ aFound = findInSelection(aRefAttrListAttr->object(i), GeomShapePtr(), aGeomSelection,
+ myWorkshop);
}
if (!aFound)
anIndicesToBeRemoved.insert(i);
bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject,
GeomShapePtr theShape,
- const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection)
+ const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection,
+ ModuleBase_IWorkshop* theWorkshop)
{
+ // issue #2154: we should not remove from list objects hidden in the viewer if selection
+ // was done with SHIFT button
+ if (theWorkshop->hasSHIFTPressed() && !theObject->isDisplayed())
+ return true;
+
bool aFound = false;
GeomShapePtr anEmptyShape(new GeomAPI_Shape());
if (theShape.get()) { // treat shape equal to context as null: 2219, keep order of shapes in list
/// \param theObject a model object, a set of shapes is searched by it
/// \param theShape a shape to be in the set of the object shapes
/// \param theGeomSelection a map built on selection
+ /// \param theWorkshop a current workshop
/// \return boolean result
static bool findInSelection(const ObjectPtr& theObject,
GeomShapePtr theShape,
- const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection);
+ const std::map<ObjectPtr, std::set<GeomShapePtr> >& theGeomSelection,
+ ModuleBase_IWorkshop* theWorkshop);
protected:
/// List control
return myWorkshop->desktop();
}
+bool XGUI_ModuleConnector::hasSHIFTPressed() const
+{
+ return myWorkshop->operationMgr()->hasSHIFTPressed();
+}
std::shared_ptr<Config_FeatureMessage> XGUI_ModuleConnector::featureInfo(const QString& theId) const
{
/// Return application main window
virtual QMainWindow* desktop() const;
+ /// Returns true if SHIFT is pressed
+ /// \return boolean value
+ virtual bool hasSHIFTPressed() const;
//! Returns workshop
XGUI_Workshop* workshop() const { return myWorkshop; }
virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
{
bool isAccepted = false;
- if (myIsActive && theEvent->type() == QEvent::KeyRelease) {
- QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
- if (aKeyEvent) {
- switch (aKeyEvent->key()) {
- case Qt::Key_Delete:
- isAccepted = myOperationMgr->onProcessDelete(theObject);
- break;
- default:
- isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
+ if (myIsActive) {
+ if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
+ if (aKeyEvent) {
+ myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier);
+ switch (aKeyEvent->key()) {
+ case Qt::Key_Delete:
+ isAccepted = myOperationMgr->onProcessDelete(theObject);
break;
+ default:
+ isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
+ break;
+ }
}
}
+ else if (theEvent->type() == QEvent::KeyPress) {
+ QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
+ myOperationMgr->setSHIFTPressed(aKeyEvent->modifiers() & Qt::ShiftModifier);
+ }
}
if (!isAccepted)
isAccepted = QObject::eventFilter(theObject, theEvent);
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
ModuleBase_IWorkshop* theWorkshop)
-: QObject(theParent), myWorkshop(theWorkshop)
+: QObject(theParent), myWorkshop(theWorkshop), mySHIFTPressed(false)
{
/// we need to install filter to the application in order to react to 'Delete' key button
/// this key can not be a short cut for a corresponded action because we need to set
/// Slot that commits the current operation.
bool onCommitOperation();
+ /// Returns true if SHIFT is pressed
+ /// \param thePressed new boolean state
+ void setSHIFTPressed(const bool thePressed) { mySHIFTPressed = thePressed; }
+
+ /// Returns true if SHIFT is pressed
+ /// \return boolean value
+ bool hasSHIFTPressed() const { return mySHIFTPressed; }
+
public slots:
/// Slot that aborts the current operation.
void onAbortOperation();
ModuleBase_IWorkshop* myWorkshop;
XGUI_ShortCutListener* myShortCutListener;
+ bool mySHIFTPressed;
};
#endif