It seems that the reason is the Deactivate of AIS_IO lost the selection state in OCC for the object and by any redisplay it is deselected.
It is decided to minimize number of deactivate call and use the same active mode during edit operation(the line selection) like in the sketch operation. In the case, the scenario do not call deactivate and selection is saved.
// Author: Vitaly Smetannikov
#include "ModuleBase_Tools.h"
+
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Data.h>
+
#include <QWidget>
#include <QLayout>
#include <QPainter>
theSpin->blockSignals(isBlocked);
}
+QString objectInfo(const ObjectPtr& theObj)
+{
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
+ FeaturePtr aFeature;// = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
+ QString aFeatureStr = "feature";
+ if(aRes.get()) {
+ aFeatureStr.append("(Result)");
+ //aFeature = ModelAPI_Feature::feature(aRes);
+ }
+ if (aFeature.get()) {
+ aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
+ if (aFeature->data().get() && aFeature->data()->isValid())
+ aFeatureStr.append(QString("(name=%1)").arg(aFeature->data()->name().c_str()).toStdString().c_str());
+ }
+ return aFeatureStr;
+}
+
}
#include "ModuleBase.h"
+#include <ModelAPI_Feature.h>
+
#include <QPixmap>
class QWidget;
/// \param theValue a new value
MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
+/// Converts the object to the feature or a result and generate information string
+/// \param theObj an object
+/// \return a string
+MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj);
+
}
#endif
#include <SketchPlugin_ConstraintFillet.h>
#include <SketchPlugin_ConstraintMirror.h>
+#include <SketcherPrs_Tools.h>
+
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
//#include <AIS_DimensionSelectionMode.hxx>
-//#include <AIS_Shape.hxx>
+#include <AIS_Shape.hxx>
#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
void PartSet_SketcherMgr::launchEditing()
{
- // there should be activate the vertex selection mode because the edit can happens by the selected
- // point
- QIntList aModes;
- aModes << TopAbs_VERTEX << TopAbs_EDGE;
- // TODO: #391 - to be uncommented
- /*aModes.append(AIS_DSM_Text);
- aModes.append(AIS_DSM_Line);
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));*/
-
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- aConnector->activateSubShapesSelection(aModes);
+ // there should be activate the sketch selection mode because the edit can happens
+ // by any sketch entity or consttant selected
+ activateObjectsInSketchMode(true);
if (!myCurrentSelection.empty()) {
FeaturePtr aFeature = myCurrentSelection.begin().key();
{
myIsMouseOverWindow = false;
myIsConstraintsShown = true;
+ // the objects activated in the sketch should be deactivated in order to do not have the specific
+ // sketch selection mode activated on objects in neutral point of the application(no started operation)
+ activateObjectsInSketchMode(false);
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
connectToPropertyPanel(false);
myIsPropertyPanelValueChanged = false;
myIsMouseOverViewProcessed = true;
+
+ // the sketch objects selection should be activated in order to select any sketch
+ // object
+ activateObjectsInSketchMode(true);
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
+
+ // 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
+ activateObjectsInSketchMode(true);
}
void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
aDisplayer->updateViewer();
}
+void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive)
+{
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ QIntList aModes;
+ if (isActive) {
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+ aModes.append(SketcherPrs_Tools::Sel_Constraint);
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+ }
+ aDisplayer->activateObjects(aModes);
+}
+
void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
{
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
/// \param isToDisplay a flag about the display or erase the feature
void visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay);
+ /// Activates all visualized objects in the following selection modes: Dimension_Text/Line/Constraint,
+ /// Shape Edge and Vertex. If the active flag is empty, it deactivates all modes
+ /// \param isActive the flag whether the modes should be activated or deactivated
+ void activateObjectsInSketchMode(const bool isActive);
+
private:
PartSet_Module* myModule;
#include <Config_PropManager.h>
#include <QLabel>
-#include <QTimer>
+//#include <QTimer>
#include <QApplication>
#include <QVBoxLayout>
#include <QCheckBox>
myLabel->setToolTip("");
myLabel->setIndent(5);
- mySelectionTimer = new QTimer(this);
- connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
- mySelectionTimer->setSingleShot(true);
+ //mySelectionTimer = new QTimer(this);
+ //connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
+ //mySelectionTimer->setSingleShot(true);
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
//XGUI_Displayer* aDisp = myWorkshop->displayer();
//aDisp->closeLocalContexts();
emit planeSelected(plane());
- setSketchingMode();
+ //setSketchingMode();
// Update sketcher actions
XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
// In order to avoid Opening/Closing of context too often
// it can be useful for a delay on the property panel filling
// it is possible that it is not necessary anymore, but it requires a check
- mySelectionTimer->start(20);
+ //mySelectionTimer->start(20);
} else {
// We have to select a plane before any operation
showPreviewPlanes();
void PartSet_WidgetSketchLabel::deactivate()
{
// Do not set selection mode if the widget was activated for a small moment
- mySelectionTimer->stop();
+ //mySelectionTimer->stop();
//XGUI_Displayer* aDisp = myWorkshop->displayer();
//aDisp->closeLocalContexts();
erasePreviewPlanes();
}
-void PartSet_WidgetSketchLabel::setSketchingMode()
+/*void PartSet_WidgetSketchLabel::setSketchingMode()
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
// Clear standard selection modes if they are defined
//aDisp->openLocalContext();
// Get default selection modes
+
QIntList aModes;
aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
aDisp->activateObjects(aModes);
-}
+}*/
void PartSet_WidgetSketchLabel::showConstraints(bool theOn)
{
#include <TopoDS_Shape.hxx>
class QLabel;
-class QTimer;
+//class QTimer;
class XGUI_OperationMgr;
class XGUI_Workshop;
class QCheckBox;
void onPlaneSelected();
/// Set sketch specific mode of selection
- void setSketchingMode();
+ //void setSketchingMode();
private:
/// Create preview of planes for sketch plane selection
AISObjectPtr myXYPlane;
bool myPreviewDisplayed;
- QTimer* mySelectionTimer;
+ //QTimer* mySelectionTimer;
QCheckBox* myShowConstraints;
};
if (aContext.IsNull() || theIO.IsNull())
return;
- aContext->Load(theIO, -1, true);
- aContext->Deactivate(theIO);
+ // deactivate object in all modes, which are not in the list of activation
+ TColStd_ListOfInteger aTColModes;
+ aContext->ActivatedModes(theIO, aTColModes);
+ TColStd_ListIteratorOfListOfInteger itr( aTColModes );
+ QIntList aModesActivatedForIO;
+ for (; itr.More(); itr.Next() ) {
+ Standard_Integer aMode = itr.Value();
+ if (!theModes.contains(aMode)) {
+#ifdef DEBUG_ACTIVATE
+ qDebug(QString("deactivate: %1").arg(aMode).toStdString().c_str());
+#endif
+ aContext->Deactivate(theIO, aMode);
+ }
+ else {
+ aModesActivatedForIO.append(aMode);
+#ifdef DEBUG_ACTIVATE
+ qDebug(QString(" active: %1").arg(aMode).toStdString().c_str());
+#endif
+ }
+ }
+ // loading the interactive object allowing the decomposition
+ if (aTColModes.IsEmpty())
+ aContext->Load(theIO, -1, true);
+
Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
//Deactivate trihedron which can be activated in local selector
if (aTrihedron.IsNull()) {
if (theModes.size() == 0) {
//aContext->Load(anAISIO, 0, true);
aContext->Activate(theIO);
+#ifdef DEBUG_ACTIVATE
+ qDebug("activate in all modes");
+#endif
} else {
foreach(int aMode, theModes) {
//aContext->Load(anAISIO, aMode, true);
- aContext->Activate(theIO, aMode);
+ if (!aModesActivatedForIO.contains(aMode)) {
+ aContext->Activate(theIO, aMode);
+#ifdef DEBUG_ACTIVATE
+ qDebug(QString("activate: %1").arg(aMode).toStdString().c_str());
+#endif
+ }
}
}
}
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IViewer.h>
-#include<ModuleBase_FilterFactory.h>
+#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_PageBase.h>
+#include <ModuleBase_Tools.h>
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
//#define DEBUG_FEATURE_CREATED
//#define DEBUG_FEATURE_REDISPLAY
-QString objectInfo(ObjectPtr theObj)
-{
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
- QString aFeatureStr = "feature";
- if(aRes.get()) {
- aFeatureStr.append("(Result)");
- aFeature = ModelAPI_Feature::feature(aRes);
- }
- if (aFeature.get()) {
- aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
- if (aFeature->data().get() && aFeature->data()->isValid())
- aFeatureStr.append(QString("(name=%1)").arg(aFeature->data()->name().c_str()).toStdString().c_str());
- }
- return aFeatureStr;
-}
-
-
QMap<QString, QString> XGUI_Workshop::myIcons;
#ifdef DEBUG_FEATURE_REDISPLAY
QStringList anInfo;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
- anInfo.append(objectInfo((*aIt)));
+ anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
}
QString anInfoStr = anInfo.join(", ");
qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
// Redisplay the visible object or the object of the current operation
bool isVisibleObject = myDisplayer->isVisible(aObj);
#ifdef DEBUG_FEATURE_REDISPLAY
- //QString anObjInfo = objectInfo((aObj));
+ //QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
//qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
#endif
#ifdef DEBUG_FEATURE_CREATED
QStringList anInfo;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
- anInfo.append(objectInfo((*aIt)));
+ anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
}
QString anInfoStr = anInfo.join(", ");
qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
// Activate objects created by current operation
// in order to clean selection modes
- QIntList aModes;
- myDisplayer->activateObjects(aModes);
+ // the deactivation should be pefromed in the same place, where the mode is activated,
+ // e.g. activation in the current widget activation, deactivation - in the widget's deactivation
+ //QIntList aModes;
+ //myDisplayer->activateObjects(aModes);
myModule->operationStopped(theOperation);
}