Port on IR-2016-11-02.

Bug in edit mode when switching 2D/3D.
Preview for edit mode.
This commit is contained in:
apl 2016-11-10 13:39:26 +03:00
parent 3d5732ec1d
commit d448d82dba
9 changed files with 246 additions and 125 deletions

View File

@ -38,7 +38,6 @@
#include <SUIT_ViewManager.h>
#include <SOCC_Prs.h>
#include <SOCC_ViewModel.h>
#include <SOCC_ViewWindow.h>
#include <Quantity_Color.hxx>
@ -68,9 +67,14 @@ QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
//================================================================
SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
GEOM::GEOM_Object_ptr theObject,
SALOME_View* theView,
SOCC_Viewer* theView,
const QString& theEntry )
{
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView ) {
return NULL;
}
Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
if ( !theEntry.isEmpty() ) {
// owner should be set to provide selection mechanizm
@ -81,7 +85,7 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
setDisplayProperties( aPresentation, theView, getEntry( theObject ).c_str() );
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() );
@ -90,8 +94,7 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
// add Prs to preview
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs =
dynamic_cast<SOCC_Prs*>( ( ( SOCC_Viewer* ) ( vw->getViewManager()->getViewModel() ) )->CreatePrs(
0 ) );
dynamic_cast<SOCC_Prs*>( ( aView )->CreatePrs( 0 ) );
if ( aPrs )
aPrs->AddObject( aPresentation );
@ -99,9 +102,9 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
return aPrs;
}
bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView ) const
bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView ) const
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView || !myVisualized.contains( aView ) )
return false;
@ -121,9 +124,9 @@ bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theI
// 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, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView )
return;
@ -137,7 +140,7 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex
// display presentation in the viewer
QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, aView, anEntry );
aView->Display( getDisplayer(), aPrs );
((SALOME_View*)aView)->Display( getDisplayer(), aPrs );
getDisplayer()->UpdateViewer();
EntryToAnnotations anEntryToMap;
@ -175,7 +178,7 @@ void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theInd
SUIT_ViewModel* vmodel = vman->getViewModel();
if ( vmodel )
{
SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
SOCC_Viewer* aView = dynamic_cast<SOCC_Viewer*>(vmodel);
if ( aView )
Redisplay( theEntry, theIndex, theProperty, aView );
}
@ -186,9 +189,9 @@ void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theInd
void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperty,
SALOME_View* theView )
SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView )
return;
@ -212,8 +215,7 @@ void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theInd
// 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 ) {
if ( anOCCPrs ) {
AIS_ListOfInteractive anIOs;
anOCCPrs->GetObjects( anIOs );
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
@ -223,14 +225,14 @@ void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theInd
Handle(GEOM_Annotation) aPresentation = Handle(GEOM_Annotation)::DownCast( aPrs );
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
anOCCViewer->getAISContext()->Redisplay(aPresentation);
aView->getAISContext()->Redisplay( aPresentation );
}
}
}
void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView )
return;
@ -247,7 +249,7 @@ void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex,
// erase presentation from the viewer
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
aView->Erase( getDisplayer(), aPrs );
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
getDisplayer()->UpdateViewer();
// remove displayed parameters from an internal container
@ -265,7 +267,7 @@ void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex,
storeVisibleState( theEntry, theView );
}
void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
{
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
@ -285,9 +287,9 @@ void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry,
}
}
void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
return;
@ -308,7 +310,7 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA
// erase presentation from the viewer
SALOME_Prs* aPrs = anAnnotationToPrs[anIndex];
aView->Erase( getDisplayer(), aPrs );
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
}
getDisplayer()->UpdateViewer();
anEntryToAnnotation.remove( theEntry );
@ -319,9 +321,9 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA
// function : GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations
// purpose :
//=======================================================================
void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
return;
@ -352,13 +354,44 @@ void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, S
getDisplayer()->UpdateViewer();
}
void GEOMGUI_AnnotationMgr::SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
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 Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB );
const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB );
QMap<SOCC_Viewer*, EntryToAnnotations>::Iterator aViewIt = myVisualized.begin();
for (; aViewIt != myVisualized.end(); ++aViewIt ) {
Handle(GEOM_Annotation) aPresentation = getAISPresentation ( theEntry, theIndex, aViewIt.key() );
if ( aPresentation.IsNull() ) {
continue;
}
if ( theIsPreview ) {
aPresentation->SetTextColor( Quantity_NOC_VIOLET );
aPresentation->SetLineColor( Quantity_NOC_VIOLET );
aPresentation->SetDepthCulling( Standard_False );
}
else {
aPresentation->SetTextColor( aOcctFontColor );
aPresentation->SetLineColor( aOcctLineColor );
aPresentation->SetDepthCulling( Standard_True );
}
}
getDisplayer()->UpdateViewer();
}
Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry,
const int theIndex,
SALOME_View* theView ) const
SOCC_Viewer* theView ) const
{
Handle(SALOME_InteractiveObject) anIO;
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
return anIO;
@ -381,17 +414,17 @@ Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( c
for ( ; anIter.More() && anIO.IsNull(); anIter.Next() ) {
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
if ( aPrs->GetOwner() )
anIO = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner());
anIO = Handle(SALOME_InteractiveObject)::DownCast( aPrs->GetOwner() );
}
return anIO;
}
int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
SALOME_View* theView )
SOCC_Viewer* theView )
{
int anIndex = -1;
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !myVisualized.contains( aView ) )
return anIndex;
@ -431,13 +464,13 @@ int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject)
// function : GEOMGUI_AnnotationMgr::RemoveView
// purpose :
//=======================================================================
void GEOMGUI_AnnotationMgr::RemoveView( SALOME_View* theView )
void GEOMGUI_AnnotationMgr::RemoveView( SOCC_Viewer* theView )
{
if ( !theView && myVisualized.contains( theView ) )
myVisualized.remove( theView );
}
QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView ) const
QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const
{
QString aDisplayedIndices;
@ -462,7 +495,7 @@ QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry,
return aDisplayedIndices;
}
void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView,
void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView,
const QString theIndicesInfo )
{
if ( theIndicesInfo.isEmpty() )
@ -480,19 +513,22 @@ GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const
return dynamic_cast<GEOM_Displayer*>( aModule->displayer() );
}
SALOME_View* GEOMGUI_AnnotationMgr::viewOrActiveView(SALOME_View* theView) const
SOCC_Viewer* GEOMGUI_AnnotationMgr::viewOrActiveView( SOCC_Viewer* theView ) const
{
if ( theView ) {
return dynamic_cast<SOCC_Viewer*>( theView );
}
else {
SOCC_Viewer* aView = theView;
if ( !aView ) {
SalomeApp_Application* anApp = getApplication();
SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
if ( anActiveWindow ) {
return dynamic_cast<SOCC_Viewer*>( anActiveWindow->getViewManager()->getViewModel() );
aView = dynamic_cast<SOCC_Viewer*>( anActiveWindow->getViewManager()->getViewModel() );
}
}
return NULL;
return aView;
}
QString GEOMGUI_AnnotationMgr::makeAnnotationEntry( const QString& theEntry, const int theIndex )
{
return QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
}
void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
@ -509,9 +545,9 @@ void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theInd
}
}
void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SALOME_View* theView )
void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SOCC_Viewer* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( !aView || !myVisualized.contains( aView ) )
return;
@ -588,7 +624,7 @@ std::string GEOMGUI_AnnotationMgr::getName( const GEOM::GEOM_Object_ptr theObjec
// purpose :
//=======================================================================
void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
SALOME_View* theView,
SOCC_Viewer* theView,
const QString& theEntry )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
@ -610,8 +646,9 @@ void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)&
thePrs->SetLineWidth( aLineWidth );
thePrs->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
thePrs->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
thePrs->SetDepthCulling( Standard_True );
SALOME_View* aView = viewOrActiveView( theView );
SOCC_Viewer* aView = viewOrActiveView( theView );
if ( aView && !theEntry.isEmpty() ) {
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
@ -629,3 +666,38 @@ void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)&
thePrs->SetDefaultZLayer();
}
}
//=======================================================================
// function : GEOMGUI_AnnotationMgr::getAISPresentation
// purpose :
//=======================================================================
Handle(GEOM_Annotation) GEOMGUI_AnnotationMgr::getAISPresentation ( const QString& theEntry,
const int theIndex,
SOCC_Viewer* theView )
{
if ( !myVisualized.contains( theView ) ) {
return Handle(GEOM_Annotation)();
}
EntryToAnnotations& aEntryToAnnotation = myVisualized[theView];
if ( !aEntryToAnnotation.contains( theEntry ) ) {
return Handle(GEOM_Annotation)();
}
AnnotationToPrs& aAnnotationToPrs = aEntryToAnnotation[theEntry];
if ( !aAnnotationToPrs.contains( theIndex ) ) {
return Handle(GEOM_Annotation)();
}
SALOME_Prs* aPrs = aAnnotationToPrs[theIndex];
// set or unset preview style for the presentation
AIS_ListOfInteractive aIObjects;
((SOCC_Prs*)aPrs)->GetObjects( aIObjects );
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
for ( ; aIOIt.More(); aIOIt.Next() ) {
return Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
}
return Handle(GEOM_Annotation)();
}

