#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_ShapeLandCoverMap.h"
+#include "HYDROGUI_OCCSelector.h"
#include <HYDROData_Iterator.h>
#include <HYDROData_StricklerTable.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SUIT_ViewWindow.h>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <AIS_Shape.hxx>
#include <QApplication>
+#include <QMouseEvent>
HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId )
: HYDROGUI_Operation( theModule ),
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if ( !aCtx.IsNull() )
{
- connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
+ disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+ disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+
+ connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+
+ LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr();
+ if( aSelectionMgr )
+ {
+ QList<SUIT_Selector*> aSelectorList;
+ aSelectionMgr->selectors( aViewManager->getType(), aSelectorList );
+ QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
+ for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
+ {
+ HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast<HYDROGUI_OCCSelector*>( *anIter );
+ if ( aHydroSelector )
+ {
+ disconnect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ connect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ }
+ }
+ }
+
+ connect( this, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
myPreviewPrs = new HYDROGUI_ShapeLandCoverMap( module()->getOCCDisplayer(), aCtx, myEditedObject, getPreviewZLayer()/*, theIsScalarMapMode*/ );
}
}
}
}
+void HYDROGUI_LandCoverMapOp::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+ myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
+}
+
+void HYDROGUI_LandCoverMapOp::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+ if (theEvent->button() != Qt::LeftButton) return;
+ if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
+
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+ if (!aView )
+ return;
+
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ if ( !aViewManager )
+ return;
+
+ OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer();
+ if ( !aViewer )
+ return;
+
+ Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+ if ( aCtx.IsNull() )
+ return;
+
+ myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
+
+ if (myStartPnt == myEndPnt)
+ {
+ if ( !aViewer->isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ aCtx->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d);
+ }
+ }
+
+ Handle(StdSelect_ViewerSelector3d) aMainSelector = aCtx->MainSelector();
+ if ( aMainSelector.IsNull() )
+ return;
+ const Standard_Integer aDetectedNb = aMainSelector->NbPicked();
+ if ( aDetectedNb == 0 )
+ {
+ aCtx->ClearSelected( false );
+ emit deselection();
+ }
+
+ for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = aMainSelector->Picked (aDetIter);
+ aCtx->AddOrRemoveSelected( anOwner, Standard_False );
+ }
+ }
+ else
+ {
+ aCtx->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
+ myEndPnt.x(), myEndPnt.y(),
+ aView->getViewPort()->getView(), Standard_False );
+ }
+
+ aCtx->UpdateCurrentViewer();
+ emit selectionChanged();
+}
+
void HYDROGUI_LandCoverMapOp::closePreview()
{
if( myPreviewPrs )
if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
aPanel->setApplyEnabled( false );
+
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ if ( aViewManager )
+ {
+ if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
+ {
+ disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+ disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+
+ LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr();
+ if( aSelectionMgr )
+ {
+ QList<SUIT_Selector*> aSelectorList;
+ aSelectionMgr->selectors( aViewManager->getType(), aSelectorList );
+ QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
+ for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
+ {
+ HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast<HYDROGUI_OCCSelector*>( *anIter );
+ if ( aHydroSelector )
+ {
+ disconnect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ connect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ }
+ }
+ }
+ }
+ }
}
Handle(AIS_InteractiveContext) HYDROGUI_LandCoverMapOp::getInteractiveContext()