<parameter name="dimensions_use_text3d" value="0" />
<!-- Shape annotation presentation properties -->
- <parameter name="shape_annotation_font_color" value="#ffffff" />
+ <parameter name="shape_annotation_font_color" value="#00007f" />
<parameter name="shape_annotation_font" value="Courier 10 Pitch,24" />
- <parameter name="shape_annotation_line_color" value="#ffffff" />
+ <parameter name="shape_annotation_line_color" value="#00007f" />
<parameter name="shape_annotation_line_width" value="1.0" />
<parameter name="shape_annotation_line_style" value="0" />
<parameter name="shape_annotation_autohide" value="false" />
#include <Quantity_Color.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TopExp.hxx>
#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <gp_Ax3.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
- gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
- GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+ if ( !aShape.IsNull() ) {
+
+ gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+ GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+
+ if ( theProperty.ShapeType == TopAbs_SHAPE ) {
+
+ aPresentation->SetHilightShape( aShape );
+ }
+ else if ( theProperty.ShapeIndex > 0 ) {
+
+ TopTools_IndexedMapOfShape aSubShapeMap;
+ TopExp::MapShapes( aShape, static_cast<TopAbs_ShapeEnum>( theProperty.ShapeType ), aSubShapeMap );
+ if ( theProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
+
+ aPresentation->SetHilightShape( aSubShapeMap( theProperty.ShapeIndex ) );
+ }
+ }
+ }
// add Prs to preview
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
myVisualized[aView] = anEntryToAnnotation;
}
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::EraseRemovedAnnotation
+// purpose : Method to update internal maps after removing an
+// annotation from the object.
+//=======================================================================
+void GEOMGUI_AnnotationMgr::EraseRemovedAnnotation( const QString& theEntry, const int theIndex )
+{
+ QMap<SOCC_Viewer*, EntryToAnnotations>::iterator aEntryMapIt = myVisualized.begin();
+ for ( ; aEntryMapIt != myVisualized.end(); ++aEntryMapIt ) {
+ SOCC_Viewer* aView = aEntryMapIt.key();
+ EntryToAnnotations& anEntryToAnnotation = aEntryMapIt.value();
+ if ( !anEntryToAnnotation.contains( theEntry ) )
+ continue;
+
+ AnnotationToPrs aUpdatedToPrs;
+ AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
+ AnnotationToPrs::iterator anAnnotationIt = anAnnotationToPrs.begin();
+ for ( ; anAnnotationIt != anAnnotationToPrs.end(); ++anAnnotationIt ) {
+
+ const int aIndex = anAnnotationIt.key();
+ SALOME_Prs* aPrs = anAnnotationIt.value();
+ if ( aIndex > theIndex ) {
+ aUpdatedToPrs[aIndex - 1] = aPrs;
+ }
+ else if ( aIndex != theIndex ) {
+ aUpdatedToPrs[aIndex] = aPrs;
+ }
+ else {
+ ((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
+ }
+ }
+
+ anAnnotationToPrs = aUpdatedToPrs;
+ }
+ getDisplayer()->UpdateViewer();
+}
+
//=======================================================================
// function : GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations
// purpose :
return QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
}
+bool GEOMGUI_AnnotationMgr::getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex )
+{
+ QStringList aSplit = theEntry.split( GetEntrySeparator() );
+ if ( aSplit.size() < 2 )
+ return false;
+
+ bool isOk = true;
+ theObjEntry = aSplit.at( 0 );
+ theIndex = aSplit.at( 1 ).toInt( &isOk );
+ return isOk;
+}
+
void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
GEOM::GEOM_Object_ptr& theObject,
GEOMGUI_AnnotationAttrs::Properties& theProperty )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
- const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) );
- const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) );
+ const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 0, 0, 127 ) );
+ const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 0, 0, 127 ) );
const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 );
const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 );
const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false );
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 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,
void storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView );
+ bool getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex );
+
+ bool isAnnotationEntry( const QString& theEntry ) { return theEntry.indexOf( GetEntrySeparator() ) != -1; }
+
protected:
SalomeApp_Application* getApplication() const { return myApplication; }
myEntry = theEntry.c_str();
myStudy = theStudy;
_PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
- myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ if ( aSObj ) {
+ myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+ }
}
virtual int GetNumber() Standard_OVERRIDE {
return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0;
QAction* anEditAction = aModule->action(GEOMOp::OpEditAnnotation);
if ( anEditAction )
aMenu.addAction( anEditAction );
+ QAction* aDeleteAction = aModule->action(GEOMOp::OpDeleteAnnotation);
+ if ( aDeleteAction )
+ aMenu.addAction( aDeleteAction );
// Show/Hide actions
if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
aMenu.addAction( myActions[GEOMOp::OpHide] );
<source>STB_EDIT_ANNOTATION</source>
<translation>Edit Annotation</translation>
</message>
+ <message>
+ <source>TOP_DELETE_ANNOTATION</source>
+ <translation>Delete Annotation</translation>
+ </message>
+ <message>
+ <source>MEN_DELETE_ANNOTATION</source>
+ <translation>Delete</translation>
+ </message>
+ <message>
+ <source>STB_DELETE_ANNOTATION</source>
+ <translation>Delete Annotation</translation>
+ </message>
<message>
<source>MEN_POP_SHOW_DEPENDENCY_TREE</source>
<translation>Show dependency tree</translation>
case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
+ case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
#ifndef DISABLE_PLOT2DVIEWER
case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
#endif
createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
+ createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
mgr->setRule( action( GEOMOp::OpEditAnnotation ), QString("($component={'GEOM'}) and type='Shape' and selcount=1"), QtxPopupMgr::VisibleRule );
+ mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
+ mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), QString("($component={'GEOM'}) and type='Shape' and selcount=1"), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // -----------
QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
SALOME_ListIO aVisible;
aViewer->GetVisible( aVisible );
- aDisplayer.Redisplay( aVisible, false, aViewer );
- GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
- SALOME_ListIteratorOfListIO Iter( aVisible );
- for ( ; Iter.More(); Iter.Next() ) {
- aAnnotationMgr->DisplayVisibleAnnotations( QString(Iter.Value()->getEntry()), aViewer );
+ GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
+ if ( anAnnotationMgr ) {
+ SALOME_ListIteratorOfListIO anIter( aVisible );
+ while ( anIter.More() ) {
+ if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
+ aVisible.Remove( anIter );
+ }
+ else {
+ anIter.Next();
+ }
+ }
}
+
+ aDisplayer.Redisplay( aVisible, false, aViewer );
}
if ( param == QString( "label_color" ) ) {
ViewManagerList aVMsVTK;
OpEditAnnotation = 5021, // POPUP MENU - EDIT ANNOTATION
OpShowAllAnnotations = 5022, // POPUP MENU - SHOW ALL ANNOTATIONS
OpHideAllAnnotations = 5023, // POPUP MENU - HIDE ALL ANNOTATIONS
+ OpDeleteAnnotation = 5024, // POPUP MENU - DELETE ANNOTATION
// GroupGUI --------------------//--------------------------------
OpGroupCreate = 6000, // MENU GROUP - CREATE
OpGroupEdit = 6001, // MENU GROUP - EDIT
case GEOMOp::OpHideAllAnnotations:
ChangeAnnotationsVisibility( false );
break; // HIDE ALL ANNOTATIONS
+ case GEOMOp::OpDeleteAnnotation:
+ DeleteAnnotation();
+ break; // DELETE ANNOTATIOn
default:
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break;
|| !anIObject->hasEntry() )
return;
- const QString aEntry = anIObject->getEntry(),c_str();
+ const QString aEntry = anIObject->getEntry();
- _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aEntry.toStdString() );\r
+ _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aEntry.toStdString() );
- const Handle(GEOMGUI_AnnotationAttrs)\r
- aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );\r
+ const Handle(GEOMGUI_AnnotationAttrs)
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
- if ( aShapeAnnotations.IsNull() ) {\r
- return;\r
- }\r
+ if ( aShapeAnnotations.IsNull() ) {
+ return;
+ }
const int aCount = aShapeAnnotations->GetNbAnnotation();
getGeometryGUI()->GetAnnotationMgr()->Display( aEntry , anI );
}
}
+
+ getGeometryGUI()->emitAnnotationsUpdated( aEntry );
+ }
+}
+
+//=======================================================================
+// function : DeleteAnnotation
+// purpose :
+//=======================================================================
+void MeasureGUI::DeleteAnnotation()
+{
+ SalomeApp_Application* anApp = getGeometryGUI()->getApp();
+ if ( !anApp )
+ return;
+
+ SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+ if ( !anActiveStudy )
+ return;
+
+ Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
+ if ( anIObject.IsNull()
+ || !anIObject->hasEntry() )
+ return;
+
+ const QString aEntry = anIObject->getEntry();
+
+ QString aObjEntry;
+
+ int aIndex = 0;
+
+ if ( getGeometryGUI()->GetAnnotationMgr()->getIndexFromEntry( aEntry, aObjEntry, aIndex ) )
+ {
+ _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aObjEntry.toStdString() );
+
+ const Handle(GEOMGUI_AnnotationAttrs)
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+
+ if ( aShapeAnnotations.IsNull() ) {
+ return;
+ }
+
+ aShapeAnnotations->Remove( aIndex );
+
+ getGeometryGUI()->GetAnnotationMgr()->EraseRemovedAnnotation( aObjEntry, aIndex );
+
+ getGeometryGUI()->emitAnnotationsUpdated( aObjEntry );
}
}
// Show/hide all shape annotations created for GEOM object
void ChangeAnnotationsVisibility( const bool theIsVisible );
+ // Deletes the selected annotation
+ void DeleteAnnotation();
+
private:
// Returns selected interactive object for single selection
Handle(SALOME_InteractiveObject) getSingleSelectedIO();
myGeomGUI->GetAnnotationMgr()->SetPreviewStyle( myEditAnnotationEntry, myEditAnnotationIndex, true );
+ SalomeApp_Application* anApp = myGeomGUI->getApp();
+ if ( anApp )
+ {
+ OCCViewer_ViewManager* aVM = (OCCViewer_ViewManager*)anApp->getViewManager( OCCViewer_Viewer::Type(), false );
+ OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)aVM->getViewModel();
+ aViewer->unHighlightAll( true, true );
+ }
+
redisplayPreview();
}
}
erasePreview( true );
+ globalSelection( myGeomGUI->getLocalSelectionMode() , true );
+
myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 );
}
else {
mySelection.Append( anAISContext->SelectedOwner() );
}
- if ( anAISContext->IsHilighted( myActiveIO ) )
- {
- anAISContext->Unhilight( myActiveIO, Standard_False );
- }
-
anAISContext->ClearSelected( Standard_False );
- anAISContext->AddOrRemoveSelected( aDetected );
+ anAISContext->Unhilight( myActiveIO, Standard_True );
myActiveViewPort = aViewPort;
myActiveViewPort->grabMouse();
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_Text.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <V3d_Viewer.hxx>
myAttach = thePoint;
}
+// =======================================================================
+// function : SetHilightShape
+// purpose : Sets shape (annotated shape) that will be used for hilighting.
+// =======================================================================
+void GEOM_Annotation::SetHilightShape( const TopoDS_Shape& theShape )
+{
+ if ( myShape.IsEqual( theShape ) )
+ {
+ return;
+ }
+
+ myShape = theShape;
+ SetToUpdate();
+ UpdateSelection();
+}
+
// =======================================================================
// function : SetColor
// purpose :
aBox = aBox.Transformed( aOffset2d );
}
- const Handle(GEOM_AnnotationOwner) anEntityOwner = new GEOM_AnnotationOwner( this, 10 );
+ const Handle(GEOM_AnnotationOwner) anEntityOwner = new GEOM_AnnotationOwner( myShape, this, 10 );
const Handle(GEOM_AnnotationSensEntity) aSensitive =
new GEOM_AnnotationSensEntity( anEntityOwner, aBox, myIsDepthCulling );
const Handle(Graphic3d_HighlightStyle)& theStyle,
const Standard_Integer theMode )
{
+ if ( myPrsSh.IsNull() )
+ {
+ Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer;
+ aDrawer->Link( Selectable()->HilightAttributes() );
+
+ Handle(Prs3d_IsoAspect) aUIsoAspect = new Prs3d_IsoAspect(
+ aDrawer->UIsoAspect()->Aspect()->Color(),
+ aDrawer->UIsoAspect()->Aspect()->Type(),
+ aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
+
+ Handle(Prs3d_IsoAspect) aVIsoAspect = new Prs3d_IsoAspect(
+ aDrawer->UIsoAspect()->Aspect()->Color(),
+ aDrawer->UIsoAspect()->Aspect()->Type(),
+ aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
+
+ aDrawer->SetIsoOnPlane( Standard_False );
+ aDrawer->SetUIsoAspect( aUIsoAspect );
+ aDrawer->SetVIsoAspect( aVIsoAspect );
+ myPrsSh = new StdSelect_Shape( myShape, aDrawer );
+ }
+
+ myPrsSh->SetZLayer ( Selectable()->ZLayer() );
+
thePM->Color( Selectable(), theStyle, theMode, NULL, Selectable()->ZLayer() );
+ thePM->Color( myPrsSh, theStyle, theMode, Selectable(), Graphic3d_ZLayerId_Topmost );
+}
+
+// =======================================================================
+// subclass : GEOM_AnnotationOwner
+// function : Unhilight
+// purpose : Removes highlighting from the type of shape.
+// =======================================================================
+void GEOM_Annotation::GEOM_AnnotationOwner::Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer theMode )
+{
+ SelectMgr_EntityOwner::Unhilight( thePM, theMode );
+
+ thePM->Unhighlight( myPrsSh, theMode );
+}
+
+// =======================================================================
+// subclass : GEOM_AnnotationOwner
+// function : Clear
+// purpose : Clears the presentation manager object aPM of all shapes
+// with the given selection mode.
+// =======================================================================
+void GEOM_Annotation::GEOM_AnnotationOwner::Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer theMode )
+{
+ SelectMgr_EntityOwner::Clear( thePM, theMode );
+
+ if ( !myPrsSh.IsNull() ) {
+ thePM->Clear( myPrsSh, theMode );
+ }
+
+ myPrsSh.Nullify();
}
#include <PrsMgr_PresentationManager3d.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
+#include <StdSelect_Shape.hxx>
#include <TCollection_ExtendedString.hxx>
class OpenGl_GraphicDriver;
//! Returns attachment point of extension line.
const gp_Pnt& GetAttachPoint() const { return myAttach; }
+ //! Sets shape (annotated shape) that will be used for hilighting.
+ Standard_EXPORT void SetHilightShape( const TopoDS_Shape& theShape );
+
+ //! Returns the hilighting shape.
+ const TopoDS_Shape HilightShape() const { return myShape; }
+
public:
//! Sets color for the presentation.
Standard_Boolean myIsDepthCulling; //!< Flag indiciating whether the "depth culling" is turned on.
HighlightMode myHilightMode; //!< Highlight mode for presentation.
TCollection_ExtendedString myText; //!< Text string of the label presentation.
+ TopoDS_Shape myShape; //!< Hilighting shape.
private:
public:
//! Constructor.
- GEOM_AnnotationOwner( const Handle(SelectMgr_SelectableObject)& theSelectable,
- const Standard_Integer thePriority = 0 )
- : SelectMgr_EntityOwner( theSelectable, thePriority ) {}
+ GEOM_AnnotationOwner( const TopoDS_Shape& theShape,
+ const Handle(SelectMgr_SelectableObject)& theSelectable,
+ const Standard_Integer thePriority )
+ : SelectMgr_EntityOwner( theSelectable, thePriority ),
+ myShape( theShape ) {}
//! Perform highlighting of the presentation.
//! \param thePresentationMgr [in] the presentation manager.
HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Graphic3d_HighlightStyle)& theStyle,
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+ //! Removes highlighting from the type of shape.
+ virtual void
+ Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+ //! Clears the presentation manager object aPM of all shapes
+ //! with the given selection mode.
+ virtual void
+ Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
+ const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+ private:
+
+ TopoDS_Shape myShape;
+ Handle(StdSelect_Shape) myPrsSh;
};
//! Custom sensitive entity with implementing option to support selection