View File

@ -31,6 +31,8 @@
#include <SALOME_Prs.h>
#include <SALOME_InteractiveObject.hxx>
#include <SOCC_ViewModel.h>
class SalomeApp_Application;
class GEOM_Annotation;
class GEOM_Displayer;
@ -53,32 +55,35 @@ public:
SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
GEOM::GEOM_Object_ptr theObject,
SALOME_View* theView = 0,
SOCC_Viewer* theView = 0,
const QString& theEntry = QString() );
bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const;
void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 );
void Erase( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 );
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 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, SALOME_View* theView );
const GEOMGUI_AnnotationAttrs::Properties& theProperties, SOCC_Viewer* theView );
void DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void UpdateVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
void UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
void SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview );
void RemoveView( SALOME_View* theView);
void RemoveView( SOCC_Viewer* theView );
int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
SALOME_View* theView = 0 );
SOCC_Viewer* theView = 0 );
Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex,
SALOME_View* theView = 0 ) const;
SOCC_Viewer* theView = 0 ) const;
QString getDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView ) const;
QString getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const;
void setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView, const QString theIndicesInfo );
void setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView, const QString theIndicesInfo );
QString makeAnnotationEntry( const QString& theEntry, const int theIndex );
protected:
@ -86,27 +91,31 @@ protected:
GEOM_Displayer* getDisplayer() const;
SALOME_View* viewOrActiveView(SALOME_View* theView) const;
SOCC_Viewer* viewOrActiveView( SOCC_Viewer* theView ) const;
void getObject( const QString& theEntry, const int theIndex,
GEOM::GEOM_Object_ptr& anObject,
GEOMGUI_AnnotationAttrs::Properties& aProperty );
void storeVisibleState( const QString& theEntry, SALOME_View* theView );
void storeVisibleState( const QString& theEntry, SOCC_Viewer* theView );
std::string getEntry( const GEOM::GEOM_Object_ptr theObject );
std::string getName( const GEOM::GEOM_Object_ptr theObject );
void setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
SALOME_View* theView = 0,
SOCC_Viewer* theView = 0,
const QString& theEntry = QString() );
Handle(GEOM_Annotation) getAISPresentation ( const QString& theEntry,
const int theIndex,
SOCC_Viewer* theView );
private:
SalomeApp_Application* myApplication;
typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
typedef QMap<QString, AnnotationToPrs> EntryToAnnotations;
QMap<SALOME_View*, EntryToAnnotations> myVisualized;
QMap<SOCC_Viewer*, EntryToAnnotations> myVisualized;
};
#endif

