Local selection in annotation dialog.

This commit is contained in:
nds 2016-10-06 14:33:25 +03:00
parent 7acc0d2541
commit f6b136c261
5 changed files with 73 additions and 34 deletions

View File

@ -84,6 +84,12 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
addTopLevelItem( myDimensionsItem ); 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 // get a free dockable window id
myWindowID = 11; myWindowID = 11;
while( app->dockWindow( myWindowID )) while( app->dockWindow( myWindowID ))

View File

@ -81,6 +81,7 @@ private slots:
QHash<QString, QTreeWidgetItem*> myObjects; QHash<QString, QTreeWidgetItem*> myObjects;
SalomeApp_Study* myStudy; SalomeApp_Study* myStudy;
QTreeWidgetItem* myDimensionsItem; QTreeWidgetItem* myDimensionsItem;
QTreeWidgetItem* myAnnotationsItem;
GEOM_Displayer myDisplayer; GEOM_Displayer myDisplayer;
QMap<int, QAction*> myActions; //!< menu actions list QMap<int, QAction*> myActions; //!< menu actions list

View File

@ -575,6 +575,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_DIMENSIONS</source> <source>GEOM_DIMENSIONS</source>
<translation>Dimensions</translation> <translation>Dimensions</translation>
</message> </message>
<message>
<source>GEOM_ANNOTATIONS</source>
<translation>Annotations</translation>
</message>
<message> <message>
<source>GEOM_SKETCHER_DIST</source> <source>GEOM_SKETCHER_DIST</source>
<translation>Distance</translation> <translation>Distance</translation>
@ -6757,6 +6761,10 @@ Please specify suitable arguments.</translation>
<source>ANNOTATION_SUB_SHAPE</source> <source>ANNOTATION_SUB_SHAPE</source>
<translation>Sub-shape type</translation> <translation>Sub-shape type</translation>
</message> </message>
<message>
<source>WHOLE_SHAPE</source>
<translation>Whole shape</translation>
</message>
<message> <message>
<source>ANNOTATION_STYLE</source> <source>ANNOTATION_STYLE</source>
<translation>Style</translation> <translation>Style</translation>

View File

