--- /dev/null
+/*! \r
+\r
+\page annotation_page Shape annotation\r
+\r
+<b> Annotation </b> functionality allows showing in the viewer special user-defined text label connected to corresponding part of a CAD model with a line.\r
+\r
+\image html annotation_preview.png\r
+\r
+Shape annotation behavior are summarized below:\r
+<ul>\r
+ <li>Annotation text is always parallel to the screen and horizontal.</li>\r
+ <li>Annotation text is not zoomed or rotated when a 3D scene is zoomed or rotated by the user.</li>\r
+ <li>The user is able to modify the font, the style, the color and the size of the annotation text and the color, the width and the style of the connection line applied to all annotations.\r
+It can be accessed from the main menu via <b>File -> Preferences</b>. The Shape annotations group on Geometry Settings pane contains controls for it.\r
+ </li>\r
+ <li>The annotation text is defined using UTF-8 encoding and thus support any Unicode characters.</li>\r
+ <li>Position of an annotation in a 3D view is defined by dragging it with the mouse.</li>\r
+ <li>There are several algorithms for the annotation position calculation during the scene manipulations (panning, zooming, rotation):</li>\r
+ <ul>\r
+ <li> Algorithm 1: an annotation has fixed position in 2D screen coordinates (fixed screen position mode). In this mode, the annotations are always visible (appear as \93topmost objects\94), never hidden by the (annotated) geometry.</li>\r
+ <li>Algorithm 2: an annotation has fixed position in 3D model space, this position is projected onto the screen just as normal point coordinates. In this mode, some annotations may be invisible depending on the camera (position, orientation, zoom).</li>\r
+ </ul>\r
+ <li>Annotations appear in an Annotations sub-tree in Text Browser.</li>\r
+ <li>All annotations may be shown/hidden in a 3D view using corresponded popup menu on Annotations item in Text Browser.</li>\r
+ <li>Annotations of a shape may be shown/hidden in a 3D view using corresponded popup menu on the shape item in Object Browser.</li>\r
+ <li>Annotation is logically connected to the shape:</li>\r
+ <ul>\r
+ <li>Selection of an annotation will highlight corresponding shape/subshape in 3D view.</li>\r
+ <li>When the shape is deleted, the annotation will be also deleted.</li>\r
+ </ul>\r
+</ul>\r
+\r
+It can be accessed from the main menu via <b>Inspection -> Annotation </b>\r
+\r
+\image html annotation.png "Create Annotation dialog"\r
+\r
+In this dialog you can:
+<ul>
+ <li>Set <b>Text</b> text shown in View 3d and a name of annotation presented in the Text Browser.</li>
+ <li>Select a \b Shape to which the annotation will be assigned.</li>
+ <li>Set <b>Fixed screen position</b> to select alogithm for the annotation position caldulation.</li>
+ <li>Select a <b>Shape Type</b> to which the annotation will be assigned on the shape.
+ It contains "Whole shape", "Vertex", "Edge", "Face" and "Solid" choices.</li>
+ <li>Select a sub shape to assign annotation to. Text control contains information about local selection in the viewer.</li>
+ <li>Push \b Apply or <b>Apply and Close</b> button to commit creation of the field.<li>
+</ul>
+\r
+*/\r
<li>\subpage angle_page "Angle"</li>
<li>\subpage tolerance_page "Tolerance"</li>
<li>\subpage managing_dimensions_page "Dimensions"</li>
+<li>\subpage annotation_page "Annotations"</li>
<li>\subpage whatis_page "WhatIs"</li>
<li>\subpage inspect_object_operation_page "Inspect Object"</li>
<li>\subpage shape_statistics_operation_page "Shape Statistics"</li>
#include <GEOM_Client.hxx>
#include <GEOM_Constants.h>
#include <GEOM_Displayer.h>
+#include <GEOMGUI_TextTreeWdg.h>
#include <GeometryGUI.h>
// purpose : Displays annotation shape presentation in view. It creates an annotation presentation
// and stores it in an internal container
//=======================================================================
-void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView )
+void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
+ const bool isStoreViewState, const bool isUpdateViewer )
{
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView )
QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, aView, anEntry );
((SALOME_View*)aView)->Display( getDisplayer(), aPrs );
- getDisplayer()->UpdateViewer();
+ if ( isUpdateViewer )
+ getDisplayer()->UpdateViewer();
EntryToAnnotations anEntryToMap;
if ( myVisualized.contains( aView ) )
anEntryToMap[theEntry] = anAnnotationToPrsMap;
myVisualized[aView] = anEntryToMap;
- // change persistent for the entry: set visible state in true for indices which presentations are shown
- storeVisibleState( theEntry, theView );
- storeFixedPosition( theEntry, theView );
+ if ( isStoreViewState ) {
+ // 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,
}
}
-void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView )
+void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
+ const bool isUpdateViewer )
{
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView )
// erase presentation from the viewer
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
- getDisplayer()->UpdateViewer();
+ if ( isUpdateViewer )
+ getDisplayer()->UpdateViewer();
// remove displayed parameters from an internal container
anAnnotationToPrs.remove( theIndex );
storeVisibleState( theEntry, theView );
}
-void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
+void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
+ const bool isUpdateViewer )
{
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
for ( int anIndex = 0; anIndex < aCount; ++anIndex )
{
if ( isVisible[anIndex] )
- Display( theEntry, anIndex, theView );
+ Display( theEntry, anIndex, theView, true, isUpdateViewer );
}
}
}
-void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
+void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
+ const bool isUpdateViewer )
{
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
SALOME_Prs* aPrs = anAnnotationToPrs[anIndex];
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
}
- getDisplayer()->UpdateViewer();
+ if ( isUpdateViewer )
+ getDisplayer()->UpdateViewer();
anEntryToAnnotation.remove( theEntry );
myVisualized[aView] = anEntryToAnnotation;
}
getDisplayer()->UpdateViewer();
}
+void GEOMGUI_AnnotationMgr::DisplayAllAnnotations( SOCC_Viewer* theView )
+{
+ SOCC_Viewer* aView = viewOrActiveView( theView );
+ if ( !myVisualized.contains( aView ) )
+ return;
+
+ GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
+ GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+ QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+ for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
+ QString anEntry = anEntries[i];
+
+ _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( anEntry.toStdString() );
+ if ( !aSObj )
+ continue;
+
+ const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ if ( !aShapeAnnotations.IsNull() )
+ continue;
+
+ int anAnnotationsCount = aShapeAnnotations->GetNbAnnotation();
+ for ( int anIndex = 0; anIndex < anAnnotationsCount; ++anIndex )
+ {
+ Display( anEntry, anIndex, aView, false, false );
+ }
+ getDisplayer()->UpdateViewer();
+ storeVisibleState( anEntry, aView );
+ storeFixedPosition( anEntry, aView );
+ }
+}
+
+void GEOMGUI_AnnotationMgr::EraseAllAnnotations( SOCC_Viewer* theView )
+{
+ SOCC_Viewer* aView = viewOrActiveView( theView );
+ if ( !myVisualized.contains( aView ) )
+ return;
+
+ GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
+ GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+ QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
+
+ for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
+ QString anEntry = anEntries[i];
+ EraseVisibleAnnotations( anEntry, aView, false );
+ storeVisibleState( anEntry, aView );
+ }
+ getDisplayer()->UpdateViewer();
+}
+
void GEOMGUI_AnnotationMgr::SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
const QString& theEntry = QString() );
bool IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 ) const;
- void Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 );
- void Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 );
+ void Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
+ const bool isStoreViewState = true, const bool isUpdateViewer = true );
+ void Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
+ const bool isUpdateViewer = true );
void EraseRemovedAnnotation( const QString& theEntry, const int theIndex );
void Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperties);
void Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperties, SOCC_Viewer* theView );
- void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
- void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
+ void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
+ const bool isUpdateViewer = true );
+ void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
+ const bool isUpdateViewer = true );
void UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
+
+ void DisplayAllAnnotations( SOCC_Viewer* theView = 0 );
+ void EraseAllAnnotations( SOCC_Viewer* theView = 0 );
+
void SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview );
void RemoveView( SOCC_Viewer* theView );
//=================================================================================
void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
{
- if ( selectedItems().isEmpty() )
- return;
+ CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+ GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
+
QMenu aMenu;
- aMenu.addAction( myActions[GEOMOp::OpShow] );
- aMenu.addAction( myActions[GEOMOp::OpHide] );
+ aMenu.addAction( aModule->action(GEOMOp::OpShowAllAnnotations) );
+ aMenu.addAction( aModule->action(GEOMOp::OpHideAllAnnotations) );
- if ( selectedItems().count() == 1 ) {
+ if ( !selectedItems().isEmpty() && selectedItems().count() == 1 ) {
QTreeWidgetItem* anItem = selectedItems().first();
QString anEntry = entryFromItem( anItem->parent() );
if ( !anEntry.isEmpty() ) {
return;
aMenu.clear();
// Edit annotation action
- CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
- GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
QAction* anEditAction = aModule->action(GEOMOp::OpEditAnnotation);
if ( anEditAction )
aMenu.addAction( anEditAction );
}
}
+//=================================================================================
+// function : getAllEntries
+// purpose :
+//=================================================================================
+QList<QString> GEOMGUI_TextTreeWdg::getAllEntries( const BranchType& theBranchType )
+{
+ return getObjects( theBranchType ).keys();
+}
+
//=================================================================================
// function : setShapeItemVisibility
// purpose :
void getSelected( QMap<QString, QList<int> >& theAnnotations );
void setSelected( const QMap<QString, QList<int> >& theAnnotations );
+ QList<QString> getAllEntries( const BranchType& theBranchType );
+
protected:
void createActions();
void redisplay( QString theEntry );
return;
Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
- if ( anIObject.IsNull()
- || !anIObject->hasEntry() )
- return;
-
- const QString aEntry = anIObject->getEntry();
+ if ( !anIObject.IsNull() && anIObject->hasEntry() ) {
+ const QString aEntry = anIObject->getEntry();
- _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aEntry.toStdString() );
+ _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aEntry.toStdString() );
- const Handle(GEOMGUI_AnnotationAttrs)
- aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ const Handle(GEOMGUI_AnnotationAttrs)
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
- if ( aShapeAnnotations.IsNull() ) {
- return;
- }
+ if ( aShapeAnnotations.IsNull() ) {
+ return;
+ }
- const int aCount = aShapeAnnotations->GetNbAnnotation();
+ const int aCount = aShapeAnnotations->GetNbAnnotation();
- if ( aCount > 0 ) {
+ if ( aCount > 0 ) {
- SUIT_OverrideCursor wc;
+ SUIT_OverrideCursor wc;
- for ( int anI = 0; anI < aCount; ++anI ) {
+ for ( int anI = 0; anI < aCount; ++anI ) {
- if ( !theIsVisible ) {
- getGeometryGUI()->GetAnnotationMgr()->Erase( aEntry, anI );
+ if ( !theIsVisible ) {
+ getGeometryGUI()->GetAnnotationMgr()->Erase( aEntry, anI );
+ }
+ else {
+ getGeometryGUI()->GetAnnotationMgr()->Display( aEntry , anI );
+ }
}
- else {
- getGeometryGUI()->GetAnnotationMgr()->Display( aEntry , anI );
- }
- }
- getGeometryGUI()->emitAnnotationsUpdated( aEntry );
+ getGeometryGUI()->emitAnnotationsUpdated( aEntry );
+ }
+ }
+ else {
+ if ( theIsVisible ) {
+ getGeometryGUI()->GetAnnotationMgr()->DisplayAllAnnotations();
+ }
+ else {
+ getGeometryGUI()->GetAnnotationMgr()->EraseAllAnnotations();
+ }
}
}