View File

@ -515,7 +515,8 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
#if OCC_VERSION_MAJOR >= 7
myColorScale = new AIS_ColorScale;
myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
myColorScale->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
myColorScale->SetTransformPersistence (
Graphic3d_TransformPers::FromDeprecatedParams(Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)));
#endif
myFieldDataType = GEOM::FDT_Double;
@ -703,10 +704,10 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule ) {
if ( !theViewFrame->isVisible( theIO ) ) {
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
}
else {
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), theViewFrame);
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
}
}
}
@ -2082,9 +2083,9 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule ) {
if ( !myIsRedisplayed ) {
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), v);
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
} else {
aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), v);
aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
}
}
}
@ -2106,7 +2107,7 @@ void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule )
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), v);
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
}
}

View File

@ -2079,7 +2079,10 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
break;
}
}
GetAnnotationMgr()->RemoveView(dynamic_cast<SALOME_View*>(viewer));
SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
if ( aSOCCView ) {
GetAnnotationMgr()->RemoveView( aSOCCView );
}
}
//================================================================================
@ -2851,6 +2854,12 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
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 );
}
}
if ( param == QString( "label_color" ) ) {
ViewManagerList aVMsVTK;
@ -3057,8 +3066,9 @@ void GeometryGUI::storeVisualParameters (int savePoint)
ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
}
if ( aAnnotationMgr ) {
std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo( o_it.key().toLatin1().data(), aView ).toStdString();
if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
o_it.key().toLatin1().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
if (!anAnnotationInfo.empty()) {
param = occParam + "ShapeAnnotationVisibleItems";
ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
@ -3252,9 +3262,13 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
displayer()->Display(entry, true, aView);
if ( vmodel->getType() == SOCC_Viewer::Type() ) {
PropMap& aProps = aListOfMap[index];
if ( aProps.contains( "ShapeAnnotationVisibleItems" ) )
GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aView, aProps["ShapeAnnotationVisibleItems"].toString() );
if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
}
}
}
}
} // for entries iterator

