From: nds Date: Thu, 6 Oct 2016 11:33:25 +0000 (+0300) Subject: Local selection in annotation dialog. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f6b136c2615c93e98846727ffde7c4ef259471d6;p=modules%2Fgeom.git Local selection in annotation dialog. --- diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx index 2e3218b1e..d7b0c221c 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -84,6 +84,12 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app ) myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); addTopLevelItem( myDimensionsItem ); + rootNames.clear(); + rootNames << tr("GEOM_ANNOTATIONS") << ""; + myAnnotationsItem = new QTreeWidgetItem( this, rootNames ); + myAnnotationsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); + addTopLevelItem( myAnnotationsItem ); + // get a free dockable window id myWindowID = 11; while( app->dockWindow( myWindowID )) diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h index 4f6677c88..6efa1609a 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h @@ -81,6 +81,7 @@ private slots: QHash myObjects; SalomeApp_Study* myStudy; QTreeWidgetItem* myDimensionsItem; + QTreeWidgetItem* myAnnotationsItem; GEOM_Displayer myDisplayer; QMap myActions; //!< menu actions list diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 5fedc59b9..8cd44f2a4 100755 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -575,6 +575,10 @@ Please, select face, shell or solid and try again GEOM_DIMENSIONS Dimensions + + GEOM_ANNOTATIONS + Annotations + GEOM_SKETCHER_DIST Distance @@ -6757,6 +6761,10 @@ Please specify suitable arguments. ANNOTATION_SUB_SHAPE Sub-shape type + + WHOLE_SHAPE + Whole shape + ANNOTATION_STYLE Style diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx index be023857f..705877db3 100644 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -148,16 +148,11 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI, QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup); mySubShapeTypeCombo = new QComboBox(propGroup); - QMap aShapeTypes; - aShapeTypes[tr("WHOLE_SHAPE")] = TopAbs_SHAPE; - aShapeTypes[tr("GEOM_VERTEX")] = TopAbs_VERTEX; - aShapeTypes[tr("GEOM_EDGE")] = TopAbs_EDGE; - aShapeTypes[tr("GEOM_FACE")] = TopAbs_FACE; - aShapeTypes[tr("GEOM_SOLID")] = TopAbs_SOLID; - QMap::const_iterator anIt = aShapeTypes.begin(), - aLast = aShapeTypes.end(); - for (; anIt != aLast; anIt++) - mySubShapeTypeCombo->addItem(anIt.key(), anIt.value()); + mySubShapeTypeCombo->addItem(tr("WHOLE_SHAPE"), TopAbs_SHAPE); + mySubShapeTypeCombo->addItem(tr("GEOM_VERTEX"), TopAbs_VERTEX); + mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE); + mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE); + mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID); mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX propLayout->addWidget(shapeTypeLabel, 3, 0); @@ -224,17 +219,16 @@ void MeasureGUI_AnnotationDlg::Init() // default presentation values myAnnotationProperties.Position = gp_Pnt(50, 50, 50); - myAnnotationProperties.Text = "Text"; + myAnnotationProperties.Text = tr("ANNOTATION_PREFIX"); myAnnotationProperties.IsVisible = true; - myAnnotationProperties.IsScreenFixed = true; - myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);; - myAnnotationProperties.ShapeIndex = 1; - myAnnotationProperties.ShapeType = 1; + myAnnotationProperties.IsScreenFixed = false; + myAnnotationProperties.Attach = gp_Pnt(0, 0, 0); + myAnnotationProperties.ShapeIndex = -1; + myAnnotationProperties.ShapeType = (int)TopAbs_SHAPE; SelectionIntoArgument(); - mySelectionModes.clear(); - mySelectionModes.append(TopAbs_SHAPE); + mySelectionMode = TopAbs_SHAPE; connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(mySubShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -244,6 +238,7 @@ void MeasureGUI_AnnotationDlg::Init() connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSubShapeTypeChange())); + SelectionIntoArgument(); } else { // edition @@ -251,6 +246,18 @@ void MeasureGUI_AnnotationDlg::Init() redisplayPreview(); } +//================================================================================= +// function : activateSelection +// purpose : Activate local selection +//================================================================================= +void MeasureGUI_AnnotationDlg::activateSelection() +{ + globalSelection(GEOM_ALLSHAPES); + if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) { + localSelection(myShape.get(), mySelectionMode); + } +} + //================================================================================= // function : getShapeType() // purpose : @@ -288,6 +295,7 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply() showError(msg); return false; } + SUIT_OverrideCursor wc; SUIT_Session::session()->activeApplication()->putInfo(""); @@ -345,6 +353,8 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() if (myEditCurrentArgument) myEditCurrentArgument->setFocus(); + aSelectButton->setDown(true); + if (aSelectButton->isChecked()) anOtherButton->setDown(false); @@ -359,28 +369,39 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() void MeasureGUI_AnnotationDlg::SelectionIntoArgument() { if (myIsCreation && myEditCurrentArgument) { - GEOM::GeomObjPtr anObj = getSelected(mySelectionModes); + GEOM::GeomObjPtr anObj = getSelected(mySelectionMode); QString aName = GEOMBase::GetName(anObj.get()); - myEditCurrentArgument->setText(aName); - gp_Pnt anAttachPoint; + gp_Pnt anAttachPoint(0, 0, 0); int aSubShapeIndex = -1; if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active - if (myShape->_is_nil()) - myShape = GEOM::GEOM_Object::_nil(); - else - myShape = anObj; + if (mySelectionMode == TopAbs_SHAPE) { + myEditCurrentArgument->setText(aName); - if (!myShape->_is_nil()) { - TopoDS_Shape aShape; - GEOMBase::GetShape(myShape.get(), aShape); + if (anObj->_is_nil()) + myShape = GEOM::GEOM_Object::_nil(); + else + myShape = anObj; + + bool aNullShape = myShape->_is_nil(); + mySubShapeTypeCombo->setEnabled(!aNullShape); + mySubShapeSelBtn->setEnabled(!aNullShape); + mySubShapeName->setEnabled(!aNullShape); + activateSelection(); - anAttachPoint = getAttachPoint(aShape); + + if (!myShape->_is_nil()) { + TopoDS_Shape aShape; + GEOMBase::GetShape(myShape.get(), aShape); + anAttachPoint = getAttachPoint(aShape); + } } } - else if (myEditCurrentArgument == myShapeName) { + else if (myEditCurrentArgument == mySubShapeName) { if (!myShape->_is_nil()) { + myEditCurrentArgument->setText(aName); + TopTools_IndexedMapOfShape aMainMap; TopoDS_Shape aMainShape; GEOMBase::GetShape(myShape.get(), aMainShape); @@ -431,9 +452,11 @@ void MeasureGUI_AnnotationDlg::onTypeChange() //======================================================================= void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() { - //TopAbs_ShapeEnum aShapeType = getShapeType(); - //myAnnotationProperties.ShapeType = aShapeType; + TopAbs_ShapeEnum aShapeType = getShapeType(); + myAnnotationProperties.ShapeType = aShapeType; + mySelectionMode = getShapeType(); + activateSelection(); redisplayPreview(); } @@ -455,7 +478,7 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) tr("GEOM_STUDY_LOCKED")) if (myIsCreation) { - //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_SHAPE")) + RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE")) } else { //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD")) @@ -463,7 +486,7 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) if (getShapeType() != TopAbs_SHAPE) { if (myIsCreation) { - //RETURN_WITH_MSG(myAnnotationProperties.SubShapeId >= 0, tr("NO_SUB_SHAPE")) + RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE")) } else { //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD")) diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h index 2c70750b9..94d41bfff 100644 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h @@ -83,11 +83,12 @@ private slots: private: void Init(); + void activateSelection(); TopAbs_ShapeEnum getShapeType() const; gp_Pnt getAttachPoint(const TopoDS_Shape& theShape); private: - QList mySelectionModes; + TopAbs_ShapeEnum mySelectionMode; GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties; /// an index of edited annotation in the list shape annotations, -1 in create operation bool myIsCreation;