--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOMGUI_AnnotationMgr.h"
+
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOM_Annotation.hxx>
+#include <GEOM_Client.hxx>
+#include <GEOM_Displayer.h>
+#include <GeometryGUI.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SALOME_Prs.h>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+
+#include <SOCC_Prs.h>
+#include <SOCC_ViewModel.h>
+
+#include <Quantity_Color.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <gp_Ax3.hxx>
+
+#include <QFont>
+#include <QColor>
+
+
+GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication )
+: myApplication( theApplication )
+{
+}
+
+SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+ GEOM::GEOM_Object_ptr theObject )
+{
+ Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
+
+ 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 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 );
+
+ 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 );
+ const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
+
+ aPresentation->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) );
+ aPresentation->SetTextHeight( aFontHeight );
+ aPresentation->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) );
+ aPresentation->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) );
+ aPresentation->SetLineWidth( aLineWidth );
+ aPresentation->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
+ aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
+ aPresentation->SetScreenFixed( theProperty.IsScreenFixed );
+
+ TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
+ //TopoDS_Shape aShape;
+ //GEOMBase::GetShape( theObject.get(), aShape );
+ gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+ GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+
+ // add Prs to preview
+ SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
+ SOCC_Prs* aPrs =
+ dynamic_cast<SOCC_Prs*>( ( ( SOCC_Viewer* ) ( vw->getViewManager()->getViewModel() ) )->CreatePrs(
+ 0 ) );
+
+ if ( aPrs )
+ aPrs->AddObject( aPresentation );
+
+ return aPrs;
+}
+
+//void GEOMGUI_AnnotationMgr::DisplayPresentation( SALOME_Prs* thePresentation )
+//{
+
+//}
+
+/*void GEOMGUI_AnnotationMgr::erasePresentation( SALOME_Prs* thePresentation )
+{
+
+}*/
+
+bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex )
+{
+ SalomeApp_Application* anApp = getApplication();
+ SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
+ SALOME_View* aView = dynamic_cast<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
+
+ if ( !myVisualized.contains( aView ) )
+ return false;
+
+ EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+
+ if ( !anEntryToAnnotation.contains( theEntry ) )
+ return false;
+
+ AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+ if ( !anAnnotationToPrs.contains( theIndex ) )
+ return false;
+
+ return true;
+}
+
+void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex )
+{
+ if ( IsDisplayed( theEntry, theIndex ) )
+ return;
+
+ SalomeApp_Application* anApp = getApplication();
+ SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
+ SALOME_View* aView = dynamic_cast<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
+
+ GEOMGUI_AnnotationAttrs::Properties aProperty;
+ GEOM::GEOM_Object_ptr anObject;
+ getObject( theEntry, theIndex, anObject, aProperty );
+
+ SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject );
+ aView->Display( getDisplayer(), aPrs );
+ getDisplayer()->UpdateViewer();
+
+ EntryToAnnotations anEntryToMap;
+ if ( myVisualized.contains( aView ) )
+ anEntryToMap = myVisualized[aView];
+
+ AnnotationToPrs anAnnotationToPrsMap;
+ if ( anEntryToMap.contains( theEntry ) )
+ anAnnotationToPrsMap = anEntryToMap[theEntry];
+ anAnnotationToPrsMap[theIndex] = aPrs;
+
+ anEntryToMap[theEntry] = anAnnotationToPrsMap;
+ myVisualized[aView] = anEntryToMap;
+}
+
+void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex )
+{
+ SalomeApp_Application* anApp = getApplication();
+ SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
+ SALOME_View* aView = dynamic_cast<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
+
+ if ( !myVisualized.contains( aView ) )
+ return;
+
+ EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+
+ if ( !anEntryToAnnotation.contains( theEntry ) )
+ return;
+
+ AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+ if ( !anAnnotationToPrs.contains( theIndex ) )
+ return;
+
+ SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
+ aView->Erase( getDisplayer(), aPrs );
+ getDisplayer()->UpdateViewer();
+
+ anAnnotationToPrs.remove( theIndex );
+ anEntryToAnnotation[theEntry] = anAnnotationToPrs;
+ myVisualized[aView] = anEntryToAnnotation;
+}
+
+GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const
+{
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( getApplication()->activeModule() );
+ return dynamic_cast<GEOM_Displayer*>( aModule->displayer() );
+}
+
+void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
+ GEOM::GEOM_Object_ptr& theObject,
+ GEOMGUI_AnnotationAttrs::Properties& theProperty )
+{
+ 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 );
+
+ aShapeAnnotations->GetProperties( theIndex, theProperty );
+
+ theObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
+}
+
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOMGUI_ANNOTATIONMGR_H
+#define GEOMGUI_ANNOTATIONMGR_H
+
+#include "GEOM_GEOMGUI.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include <QObject>
+#include <GEOMGUI_AnnotationAttrs.h>
+
+#include <SALOME_Prs.h>
+
+class SalomeApp_Application;
+class GEOM_Displayer;
+
+/*!
+ * \brief A help class to process visualizatin of annotation presentations.
+ * It contains a map of presentations shown in each viewer.
+ * and correct 2D position persistent properties of annotations of active viewer.
+ * When the viewer is closed, information about the viewer is removed from the manager
+ */
+class GEOMGUI_EXPORT GEOMGUI_AnnotationMgr : public QObject
+{
+ Q_OBJECT;
+
+public:
+ GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication );
+ ~GEOMGUI_AnnotationMgr() {}
+
+ SALOME_Prs* CreatePresentation(const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+ GEOM::GEOM_Object_ptr theObject);
+
+ //void DisplayPresentation(SALOME_Prs* thePresentation);
+ //void erasePresentation(SALOME_Prs* thePresentation);
+
+ bool IsDisplayed(const QString& theEntry, const int theIndex);
+ void Display(const QString& theEntry, const int theIndex);
+ void Erase(const QString& theEntry, const int theIndex);
+
+protected:
+ SalomeApp_Application* getApplication() const { return myApplication; }
+
+ GEOM_Displayer* getDisplayer() const;
+
+ void getObject( const QString& theEntry, const int theIndex,
+ GEOM::GEOM_Object_ptr& anObject,
+ GEOMGUI_AnnotationAttrs::Properties& aProperty );
+
+private:
+ SalomeApp_Application* myApplication;
+
+ typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
+ typedef QMap<QString, AnnotationToPrs> EntryToAnnotations;
+ QMap<SALOME_View*, EntryToAnnotations> myVisualized;
+};
+#endif
#include "GEOMGUI_DimensionProperty.h"
#include "GEOMGUI_AnnotationAttrs.h"
+#include "GEOMGUI_AnnotationMgr.h"
#include "GeometryGUI.h"
#include "GeometryGUI_Operations.h"
#include <GEOM_Constants.h>
public:
AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
+ myEntry = theEntry.c_str();
+ myStudy = theStudy;
_PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
}
return !myAttr.IsNull() ? myAttr->GetName( theIndex ) : QString();
}
virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
- return !myAttr.IsNull() ? myAttr->GetIsVisible( theIndex ) : false;
+ return annotationMgr()->IsDisplayed(myEntry, theIndex);
+ //return !myAttr.IsNull() ? myAttr->GetIsVisible( theIndex ) : false;
}
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
- if ( !myAttr.IsNull() ) {
+ if (theIsVisible)
+ annotationMgr()->Display(myEntry, theIndex);
+ else
+ annotationMgr()->Erase(myEntry, theIndex);
+ /*if ( !myAttr.IsNull() ) {
myAttr->SetIsVisible( theIndex, theIsVisible );
- }
+ }*/
}
virtual void Save() Standard_OVERRIDE {
/* every change is automatically saved */
}
Handle(GEOMGUI_AnnotationAttrs) Attr() { return myAttr; }
- private:
+protected:
+ GEOMGUI_AnnotationMgr* annotationMgr() const
+ {
+ CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+ GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
+ return aModule->GetAnnotationMgr();
+ }
+private:
+ QString myEntry;
Handle(GEOMGUI_AnnotationAttrs) myAttr;
+ SalomeApp_Study* myStudy;
};
}
#include "GEOM_Displayer.h"
#include "GEOM_AISShape.hxx"
#include "GEOMUtils_XmlHandler.hxx"
+#include "GEOMGUI_AnnotationMgr.h"
#include "GEOM_Actor.h"
myCreationInfoWdg = 0;
myTextTreeWdg = 0;
+ myAnnotationMgr = 0;
connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
}
}
+//=======================================================================
+// function : GeometryGUI::SetActiveDialogBox()
+// purpose : Set active dialog box
+//=======================================================================
+GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
+{
+ if ( !myAnnotationMgr )
+ myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
+ return myAnnotationMgr;
+}
+
//=======================================================================
// function : GeometryGUI::SetActiveDialogBox()
// purpose : Set active dialog box
if ( !myTextTreeWdg )
myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
+
getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
std::string aStudyEntry = (*aEntryIt).toLatin1().data();
std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
+ // store dimension parameters
GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
if ( aDimensions.GetNumber() == 0 )
}
ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
+
+ // store annotation parameters
+ //GetAnnotationMgr()->storeVisualParameters(ip, aStudyEntry);
+ //_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
}
}