@ -148,16 +148,11 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup); QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
mySubShapeTypeCombo = new QComboBox(propGroup); mySubShapeTypeCombo = new QComboBox(propGroup);
QMap<QString, TopAbs_ShapeEnum> aShapeTypes; mySubShapeTypeCombo->addItem(tr("WHOLE_SHAPE"), TopAbs_SHAPE);
aShapeTypes[tr("WHOLE_SHAPE")] = TopAbs_SHAPE; mySubShapeTypeCombo->addItem(tr("GEOM_VERTEX"), TopAbs_VERTEX);
aShapeTypes[tr("GEOM_VERTEX")] = TopAbs_VERTEX; mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
aShapeTypes[tr("GEOM_EDGE")] = TopAbs_EDGE; mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
aShapeTypes[tr("GEOM_FACE")] = TopAbs_FACE; mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
aShapeTypes[tr("GEOM_SOLID")] = TopAbs_SOLID;
QMap<QString, TopAbs_ShapeEnum>::const_iterator anIt = aShapeTypes.begin(),
aLast = aShapeTypes.end();
for (; anIt != aLast; anIt++)
mySubShapeTypeCombo->addItem(anIt.key(), anIt.value());
mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX
propLayout->addWidget(shapeTypeLabel, 3, 0); propLayout->addWidget(shapeTypeLabel, 3, 0);
@ -224,17 +219,16 @@ void MeasureGUI_AnnotationDlg::Init()
// default presentation values // default presentation values
myAnnotationProperties.Position = gp_Pnt(50, 50, 50); myAnnotationProperties.Position = gp_Pnt(50, 50, 50);
myAnnotationProperties.Text = "Text"; myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
myAnnotationProperties.IsVisible = true; myAnnotationProperties.IsVisible = true;
myAnnotationProperties.IsScreenFixed = true; myAnnotationProperties.IsScreenFixed = false;
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);; myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
myAnnotationProperties.ShapeIndex = 1; myAnnotationProperties.ShapeIndex = -1;
myAnnotationProperties.ShapeType = 1; myAnnotationProperties.ShapeType = (int)TopAbs_SHAPE;
SelectionIntoArgument(); SelectionIntoArgument();
mySelectionModes.clear(); mySelectionMode = TopAbs_SHAPE;
mySelectionModes.append(TopAbs_SHAPE);
connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(mySubShapeSelBtn, 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)), connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onSubShapeTypeChange())); this, SLOT(onSubShapeTypeChange()));
SelectionIntoArgument();
} }
else { // edition else { // edition
@ -251,6 +246,18 @@ void MeasureGUI_AnnotationDlg::Init()
redisplayPreview(); 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() // function : getShapeType()
// purpose : // purpose :
@ -288,6 +295,7 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply()
showError(msg); showError(msg);
return false; return false;
} }
SUIT_OverrideCursor wc; SUIT_OverrideCursor wc;
SUIT_Session::session()->activeApplication()->putInfo(""); SUIT_Session::session()->activeApplication()->putInfo("");
@ -345,6 +353,8 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
if (myEditCurrentArgument) if (myEditCurrentArgument)
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
aSelectButton->setDown(true);
if (aSelectButton->isChecked()) if (aSelectButton->isChecked())
anOtherButton->setDown(false); anOtherButton->setDown(false);
@ -359,28 +369,39 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
void MeasureGUI_AnnotationDlg::SelectionIntoArgument() void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
{ {
if (myIsCreation && myEditCurrentArgument) { if (myIsCreation && myEditCurrentArgument) {
GEOM::GeomObjPtr anObj = getSelected(mySelectionModes); GEOM::GeomObjPtr anObj = getSelected(mySelectionMode);
QString aName = GEOMBase::GetName(anObj.get()); QString aName = GEOMBase::GetName(anObj.get());
myEditCurrentArgument->setText(aName);
gp_Pnt anAttachPoint; gp_Pnt anAttachPoint(0, 0, 0);
int aSubShapeIndex = -1; int aSubShapeIndex = -1;
if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
if (myShape->_is_nil()) if (mySelectionMode == TopAbs_SHAPE) {
myEditCurrentArgument->setText(aName);
if (anObj->_is_nil())
myShape = GEOM::GEOM_Object::_nil(); myShape = GEOM::GEOM_Object::_nil();
else else
myShape = anObj; myShape = anObj;
bool aNullShape = myShape->_is_nil();
mySubShapeTypeCombo->setEnabled(!aNullShape);
mySubShapeSelBtn->setEnabled(!aNullShape);
mySubShapeName->setEnabled(!aNullShape);
activateSelection();
if (!myShape->_is_nil()) { if (!myShape->_is_nil()) {
TopoDS_Shape aShape; TopoDS_Shape aShape;
GEOMBase::GetShape(myShape.get(), aShape); GEOMBase::GetShape(myShape.get(), aShape);
anAttachPoint = getAttachPoint(aShape); anAttachPoint = getAttachPoint(aShape);
} }
} }
else if (myEditCurrentArgument == myShapeName) { }
else if (myEditCurrentArgument == mySubShapeName) {
if (!myShape->_is_nil()) { if (!myShape->_is_nil()) {
myEditCurrentArgument->setText(aName);
TopTools_IndexedMapOfShape aMainMap; TopTools_IndexedMapOfShape aMainMap;
TopoDS_Shape aMainShape; TopoDS_Shape aMainShape;
GEOMBase::GetShape(myShape.get(), aMainShape); GEOMBase::GetShape(myShape.get(), aMainShape);
@ -431,9 +452,11 @@ void MeasureGUI_AnnotationDlg::onTypeChange()
//======================================================================= //=======================================================================
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
{ {
//TopAbs_ShapeEnum aShapeType = getShapeType(); TopAbs_ShapeEnum aShapeType = getShapeType();
//myAnnotationProperties.ShapeType = aShapeType; myAnnotationProperties.ShapeType = aShapeType;
mySelectionMode = getShapeType();
activateSelection();
redisplayPreview(); redisplayPreview();
} }
@ -455,7 +478,7 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
tr("GEOM_STUDY_LOCKED")) tr("GEOM_STUDY_LOCKED"))
if (myIsCreation) { if (myIsCreation) {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_SHAPE")) RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
} }
else { else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD")) //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 (getShapeType() != TopAbs_SHAPE) {
if (myIsCreation) { if (myIsCreation) {
//RETURN_WITH_MSG(myAnnotationProperties.SubShapeId >= 0, tr("NO_SUB_SHAPE")) RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
} }
else { else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD")) //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))

View File

@ -83,11 +83,12 @@ private slots:
private: private:
void Init(); void Init();
void activateSelection();
TopAbs_ShapeEnum getShapeType() const; TopAbs_ShapeEnum getShapeType() const;
gp_Pnt getAttachPoint(const TopoDS_Shape& theShape); gp_Pnt getAttachPoint(const TopoDS_Shape& theShape);
private: private:
QList<TopAbs_ShapeEnum> mySelectionModes; TopAbs_ShapeEnum mySelectionMode;
GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties; GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties;
/// an index of edited annotation in the list shape annotations, -1 in create operation /// an index of edited annotation in the list shape annotations, -1 in create operation
bool myIsCreation; bool myIsCreation;