View File

@ -326,6 +326,10 @@ void MeasureGUI_AnnotationDlg::Init()
// connect controls
connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) );
myGeomGUI->GetAnnotationMgr()->SetPreviewStyle( myEditAnnotationEntry, myEditAnnotationIndex, true );
redisplayPreview();
}
}
@ -673,17 +677,6 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
//=================================================================================
void MeasureGUI_AnnotationDlg::onDragged( Handle_GEOM_Annotation theAnnotation )
{
const PrsList& aPreview = getPreview();
PrsList::const_iterator anIt = aPreview.cbegin();
for ( ; anIt != aPreview.cend(); ++anIt ) {
AIS_ListOfInteractive aIObjects;
((SOCC_Prs*)(*anIt))->GetObjects( aIObjects );
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
for ( ; aIOIt.More(); aIOIt.Next() ) {
if ( aIOIt.Value() == theAnnotation ) {
TopoDS_Shape aShape;
GEOMBase::GetShape( myShape.get(), aShape );
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
@ -696,11 +689,6 @@ void MeasureGUI_AnnotationDlg::onDragged( Handle_GEOM_Annotation theAnnotation )
else {
myAnnotationProperties.Position = theAnnotation->GetPosition();
}
return;
}
}
}
}
#define RETURN_WITH_MSG( a, b ) \
@ -785,7 +773,12 @@ bool MeasureGUI_AnnotationDlg::execute()
//=================================================================================
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
{
SALOME_Prs* aPrs = myGeomGUI->GetAnnotationMgr()->CreatePresentation( myAnnotationProperties, myShape.get() );
QString aEntry = myIsCreation ?
myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myShape->GetStudyEntry(), - 1 ) :
myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myEditAnnotationEntry, myEditAnnotationIndex );
SALOME_Prs* aPrs = myGeomGUI->GetAnnotationMgr()->CreatePresentation(
myAnnotationProperties, myShape.get(), 0, aEntry );
// set preview style for the created presentation
AIS_ListOfInteractive aIObjects;
@ -845,6 +838,16 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
myGeomGUI->GetAnnotationMgr()->Redisplay( myEditAnnotationEntry, myEditAnnotationIndex,
myAnnotationProperties );
}
QString anEntry;
if ( myIsCreation && !myShape->_is_nil() ) {
anEntry = myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myShape->GetStudyEntry(), -1 );
}
else if ( !myIsCreation ) {
anEntry = myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myEditAnnotationEntry, myEditAnnotationIndex );
}
myInteractor->SetEditEntry( anEntry );
}
//=================================================================================

View File

