storeVisibleState( theEntry, theView );
}
+void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
+ const GEOMGUI_AnnotationAttrs::Properties& theProperty )
+{
+ SUIT_Session* ses = SUIT_Session::session();
+ SUIT_Application* app = ses->activeApplication();
+ if ( app )
+ {
+ SUIT_Desktop* desk = app->desktop();
+ QList<SUIT_ViewWindow*> wnds = desk->windows();
+ SUIT_ViewWindow* wnd;
+ QListIterator<SUIT_ViewWindow*> it( wnds );
+ while ( it.hasNext() && (wnd = it.next()) )
+ {
+ SUIT_ViewManager* vman = wnd->getViewManager();
+ if ( vman )
+ {
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ if ( vmodel )
+ {
+ SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
+ if ( aView )
+ Redisplay( theEntry, theIndex, theProperty, aView );
+ }
+ }
+ }
+ }
+}
+
+void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
+ const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+ SALOME_View* theView )
+{
+ SALOME_View* aView = viewOrActiveView( theView );
+ if ( !aView )
+ return;
+
+ if ( !myVisualized.contains( aView ) )
+ return;
+
+ EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+ if ( !anEntryToAnnotation.contains( theEntry ) )
+ return;
+
+ AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+ if ( !anAnnotationToPrs.contains( theIndex ) )
+ return;
+
+ GEOMGUI_AnnotationAttrs::Properties aProperty;
+ GEOM::GEOM_Object_ptr anObject;
+ getObject( theEntry, theIndex, anObject, aProperty );
+ TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
+ gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+ // erase presentation from the viewer
+ SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
+ SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+ SOCC_Viewer* anOCCViewer = dynamic_cast<SOCC_Viewer*>(theView);
+ if ( anOCCPrs && anOCCViewer ) {
+ AIS_ListOfInteractive anIOs;
+ anOCCPrs->GetObjects( anIOs );
+ AIS_ListIteratorOfListOfInteractive anIter( anIOs );
+
+ for ( ; anIter.More(); anIter.Next() ) {
+ Handle(AIS_InteractiveObject) aPrs = anIter.Value();
+ Handle(GEOM_Annotation) aPresentation = Handle(GEOM_Annotation)::DownCast( aPrs );
+
+ GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+ anOCCViewer->getAISContext()->Redisplay(aPresentation);
+ }
+ }
+}
+
void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SALOME_View* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
#include <GEOM_Displayer.h>
#include <GeometryGUI.h>
#include <GEOMGUI_AnnotationMgr.h>
+#include <GEOMGUI_TextTreeWdg.h>
#include <SOCC_Prs.h>
#include <SOCC_ViewModel.h>
QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup );
mySubShapeTypeCombo = new QComboBox( propGroup );
+ mySubShapeTypeCombo->setEnabled( myIsCreation );
mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE );
mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX );
mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE );
// update internal controls and fields following to default values
activateSelectionArgument( myShapeSelBtn );
+
myTextEdit->setText( myAnnotationProperties.Text );
myShapeNameModified = false;
- myTypeCombo->setCurrentIndex( 0 );
+ myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 );
int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
this, SLOT( onSubShapeTypeChange() ) );
//SelectionIntoArgument();
+
+ redisplayPreview();
} else { // edition
+ mySelectionMode = TopAbs_SHAPE;
+ // find annotation
+ GEOMGUI_TextTreeWdg* aTextTreeWdg = myGeomGUI->GetTextTreeWdg();
+ // text tree widget should be not empty
+ QMap<QString, QList<int> > anAnnotations;
+ aTextTreeWdg->getSelected( anAnnotations );
+ // there is only one annotation selected when edit is started
+ QMap<QString, QList<int> >::const_iterator anIt = anAnnotations.begin();
+ myEditAnnotationEntry = anIt.key();
+ myEditAnnotationIndex = anIt.value()[0];
+
+ SalomeApp_Study* aStudy = getStudy();
+ _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myEditAnnotationEntry.toStdString() );
+ const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ if ( !aShapeAnnotations.IsNull() ) {
+ aShapeAnnotations->GetProperties( myEditAnnotationIndex, myAnnotationProperties );
+
+ myShape = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
+ }
+
+ /// fill dialog controls
+ myTextEdit->setText( myAnnotationProperties.Text );
+ myShapeNameModified = false;
+ myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 );
+
+ int aSubShapeTypeIndex = -1;
+ int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
+ for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
+ int aType = mySubShapeTypeCombo->itemData( i ).toInt();
+ if ( aType == myAnnotationProperties.ShapeType )
+ aSubShapeTypeIndex = i;
+ }
+ mySubShapeTypeCombo->setCurrentIndex( aSubShapeTypeIndex );
+
+ QString aShapeName = "";
+ _PTR(GenericAttribute) anAttr;
+ if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
+ _PTR(AttributeName) aNameAttr( anAttr );
+ aNameAttr->Value();
+ aShapeName = aNameAttr->Value().c_str();
+ }
+ myShapeName->setText( aShapeName );
+
+ QString aSubShapeName = "";
+ TopAbs_ShapeEnum aShapeType = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
+ if ( aShapeType != TopAbs_SHAPE ) {
+ aSubShapeName = QString( "%1:%2_%3" ).arg( aShapeName )
+ .arg( GEOMBase::TypeName( aShapeType ) )
+ .arg( myAnnotationProperties.ShapeIndex );
+ }
+ mySubShapeName->setText( aSubShapeName );
+
+ mySelectionMode = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
+ //SelectionIntoArgument();
+ updateSubShapeEnableState();
+ // connect controls
+ connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
+ connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) );
}
- redisplayPreview();
}
//=================================================================================
if ( !isValid( anError ) )
return false;
- if ( myIsCreation ) {
-
- SalomeApp_Study* aStudy = getStudy();
+ SalomeApp_Study* aStudy = getStudy();
+ _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() );
- _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() );
-
- Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations =
- GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy );
+ Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations =
+ GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy );
+ if ( myIsCreation ) {
myAnnotationProperties.IsVisible = true; // initially created annotation is hidden
aShapeAnnotations->Append( myAnnotationProperties );
myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 );
}
else {
- /*SalomeApp_Study* aStudy = getStudy();
- myAnnotationProperties = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
- myShape->GetStudyEntry(),
- GEOM::propertyName( GEOM::ShapeAnnotations ),
- QVariant() )
- .value<GEOMGUI_ShapeAnnotations>();
- mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );*/
+
+ aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties );
}
return true;
}
//=================================================================================
void MeasureGUI_AnnotationDlg::redisplayPreview()
{
- QString aMess;
- if ( !isValid( aMess ) ) {
- erasePreview( true );
- return;
- }
+ if ( myIsCreation ) {
- erasePreview( false );
+ QString aMess;
+ if ( !isValid( aMess ) ) {
+ erasePreview( true );
+ return;
+ }
- try {
- SUIT_OverrideCursor wc;
- getDisplayer()->SetToActivate( true );
+ erasePreview( false );
- if ( SALOME_Prs* aPrs = buildPrs() )
- displayPreview( aPrs );
- } catch ( const SALOME::SALOME_Exception& e ) {
- SalomeApp_Tools::QtCatchCorbaException( e );
- } catch ( ... ) {
+ try {
+ SUIT_OverrideCursor wc;
+ getDisplayer()->SetToActivate( true );
+
+ if ( SALOME_Prs* aPrs = buildPrs() )
+ displayPreview( aPrs );
+ } catch ( const SALOME::SALOME_Exception& e ) {
+ SalomeApp_Tools::QtCatchCorbaException( e );
+ } catch ( ... ) {
+ }
+ }
+ else {
+ myGeomGUI->GetAnnotationMgr()->Redisplay( myEditAnnotationEntry, myEditAnnotationIndex,
+ myAnnotationProperties );
}
}