mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 06:00:32 +05:00
Store fixed 2D position into attribute; check box is provided for fixed screen position
This commit is contained in:
parent
a2313210be
commit
c0dab87689
@ -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<SalomeApp_Study*>( 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<SOCC_Prs*> (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 );
|
||||
|
@ -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; }
|
||||
|
@ -6797,6 +6797,10 @@ Please specify suitable arguments.</translation>
|
||||
<source>ANNOTATION_SUB_SHAPE</source>
|
||||
<translation>Sub-shape type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_IS_SCREEN_FIXED</source>
|
||||
<translation>Fixed screen position</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WHOLE_SHAPE</source>
|
||||
<translation>Whole shape</translation>
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user