Salome HOME
Dialog SetupCurveDlg has been added
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewModel.cxx
index 5de1e756ad55883c2865af098a47b955ca3bb876..d8171544456f0452fd421dd1694e12ec168b1b21 100755 (executable)
 #include <Prs3d_LineAspect.hxx>
 
 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron )
-:SUIT_ViewModel() 
+: SUIT_ViewModel(),
+myBgColor( Qt::black )
 {
-    // init CasCade viewers
+  // init CasCade viewers
   myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000.,
                                               V3d_XposYnegZpos, true, true );
 
@@ -73,11 +74,26 @@ OCCViewer_Viewer::~OCCViewer_Viewer()
 {
 }
 
+QColor OCCViewer_Viewer::backgroundColor() const
+{
+  return myBgColor;
+}
+
+void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
+{
+  if ( c.isValid() )
+    myBgColor = c;
+}
 
-SUIT_ViewWindow* OCCViewer_Viewer::createView(SUIT_Desktop* theDesktop)
+SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
 {
   OCCViewer_ViewWindow* res = new OCCViewer_ViewWindow(theDesktop, this);
   res->initLayout();
+
+  OCCViewer_ViewPort3d* vp3d = res->getViewPort();
+  if ( vp3d )
+    vp3d->setBackgroundColor( myBgColor );
+
   return res;
 }
 
@@ -373,3 +389,59 @@ void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj
   if( update )
     myV3dViewer->Update();
 }
+
+//****************************************************************
+void OCCViewer_Viewer::toggleTrihedron()
+{
+  setTrihedronShown( !isTrihedronVisible() );
+}
+
+bool OCCViewer_Viewer::isTrihedronVisible() const
+{
+  return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
+}
+
+void OCCViewer_Viewer::setTrihedronShown( const bool on )
+{
+  if ( myTrihedron.IsNull() )
+    return;
+
+  if ( on )
+    myAISContext->Display( myTrihedron );
+  else
+    myAISContext->Erase( myTrihedron );
+}
+
+int OCCViewer_Viewer::trihedronSize() const
+{
+  int sz = 0;
+  if ( !myTrihedron.IsNull() )
+    sz = (int)myTrihedron->Size();
+  return sz;
+}
+
+void OCCViewer_Viewer::setTrihedronSize( const int sz )
+{
+  if ( !myTrihedron.IsNull() )
+    myTrihedron->SetSize( sz );
+}
+
+void OCCViewer_Viewer::setIsos( const int u, const int v )
+{
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  if ( ic.IsNull() )
+  return;
+
+  ic->SetIsoNumber( u, AIS_TOI_IsoU );
+  ic->SetIsoNumber( u, AIS_TOI_IsoV );
+}
+
+void OCCViewer_Viewer::isos( int& u, int& v ) const
+{
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  if ( !ic.IsNull() )
+  {
+    u = ic->IsoNumber( AIS_TOI_IsoU );
+    v = ic->IsoNumber( AIS_TOI_IsoV );
+  }
+}