mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-15 14:20:37 +05:00
Local selection in annotation dialog.
This commit is contained in:
parent
7acc0d2541
commit
f6b136c261
@ -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 ))
|
||||
|
@ -81,6 +81,7 @@ private slots:
|
||||
QHash<QString, QTreeWidgetItem*> myObjects;
|
||||
SalomeApp_Study* myStudy;
|
||||
QTreeWidgetItem* myDimensionsItem;
|
||||
QTreeWidgetItem* myAnnotationsItem;
|
||||
GEOM_Displayer myDisplayer;
|
||||
|
||||
QMap<int, QAction*> myActions; //!< menu actions list
|
||||
|
@ -575,6 +575,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>GEOM_DIMENSIONS</source>
|
||||
<translation>Dimensions</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_ANNOTATIONS</source>
|
||||
<translation>Annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_SKETCHER_DIST</source>
|
||||
<translation>Distance</translation>
|
||||
@ -6757,6 +6761,10 @@ Please specify suitable arguments.</translation>
|
||||
<source>ANNOTATION_SUB_SHAPE</source>
|
||||
<translation>Sub-shape type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WHOLE_SHAPE</source>
|
||||
<translation>Whole shape</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_STYLE</source>
|
||||
<translation>Style</translation>
|
||||
|
@ -148,16 +148,11 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
||||
|
||||
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
|
||||
mySubShapeTypeCombo = new QComboBox(propGroup);
|
||||
QMap<QString, TopAbs_ShapeEnum> 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<QString, TopAbs_ShapeEnum>::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())
|
||||
if (mySelectionMode == TopAbs_SHAPE) {
|
||||
myEditCurrentArgument->setText(aName);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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"))
|
||||
|
@ -83,11 +83,12 @@ private slots:
|
||||
private:
|
||||
void Init();
|
||||
|
||||
void activateSelection();
|
||||
TopAbs_ShapeEnum getShapeType() const;
|
||||
gp_Pnt getAttachPoint(const TopoDS_Shape& theShape);
|
||||
|
||||
private:
|
||||
QList<TopAbs_ShapeEnum> mySelectionModes;
|
||||
TopAbs_ShapeEnum mySelectionMode;
|
||||
GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties;
|
||||
/// an index of edited annotation in the list shape annotations, -1 in create operation
|
||||
bool myIsCreation;
|
||||
|
Loading…
Reference in New Issue
Block a user