From 7328bb16f4ebb748b2d0bec615fdfb92797e6719 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 29 Nov 2005 08:59:31 +0000 Subject: [PATCH] Merge with maintanace of the Base version of the D5-38-2003 --- src/LightApp/LightApp_OBSelector.cxx | 21 ++- src/LightApp/LightApp_OBSelector.h | 7 + src/ObjBrowser/OB_Browser.cxx | 13 ++ src/ObjBrowser/OB_Browser.h | 5 + src/SVTK/SALOME_Actor.cxx | 80 ++++---- src/SVTK/SVTK_Actor.cxx | 61 ++++-- src/SVTK/SVTK_Actor.h | 6 +- src/SVTK/SVTK_InteractorStyle.cxx | 228 ++++++++++++++++------- src/SVTK/SVTK_InteractorStyle.h | 99 +++++++++- src/SVTK/SVTK_MainWindow.cxx | 1 + src/SVTK/SVTK_RenderWindowInteractor.cxx | 8 +- src/SVTK/SVTK_RenderWindowInteractor.h | 1 - src/SVTK/SVTK_ViewManager.h | 4 + src/SalomeApp/resources/SalomeApp.xml | 4 +- 14 files changed, 395 insertions(+), 143 deletions(-) diff --git a/src/LightApp/LightApp_OBSelector.cxx b/src/LightApp/LightApp_OBSelector.cxx index 3129b240e..64d184c93 100644 --- a/src/LightApp/LightApp_OBSelector.cxx +++ b/src/LightApp/LightApp_OBSelector.cxx @@ -17,6 +17,8 @@ LightApp_OBSelector::LightApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr if ( myBrowser ) { connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); } + + setModified(); } /*! @@ -63,15 +65,16 @@ void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) if ( !myBrowser ) return; - QMap themap; - fillEntries( themap ); + if( myEntries.count() == 0 || + myModifiedTime < myBrowser->getModifiedTime() ) + fillEntries( myEntries ); DataObjectList objList; for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) { - const LightApp_DataOwner* owner = dynamic_cast( (*it).operator->() ); - if ( owner && themap.contains( owner->entry() ) ) - objList.append( themap[owner->entry()] ); + const LightApp_DataObject* owner = dynamic_cast( (*it).operator->() ); + if ( owner && myEntries.contains( owner->entry() ) ) + objList.append( myEntries[owner->entry()] ); } myBrowser->setSelected( objList ); @@ -98,4 +101,12 @@ void LightApp_OBSelector::fillEntries( QMap& enti if ( obj ) entires.insert( obj->entry(), obj ); } + + setModified(); +} + +/*!Update modified time.*/ +void LightApp_OBSelector::setModified() +{ + myModifiedTime = clock(); } diff --git a/src/LightApp/LightApp_OBSelector.h b/src/LightApp/LightApp_OBSelector.h index 22e4eae50..a48432b1e 100644 --- a/src/LightApp/LightApp_OBSelector.h +++ b/src/LightApp/LightApp_OBSelector.h @@ -21,6 +21,9 @@ public: /*!Return "ObjectBrowser"*/ virtual QString type() const { return "ObjectBrowser"; } + void setModified(); + unsigned long getModifiedTime() { return myModifiedTime; } + private slots: void onSelectionChanged(); @@ -33,6 +36,10 @@ private: private: OB_Browser* myBrowser; + + QMap myEntries; + + unsigned long myModifiedTime; }; #endif diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 4b613ce11..4ec44404d 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -97,6 +97,8 @@ myRootDecorated( true ) this, SLOT( onDoubleClicked( QListViewItem* ) ) ); setRootObject( root ); + + setModified(); } OB_Browser::~OB_Browser() @@ -201,6 +203,8 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot ) autoOpenBranches(); + setModified(); + if ( selNum != numberOfSelected() ) emit selectionChanged(); } @@ -507,6 +511,8 @@ void OB_Browser::updateTree( SUIT_DataObject* obj ) autoOpenBranches(); + setModified(); + if ( selNum != numberOfSelected() ) emit selectionChanged(); } @@ -545,6 +551,8 @@ void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg ) autoOpenBranches(); + setModified(); + if ( selNum != numberOfSelected() ) emit selectionChanged(); } @@ -1101,3 +1109,8 @@ void OB_Browser::onDoubleClicked( QListViewItem* item ) if ( item ) emit doubleClicked( dataObject( item ) ); } + +void OB_Browser::setModified() +{ + myModifiedTime = clock(); +} diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 838896769..419511e1e 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -99,6 +99,9 @@ public: virtual void contextMenuPopup( QPopupMenu* ); + void setModified(); + unsigned long getModifiedTime() { return myModifiedTime; } + signals: void selectionChanged(); void doubleClicked( SUIT_DataObject* ); @@ -165,6 +168,8 @@ private: int myAutoOpenLevel; friend class OB_Browser::ToolTip; + + unsigned long myModifiedTime; }; #endif diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 646344064..c7b744bc5 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -89,7 +89,7 @@ namespace vtkPicker* thePicker, int theObjId) { - int anEdgeId = -1; + int anEdgeId = 0; if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) { float aPickPosition[3]; thePicker->GetPickPosition(aPickPosition); @@ -100,7 +100,7 @@ namespace aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); if (aDist < aMinDist) { aMinDist = aDist; - anEdgeId = i; + anEdgeId = -1 - i; } } } @@ -802,7 +802,8 @@ SALOME_Actor vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // myPreHighlightActor->SetVisibility( false ); - + bool anIsPreselected = myIsPreselected; + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; bool anIsChanged = (mySelectionMode != aSelectionMode); @@ -819,7 +820,6 @@ SALOME_Actor if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) ) anActor->SetPreSelected( false ); - anIsChanged = true; }else{ switch(aSelectionMode){ case NodeSelection: @@ -829,16 +829,19 @@ SALOME_Actor int aVtkId = myPointPicker->GetPointId(); if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) { int anObjId = GetNodeObjId( aVtkId ); - if ( anObjId >= 0 ) { - TColStd_IndexedMapOfInteger aMapIndex; - aMapIndex.Add( anObjId ); - - myPreHighlightActor->GetProperty()->SetRepresentationToPoints(); - myPreHighlightActor->SetVisibility( true ); - myPreHighlightActor->MapPoints( this, aMapIndex ); - - myIsPreselected = theIsHighlight; - anIsChanged = true; + myIsPreselected = (anObjId >= 0); + if(myIsPreselected){ + const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); + int anExtent = aMapIndex.Extent(); + anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1)); + if(anIsChanged){ + TColStd_IndexedMapOfInteger aMapIndex; + aMapIndex.Add( anObjId ); + + myPreHighlightActor->GetProperty()->SetRepresentationToPoints(); + myPreHighlightActor->SetVisibility( true ); + myPreHighlightActor->MapPoints( this, aMapIndex ); + } } } break; @@ -854,16 +857,19 @@ SALOME_Actor if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) { int anObjId = GetElemObjId (aVtkId ); if ( anObjId >= 0 ) { - if ( CheckDimensionId(aSelectionMode,this,anObjId) ) { - TColStd_IndexedMapOfInteger aMapIndex; - aMapIndex.Add( anObjId ); - - myPreHighlightActor->GetProperty()->SetRepresentationToSurface(); - myPreHighlightActor->SetVisibility( true ); - myPreHighlightActor->MapCells( this, aMapIndex ); - - myIsPreselected = theIsHighlight; - anIsChanged = true; + myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId); + if(myIsPreselected){ + const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); + int anExtent = aMapIndex.Extent(); + anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1)); + if(anIsChanged){ + TColStd_IndexedMapOfInteger aMapIndex; + aMapIndex.Add( anObjId ); + + myPreHighlightActor->GetProperty()->SetRepresentationToSurface(); + myPreHighlightActor->SetVisibility( true ); + myPreHighlightActor->MapCells( this, aMapIndex ); + } } } } @@ -878,16 +884,22 @@ SALOME_Actor int anObjId = GetElemObjId( aVtkId ); if ( anObjId >= 0 ) { int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); - TColStd_IndexedMapOfInteger aMapIndex; - aMapIndex.Add( anObjId ); - aMapIndex.Add( anEdgeId ); + myIsPreselected = anEdgeId < 0; + if(myIsPreselected){ + const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); + int anExtent = aMapIndex.Extent(); + anIsChanged |= (anExtent != 2); + anIsChanged |= (anExtent == 0 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2))); + if(anIsChanged){ + TColStd_IndexedMapOfInteger aMapIndex; + aMapIndex.Add( anObjId ); + aMapIndex.Add( anEdgeId ); - myPreHighlightActor->GetProperty()->SetRepresentationToWireframe(); - myPreHighlightActor->SetVisibility( true ); - myPreHighlightActor->MapEdge( this, aMapIndex ); - - myIsPreselected = theIsHighlight; - anIsChanged = true; + myPreHighlightActor->GetProperty()->SetRepresentationToWireframe(); + myPreHighlightActor->SetVisibility( true ); + myPreHighlightActor->MapEdge( this, aMapIndex ); + } + } } } break; @@ -906,7 +918,6 @@ SALOME_Actor anActor->SetPreSelected( true ); } } - anIsChanged = true; } default: break; @@ -914,6 +925,7 @@ SALOME_Actor } mySelectionMode = aSelectionMode; + anIsChanged |= (anIsPreselected != myIsPreselected); return anIsChanged; } diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index 16faf1791..b633626b2 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -42,7 +42,10 @@ static int MYDEBUG = 0; #endif -static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet){ +static +void +CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet) +{ vtkPoints *aPoints = vtkPoints::New(); vtkIdType iEnd = theSourceDataSet->GetNumberOfPoints(); aPoints->SetNumberOfPoints(iEnd); @@ -57,7 +60,8 @@ static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSe vtkStandardNewMacro(SVTK_Actor); -SVTK_Actor::SVTK_Actor() +SVTK_Actor +::SVTK_Actor() { if(MYDEBUG) INFOS("SVTK_Actor - "<SetShrinkFactor(theValue); Modified(); } -void SVTK_Actor::SetShrink() +void +SVTK_Actor +::SetShrink() { if ( !myIsShrinkable ) return; if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() ) @@ -97,7 +106,9 @@ void SVTK_Actor::SetShrink() } } -void SVTK_Actor::UnShrink() +void +SVTK_Actor +::UnShrink() { if ( !myIsShrunk ) return; if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() ) @@ -111,7 +122,8 @@ void SVTK_Actor::UnShrink() //---------------------------------------------------------------------------- -SVTK_Actor::~SVTK_Actor() +SVTK_Actor +::~SVTK_Actor() { if(MYDEBUG) INFOS("~SVTK_Actor()"); @@ -126,8 +138,19 @@ SVTK_Actor::~SVTK_Actor() //---------------------------------------------------------------------------- -void SVTK_Actor::MapCells(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) +const TColStd_IndexedMapOfInteger& +SVTK_Actor +::GetMapIndex() const +{ + return myMapIndex; +} + + +//---------------------------------------------------------------------------- +void +SVTK_Actor +::MapCells(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) { myUnstructuredGrid->Reset(); @@ -139,10 +162,6 @@ void SVTK_Actor::MapCells(SALOME_Actor* theMapActor, int aPartId = theMapIndex( ind ); vtkCell* aCell = theMapActor->GetElemCell(aPartId); myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); - //for (int i = 0, iEnd = aCell->GetNumberOfEdges(); i < iEnd; i++){ - // vtkCell* anEdgeCell = aCell->GetEdge(i); - // myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds()); - //} } UnShrink(); @@ -150,12 +169,16 @@ void SVTK_Actor::MapCells(SALOME_Actor* theMapActor, SetShrinkFactor(theMapActor->GetShrinkFactor()); SetShrink(); } + + myMapIndex = theMapIndex; } //---------------------------------------------------------------------------- -void SVTK_Actor::MapPoints(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) +void +SVTK_Actor +::MapPoints(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) { myUnstructuredGrid->Reset(); if(int aNbOfParts = theMapIndex.Extent()){ @@ -172,12 +195,16 @@ void SVTK_Actor::MapPoints(SALOME_Actor* theMapActor, } UnShrink(); + + myMapIndex = theMapIndex; } //---------------------------------------------------------------------------- -void SVTK_Actor::MapEdge(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) +void +SVTK_Actor +::MapEdge(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) { myUnstructuredGrid->Reset(); @@ -227,6 +254,8 @@ void SVTK_Actor::MapEdge(SALOME_Actor* theMapActor, SetShrinkFactor(theMapActor->GetShrinkFactor()); SetShrink(); } + + myMapIndex = theMapIndex; } //---------------------------------------------------------------------------- diff --git a/src/SVTK/SVTK_Actor.h b/src/SVTK/SVTK_Actor.h index 74a883a1a..d43ca24d6 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -56,10 +56,14 @@ public: void MapEdge(SALOME_Actor* theMapActor, const TColStd_IndexedMapOfInteger& theMapIndex); + const TColStd_IndexedMapOfInteger& + GetMapIndex() const; + protected: + TColStd_IndexedMapOfInteger myMapIndex; + vtkUnstructuredGrid* myUnstructuredGrid; vtkDataSetMapper* myMapper; - vtkRenderer* myRenderer; vtkShrinkFilter* myShrinkFilter; diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index b2e4b60e0..8e1a1a8e7 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -72,10 +72,6 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -static - bool GetFirstSALOMEActor(vtkPicker *pPicker, - SALOME_Actor*& pSA); - namespace { inline @@ -87,15 +83,40 @@ namespace theInteractor->GetEventPosition(theX,theY); theY = theInteractor->GetSize()[1] - theY - 1; } -} + + //================================================================== + // function : GetFirstSALOMEActor + // purpose : + //================================================================== + struct THaveIO + { + bool + operator()(SALOME_Actor* theActor) + { + return theActor->hasIO(); + } + }; + + inline + SALOME_Actor* + GetFirstSALOMEActor(vtkPicker *thePicker) + { + return VTK::Find(thePicker->GetActors(),THaveIO()); + } +} + + //---------------------------------------------------------------------------- vtkStandardNewMacro(SVTK_InteractorStyle); //---------------------------------------------------------------------------- - SVTK_InteractorStyle ::SVTK_InteractorStyle(): mySelectionEvent(new SVTK_SelectionEvent()), - myPicker(vtkPicker::New()) + myPicker(vtkPicker::New()), + myLastHighlitedActor(NULL), + myLastPreHighlitedActor(NULL), + myControllerIncrement(SVTK_ControllerIncrement::New()), + myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()) { myPicker->Delete(); @@ -112,10 +133,12 @@ SVTK_InteractorStyle EventCallbackCommand->SetCallback( SVTK_InteractorStyle::ProcessEvents ); // set default values of properties. user may edit them in preferences. - mySpeedIncrement = 10; mySMDecreaseSpeedBtn = 1; mySMIncreaseSpeedBtn = 2; mySMDominantCombinedSwitchBtn = 9; + // + myControllerIncrement->Delete(); + myControllerOnKeyDown->Delete(); } //---------------------------------------------------------------------------- @@ -895,20 +918,17 @@ SVTK_InteractorStyle 0.0, GetCurrentRenderer()); // - SALOME_Actor* aSActor=NULL; - // - GetFirstSALOMEActor(myPicker.GetPointer(), aSActor); - if (aSActor){ - //if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor())){ - if(aSActor->hasIO()){ - aSelectionEvent->myIsRectangle = false; - aSActor->Highlight( this, aSelectionEvent, true ); - } - } - else{ + SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer()); + aSelectionEvent->myIsRectangle = false; + if(anActor){ + anActor->Highlight( this, aSelectionEvent, true ); + }else{ + if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor) + myLastHighlitedActor->Highlight( this, aSelectionEvent, false ); GetSelector()->ClearIObjects(); } - } + myLastHighlitedActor = anActor; + } else { //processing rectangle selection Interactor->StartPickCallback(); @@ -1021,24 +1041,22 @@ SVTK_InteractorStyle this->FindPokedRenderer(aSelectionEvent->myX,aSelectionEvent->myY); bool anIsChanged = false; - SALOME_Actor *aLastActor=NULL; - // - GetFirstSALOMEActor(myPicker.GetPointer(), aLastActor); - if (aLastActor){ - anIsChanged |= aLastActor->PreHighlight( this, aSelectionEvent, false ); - } + myPicker->Pick(aSelectionEvent->myX, aSelectionEvent->myY, 0.0, GetCurrentRenderer()); - SALOME_Actor *anActor=NULL; - // - GetFirstSALOMEActor(myPicker.GetPointer(), anActor); + SALOME_Actor *anActor = GetFirstSALOMEActor(myPicker.GetPointer()); if (anActor){ anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true ); } - + + if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor) + anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false ); + + myLastPreHighlitedActor = anActor; + if(anIsChanged) this->Render(); } @@ -1207,10 +1225,12 @@ void SVTK_InteractorStyle ::onSpaceMouseButton( int button ) { - if( mySMDecreaseSpeedBtn == button ) - --mySpeedIncrement; - if( mySMIncreaseSpeedBtn == button ) - ++mySpeedIncrement; + if( mySMDecreaseSpeedBtn == button ) { + ControllerIncrement()->Decrease(); + } + if( mySMIncreaseSpeedBtn == button ) { + ControllerIncrement()->Increase(); + } if( mySMDominantCombinedSwitchBtn == button ) DominantCombinedSwitch(); } @@ -1234,6 +1254,7 @@ SVTK_InteractorStyle if ( clientData ) { vtkObject* anObject = reinterpret_cast( clientData ); SVTK_InteractorStyle* self = dynamic_cast( anObject ); + int aSpeedIncrement=self->ControllerIncrement()->Current(); if ( self ) { switch ( event ) { case SVTK::SpaceMouseMoveEvent : @@ -1243,43 +1264,43 @@ SVTK_InteractorStyle self->onSpaceMouseButton( *((int*)callData) ); return; case SVTK::PanLeftEvent: - self->IncrementalPan( -self->mySpeedIncrement, 0 ); + self->IncrementalPan(-aSpeedIncrement, 0); return; case SVTK::PanRightEvent: - self->IncrementalPan( self->mySpeedIncrement, 0 ); + self->IncrementalPan(aSpeedIncrement, 0); return; case SVTK::PanUpEvent: - self->IncrementalPan( 0, self->mySpeedIncrement ); + self->IncrementalPan(0, aSpeedIncrement); return; case SVTK::PanDownEvent: - self->IncrementalPan( 0, -self->mySpeedIncrement ); + self->IncrementalPan(0, -aSpeedIncrement); return; case SVTK::ZoomInEvent: - self->IncrementalZoom( self->mySpeedIncrement ); + self->IncrementalZoom(aSpeedIncrement); return; case SVTK::ZoomOutEvent: - self->IncrementalZoom( -self->mySpeedIncrement ); + self->IncrementalZoom(-aSpeedIncrement); return; case SVTK::RotateLeftEvent: - self->IncrementalRotate( -self->mySpeedIncrement, 0 ); + self->IncrementalRotate(-aSpeedIncrement, 0); return; case SVTK::RotateRightEvent: - self->IncrementalRotate( self->mySpeedIncrement, 0 ); + self->IncrementalRotate(aSpeedIncrement, 0); return; case SVTK::RotateUpEvent: - self->IncrementalRotate( 0, -self->mySpeedIncrement ); + self->IncrementalRotate(0, -aSpeedIncrement); return; case SVTK::RotateDownEvent: - self->IncrementalRotate( 0, self->mySpeedIncrement ); + self->IncrementalRotate(0, aSpeedIncrement); return; case SVTK::PlusSpeedIncrementEvent: - ++(self->mySpeedIncrement); + self->ControllerIncrement()->Increase(); return; case SVTK::MinusSpeedIncrementEvent: - --(self->mySpeedIncrement); + self->ControllerIncrement()->Decrease(); return; case SVTK::SetSpeedIncrementEvent: - self->mySpeedIncrement = *((int*)callData); + self->ControllerIncrement()->SetStartValue(*((int*)callData)); return; case SVTK::SetSMDecreaseSpeedEvent: @@ -1317,31 +1338,94 @@ SVTK_InteractorStyle void SVTK_InteractorStyle::OnChar() { } -//================================================================== -// function : GetFirstSALOMEActor -// purpose : -//================================================================== -bool GetFirstSALOMEActor(vtkPicker *pPicker, - SALOME_Actor*& pSA) +//---------------------------------------------------------------------------- +void SVTK_InteractorStyle::OnKeyDown() { - bool bRet=false; - pSA=NULL; - vtkActor *pA; - // - vtkActorCollection *pActors=pPicker->GetActors(); - // - pActors->InitTraversal(); - while(1) { - pA=pActors->GetNextActor(); - if (!pA) { - break; - } - // - pSA=SALOME_Actor::SafeDownCast(pA); - if (pSA){ - bRet=!bRet; - break; - } + bool bInvokeSuperclass=myControllerOnKeyDown->OnKeyDown(this); + if (bInvokeSuperclass){ + Superclass::OnKeyDown(); + } +} +//---------------------------------------------------------------------------- +void SVTK_InteractorStyle::ActionPicking() +{ + int x, y; + Interactor->GetEventPosition( x, y ); + FindPokedRenderer( x, y ); + + myOtherPoint = myPoint = QPoint(x, y); + + startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); +} +//---------------------------------------------------------------------------- +void SVTK_InteractorStyle::SetControllerOnKeyDown(SVTK_ControllerOnKeyDown* theController) +{ + myControllerOnKeyDown=theController; +} +//---------------------------------------------------------------------------- +SVTK_ControllerOnKeyDown* SVTK_InteractorStyle::ControllerOnKeyDown() +{ + return myControllerOnKeyDown.GetPointer(); +} +//---------------------------------------------------------------------------- +void SVTK_InteractorStyle::SetControllerIncrement(SVTK_ControllerIncrement* theController) +{ + myControllerIncrement=theController; +} +//---------------------------------------------------------------------------- +SVTK_ControllerIncrement* SVTK_InteractorStyle::ControllerIncrement() +{ + return myControllerIncrement.GetPointer(); +} + +vtkStandardNewMacro(SVTK_ControllerIncrement); +//---------------------------------------------------------------------------- +SVTK_ControllerIncrement::SVTK_ControllerIncrement() +{ + myIncrement=10; +} +//---------------------------------------------------------------------------- +SVTK_ControllerIncrement::~SVTK_ControllerIncrement() +{ +} +//---------------------------------------------------------------------------- +void SVTK_ControllerIncrement::SetStartValue(const int theValue) +{ + myIncrement=theValue; +} +//---------------------------------------------------------------------------- +int SVTK_ControllerIncrement::Current()const +{ + return myIncrement; +} +//---------------------------------------------------------------------------- +int SVTK_ControllerIncrement::Increase() +{ + ++myIncrement; + return myIncrement; +} +//---------------------------------------------------------------------------- +int SVTK_ControllerIncrement::Decrease() +{ + if (myIncrement>1){ + --myIncrement; } - return bRet; + return myIncrement; +} + +vtkStandardNewMacro(SVTK_ControllerOnKeyDown); +//---------------------------------------------------------------------------- +SVTK_ControllerOnKeyDown::SVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +SVTK_ControllerOnKeyDown::~SVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +bool SVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS) +{ + return true; } diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 5667a42cb..7ea671df4 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -43,9 +43,69 @@ #include +#include +// +//------------------------------------------- +//! Control the value of increment in SALOME way. +/*! + This class controls of value of increment, + for pan/rotate/zoom operations in SALOME way +*/ +class SVTK_ControllerIncrement : public vtkObject{ + public: + vtkTypeMacro(SVTK_ControllerIncrement, vtkObject); + static SVTK_ControllerIncrement* New(); + + //! Set start value of increment + void SetStartValue(const int ); + + //! Get current value of increment + int Current()const; + + //! Increace the increment value by add 1 + virtual int Increase(); + + //! Decreace the increment value by subtract 1 + virtual int Decrease(); + protected: + SVTK_ControllerIncrement(); + virtual ~SVTK_ControllerIncrement(); + protected: + int myIncrement; + private: + SVTK_ControllerIncrement(const SVTK_ControllerIncrement&);//Not implemented + void operator=(const SVTK_ControllerIncrement&); //Not implemented +}; +// +//------------------------------------------- +//! Control the behaviour of KeyDown event in SALOME way. +/*! + This class controls the behaviour of KeyDown event + in SALOME way +*/ +class SVTK_ControllerOnKeyDown : public vtkObject{ + public: + vtkTypeMacro(SVTK_ControllerOnKeyDown, vtkObject); + static SVTK_ControllerOnKeyDown* New(); + + //! Provides the action on event + virtual bool OnKeyDown(vtkInteractorStyle* ); + + protected: + SVTK_ControllerOnKeyDown(); + virtual ~SVTK_ControllerOnKeyDown(); + + private: + SVTK_ControllerOnKeyDown(const SVTK_ControllerOnKeyDown&);//Not implemented + void operator=(const SVTK_ControllerOnKeyDown&); //Not implemented +}; +//------------------------------------------- + class vtkCell; class vtkPicker; +class SALOME_Actor; + class SVTK_Selector; class SVTK_GenericRenderWindowInteractor; @@ -71,6 +131,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle typedef boost::shared_ptr PSelectionEvent; + + //! Generate special #SVTK_SelectionEvent virtual SVTK_SelectionEvent* @@ -141,16 +203,33 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle void OnChar(); + //! To set current increment controller + void SetControllerIncrement(SVTK_ControllerIncrement*); + + //! To get current increment controller + SVTK_ControllerIncrement* ControllerIncrement(); + + //! Redefine vtkInteractorStyle::OnKeyDown + virtual void OnKeyDown(); + + //! Provide instructions for Picking + void ActionPicking(); + + //! To set current OnKeyDown controller + void SetControllerOnKeyDown(SVTK_ControllerOnKeyDown*); + + //! To get current OnKeyDown controller + SVTK_ControllerOnKeyDown* ControllerOnKeyDown(); + + SVTK_Selector* GetSelector(); + protected: SVTK_InteractorStyle(); ~SVTK_InteractorStyle(); QWidget* GetRenderWidget(); - - SVTK_Selector* - GetSelector(); - + // Generic event bindings must be overridden in subclasses virtual void OnMouseMove (int ctrl, int shift, int x, int y); virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y); @@ -225,9 +304,15 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle bool myShiftState; int ForcedState; - //! "Increment" for pan/rotate/zoom operations - int mySpeedIncrement; - + vtkSmartPointer myLastHighlitedActor; + vtkSmartPointer myLastPreHighlitedActor; + + //! "Increment" controller for pan/rotate/zoom operations + vtkSmartPointer myControllerIncrement; + + //!controls the behaviour of KeyDown event in SALOME way + vtkSmartPointer myControllerOnKeyDown; + // SpaceMouse short cuts int mySMDecreaseSpeedBtn; int mySMIncreaseSpeedBtn; diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index f1b6867d9..c5e260cd7 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -84,6 +84,7 @@ SVTK_MainWindow SetEventDispatcher(myInteractor->GetDevice()); setCentralWidget(myInteractor); + myInteractor->setBackgroundMode(Qt::NoBackground); myInteractor->setFocusPolicy(StrongFocus); myInteractor->setFocus(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 0119104ca..ecf0dda1d 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -74,9 +74,8 @@ static bool GENERATE_SUIT_EVENTS = false; QVTK_RenderWindowInteractor ::QVTK_RenderWindowInteractor(QWidget* theParent, const char* theName): - QWidget(theParent,theName), - myRenderWindow(vtkRenderWindow::New()), - myPreviousFocusWidget(NULL) + QWidget(theParent,theName,Qt::WNoAutoErase), + myRenderWindow(vtkRenderWindow::New()) { if(MYDEBUG) INFOS("QVTK_RenderWindowInteractor() - "<focusWidget() != this) - myPreviousFocusWidget = qApp->focusWidget(); - GetDevice()->EnterEvent(); } diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index 4d7e6ca95..bc0020ddf 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -119,7 +119,6 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget //! To handle native X11 events (from such devices as SpaceMouse) virtual bool x11Event( XEvent *e ); - QWidget* myPreviousFocusWidget; vtkSmartPointer myRenderWindow; vtkSmartPointer myDevice; }; diff --git a/src/SVTK/SVTK_ViewManager.h b/src/SVTK/SVTK_ViewManager.h index e6fa784f9..e003d7a12 100644 --- a/src/SVTK/SVTK_ViewManager.h +++ b/src/SVTK/SVTK_ViewManager.h @@ -6,12 +6,16 @@ class SUIT_Desktop; +//! Extend SUIT_ViewManager to deal with SVTK_Viewer class SVTK_EXPORT SVTK_ViewManager : public SUIT_ViewManager { Q_OBJECT public: + //! Construct the view manager SVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* ); + + //! Destroy the view manager virtual ~SVTK_ViewManager(); protected: diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 364b2fd5e..6b220f42f 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -221,8 +221,10 @@ - + + + -- 2.39.2