--- /dev/null
+<!DOCTYPE TS><TS>
+<context>
+ <name>@default</name>
+ <message>
+ <source>APP_OK</source>
+ <translation>Ok</translation>
+ </message>
+ <message>
+ <source>APP_ERROR</source>
+ <translation>Error</translation>
+ </message>
+ <message>
+ <source>APP_UNK_EXCEPTION</source>
+ <translation>Unknown exception</translation>
+ </message>
+</context>
+</TS>
#include "SVTK_SelectorDef.h"
-#include "VTKViewer_Filter.h"
+#include <VTKViewer_Filter.h>
#include "SALOME_Actor.h"
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <vtkCallbackCommand.h>
+#include <vtkActorCollection.h>
+#include <vtkCellPicker.h>
+
+
+/*!
+ Find first SALOME_Actor from the end of actors collection
+*/
+inline
+SALOME_Actor*
+GetLastSALOMEActor(vtkActorCollection* theCollection)
+{
+ if (theCollection) {
+ for (int i = theCollection->GetNumberOfItems() - 1; i >= 0; i--) {
+ if (SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theCollection->GetItemAsObject(i)))
+ if (anActor->hasIO())
+ return anActor;
+ }
+ }
+ return NULL;
+}
+
/*!
\return new SVTK_Selector
Default constructor
*/
SVTK_SelectorDef
-::SVTK_SelectorDef()
+::SVTK_SelectorDef():
+ myPicker(vtkPicker::New()),
+ myCellPicker(vtkCellPicker::New())
{
mySelectionMode = ActorSelection;
+
+ myPicker->Delete();
+ myCellPicker->Delete();
}
/*!
return Handle(VTKViewer_Filter)();
}
+SALOME_Actor*
+SVTK_SelectorDef
+::Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const
+{
+ bool anAdvancedSelectionAlgorithm = true;
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+ if ( aResourceMgr )
+ anAdvancedSelectionAlgorithm = aResourceMgr->booleanValue( "VTKViewer", "use_advanced_selection_algorithm", true );
+
+ SALOME_Actor* anActor = NULL;
+ vtkActorCollection* aListActors = NULL;
+ if ( anAdvancedSelectionAlgorithm ) {
+ myCellPicker->Pick(theEvent->myX,
+ theEvent->myY,
+ 0.0,
+ theRenderer);
+
+ aListActors = myCellPicker->GetActors();
+ anActor = GetLastSALOMEActor(aListActors);
+ }
+
+ if ( !anActor ) {
+ myPicker->Pick(theEvent->myX,
+ theEvent->myY,
+ 0.0,
+ theRenderer);
+ aListActors = myPicker->GetActors();
+ anActor = GetLastSALOMEActor(aListActors);
+ }
+
+ return anActor;
+}
+
+void
+SVTK_SelectorDef
+::SetTolerance(const double& theTolerance)
+{
+ myPicker->SetTolerance(theTolerance);
+ myCellPicker->SetTolerance(theTolerance);
+}
class Handle(VTKViewer_Filter);
class SALOME_Actor;
+class SVTK_SelectionEvent;
+class vtkRenderer;
class Handle(SALOME_InteractiveObject);
//! Define an abstract interface for selection in SVTK package
virtual
void
EndPickCallback() = 0;
+
+ //----------------------------------------------------------------------------
+ virtual
+ SALOME_Actor*
+ Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const = 0;
+
+ virtual
+ void
+ SetTolerance(const double& theTolerance) = 0;
};
class SVTK_Viewer;
class SVTK_ViewWindow;
+class vtkPicker;
+class vtkCellPicker;
class SVTK_SelectorDef: public SVTK_Selector
{
void
EndPickCallback();
+ //----------------------------------------------------------------------------
+ virtual
+ SALOME_Actor*
+ Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
+
+ virtual
+ void
+ SetTolerance(const double& theTolerance);
+
private:
int mySelectionMode;
typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
TFilters myFilters;
+
+ vtkSmartPointer<vtkPicker> myPicker;
+ vtkSmartPointer<vtkCellPicker> myCellPicker;
};
#endif
void
SVTK_View
::SetSelectionTolerance(const double& theTolNodes,
- const double& theTolCell)
+ const double& theTolCell,
+ const double& theTolObjects)
{
- GetRenderer()->SetSelectionTolerance(theTolNodes,theTolCell);
+ GetRenderer()->SetSelectionTolerance(theTolNodes, theTolCell, theTolObjects);
}
/*!
//! Redirect the request to #SVTK_Renderer::SetPreselectionProp
void
SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001);
+ const double& theTolCell = 0.001,
+ const double& theTolObjects = 0.025);
protected:
int myDisplayMode;
thePopup->addSeparator();
if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
- if ( !aView->getMainWindow()->getToolBar()->isVisible() ){
- thePopup->addAction( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
- }
+ //Support of several toolbars in the popup menu
+ QList<QToolBar*> lst = qFindChildren<QToolBar*>( aView );
+ QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
+ for( ; it!=last; it++ )
+ thePopup->addAction( (*it)->toggleViewAction() );
aView->RefreshDumpImage();
}
}
}
}
-/*!
- SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window
-*/
-void
-SVTK_Viewer
-::onShowToolbar()
-{
- QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
- if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))){
- aView->getMainWindow()->getToolBar()->show();
- }
- }
-}
-
/*!
Display presentation
\param prs - presentation
void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
void onDumpView();
- void onShowToolbar();
void onChangeBgColor();
private:
void
SVTK_ViewWindow
::SetSelectionTolerance(const double& theTolNodes,
- const double& theTolItems)
+ const double& theTolItems,
+ const double& theTolObjects)
{
- myView->SetSelectionTolerance(theTolNodes,theTolItems);
+ myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
}
/*!
// 76 values for graduated axes, so both numbers are processed.
const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
-const int nNormalGradAxisParams = nNormalParams + 3*nGradAxisParams + 1; // number of visual parameters with graduated axes
-const int nBgColorParams = 4; // number of parameters of BgColor ("BgColor",Red,Gree,Blue)
-const int nNormalBgColorParams = nNormalGradAxisParams + nBgColorParams; // number of visual parameters with background color
+const int nAllParams = nNormalParams + 3*nGradAxisParams + 1; // number of all visual parameters
/*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
*/
retStr += ::getGradAxisVisualParams( gradAxesActor->GetZAxisActor2D() );
}
- QColor bgColor=backgroundColor();
-
- retStr += QString("* BgColor ");
- retStr += QString( "*%1" ).arg(bgColor.red());
- retStr += QString( "*%1" ).arg(bgColor.green());
- retStr += QString( "*%1" ).arg(bgColor.blue());
-
return retStr;
}
// apply graduated axes parameters
SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
- if ( gradAxesActor && paramsLst.size() >= nNormalGradAxisParams ) {
+ if ( gradAxesActor && paramsLst.size() == nAllParams ) {
int i = nNormalParams+1, j = i + nGradAxisParams - 1;
::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
else
gradAxesActor->VisibilityOff();
}
- if(paramsLst.size() >= nNormalBgColorParams) {
- QColor bgColor(paramsLst[nNormalBgColorParams-3].toInt(),
- paramsLst[nNormalBgColorParams-2].toInt(),
- paramsLst[nNormalBgColorParams-1].toInt()
- );
- setBackgroundColor(bgColor);
- }
}
}
virtual
void
SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001);
+ const double& theTolCell = 0.001,
+ const double& theTolObjects = 0.025);
//! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
virtual
--- /dev/null
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>images/critical.png</file>
+ <file>images/information.png</file>
+ <file>images/question.png</file>
+ <file>images/warning.png</file>
+ </qresource>
+ </RCC>