#define VISU_Event_h
#include "SVTK_Event.h"
+#include "SVTK_Selection.h"
namespace VISU
{
LastEvent
};
}
+
+const Selection_Mode GaussPointSelection = 100;
#endif
if(aSelectionMode == ActorSelection || !theIsHighlight)
return Superclass::PreHighlight(theInteractorStyle,
theSelectionEvent,
- theIsHighlight);
+ theIsHighlight);
bool anIsChanged = (mySelectionMode != aSelectionMode);
bool anIsPreselected = myIsPreselected;
+ myIsPreselected = false;
- if(theIsHighlight){
- switch(mySelectionMode){
- case NodeSelection:
- case CellSelection:
- {
- myPointPicker->Pick(theSelectionEvent->myX,
- theSelectionEvent->myY,
- 0.0,
- theInteractorStyle->GetCurrentRenderer());
-
- if(myPointPicker->GetActor() != this)
- return false;
-
- vtkIdType aVtkId = myPointPicker->GetPointId();
-
- if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
- vtkIdType anObjId = GetNodeObjId( aVtkId );
- myIsPreselected = (anObjId >= 0);
- if(myIsPreselected){
- anIsChanged = (myLastObjPointID != anObjId);
- if(anIsChanged){
- float* aNodeCoord = GetNodeCoord(anObjId);
- vtkDataSet* aDataSet = GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
- float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
- float aPyramidHeight = myPickingSettings->GetPyramidHeight();
- aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
- //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
- float aColor[3];
- theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
- aColor[0] = 1. - aColor[0];
- aColor[1] = 1. - aColor[1];
- aColor[2] = 1. - aColor[2];
- myCursorPyramid->Init(aPyramidHeight,
- aRadius,
- aNodeCoord,
- aColor);
- }
- myLastObjPointID = anObjId;
+ if(aSelectionMode == GaussPointSelection && theIsHighlight){
+ myPointPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ theInteractorStyle->GetCurrentRenderer());
+
+ if(myPointPicker->GetActor() != this)
+ return (anIsPreselected != myIsPreselected);
+
+ vtkIdType aVtkId = myPointPicker->GetPointId();
+
+ if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
+ vtkIdType anObjId = GetNodeObjId( aVtkId );
+ myIsPreselected = (anObjId >= 0);
+ if(myIsPreselected){
+ anIsChanged = (myLastObjPointID != anObjId);
+ if(anIsChanged){
+ float* aNodeCoord = GetNodeCoord(anObjId);
+ vtkDataSet* aDataSet = GetInput();
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
+ float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
+ float aPyramidHeight = myPickingSettings->GetPyramidHeight();
+ aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
+ //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
+ float aColor[3];
+ theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
+ aColor[0] = 1. - aColor[0];
+ aColor[1] = 1. - aColor[1];
+ aColor[2] = 1. - aColor[2];
+ myCursorPyramid->Init(aPyramidHeight,
+ aRadius,
+ aNodeCoord,
+ aColor);
}
- myCursorPyramid->SetVisibility(true);
+ myLastObjPointID = anObjId;
}
+ myCursorPyramid->SetVisibility(true);
}
}
- break;
- }
}
-
+
mySelectionMode = aSelectionMode;
anIsChanged |= (anIsPreselected != myIsPreselected);
{
Handle(SALOME_InteractiveObject) anIO = getIO();
int anInitialHasIndex = mySelector->HasIndex(anIO);
- if(!theIsHighlight){
+
+ Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
+ //
+ if(!theIsHighlight && aSelectionMode == GaussPointSelection){
mySelector->RemoveIObject(anIO);
ChangeZoom(myPickingSettings,
return false;
}
//
- Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
- //
if(aSelectionMode == ActorSelection){
return Superclass::Highlight(theInteractorStyle,
theSelectionEvent,
theIsHighlight);
}
//
- if(!theSelectionEvent->myIsRectangle){
+ if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
myPointPicker->Pick(theSelectionEvent->myX,
bool anIsVisible = GetVisibility();
- if(mySelector->SelectionMode() == ActorSelection)
+ Selection_Mode aSelectionMode = mySelector->SelectionMode();
+
+ if(aSelectionMode == ActorSelection)
Superclass::highlight(theIsHighlight);
+ else if(aSelectionMode != GaussPointSelection)
+ return;
TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex( getIO(), aMapIndex );
OnSelectionInfo()
{
if (GetViewWindow(this))
- (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
+ (new VisuGUI_SelectionDlg(this))->show();
else
SUIT_MessageBox::warn1(GetDesktop(this),
tr("WRN_VISU"),
static VisuGUI_SelectionDlg* mySelectionDlg = NULL;
-VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent)
- : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder |
- WStyle_Title | WStyle_SysMenu | WDestructiveClose),
- mySelectionMgr(NULL)
+VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule):
+ QDialog(VISU::GetDesktop(theModule),
+ 0,
+ false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ mySelectionMgr(NULL),
+ myModule(theModule)
{
if (mySelectionDlg)
mySelectionDlg->close(true);
myFl = false;
// Activate Points pane
- SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
myWidgetStack->raiseWidget(myPointsPane);
- if (aSVTKVW)
- aSVTKVW->SetSelectionMode(NodeSelection);
+ if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule))
+ aViewWindow->SetSelectionMode(NodeSelection);
onSelectionEvent();
mySelectionDlg = this;
void VisuGUI_SelectionDlg::onSelectionChange (int theId)
{
- SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
- if (!aSVTKVW) return;
+ SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule);
+ if (!aViewWindow) return;
switch (theId) {
case 0: // Points
myWidgetStack->raiseWidget(myPointsPane);
- aSVTKVW->SetSelectionMode(NodeSelection);
+ aViewWindow->SetSelectionMode(NodeSelection);
onPointIdEdit(myIDValLbl->text());
break;
case 1: // Cells
myWidgetStack->raiseWidget(myCellsPane);
- aSVTKVW->SetSelectionMode(CellSelection);
+ aViewWindow->SetSelectionMode(CellSelection);
onCellIdEdit(myCellIDValLbl->text());
break;
case 2: // Actor
myWidgetStack->raiseWidget(myActorsPane);
- aSVTKVW->SetSelectionMode(ActorSelection);
+ aViewWindow->SetSelectionMode(ActorSelection);
onSelectionEvent();
}
}
void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent)
{
- SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
-
mySelectionDlg = NULL;
- if (aSVTKVW)
- aSVTKVW->SetSelectionMode(ActorSelection);
+ if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule))
+ aViewWindow->SetSelectionMode(ActorSelection);
disconnect(mySelectionMgr,0,0,0);
QDialog::closeEvent(theEvent);
}
#define ABS(a) (a>=0)?a:-a
void VisuGUI_SelectionDlg::onSelectionEvent() {
- SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
- if (!aSVTKVW) return;
+ SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule);
+ if (!aViewWindow) return;
if (myFl) return;
myFl = true;
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
(SUIT_Session::session()->activeApplication());
- SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
VISU::Prs3d_i* aPrs3d = NULL;
_PTR(SObject) aSObject;
Handle(SALOME_InteractiveObject) anIO;
SALOME_ListIO aListIO;
- mySelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type());
+ mySelectionMgr->selectedObjects(aListIO);
if (aListIO.Extent() == 1) {
anIO = aListIO.First();
myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
VISU_Actor* anVISUActor =
- VISU::FindActor(aSVTKVW, aSObject->GetID().c_str());
+ VISU::FindActor(aViewWindow, aSObject->GetID().c_str());
if (anVISUActor) {
float aCoord[6];
anVISUActor->GetBounds(aCoord);
bool onIdEdit (const QString& theText,
TDataSetMethod theMethod,
bool theIsCell,
+ const SalomeApp_Module* theModule,
SalomeApp_SelectionMgr* theSelectionMgr,
QLabel* theMeshName,
QString theValue,
QLabel* theFieldName)
{
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
- (SUIT_Session::session()->activeApplication());
- SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
- if (!aSVTKVW) return false;
- SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+ SalomeApp_Application* anApp = theModule->getApp();
+ SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theModule);
+ if (!aViewWindow) return false;
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
VISU::Prs3d_i* aPrs3d = NULL;
Handle(SALOME_InteractiveObject) anIO;
TColStd_MapOfInteger newIndices;
newIndices.Add(anId);
aSelector->AddOrRemoveIndex(anIO, newIndices, false);
- aSVTKVW->highlight(anIO, true, true);
+ aViewWindow->highlight(anIO, true, true);
return true;
{
if (myFl) return;
TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
- bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr,
+ bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr,
myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
if (anIsSelected)
{
if (myFl) return;
TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
- bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr,
+ bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr,
myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
if (anIsSelected)
class QTable;
class SalomeApp_SelectionMgr;
class SalomeApp_Application;
+class SalomeApp_Module;
class VisuGUI_SelectionDlg: public QDialog {
Q_OBJECT
public:
- VisuGUI_SelectionDlg (QWidget*);
+ VisuGUI_SelectionDlg (const SalomeApp_Module* theModule);
virtual ~VisuGUI_SelectionDlg ();
protected:
QLabel* myDYLbl;
QLabel* myDZLbl;
+ const SalomeApp_Module* myModule;
SalomeApp_SelectionMgr* mySelectionMgr;
bool myFl;
};
VVTK_InteractorStyle
::OnKeyDown()
{
- if( GetSelector()->SelectionMode() != NodeSelection )
+ if( GetSelector()->SelectionMode() != GaussPointSelection )
return;
char key = Interactor->GetKeyCode();
FindPokedRenderer( x, y ); // calls SetCurrentRenderer
myOtherPoint = myPoint = QPoint(x, y);
- //printf ( "--- myPoint[ %d, %d ], myOtherPoint[ %d, %d ] ---\n",
- //myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y() );
startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
onFinishOperation();
#include "VVTK_InteractorStyle.h"
#include "VISU_ImplicitFunctionWidget.h"
#include "VISU_GaussPtsAct.h"
+#include "VISU_Event.h"
#include "SVTK_RenderWindowInteractor.h"
#include "VVTK_Renderer.h"
VVTK_MainWindow
::OnSelectionModeSwitch(bool theIsSelectionOn)
{
- SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection);
+ SetSelectionMode(theIsSelectionOn? GaussPointSelection: ActorSelection);
}
//----------------------------------------------------------------------------