- <b>OCC Viewer 3d</b>
- <b>Trihedron size</b> - this submenu allows to set the size of
coordinate axes displayed in the viewer.
+ - <b>Relative size</b> - if checked in, trihedron axes scale to fit the
+ size of the area displayed in 3D Viewer.
- <b>Navigation</b> - this option allows to choose one of the
modes of work with mouse in OCC and VTK 3D viewers.
- <b>Salome Standard Controls</b> - allows to manipulate objects in the
relatively to its center.
- <b>Relative to the cursor</b> - allows to zoom the view
relatively to the current cursor position.
+ - <b>Show static trihedron</b> - allows to show/hide the static trihedron
+ located in the bottom-left corner of the viewer.
- <b>VTK Viewer 3d</b>
- <b>Projection mode</b> - allows choosing between \b Orthogonal and
\b Perspective projection mode.
#ifndef DISABLE_SALOMEOBJECT
vm = new SOCC_Viewer();
#else
- vm = new OCCViewer_Viewer( true, resMgr->booleanValue( "OCCViewer", "static_trihedron", true ) );
+ vm = new OCCViewer_Viewer( true );
#endif
vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT,
resMgr->colorValue( "OCCViewer", "xz_background", vm->backgroundColor() ) );
vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT,
resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
- vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+ vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
+ resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
int u( 1 ), v( 1 );
vm->isos( u, v );
u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
pref->setItemProperty( "min", 1.0E-06, occTS );
pref->setItemProperty( "max", 1000, occTS );
+
+ pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup,
LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
pref->setItemProperty( "indexes", aModeIndexesList, occZoomingStyleMode );
#endif
+ pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
+
// VTK Viewer
int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "columns", 2, vtkGen );
}
#ifndef DISABLE_OCCVIEWER
- if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
+ if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
{
- double sz = resMgr->doubleValue( sec, param, -1 );
+ double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
+ bool relative = resMgr->booleanValue( sec, "relative_size", true );
QList<SUIT_ViewManager*> lst;
viewManagers( OCCViewer_Viewer::Type(), lst );
QListIterator<SUIT_ViewManager*> it( lst );
continue;
OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
- occVM->setTrihedronSize( sz );
+ occVM->setTrihedronSize( sz, relative );
occVM->getAISContext()->UpdateCurrentViewer();
}
}
#endif
+#ifndef DISABLE_OCCVIEWER
+ if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
+ {
+ bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
+ QList<SUIT_ViewManager*> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> it( lst );
+ while ( it.hasNext() )
+ {
+ SUIT_ViewModel* vm = it.next()->getViewModel();
+ if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+ continue;
+
+ OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
+ if( occVM )
+ {
+ occVM->setStaticTrihedronDisplayed( isVisible );
+ }
+ }
+ }
+#endif
+
#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
{
<parameter name="trihedron_size" value="100" />
<parameter name="navigation_mode" value="0" />
<parameter name="zooming_mode" value="0" />
+ <parameter name="show_static_trihedron" value="true"/>
+ <parameter name="relative_size" value="true"/>
</section>
<section name="VTKViewer" >
<!-- VTK viewer preferences -->
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron, false ) )
-{
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+{
setTitle( tr( "OCC_VIEW_TITLE" ) );
}
#include "SUIT_ViewManager.h"
#include "SUIT_Desktop.h"
#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
#include "QtxActionToolMgr.h"
#include <Prs3d_AngleAspect.hxx>
#include <Prs3d_TextAspect.hxx>
+#include <Visual3d_View.hxx>
+
/*!
Constructor
\param DisplayTrihedron - is trihedron displayed
*/
-OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTrihedron )
+OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
: SUIT_ViewModel(),
- myShowStaticTrihedron( DisplayStaticTrihedron ),
- myColors(4, Qt::black)
+ myColors(4, Qt::black),
+ myIsRelative(true),
+ myTrihedronSize(100)
{
// init CasCade viewers
myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000.,
// selection
mySelectionEnabled = true;
myMultiSelectionEnabled = true;
+
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if(resMgr)
+ myShowStaticTrihedron = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
}
/*!
Changes trihedron size
\param sz - new size
*/
-void OCCViewer_Viewer::setTrihedronSize( const double sz )
+void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
{
- if ( !myTrihedron.IsNull() )
- myTrihedron->SetSize( sz );
+ if ( myTrihedronSize != sz || isRelative != myIsRelative) {
+ myTrihedronSize = sz;
+ myIsRelative = isRelative;
+ updateTrihedron();
+ }
}
/*!
if ( theColor.isValid() && theViewId >= 0 && theViewId < myColors.count() )
myColors[theViewId] = theColor;
}
+
+
+/*!
+ Set the show static trihedron flag
+*/
+void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on) {
+ if(myShowStaticTrihedron != on) {
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+ if(!aView)
+ return;
+
+ OCCViewer_ViewPort3d* vp3d = aView->getViewPort();
+ if(vp3d) {
+ myShowStaticTrihedron = on;
+ vp3d->updateStaticTriedronVisibility();
+ }
+ }
+}
+
+/*!
+ Get new and current trihedron size corresponding to the current model size
+*/
+bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
+{
+ theNewSize = 100;
+ theSize = 100;
+
+ //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
+ Handle(V3d_Viewer) viewer = getViewer3d();
+ viewer->InitActiveViews();
+ if(!viewer->MoreActiveViews()) return false;
+
+ Handle(V3d_View) view3d = viewer->ActiveView();
+ //SRN: END of fix
+
+ if ( view3d.IsNull() )
+ return false;
+
+ double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
+ double aMaxSide;
+
+ view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
+
+ if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
+ Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() )
+ return false;
+
+ aMaxSide = Xmax - Xmin;
+ if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
+ if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
+
+ // IPAL21687
+ // The boundary box of the view may be initialized but nullified
+ // (case of infinite objects)
+ if ( aMaxSide < Precision::Confusion() )
+ return false;
+
+ float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("OCCViewer","trihedron_size", 100.);
+
+ static float EPS = 5.0E-3;
+ theSize = getTrihedron()->Size();
+ theNewSize = aMaxSide*aSizeInPercents / 100.0;
+
+ return fabs( theNewSize - theSize ) > theSize * EPS ||
+ fabs( theNewSize - theSize) > theNewSize * EPS;
+}
+
+/*!
+ * Update the size of the trihedron
+ */
+void OCCViewer_Viewer::updateTrihedron() {
+ if(myIsRelative){
+ double newSz, oldSz;
+
+ if(computeTrihedronSize(newSz, oldSz))
+ myTrihedron->SetSize(newSz);
+
+ } else if(myTrihedron->Size() != myTrihedronSize) {
+ myTrihedron->SetSize(myTrihedronSize);
+ }
+}
public:
static QString Type() { return "OCCViewer"; }
- OCCViewer_Viewer( bool DisplayTrihedron = true, bool DisplayStaticTrihedron = true );
+ OCCViewer_Viewer( bool DisplayTrihedron = true);
virtual ~OCCViewer_Viewer();
void update();
virtual void setTrihedronShown( const bool );
double trihedronSize() const;
- virtual void setTrihedronSize( const double );
+ virtual void setTrihedronSize( const double , bool isRelative = true);
+
+ bool trihedronRelative() const {return myIsRelative; }
+
+ // a utility function, used by SALOME_View_s methods
+ bool computeTrihedronSize( double& theNewSize, double& theSize );
+
+ void updateTrihedron();
+
virtual OCCViewer_ViewWindow* createSubWindow();
bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
+
bool isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
+ void setStaticTrihedronDisplayed(const bool on);
/* Selection management */
bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
+ bool myIsRelative;
//QColor myBgColor;
QPoint myStartPnt, myEndPnt;
bool myShowStaticTrihedron;
+ double myTrihedronSize;
+
QVector<QColor> myColors;
};
return true;
}
+
+
/*!
Sets new CASCADE view on viewport. Returns the previous active view. [ public ]
*/
return ok;
}
+/*
+ * Show/Hide static triedron
+ */
+void OCCViewer_ViewPort3d::updateStaticTriedronVisibility() {
+ OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
+ if ( aVW ) {
+ OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
+ Handle(V3d_View) aView = activeView();
+ if ( aViewModel ){
+ if(aViewModel->isStaticTrihedronDisplayed()) {
+ aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+ } else {
+ aView->TriedronErase();
+ }
+ aView->Update();
+ }
+ }
+}
virtual QString backgroundImageFilename() const;
virtual void setBackgroundImage( const QString& fileName , const Aspect_FillMethod& theFillMethod);
+ virtual void updateStaticTriedronVisibility();
+
// void setActive( V3d_TypeOfView );
virtual bool syncronize( const OCCViewer_ViewPort3d* );
{
Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS );
double aNewSize = 100, aSize = 100;
- getTrihedronSize( aNewSize, aSize );
+ computeTrihedronSize( aNewSize, aSize );
aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize );
}
ic->Deactivate( anAIS );
}
}
+ updateTrihedron();
}
//}
}
}
+ updateTrihedron();
}
// }
//}
}
-
+
Repaint();
+ updateTrihedron();
}
/*!
}
}
-/*!
- Get new and current trihedron size corresponding to the current model size
-*/
-bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize )
-{
- theNewSize = 100;
- theSize = 100;
-
- //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
- Handle(V3d_Viewer) viewer = getViewer3d();
- viewer->InitActiveViews();
- if(!viewer->MoreActiveViews()) return false;
-
- Handle(V3d_View) view3d = viewer->ActiveView();
- //SRN: END of fix
-
- if ( view3d.IsNull() )
- return false;
-
- double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
- double aMaxSide;
-
- view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
-
- if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
- Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() )
- return false;
-
- aMaxSide = Xmax - Xmin;
- if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
- if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
-
- // IPAL21687
- // The boundary box of the view may be initialized but nullified
- // (case of infinite objects)
- if ( aMaxSide < Precision::Confusion() )
- return false;
-
- float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("Viewer","TrihedronSize", 105.);
-
- static float EPS = 5.0E-3;
- theSize = getTrihedron()->Size();
- theNewSize = aMaxSide*aSizeInPercents / 100.0;
-
- return fabs( theNewSize - theSize ) > theSize * EPS ||
- fabs( theNewSize - theSize) > theNewSize * EPS;
-}
/*!
\Collect objects visible in viewer
virtual void GetVisible( SALOME_ListIO& );
virtual void Repaint();
- // a utility function, used by SALOME_View_s methods
- bool getTrihedronSize( double& theNewSize, double& theSize );
-
//a map to store AIS objects associated to a SALOME entry
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> > entry2aisobjects;
};