@ -199,6 +199,11 @@ bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* t
{
QMouseEvent* aMouseEv = dynamic_cast<QMouseEvent*>( theEvent );
if ( myEditEntry.isEmpty() )
{
return false;
}
if ( !( aMouseEv->buttons() & Qt::LeftButton ) )
{
return false;
@ -228,6 +233,14 @@ bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* t
return false;
}
const Handle(SALOME_InteractiveObject) anIO =
Handle(SALOME_InteractiveObject)::DownCast( aAnnotation->GetOwner() );
if ( anIO.IsNull() || anIO->getEntry() != myEditEntry )
{
return false;
}
myStartPoint = aMouseEv->pos();
mySelection.Clear();

View File

@ -70,6 +70,9 @@ public:
//! Disables event processing and interaction handlers.
void Disable();
//! Set entry of allowed annotation presentations.
void SetEditEntry( const QString& theEntry ) { myEditEntry = theEntry; }
protected:
//! Connect interactor's event handler to the view window given.
@ -113,6 +116,7 @@ private:
Handle(GEOM_Annotation) myActiveIO;
SelectMgr_SequenceOfOwner mySelection;
QPoint myStartPoint;
QString myEditEntry;
};
#endif

View File

@ -63,7 +63,7 @@ GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
SetIsScreenFixed( Standard_False );
SetAttachPoint( gp_Pnt( 0.0, 0.0, 0.0 ) );
SetDisplayMode( 0 );
SetZLayer( Graphic3d_ZLayerId_Default );
SetZLayer( Graphic3d_ZLayerId_Top );
SetAutoHide( Standard_True );
SetHilightMode( HighlightAll );
SetMutable( Standard_True );
@ -118,10 +118,12 @@ void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition, const Standard_Boo
{
myPosition = thePosition;
Handle(Graphic3d_TransformPers) aPersistence;
if ( !myIsScreenFixed )
{
AIS_InteractiveObject::SetTransformPersistence( Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers, thePosition );
Handle(Graphic3d_TransformPers) aPersistence =
new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, thePosition );
AIS_InteractiveObject::SetTransformPersistence( aPersistence );
}
SetToUpdate();
@ -140,16 +142,20 @@ void GEOM_Annotation::SetIsScreenFixed( const Standard_Boolean theIsFixed )
{
myIsScreenFixed = theIsFixed;
Handle(Graphic3d_TransformPers) aPersistence;
if (!myIsScreenFixed)
{
AIS_InteractiveObject::SetTransformPersistence( Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers, myPosition );
aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, myPosition );
}
else
{
AIS_InteractiveObject::SetTransformPersistence( Graphic3d_TMF_2d );
aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_2d, Aspect_TOTP_CENTER );
}
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
AIS_InteractiveObject::SetTransformPersistence( aPersistence );
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Top );
SetToUpdate();
@ -340,7 +346,7 @@ void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable )
// =======================================================================
void GEOM_Annotation::SetDefaultZLayer()
{
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Top );
SetToUpdate();
}
@ -856,9 +862,9 @@ void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)&
// function : HilightWithColor
// purpose : Perform highlighting of the presentation.
// =======================================================================
void GEOM_Annotation::GEOM_AnnotationOwner::HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePresentationMgr,
const Quantity_NameOfColor theColor,
void GEOM_Annotation::GEOM_AnnotationOwner::HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Graphic3d_HighlightStyle)& theStyle,
const Standard_Integer theMode )
{
thePresentationMgr->Color( Selectable(), theColor, theMode, NULL, Selectable()->ZLayer() );
thePM->Color( Selectable(), theStyle, theMode, NULL, Selectable()->ZLayer() );
}

View File

@ -261,10 +261,9 @@ private:
virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode ) Standard_OVERRIDE;
virtual void SetLocalTransformation( const gp_Trsf& /*theTransformation*/ ) Standard_OVERRIDE {}
virtual void setLocalTransformation( const Handle(Geom_Transformation)& /*theTransformation*/ ) Standard_OVERRIDE {}
virtual void SetTransformPersistence( const Graphic3d_TransModeFlags& /*theFlag*/,
const gp_Pnt& /*thePoint*/ ) Standard_OVERRIDE {}
virtual void SetTransformPersistence( const Handle(Graphic3d_TransformPers)& /*theTrsfPers*/ ) Standard_OVERRIDE {}
Bnd_Box TextBoundingBox() const;
@ -351,8 +350,8 @@ public:
//! \param theColor [in] the highlighting color.
//! \param theMode [in] the display mode.
virtual void
HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePresentationMgr,
const Quantity_NameOfColor theColor,
HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Graphic3d_HighlightStyle)& theStyle,
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
};