From: nds Date: Tue, 15 Nov 2016 13:45:26 +0000 (+0300) Subject: Store fixed 2D position into attribute; check box is provided for fixed screen position X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0dab87689b57a4e5c72384909914fec20cc2b37;p=modules%2Fgeom.git Store fixed 2D position into attribute; check box is provided for fixed screen position --- diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx index 89d46eae6..b77b46059 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx @@ -157,6 +157,7 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex // change persistent for the entry: set visible state in true for indices which presentations are shown storeVisibleState( theEntry, theView ); + storeFixedPosition( theEntry, theView ); } void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex, @@ -545,6 +546,47 @@ void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theInd } } +void GEOMGUI_AnnotationMgr::storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView ) +{ + SOCC_Viewer* aView = viewOrActiveView( theView ); + if ( !aView || !myVisualized.contains( aView ) ) + return; + + SalomeApp_Study* aStudy = dynamic_cast( getApplication()->activeStudy() ); + _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() ); + const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj ); + if ( aShapeAnnotations.IsNull() ) + return; + + + EntryToAnnotations anEntryToAnnotation = myVisualized[aView]; + AnnotationToPrs anAnnotationToPrs; + if ( anEntryToAnnotation.contains( theEntry ) ) + anAnnotationToPrs = anEntryToAnnotation[theEntry]; + + AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin(); + for (; anIt != anAnnotationToPrs.end(); ++anIt ) { + int anIndex = anIt.key(); + bool isFixedAnnotation = aShapeAnnotations->GetIsScreenFixed( anIndex ); + if ( !isFixedAnnotation ) + continue; + + SOCC_Prs* aPrs = dynamic_cast (anIt.value()); + Handle(GEOM_Annotation) anAnnotationPresentation; + + AIS_ListOfInteractive aIObjects; + aPrs->GetObjects( aIObjects ); + AIS_ListOfInteractive::Iterator aIOIt( aIObjects ); + for ( ; aIOIt.More(); aIOIt.Next() ) { + anAnnotationPresentation = Handle(GEOM_Annotation)::DownCast( aIOIt.Value() ); + if ( !anAnnotationPresentation.IsNull() ) + break; + } + if ( !anAnnotationPresentation.IsNull() ) + aShapeAnnotations->SetPosition( anIndex, anAnnotationPresentation->GetPosition() ); + } +} + void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SOCC_Viewer* theView ) { SOCC_Viewer* aView = viewOrActiveView( theView ); diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h index 0958ad146..44ae4313d 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h @@ -85,6 +85,8 @@ public: QString makeAnnotationEntry( const QString& theEntry, const int theIndex ); + void storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView ); + protected: SalomeApp_Application* getApplication() const { return myApplication; } diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index dce9204b5..722a05998 100755 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -6797,6 +6797,10 @@ Please specify suitable arguments. ANNOTATION_SUB_SHAPE Sub-shape type + + ANNOTATION_IS_SCREEN_FIXED + Fixed screen position + WHOLE_SHAPE Whole shape diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx index bcd2163d3..ffe7a327c 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -147,17 +147,13 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, myShapeName->setEnabled( myIsCreation ); // data type - QLabel* typeLabel = new QLabel( tr( "ANNOTATION_TYPE" ), propGroup ); - myTypeCombo = new QComboBox( propGroup ); - myTypeCombo->addItem( tr( "3D" ), 0 ); - myTypeCombo->addItem( tr( "2D" ), 1 ); - myTypeCombo->setCurrentIndex( 0 ); // 3D, not fixed + myIsScreenFixed = new QCheckBox( tr( "ANNOTATION_IS_SCREEN_FIXED" ), propGroup ); + myIsScreenFixed->setChecked( false ); // 3D, not fixed propLayout->addWidget( shapeLabel, 1, 0 ); propLayout->addWidget( myShapeSelBtn, 1, 1 ); propLayout->addWidget( myShapeName, 1, 2 ); - propLayout->addWidget( typeLabel, 2, 0, 1, 2 ); - propLayout->addWidget( myTypeCombo, 2, 2 ); + propLayout->addWidget( myIsScreenFixed, 2, 0, 1, 3 ); propLayout->setColumnStretch( 2, 5 ); QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup ); @@ -237,7 +233,7 @@ void MeasureGUI_AnnotationDlg::Init() myTextEdit->setText( myAnnotationProperties.Text ); myShapeNameModified = false; - myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 ); + myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed ); int aSubShapeTypeIndex = -1; int aTypesCount = aTypesCount = mySubShapeTypeCombo->count(); @@ -259,7 +255,7 @@ void MeasureGUI_AnnotationDlg::Init() SLOT( SetEditCurrentArgument() ) ); connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) ); - connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) ); + connect( myIsScreenFixed, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChange() ) ); connect( mySubShapeTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSubShapeTypeChange() ) ); @@ -290,7 +286,7 @@ void MeasureGUI_AnnotationDlg::Init() /// fill dialog controls myTextEdit->setText( myAnnotationProperties.Text ); myShapeNameModified = false; - myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 ); + myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed ); int aSubShapeTypeIndex = -1; int aTypesCount = aTypesCount = mySubShapeTypeCombo->count(); @@ -325,7 +321,7 @@ void MeasureGUI_AnnotationDlg::Init() // connect controls connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) ); - connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) ); + connect( myIsScreenFixed, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChange() ) ); myGeomGUI->GetAnnotationMgr()->SetPreviewStyle( myEditAnnotationEntry, myEditAnnotationIndex, true ); @@ -604,7 +600,7 @@ void MeasureGUI_AnnotationDlg::onTypeChange() { const bool isScreenFixedBefore = myAnnotationProperties.IsScreenFixed; - myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1; + myAnnotationProperties.IsScreenFixed = myIsScreenFixed->isChecked(); // convert point position from screen space to 3D space if ( myIsPositionDefined ) { @@ -685,6 +681,10 @@ void MeasureGUI_AnnotationDlg::onDragged( Handle_GEOM_Annotation theAnnotation ) if ( !myAnnotationProperties.IsScreenFixed ) { myAnnotationProperties.Position = theAnnotation->GetPosition().Transformed( aToShapeLCS ); + + if ( !myIsCreation ) { + myGeomGUI->GetAnnotationMgr()->storeFixedPosition( myEditAnnotationEntry, 0 ); + } } else { myAnnotationProperties.Position = theAnnotation->GetPosition(); diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h index a3f0bf04e..a29d88712 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h @@ -46,6 +46,7 @@ class QGroupBox; class QLineEdit; class QPushButton; class QComboBox; +class QCheckBox; class SalomeApp_IntSpinBox; class MeasureGUI_AnnotationInteractor; @@ -115,7 +116,7 @@ private: // update shape name by shape selection if it has not been manually modified yet bool myShapeNameModified; QLineEdit* myShapeName; - QComboBox* myTypeCombo; + QCheckBox* myIsScreenFixed; QComboBox* mySubShapeTypeCombo;