From: vsr Date: Tue, 8 Dec 2009 06:45:30 +0000 (+0000) Subject: Merge from V5_1_3_BR 07/12/2009 X-Git-Tag: WSDL_Dev_V1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=579dad73567fab10aef4b1fd0ee496368fdb6063;p=modules%2Fgui.git Merge from V5_1_3_BR 07/12/2009 --- diff --git a/adm_local/unix/config_files/check_qt.m4 b/adm_local/unix/config_files/check_qt.m4 index d98fff260..0f28aef7d 100644 --- a/adm_local/unix/config_files/check_qt.m4 +++ b/adm_local/unix/config_files/check_qt.m4 @@ -51,6 +51,8 @@ fi qt_ok=yes +QTDIR=$(echo $QTDIR | sed 's%[/]\+$%%') + AC_LANG_SAVE AC_LANG_CPLUSPLUS diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index dab5b8143..0e7585504 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -39,6 +39,8 @@ #include #endif +#include + /*! \brief Create new instance of CAM_Application. \return new instance of CAM_Application class @@ -88,6 +90,9 @@ CAM_Application::CAM_Application( const bool autoLoad ) */ CAM_Application::~CAM_Application() { + for ( QList::const_iterator it = myModules.begin(); it != myModules.end(); ++it ) + delete *it; + myModules.clear(); } /*! @@ -437,9 +442,6 @@ void CAM_Application::beforeCloseDoc( SUIT_Study* theDoc ) void CAM_Application::afterCloseDoc() { - for ( QList::const_iterator it = myModules.begin(); it != myModules.end(); ++it ) - delete *it; - myModules.clear(); } /*! diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index b52bdb69f..4fa9bc876 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -153,7 +153,7 @@ void GLViewer_ViewFrame::createActions() */ void GLViewer_ViewFrame::createToolBar() { - int tid = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL") ); + int tid = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false ); toolMgr()->append( DumpId, tid ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index e7ba5ea8f..02f104d7e 100755 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #else @@ -82,23 +81,32 @@ return XServiceImageDevice; #endif // WNT /*! - Maps CasCade view to the window [ static ] + Create native view window for CasCade view [ static ] */ -void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view, - const Standard_Integer hiwin, - const Standard_Integer lowin, - const Xw_WindowQuality quality ) +Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality quality ) { #ifdef WNT - Handle(WNT_Window) w = - new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin ); - // Prevent flicker - w->SetFlags( WDF_NOERASEBKGRND ); + Handle(WNT_Window) viewWindow = new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin ); + // Prevent flickering + viewWindow->SetFlags( WDF_NOERASEBKGRND ); #else - Handle(Xw_Window) w = - new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality ); + Handle(Xw_Window) viewWindow = new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality ); #endif - view->SetWindow( w ); + return viewWindow; +} + +/*! + Maps CasCade view to the window [ static ] +*/ +void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality quality ) +{ + view->SetWindow( OCCViewer_VService::CreateWindow( view, hiwin, lowin, quality ) ); } /*! diff --git a/src/OCCViewer/OCCViewer_VService.h b/src/OCCViewer/OCCViewer_VService.h index 43298b1f3..2e7b392f6 100755 --- a/src/OCCViewer/OCCViewer_VService.h +++ b/src/OCCViewer/OCCViewer_VService.h @@ -58,6 +58,9 @@ #ifndef _Handle_Aspect_WindowDriver_HeaderFile #include #endif +#ifndef _Handle_Aspect_Window_HeaderFile +#include +#endif class V3d_View; class V2d_View; @@ -90,6 +93,12 @@ public: } // STATIC METHODS + static Handle(Aspect_Window) + CreateWindow( const Handle(V3d_View)& view, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality quality ); + static void SetWindow( const Handle( V3d_View )& view, const Standard_Integer hiwin, const Standard_Integer lowin, diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 7fc204ddd..523018d33 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -51,14 +51,14 @@ static int sy = 0; static Standard_Boolean zRotation = Standard_False; /*! - Constructor + Constructor */ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, V3d_TypeOfView type ) -: OCCViewer_ViewPort( parent ), -myScale( 1.0 ), -myDegenerated( true ), -myAnimate( false ), -myBusy( true ) + : OCCViewer_ViewPort( parent ), + myScale( 1.0 ), + myDegenerated( true ), + myAnimate( false ), + myBusy( true ) { selectVisualId(); @@ -75,7 +75,7 @@ myBusy( true ) } /*! - Destructor + Destructor */ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() { @@ -85,41 +85,40 @@ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() } /*! - Activates the desired 'type' of view in the viewer - ( view of 'type' is created if it doesn't exist ). [ public ] + Activates the desired 'type' of view in the viewer + ( view of 'type' is created if it doesn't exist ). [ public ] */ /*void OCCViewer_ViewPort3d::setActive( V3d_TypeOfView type ) { - if ( activeView().IsNull() ) - return; - - if ( activeView()->Type() != type ) - { - if ( type == V3d_ORTHOGRAPHIC ) - setView( myOrthoView ); - if ( type == V3d_PERSPECTIVE ) - setView( myPerspView ); - } + if ( activeView().IsNull() ) + return; + + if ( activeView()->Type() != type ) + { + if ( type == V3d_ORTHOGRAPHIC ) + setView( myOrthoView ); + if ( type == V3d_PERSPECTIVE ) + setView( myPerspView ); + } }*/ /*! - Maps CasCade 'view' to this viewport. [ private ] + Maps CasCade 'view' to this viewport. [ private ] */ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) { if ( !setWindow( view ) ) return false; - if ( !mapped( view ) ) - { - view->SetWindow( myWindow ); - if ( view != activeView() ) - view->View()->Deactivate(); - } + if ( !mapped( view ) ) { + view->SetWindow( myWindow ); + if ( view != activeView() ) + view->View()->Deactivate(); + } /* create static trihedron (16551: EDF PAL 501) */ OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget() ); - if ( aVW ){ + if ( aVW ) { OCCViewer_Viewer* aViewModel = dynamic_cast( aVW->getViewManager()->getViewModel() ); if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){ view->ZBufferTriedronSetup(); @@ -130,7 +129,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) } /*! - Sets new CASCADE view on viewport. Returns the previous active view. [ public ] + Sets new CASCADE view on viewport. Returns the previous active view. [ public ] */ Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view ) { @@ -138,13 +137,14 @@ Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view if ( view == activeView() || !mapView( view ) ) return activeView(); - /* activate the new view*/ + /* activate the new view*/ Handle( V3d_View ) oldView = activeView(); - if ( !oldView.IsNull() ) - { - oldView->View()->Deactivate(); - view->SetBackgroundColor( oldView->BackgroundColor() ); - } + if ( !oldView.IsNull() ) { + if (oldView->View()->IsDefined()) + oldView->View()->Deactivate(); + view->SetBackgroundColor( oldView->BackgroundColor() ); + } + if ( myDegenerated ) view->SetDegenerateModeOn(); else @@ -152,32 +152,32 @@ Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view view->View()->Activate(); activeView() = view; - return oldView; + return oldView; } /*! - Returns CasCade 3D view. [ public ] + Returns CasCade 3D view. [ public ] */ Handle(V3d_View) OCCViewer_ViewPort3d::getView() const { - return activeView(); + return activeView(); } /*! - Returns CasCade 3D viewer [ public ] + Returns CasCade 3D viewer [ public ] */ Handle(V3d_Viewer) OCCViewer_ViewPort3d::getViewer() const { - Handle(V3d_Viewer) viewer; - if ( !activeView().IsNull() ) + Handle(V3d_Viewer) viewer; + if ( !activeView().IsNull() ) viewer = activeView()->Viewer(); - return viewer; + return viewer; } /*! - Syncronizes visual state of this viewport with 'ref' - ( scale, projection, eye etc ) Returns 'true' if copied OK, - 'false' otherwise. [ virtual public ] + Syncronizes visual state of this viewport with 'ref' + ( scale, projection, eye etc ) Returns 'true' if copied OK, + 'false' otherwise. [ virtual public ] */ bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref ) { @@ -186,11 +186,11 @@ bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref ) Handle(V3d_View) tgtView = getView(); /* Syncronize view types */ -/* if ( tgtView->Type() != refView->Type() ) - { - setActive( refView->Type() ); - tgtView = getView(); - }*/ + /* if ( tgtView->Type() != refView->Type() ) + { + setActive( refView->Type() ); + tgtView = getView(); + }*/ /* The following params are copied: - view type( ortho/persp ) @@ -208,7 +208,7 @@ bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref ) /* perspective */ if ( refView->Type() == V3d_PERSPECTIVE ) - tgtView->SetFocale( refView->Focale() ); + tgtView->SetFocale( refView->Focale() ); /* copy params */ Standard_Real x, y, z; @@ -227,7 +227,7 @@ bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref ) } /*! - Returns Z-size of this view. [ public ] + Returns Z-size of this view. [ public ] */ double OCCViewer_ViewPort3d::getZSize() const { @@ -237,46 +237,44 @@ double OCCViewer_ViewPort3d::getZSize() const } /*! - Sets Z-size of this view ( for both orthographic and perspective ). [ public ] + Sets Z-size of this view ( for both orthographic and perspective ). [ public ] */ void OCCViewer_ViewPort3d::setZSize( double zsize ) { myActiveView->SetZSize( zsize ); -/* if ( !myOrthoView.IsNull() ) + /* if ( !myOrthoView.IsNull() ) myOrthoView->SetZSize( zsize ); - if ( !myPerspView.IsNull() ) + if ( !myPerspView.IsNull() ) myPerspView->SetZSize( zsize );*/ } /*! - Returns the background color [ virtual public ] + Returns the background color [ virtual public ] */ QColor OCCViewer_ViewPort3d::backgroundColor() const { - if ( !activeView().IsNull() ) - { - Standard_Real aRed, aGreen, aBlue; - activeView()->BackgroundColor( Quantity_TOC_RGB, aRed, aGreen, aBlue ); - int red = (int) (aRed * 255); - int green = (int) (aGreen * 255); - int blue = (int) (aBlue * 255); - return QColor( red, green, blue ); - } - return OCCViewer_ViewPort::backgroundColor(); + if ( !activeView().IsNull() ) { + Standard_Real aRed, aGreen, aBlue; + activeView()->BackgroundColor( Quantity_TOC_RGB, aRed, aGreen, aBlue ); + int red = (int) (aRed * 255); + int green = (int) (aGreen * 255); + int blue = (int) (aBlue * 255); + return QColor( red, green, blue ); + } + return OCCViewer_ViewPort::backgroundColor(); } /*! - Sets the background color [ virtual public ] + Sets the background color [ virtual public ] */ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color ) { - if ( !activeView().IsNull() ) - { - activeView()->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255., - color.green()/255., color.blue()/255.); - activeView()->Update(); - emit vpChangeBGColor( color ); - } + if ( !activeView().IsNull() ) { + activeView()->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255., + color.green()/255., color.blue()/255.); + activeView()->Update(); + emit vpChangeBGColor( color ); + } } /*! @@ -285,15 +283,14 @@ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color ) */ void OCCViewer_ViewPort3d::setAnimationMode(bool theDegenerated) { - if ( !activeView().IsNull() ) - { + if ( !activeView().IsNull() ) { myAnimate = theDegenerated; activeView()->SetAnimationMode(true, theDegenerated); } } /*! - Updates the active viewport. [ virtual public ] + Updates the active viewport. [ virtual public ] */ void OCCViewer_ViewPort3d::onUpdate() { @@ -302,16 +299,16 @@ void OCCViewer_ViewPort3d::onUpdate() } /*! - Called at 'window fit' transformation. [ virtual protected ] + Called at 'window fit' transformation. [ virtual protected ] */ void OCCViewer_ViewPort3d::fitRect( const QRect& rect ) { - if ( !activeView().IsNull() ) - activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() ); + if ( !activeView().IsNull() ) + activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() ); } /*! - Called at 'zoom' transformation. [ virtual protected ] + Called at 'zoom' transformation. [ virtual protected ] */ void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y ) { @@ -324,74 +321,73 @@ void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y ) } /*! - Centers the viewport. [ virtual protected ] + Centers the viewport. [ virtual protected ] */ void OCCViewer_ViewPort3d::setCenter( int x, int y ) { - if ( !activeView().IsNull() ) - activeView()->Place( x, y, myScale ); + if ( !activeView().IsNull() ) + activeView()->Place( x, y, myScale ); } /*! - Called at 'pan' transformation. [ virtual protected ] + Called at 'pan' transformation. [ virtual protected ] */ void OCCViewer_ViewPort3d::pan( int dx, int dy ) { - if ( !activeView().IsNull() ) - activeView()->Pan( dx, dy, 1.0 ); + if ( !activeView().IsNull() ) + activeView()->Pan( dx, dy, 1.0 ); } /*! - Inits 'rotation' transformation. [ protected ] + Inits 'rotation' transformation. [ protected ] */ void OCCViewer_ViewPort3d::startRotation( int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint ) { - if ( !activeView().IsNull() ) - { - myDegenerated = activeView()->DegenerateModeIsOn(); - activeView()->SetDegenerateModeOn(); - if (myAnimate) activeView()->SetAnimationModeOn(); - - //double gx, gy, gz; - //double gx = activeView()->gx; - //activeView()->Gravity(gx,gy,gz); - - switch ( theRotationPointType ) { - case OCCViewer_ViewWindow::GRAVITY: - activeView()->StartRotation( x, y, 0.45 ); - break; - case OCCViewer_ViewWindow::SELECTED: - sx = x; sy = y; - - double X,Y; - activeView()->Size(X,Y); - rx = Standard_Real(activeView()->Convert(X)); - ry = Standard_Real(activeView()->Convert(Y)); - - activeView()->Rotate( 0., 0., 0., - theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(), - Standard_True ); - - Quantity_Ratio zRotationThreshold; - zRotation = Standard_False; - zRotationThreshold = 0.45; - if( zRotationThreshold > 0. ) { - Standard_Real dx = Abs(sx - rx/2.); - Standard_Real dy = Abs(sy - ry/2.); - Standard_Real dd = zRotationThreshold * (rx + ry)/2.; - if( dx > dd || dy > dd ) zRotation = Standard_True; - } - break; - default: - break; + if ( !activeView().IsNull() ) { + myDegenerated = activeView()->DegenerateModeIsOn(); + activeView()->SetDegenerateModeOn(); + if (myAnimate) activeView()->SetAnimationModeOn(); + + //double gx, gy, gz; + //double gx = activeView()->gx; + //activeView()->Gravity(gx,gy,gz); + + switch ( theRotationPointType ) { + case OCCViewer_ViewWindow::GRAVITY: + activeView()->StartRotation( x, y, 0.45 ); + break; + case OCCViewer_ViewWindow::SELECTED: + sx = x; sy = y; + + double X,Y; + activeView()->Size(X,Y); + rx = Standard_Real(activeView()->Convert(X)); + ry = Standard_Real(activeView()->Convert(Y)); + + activeView()->Rotate( 0., 0., 0., + theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(), + Standard_True ); + + Quantity_Ratio zRotationThreshold; + zRotation = Standard_False; + zRotationThreshold = 0.45; + if( zRotationThreshold > 0. ) { + Standard_Real dx = Abs(sx - rx/2.); + Standard_Real dy = Abs(sy - ry/2.); + Standard_Real dd = zRotationThreshold * (rx + ry)/2.; + if( dx > dd || dy > dd ) zRotation = Standard_True; } + break; + default: + break; } + } } /*! - Rotates the viewport. [ protected ] + Rotates the viewport. [ protected ] */ void OCCViewer_ViewPort3d::rotate( int x, int y, int theRotationPointType, @@ -427,66 +423,63 @@ void OCCViewer_ViewPort3d::rotate( int x, int y, } /*! - Resets the viewport after 'rotation'. [ protected ] + Resets the viewport after 'rotation'. [ protected ] */ void OCCViewer_ViewPort3d::endRotation() { - if ( !activeView().IsNull() ) - { - if (myAnimate) activeView()->SetAnimationModeOff(); - if ( !myDegenerated ) - activeView()->SetDegenerateModeOff(); - activeView()->ZFitAll(1.); - activeView()->SetZSize(0.); - activeView()->Update(); - } + if ( !activeView().IsNull() ) { + if (myAnimate) activeView()->SetAnimationModeOff(); + if ( !myDegenerated ) + activeView()->SetDegenerateModeOff(); + activeView()->ZFitAll(1.); + activeView()->SetZSize(0.); + activeView()->Update(); + } } /*! - Repaints the viewport. [ virtual protected ] + Repaints the viewport. [ virtual protected ] */ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e ) { #ifndef WNT - /* X11 : map before show doesn't work */ - if ( !mapped( activeView() ) ) - mapView( activeView() ); + /* X11 : map before show doesn't work */ + if ( !mapped( activeView() ) ) + mapView( activeView() ); #endif - if ( !myWindow.IsNull() ) - { - QApplication::syncX(); - QRect rc = e->rect(); - if ( !myPaintersRedrawing ) - activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() ); - } - OCCViewer_ViewPort::paintEvent( e ); - myBusy = false; + if ( !myWindow.IsNull() ) { + QApplication::syncX(); + QRect rc = e->rect(); + if ( !myPaintersRedrawing ) + activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() ); + } + OCCViewer_ViewPort::paintEvent( e ); + myBusy = false; } /*! - Resizes the viewport. [ virtual protected ] + Resizes the viewport. [ virtual protected ] */ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) { #ifdef WNT - /* Win32 : map before first show to avoid flicker */ - if ( !mapped( activeView() ) ) - mapView( activeView() ); + /* Win32 : map before first show to avoid flicker */ + if ( !mapped( activeView() ) ) + mapView( activeView() ); #endif - QApplication::syncX(); - if ( !activeView().IsNull() ) - activeView()->MustBeResized(); + QApplication::syncX(); + if ( !activeView().IsNull() ) + activeView()->MustBeResized(); } /*! - Fits all objects in view. [ virtual protected ] + Fits all objects in view. [ virtual protected ] */ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd ) { if ( activeView().IsNull() ) return; - if ( keepScale ) myScale = activeView()->Scale(); @@ -496,59 +489,68 @@ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd ) } /*! - Resets the view. [ virtual protected ] + Resets the view. [ virtual protected ] */ void OCCViewer_ViewPort3d::reset() { -// double zsize = getZSize(); - if ( !activeView().IsNull() ) - activeView()->Reset(); -// setZSize( zsize ); + // double zsize = getZSize(); + if ( !activeView().IsNull() ) + activeView()->Reset(); + // setZSize( zsize ); } /*! - Passed the handle of native window of the component to CASCADE view. [ private ] + Passed the handle of native window of the component to CASCADE view. [ private ] */ bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view ) { - if ( !myWindow.IsNull() ) - return true; - - if ( view.IsNull() ) - return false; - - int hwnd = (int)winId(); - if ( !hwnd ) - return false; - - /* set this widget as the drawing window */ - short lo = (short)hwnd; - short hi = (short)( hwnd >> 16 ); - OCCViewer_VService::SetWindow( view, (int)hi, (int)lo, Xw_WQ_SAMEQUALITY ); - myWindow = view->Window(); - return !myWindow.IsNull(); + if ( !myWindow.IsNull() ) + return true; + + if ( view.IsNull() ) + return false; + + int hwnd = (int)winId(); + if ( !hwnd ) + return false; + + /* set this widget as the drawing window */ + short lo = (short)hwnd; + short hi = (short)( hwnd >> 16 ); + + attachWindow( view, OCCViewer_VService::CreateWindow( view, (int)hi, (int)lo, Xw_WQ_SAMEQUALITY ) ); + + myWindow = view->Window(); + return !myWindow.IsNull(); +} + +void OCCViewer_ViewPort3d::attachWindow( const Handle(V3d_View)& view, + const Handle(Aspect_Window)& window) +{ + if (!view.IsNull()) + view->SetWindow( window ); } /*! - Returns the current active view. [ private ] + Returns the current active view. [ private ] */ Handle(V3d_View) OCCViewer_ViewPort3d::activeView() const { - return myActiveView; + return myActiveView; } /*! - Returns the current inactive view [ private ] + Returns the current inactive view [ private ] */ /*Handle(V3d_View) OCCViewer_ViewPort3d::inactiveView() const -{ - return ( activeView() == myOrthoView ? myPerspView : myOrthoView ); -}*/ + { + return ( activeView() == myOrthoView ? myPerspView : myOrthoView ); + }*/ /*! - Returns 'true' if the given view is mapped to window. [ private ] + Returns 'true' if the given view is mapped to window. [ private ] */ bool OCCViewer_ViewPort3d::mapped( const Handle(V3d_View)& view ) const { - return ( !view.IsNull() && view->View()->IsDefined() ); + return ( !view.IsNull() && view->View()->IsDefined() ); } diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index efa011d4b..41d2c6744 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -81,6 +81,9 @@ protected: virtual void paintEvent( QPaintEvent* ); virtual void resizeEvent( QResizeEvent* ); + // initialization + virtual void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& ); + private: Handle(V3d_View) activeView() const; Handle(V3d_View) inactiveView() const; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index f7e311ff2..ea102e914 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -75,6 +75,8 @@ static QEvent* l_mbPressEvent = 0; # include #endif +#include + const char* imageZoomCursor[] = { "32 32 3 1", ". c None", @@ -1102,7 +1104,7 @@ void OCCViewer_ViewWindow::createActions() */ void OCCViewer_ViewWindow::createToolBar() { - int tid = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + int tid = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false ); toolMgr()->append( DumpId, tid ); if( myModel->trihedronActivated() ) @@ -1164,6 +1166,7 @@ void OCCViewer_ViewWindow::onFrontView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos); onViewFitAll(); + emit vpTransformationFinished ( FRONTVIEW ); } /*! @@ -1175,6 +1178,7 @@ void OCCViewer_ViewWindow::onBackView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg); onViewFitAll(); + emit vpTransformationFinished ( BACKVIEW ); } /*! @@ -1186,6 +1190,7 @@ void OCCViewer_ViewWindow::onTopView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos); onViewFitAll(); + emit vpTransformationFinished ( TOPVIEW ); } /*! @@ -1197,6 +1202,7 @@ void OCCViewer_ViewWindow::onBottomView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg); onViewFitAll(); + emit vpTransformationFinished ( BOTTOMVIEW ); } /*! @@ -1208,6 +1214,7 @@ void OCCViewer_ViewWindow::onLeftView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg); onViewFitAll(); + emit vpTransformationFinished ( LEFTVIEW ); } /*! @@ -1219,6 +1226,7 @@ void OCCViewer_ViewWindow::onRightView() Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos); onViewFitAll(); + emit vpTransformationFinished ( RIGHTVIEW ); } /*! @@ -1234,6 +1242,7 @@ void OCCViewer_ViewWindow::onResetView() myViewPort->fitAll( false, true, false ); myViewPort->getView()->SetImmediateUpdate( upd ); myViewPort->getView()->Update(); + emit vpTransformationFinished( RESETVIEW ); } /*! @@ -1243,6 +1252,7 @@ void OCCViewer_ViewWindow::onFitAll() { emit vpTransformationStarted( FITALLVIEW ); myViewPort->fitAll(); + emit vpTransformationFinished( FITALLVIEW ); } /*! @@ -1419,8 +1429,25 @@ void OCCViewer_ViewWindow::onTrihedronShow() */ QImage OCCViewer_ViewWindow::dumpView() { - QPixmap px = QPixmap::grabWindow( myViewPort->winId() ); - return px.toImage(); + Handle(V3d_View) view = myViewPort->getView(); + if ( view.IsNull() ) + return QImage(); + QApplication::syncX(); + view->Update(); + view->Redraw(); + + unsigned char* data = new unsigned char[ (myViewPort->width()*myViewPort->height())*4 ]; + + QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft()); + + glReadPixels( p.x(), p.y(), myViewPort->width(), myViewPort->height(), GL_RGBA, GL_UNSIGNED_BYTE, + data); + + QImage anImage( data, myViewPort->width(), myViewPort->height(), QImage::Format_ARGB32 ); + anImage = anImage.mirrored(); + anImage = anImage.rgbSwapped(); + return anImage; + } bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, @@ -1433,9 +1460,9 @@ bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, Handle(Visual3d_View) a3dView = myViewPort->getView()->View(); if (format == "PS") - a3dView->Export(qPrintable(fileName), Graphic3d_EF_PostScript); + a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript); else if (format == "EPS") - a3dView->Export(qPrintable(fileName), Graphic3d_EF_EnhPostScript); + a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript); return true; } diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 6fcdd2642..4f3dda2ca 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -386,7 +386,7 @@ void Plot2d_ViewWindow::createActions() void Plot2d_ViewWindow::createToolBar() { QtxActionToolMgr* mgr = toolMgr(); - myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false ); mgr->append( DumpId, myToolBar ); mgr->append( ScaleOpId, myToolBar ); mgr->append( MoveOpId, myToolBar ); diff --git a/src/PyInterp/PyInterp_Interp.cxx b/src/PyInterp/PyInterp_Interp.cxx index 0dfe60dc3..fecaeb387 100644 --- a/src/PyInterp/PyInterp_Interp.cxx +++ b/src/PyInterp/PyInterp_Interp.cxx @@ -142,9 +142,16 @@ PyStdOut_write(PyStdOut *self, PyObject *args) return Py_None; } +static PyObject* +PyStdOut_flush(PyStdOut *self) +{ + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef PyStdOut_methods[] = { - {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, - PyDoc_STR("write(string) -> None")}, + {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, PyDoc_STR("write(string) -> None")}, + {"flush", (PyCFunction)PyStdOut_flush, METH_NOARGS, PyDoc_STR("flush() -> None")}, {NULL, NULL} /* sentinel */ }; diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 774538fe0..f0b532fa2 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -814,7 +814,7 @@ void Qtx::scaleColors( const int num, QColorList& lst ) /*! \brief Scale the pixmap to the required size. - If \h is 0 (default) the value of \a w is used instead (to create + If \a h is 0 (default) the value of \a w is used instead (to create square pixmap). \param icon pixmap to be resized @@ -1058,7 +1058,7 @@ QString Qtx::colorToString( const QColor& color ) - "RR,GG,BB[,AA]" or "RR GG BB[ AA]" (\c RR, \c GG, \c BB and optional \c AA values represent red, green, blue and alpha components of the color in decimal form) - - #RRGGBB" - (\c RR, \c GG and \c BB values represent red, green and blue + - "#RRGGBB" - (\c RR, \c GG and \c BB values represent red, green and blue components of the color in hexadecimal form) - an integer value representing packed color components (see rgbSet()) - a name from the list of colors defined in the list of SVG color keyword names diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index 8f3b8804e..45a28aa04 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -99,6 +99,12 @@ QMainWindow* QtxActionToolMgr::mainWindow() const \return id of created/found toolbar */ int QtxActionToolMgr::createToolBar( const QString& title, const int tid, QMainWindow* mw ) +{ + return createToolBar( title, true, Qt::AllToolBarAreas, tid, mw ); +} + +int QtxActionToolMgr::createToolBar( const QString& title, bool floatable, Qt::ToolBarAreas dockAreas, + int tid, QMainWindow* mw ) { static int _toolBarId = -1; @@ -124,6 +130,9 @@ int QtxActionToolMgr::createToolBar( const QString& title, const int tid, QMainW if ( !tb ) { tb = new QtxToolBar( true, tbw ); + tb->setFloatable( floatable ); + tb->setAllowedAreas( dockAreas ); + tb->setMovable( dockAreas & Qt::AllToolBarAreas ); //mainWindow()->addToolBar( tb ); tb->setWindowTitle( title ); tb->setObjectName( title ); diff --git a/src/Qtx/QtxActionToolMgr.h b/src/Qtx/QtxActionToolMgr.h index dd6b19cf4..5f81e6e21 100644 --- a/src/Qtx/QtxActionToolMgr.h +++ b/src/Qtx/QtxActionToolMgr.h @@ -65,6 +65,8 @@ public: QMainWindow* mainWindow() const; int createToolBar( const QString&, int = -1, QMainWindow* = 0 ); + int createToolBar( const QString&, bool, Qt::ToolBarAreas = Qt::AllToolBarAreas, + int = -1, QMainWindow* = 0 ); void removeToolBar( const QString& ); void removeToolBar( const int ); diff --git a/src/Qtx/QtxDockWidget.cxx b/src/Qtx/QtxDockWidget.cxx index fcb52318d..a14b2fd40 100644 --- a/src/Qtx/QtxDockWidget.cxx +++ b/src/Qtx/QtxDockWidget.cxx @@ -377,7 +377,7 @@ QSize QtxDockWidget::sizeHint() const { QSize sz = QDockWidget::sizeHint(); - printf( "----------------> QtxDockWidget::sizeHint()\n" ); + // printf( "----------------> QtxDockWidget::sizeHint()\n" ); return QSize( 500, 100 ); diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 4d333f884..35c84807d 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -45,6 +45,8 @@ #include #include +#include + /*! \class QtxPagePrefMgr \brief GUI implementation of the QtxPreferenceMgr class: preferences manager. @@ -2296,7 +2298,7 @@ void QtxPagePrefSelectItem::setInputType( const int type ) /*! \brief Get the list of the values from the selection widget. \return list of values - \sa numbers(), setStrings() + \sa numbers(), icons(), setStrings() */ QStringList QtxPagePrefSelectItem::strings() const { @@ -2309,7 +2311,7 @@ QStringList QtxPagePrefSelectItem::strings() const /*! \brief Get the list of the values identifiers from the selection widget. \return list of values IDs - \sa strings(), setNumbers() + \sa strings(), icons(), setNumbers() */ QList QtxPagePrefSelectItem::numbers() const { @@ -2322,10 +2324,23 @@ QList QtxPagePrefSelectItem::numbers() const return res; } +/*! + \brief Get the list of the icons associated with the selection widget.items + \return list of icons + \sa strings(), numbers(), setIcons() +*/ +QList QtxPagePrefSelectItem::icons() const +{ + QList res; + for ( uint i = 0; i < mySelector->count(); i++ ) + res.append( mySelector->itemIcon( i ) ); + return res; +} + /*! \brief Set the list of the values to the selection widget. \param lst new list of values - \sa strings(), setNumbers() + \sa strings(), setNumbers(), setIcons() */ void QtxPagePrefSelectItem::setStrings( const QStringList& lst ) { @@ -2334,15 +2349,34 @@ void QtxPagePrefSelectItem::setStrings( const QStringList& lst ) } /*! - \brief Set the list of the values identifiers to the selection widget. + \brief Set the list of the values identifiers to the selection widget \param ids new list of values IDs - \sa numbers(), setStrings() + \sa numbers(), setStrings(), setIcons() */ void QtxPagePrefSelectItem::setNumbers( const QList& ids ) { uint i = 0; - for ( QList::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ ) + for ( QList::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) { + if ( i >= mySelector->count() ) + mySelector->addItem(QString("") ); + mySelector->setId( i, *it ); + } +} + +/*! + \brief Set the list of the icons to the selection widget items + + Important: call this method after setStrings() or setNumbers() + + \param icns new list of icons + \sa icons(), setStrings(), setNumbers() +*/ +void QtxPagePrefSelectItem::setIcons( const QList& icns ) +{ + uint i = 0; + for ( QList::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ ) + mySelector->setItemIcon( i, *it ); } /*! @@ -2422,6 +2456,14 @@ QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const lst.append( *it ); return lst; } + else if ( name == "icons" || name == "pixmaps" ) + { + QList lst; + QList ics = icons(); + for ( QList::const_iterator it = ics.begin(); it != ics.end(); ++it ) + lst.append( *it ); + return lst; + } else return QtxPageNamedPrefItem::optionValue( name ); } @@ -2443,6 +2485,8 @@ void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& setStrings( val ); else if ( name == "numbers" || name == "ids" || name == "indexes" ) setNumbers( val ); + else if ( name == "icons" || name == "pixmaps" ) + setIcons( val ); else QtxPageNamedPrefItem::setOptionValue( name, val ); } @@ -2480,6 +2524,30 @@ void QtxPagePrefSelectItem::setNumbers( const QVariant& var ) setNumbers( lst ); } +/*! + \brief Set the list of the icons from the resource manager. + \param var new icons list + \internal +*/ +void QtxPagePrefSelectItem::setIcons( const QVariant& var ) +{ + if ( var.type() != QVariant::List ) + return; + + QList lst; + QList varList = var.toList(); + for ( QList::const_iterator it = varList.begin(); it != varList.end(); ++it ) + { + if ( (*it).canConvert() ) + lst.append( (*it).value() ); + else if ( (*it).canConvert() ) + lst.append( (*it).value() ); + else + lst.append( QIcon() ); + } + setIcons( lst ); +} + /*! \brief Update selector widget. */ diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 28fada6dc..f853ba6ac 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -33,6 +33,7 @@ #include #include #include +#include class QtxGridBox; class QtxFontEdit; @@ -434,9 +435,11 @@ public: QStringList strings() const; QList numbers() const; + QList icons() const; void setStrings( const QStringList& ); void setNumbers( const QList& ); + void setIcons( const QList& ); virtual void store(); virtual void retrieve(); @@ -449,6 +452,7 @@ private: void updateSelector(); void setStrings( const QVariant& ); void setNumbers( const QVariant& ); + void setIcons( const QVariant& ); private: int myType; diff --git a/src/Qtx/QtxSplash.cxx b/src/Qtx/QtxSplash.cxx index e32a29aae..f3610af52 100644 --- a/src/Qtx/QtxSplash.cxx +++ b/src/Qtx/QtxSplash.cxx @@ -24,6 +24,7 @@ // #include "QtxSplash.h" #include "QtxResourceMgr.h" +#include #include #include diff --git a/src/QxScene/QxScene_ViewWindow.cxx b/src/QxScene/QxScene_ViewWindow.cxx index 0e1435cd8..28d7d71d4 100644 --- a/src/QxScene/QxScene_ViewWindow.cxx +++ b/src/QxScene/QxScene_ViewWindow.cxx @@ -161,7 +161,7 @@ void QxScene_ViewWindow::createToolBar() { DEBTRACE("QxScene_ViewWindow::createToolBar"); QtxActionToolMgr* mgr = toolMgr(); - myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false ); mgr->append( ScaleOpId, myToolBar ); mgr->append( MoveOpId, myToolBar ); mgr->append( ResetId, myToolBar ); diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index 42e24296b..80da8eb31 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -157,8 +157,8 @@ void SALOME_PYQT_Module::getEngineIOR() if ( !myInterp || !myModule ) return; - if ( PyObject_HasAttrString( myModule->get() , "engineIOR" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"engineIOR", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule , "engineIOR" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"engineIOR", (char*)"" ) ); if ( !res ) { PyErr_Print(); } diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx index 735f705f4..8c278a4bc 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx @@ -63,7 +63,6 @@ #include #include - #include "sipAPISalomePyQtGUILight.h" #include @@ -283,9 +282,9 @@ SALOME_PYQT_ModuleLight::~SALOME_PYQT_ModuleLight() { if ( myXmlHandler ) delete myXmlHandler; - if ( myInterp ) { + if ( myInterp && myModule ) { PyLockWrapper aLock = myInterp->GetLockWrapper(); - delete myModule; + Py_XDECREF(myModule); } } @@ -866,8 +865,8 @@ void SALOME_PYQT_ModuleLight::init( CAM_Application* app ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // ... (the Python module is already imported) // ... finally call Python module's initialize() method - if ( PyObject_HasAttrString( myModule->get(), "initialize" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"initialize", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule, "initialize" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"initialize", (char*)"" ) ); if ( !res ) { PyErr_Print(); } @@ -880,8 +879,8 @@ void SALOME_PYQT_ModuleLight::init( CAM_Application* app ) myWindowsMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); myWindowsMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea ); - if ( PyObject_HasAttrString( myModule->get() , "windows" ) ) { - PyObjWrapper res1( PyObject_CallMethod( myModule->get(), (char*)"windows", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule , "windows" ) ) { + PyObjWrapper res1( PyObject_CallMethod( myModule, (char*)"windows", (char*)"" ) ); if ( !res1 ) { PyErr_Print(); } @@ -907,8 +906,8 @@ void SALOME_PYQT_ModuleLight::init( CAM_Application* app ) // get compatible view windows types from the Python module // by calling views() method - if ( PyObject_HasAttrString( myModule->get() , "views" ) ) { - PyObjWrapper res2( PyObject_CallMethod( myModule->get(), (char*)"views", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule , "views" ) ) { + PyObjWrapper res2( PyObject_CallMethod( myModule, (char*)"views", (char*)"" ) ); if ( !res2 ) { PyErr_Print(); } @@ -954,20 +953,24 @@ void SALOME_PYQT_ModuleLight::activate( SUIT_Study* theStudy ) // initialize Python subinterpreter (on per study) and put it in variable initInterp( aStudyId ); - if ( !myInterp ) + if ( !myInterp ) { + myLastActivateStatus = false; return; // Error + } // import Python GUI module importModule(); - if ( !myModule ) + if ( !myModule ) { + myLastActivateStatus = false; return; // Error + } // get python lock PyLockWrapper aLock = myInterp->GetLockWrapper(); // call Python module's activate() method (for the new modules) - if ( PyObject_HasAttrString( myModule->get() , "activate" ) ) { - PyObject* res1 = PyObject_CallMethod( myModule->get(), (char*)"activate", (char*)"" ); + if ( PyObject_HasAttrString( myModule , "activate" ) ) { + PyObject* res1 = PyObject_CallMethod( myModule, (char*)"activate", (char*)"" ); if ( !res1 || !PyBool_Check( res1 ) ) { PyErr_Print(); // always true for old modules (no return value) @@ -1039,8 +1042,8 @@ void SALOME_PYQT_ModuleLight::customize( SUIT_Study* theStudy ) if ( IsCallOldMethods ) { // call Python module's setSettings() method (obsolete) - if ( PyObject_HasAttrString( myModule->get() , "setSettings" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"setSettings", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule , "setSettings" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"setSettings", (char*)"" ) ); if( !res ) { PyErr_Print(); } @@ -1066,8 +1069,8 @@ void SALOME_PYQT_ModuleLight::deactivate( SUIT_Study* theStudy ) return; } // then call Python module's deactivate() method - if ( PyObject_HasAttrString( myModule->get() , "deactivate" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"deactivate", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule , "deactivate" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"deactivate", (char*)"" ) ); if( !res ) { PyErr_Print(); } @@ -1120,8 +1123,8 @@ void SALOME_PYQT_ModuleLight::studyChanged( SUIT_Study* theStudy ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // call Python module's activeStudyChanged() method - if ( PyObject_HasAttrString( myModule->get(), "activeStudyChanged" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"activeStudyChanged", (char*)"i", aStudyId ) ); + if ( PyObject_HasAttrString( myModule, "activeStudyChanged" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"activeStudyChanged", (char*)"i", aStudyId ) ); if( !res ) { PyErr_Print(); } @@ -1154,10 +1157,10 @@ void SALOME_PYQT_ModuleLight::contextMenu( const QString& theContext, QMenu* the QString aContext( "" ), aObject( "" ), aParent( theContext ); - if ( IsCallOldMethods && PyObject_HasAttrString( myModule->get(), "definePopup" ) ) { + if ( IsCallOldMethods && PyObject_HasAttrString( myModule, "definePopup" ) ) { // call definePopup() Python module's function // this is obsolete function, used only for compatibility reasons - PyObjWrapper res( PyObject_CallMethod( myModule->get(), + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"definePopup", (char*)"sss", theContext.toLatin1().constData(), @@ -1182,11 +1185,15 @@ void SALOME_PYQT_ModuleLight::contextMenu( const QString& theContext, QMenu* the if ( myXmlHandler ) myXmlHandler->createPopup( thePopupMenu, aContext, aParent, aObject ); - PyObjWrapper sipPopup( sipBuildResult( 0, "M", thePopupMenu, sipClass_QMenu ) ); +#if SIP_VERSION < 0x040800 + PyObjWrapper sipPopup( sipBuildResult( 0, "M", thePopupMenu, sipClass_QMenu) ); +#else + PyObjWrapper sipPopup( sipBuildResult( 0, "D", thePopupMenu, sipType_QMenu, NULL) ); +#endif // then call Python module's createPopupMenu() method (for new modules) - if ( PyObject_HasAttrString( myModule->get(), "createPopupMenu" ) ) { - PyObjWrapper res1( PyObject_CallMethod( myModule->get(), + if ( PyObject_HasAttrString( myModule, "createPopupMenu" ) ) { + PyObjWrapper res1( PyObject_CallMethod( myModule, (char*)"createPopupMenu", (char*)"Os", sipPopup.get(), @@ -1196,10 +1203,10 @@ void SALOME_PYQT_ModuleLight::contextMenu( const QString& theContext, QMenu* the } } - if ( IsCallOldMethods && PyObject_HasAttrString( myModule->get(), "customPopup" ) ) { + if ( IsCallOldMethods && PyObject_HasAttrString( myModule, "customPopup" ) ) { // call customPopup() Python module's function // this is obsolete function, used only for compatibility reasons - PyObjWrapper res2( PyObject_CallMethod( myModule->get(), + PyObjWrapper res2( PyObject_CallMethod( myModule, (char*)"customPopup", (char*)"Osss", sipPopup.get(), @@ -1229,8 +1236,8 @@ void SALOME_PYQT_ModuleLight::guiEvent( const int theId ) if ( !myInterp || !myModule ) return; - if ( PyObject_HasAttrString( myModule->get(), "OnGUIEvent" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"OnGUIEvent", (char*)"i", theId ) ); + if ( PyObject_HasAttrString( myModule, "OnGUIEvent" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"OnGUIEvent", (char*)"i", theId ) ); if( !res ) { PyErr_Print(); } @@ -1256,8 +1263,8 @@ void SALOME_PYQT_ModuleLight::initPreferences() // might be called during the module intialization process myInitModule = this; - if ( PyObject_HasAttrString( myModule->get(), "createPreferences" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"createPreferences", (char*)"" ) ); + if ( PyObject_HasAttrString( myModule, "createPreferences" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"createPreferences", (char*)"" ) ); if( !res ) { PyErr_Print(); } @@ -1339,7 +1346,11 @@ void SALOME_PYQT_ModuleLight::importModule() PyLockWrapper aLock = myInterp->GetLockWrapper(); // ... then import a module QString aMod = name() + "GUI"; - myModule = new PyObjWrapper( PyImport_ImportModule( aMod.toLatin1().data() ) ); + try { + myModule = PyImport_ImportModule( aMod.toLatin1().data() ); + } + catch (...) { + } if( !myModule ) { // Error! PyErr_Print(); @@ -1390,10 +1401,14 @@ void SALOME_PYQT_ModuleLight::setWorkSpace() if ( aDesktop ) aWorkspace = aDesktop->workstack(); } - PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget ) ); +#if SIP_VERSION < 0x040800 + PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget) ); +#else + PyObjWrapper pyws( sipBuildResult( 0, "D", aWorkspace, sipType_QWidget , NULL) ); +#endif // ... and finally call Python module's setWorkspace() method (obsolete) - if ( PyObject_HasAttrString( myModule->get(), "setWorkSpace" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"setWorkSpace", (char*)"O", pyws.get() ) ); + if ( PyObject_HasAttrString( myModule, "setWorkSpace" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"setWorkSpace", (char*)"O", pyws.get() ) ); if( !res ) { PyErr_Print(); } @@ -1419,8 +1434,8 @@ void SALOME_PYQT_ModuleLight::prefChanged( const QString& section, const QString if ( !myInterp || !myModule ) return; - if ( PyObject_HasAttrString( myModule->get(), "preferenceChanged" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), + if ( PyObject_HasAttrString( myModule, "preferenceChanged" ) ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"preferenceChanged", (char*)"ss", section.toLatin1().constData(), @@ -1817,12 +1832,12 @@ void SALOME_PYQT_ModuleLight::activeViewChanged( const SUIT_ViewWindow* pview ) connectView( pview ); - if ( PyObject_HasAttrString( myModule->get(), "activeViewChanged" ) ) + if ( PyObject_HasAttrString( myModule, "activeViewChanged" ) ) { if ( !pview ) return; - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"activeViewChanged", (char*)"i" , pview->getId() ) ); + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"activeViewChanged", (char*)"i" , pview->getId() ) ); if( !res ) PyErr_Print(); } @@ -1864,9 +1879,9 @@ void SALOME_PYQT_ModuleLight::viewCloned( const SUIT_ViewWindow* pview ) if ( !myInterp || !myModule || !pview ) return; - if ( PyObject_HasAttrString( myModule->get(), "viewCloned" ) ) + if ( PyObject_HasAttrString( myModule, "viewCloned" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"viewCloned", (char*)"i", pview->getId() ) ); + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"viewCloned", (char*)"i", pview->getId() ) ); if( !res ) PyErr_Print(); } @@ -1908,9 +1923,9 @@ void SALOME_PYQT_ModuleLight::viewClosed( const SUIT_ViewWindow* pview ) if ( !myInterp || !myModule ) return; - if ( PyObject_HasAttrString( myModule->get(), "viewClosed" ) ) + if ( PyObject_HasAttrString( myModule, "viewClosed" ) ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"viewClosed", (char*)"i", pview->getId() ) ); + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"viewClosed", (char*)"i", pview->getId() ) ); if ( !res ) { PyErr_Print(); @@ -2376,8 +2391,8 @@ void SALOME_PYQT_ModuleLight::saveEvent(QStringList& theListOfFiles) if ( !myInterp || !myModule || (it == theListOfFiles.end())) return; - if ( PyObject_HasAttrString(myModule->get(), "saveFiles") ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"saveFiles", + if ( PyObject_HasAttrString(myModule, "saveFiles") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"saveFiles", (char*)"s", (*it).toLatin1().constData())); if( !res ) { PyErr_Print(); @@ -2453,10 +2468,13 @@ void SALOME_PYQT_ModuleLight::openEvent(QStringList theListOfFiles, bool &opened return; QStringList* theList = new QStringList(theListOfFiles); - PyObjWrapper sipList( sipBuildResult( 0, "M", theList, sipClass_QStringList ) ); - - if ( PyObject_HasAttrString(myModule->get() , "openFiles") ) { - PyObjWrapper res( PyObject_CallMethod( myModule->get(), (char*)"openFiles", +#if SIP_VERSION < 0x040800 + PyObjWrapper sipList( sipBuildResult( 0, "M", theList, sipClass_QStringList) ); +#else + PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList , NULL) ); +#endif + if ( PyObject_HasAttrString(myModule , "openFiles") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"openFiles", (char*)"O", sipList.get())); if( !res || !PyBool_Check( res )) { PyErr_Print(); diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h index f9066c640..44c4a71e2 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h @@ -63,9 +63,9 @@ private: bool myLastActivateStatus; //!< latest module activation status protected: - PyObjWrapper* myModule; //!< Python GUI module - PyInterp_Interp* myInterp; //!< current Python subinterpreter - static InterpMap myInterpMap; //!< study to Python subinterpreter map + PyObject* myModule; //!< Python GUI module + PyInterp_Interp* myInterp; //!< current Python subinterpreter + static InterpMap myInterpMap; //!< study to Python subinterpreter map public: SALOME_PYQT_ModuleLight(); diff --git a/src/SALOME_SWIG/examplevtk1.py b/src/SALOME_SWIG/examplevtk1.py index 63fafd046..d340da560 100755 --- a/src/SALOME_SWIG/examplevtk1.py +++ b/src/SALOME_SWIG/examplevtk1.py @@ -24,18 +24,22 @@ # Module : SALOME # import libSalomePy -ren=libSalomePy.renderer -#iren=libSalomePy.interactor +import vtk -from libVTKCommonPython import * -from libVTKGraphicsPython import * -cone = vtkConeSource() +# get the "vtkRenderer": an OpenGL rendering context +ren=libSalomePy.getRenderer() + +# create an actor and give it cone geometry +cone = vtk.vtkConeSource() cone.SetResolution(8) -coneMapper = vtkPolyDataMapper() +coneMapper = vtk.vtkPolyDataMapper() coneMapper.SetInput(cone.GetOutput()) -coneActor = vtkActor() +coneActor = vtk.vtkActor() coneActor.SetMapper(coneMapper) +# assign our actor to the renderer ren.AddActor(coneActor) -iren = vtkRenderWindowInteractor() +libSalomePy.fitAll() + +iren = libSalomePy.getRenderWindowInteractor() diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index 1f4b4033a..6b19753e2 100644 --- a/src/SPlot2d/Makefile.am +++ b/src/SPlot2d/Makefile.am @@ -44,7 +44,10 @@ nodist_libSPlot2d_la_SOURCES = $(MOC_FILES) libSPlot2d_la_CPPFLAGS = $(QT_INCLUDES) $(CAS_CPPFLAGS) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT -I$(srcdir)/../Plot2d \ -I$(srcdir)/../Prs -I$(srcdir)/../OBJECT -libSPlot2d_la_LDFLAGS = $(QT_MT_LIBS) $(CAS_KERNEL) $(QWT_LIBS) ../SUIT/libsuit.la ../Plot2d/libPlot2d.la ../Prs/libSalomePrs.la ../OBJECT/libSalomeObject.la +libSPlot2d_la_LDFLAGS = ../SUIT/libsuit.la ../Plot2d/libPlot2d.la ../Prs/libSalomePrs.la ../OBJECT/libSalomeObject.la + +### VSR: 24/11/2009: remove these libs to avoid double linking to the native libraries +###$(QT_MT_LIBS) $(CAS_KERNEL) $(QWT_LIBS) diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 7f4f1db88..1c4fe33f2 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -24,6 +24,7 @@ // #include "SUIT_DataObject.h" #include "SUIT_DataObjectKey.h" +#include SUIT_DataObject::Signal* SUIT_DataObject::mySignal = 0; diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx index 6cabb4e4e..2a08d294b 100755 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx @@ -93,6 +93,7 @@ SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop ) setBackgroundColor(QColor(R,G,B));*/ myToolBar = new QToolBar(this); + myToolBar->setFloatable(false); //myToolBar->setCloseMode(QDockWindow::Undocked); myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL")); createActions(); diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index f7e422f60..27976ea9d 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -57,7 +57,6 @@ salomeinclude_HEADERS= \ SVTK_SetRotationPointDlg.h \ SVTK_ViewParameterDlg.h \ SVTK_ComboAction.h \ - SVTK_Extension.h \ SVTK_Recorder.h \ SVTK_RecorderDlg.h \ SVTK_ImageWriter.h \ @@ -90,7 +89,6 @@ dist_libSVTK_la_SOURCES= \ SVTK_SetRotationPointDlg.cxx \ SVTK_ViewParameterDlg.cxx \ SVTK_ComboAction.cxx \ - SVTK_Extension.cxx \ SVTK_Recorder.cxx \ SVTK_RecorderDlg.cxx \ SVTK_ImageWriter.cxx \ diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 920402a61..07f52de15 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -382,17 +382,8 @@ SALOME_Actor myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected ); - vtkProperty* aProp = vtkProperty::New(); - aProp->SetColor( 255, 255, 255); - aProp->SetLineWidth ( 3 ); - myPreHighlightActor->SetProperty(aProp); - aProp->Delete(); - - int vis = myPreHighlightActor->GetVisibility(); - //printf ("\n Visibility = %d", vis); - if(mySelector.GetPointer() && hasIO()){ - if(mySelector->SelectionMode() != ActorSelection) { + if(mySelector->SelectionMode() != ActorSelection){ int aHasIndex = mySelector->HasIndex( getIO() ); myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex); } diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 83abf056c..2fdc252a6 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -143,8 +143,8 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) aRenderer->Delete(); aSelector->Delete(); - myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this ); - myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), -1, this ); + myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this ); + myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this ); createActions( SUIT_Session::session()->activeApplication()->resourceMgr() ); createToolBar(); @@ -846,6 +846,7 @@ QImage SVTK_ViewWindow::dumpView() if( myDumpImage.isNull() ) return dumpViewContent(); + RefreshDumpImage(); return myDumpImage; } diff --git a/src/SalomeApp/SalomeApp_VisualState.cxx b/src/SalomeApp/SalomeApp_VisualState.cxx index 8abfcaa27..4edce501e 100644 --- a/src/SalomeApp/SalomeApp_VisualState.cxx +++ b/src/SalomeApp/SalomeApp_VisualState.cxx @@ -41,6 +41,7 @@ #include //? #include //? +#include /*! Constructor. diff --git a/src/Session/Makefile.am b/src/Session/Makefile.am index 1871c3eda..6ee316dd5 100755 --- a/src/Session/Makefile.am +++ b/src/Session/Makefile.am @@ -57,13 +57,13 @@ if ENABLE_TESTRECORDER libSalomeSession_la_CPPFLAGS+= -DENABLE_TESTRECORDER $(TESTRECORDER_INCLUDES) endif -libSalomeSession_la_LDFLAGS = $(QT_MT_LIBS) $(KERNEL_LDFLAGS) -lSalomeNS \ +libSalomeSession_la_LDFLAGS = $(KERNEL_LDFLAGS) -lSalomeNS \ -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace -lSalomeCatalog \ -lSalomeDSClient $(CAS_KERNEL) -lwith_loggerTraceCollector \ -lSalomeIDLKernel -lSalomeContainer -lTOOLSDS -lSalomeLauncher \ -lRegistry -lSALOMEBasics \ ../SUIT/libsuit.la ../Event/libEvent.la ../../idl/libSalomeIDLGUI.la \ - ../Style/libSalomeStyle.la + ../Style/libSalomeStyle.la $(QT_MT_LIBS) if ENABLE_TESTRECORDER libSalomeSession_la_LDFLAGS+= $(TESTRECORDER_LIBS) @@ -76,12 +76,11 @@ dist_SALOME_Session_Server_SOURCES = SALOME_Session_Server.cxx SALOME_Session_Server_CPPFLAGS = $(libSalomeSession_la_CPPFLAGS) SALOME_Session_Server_LDADD = $(libSalomeSession_la_LDFLAGS) \ - $(PYTHON_LIBS) $(OMNIORB_LIBS) \ - $(HDF5_LIBS) -lSalomeContainer -lSalomeResourcesManager -lTOOLSDS \ + -lSalomeContainer -lSalomeResourcesManager -lTOOLSDS \ -lSalomeHDFPersist -lSalomeDSImpl -lSalomeGenericObj -lRegistry \ -lSalomeNotification -lSALOMEBasics -lSalomeLauncher ../Qtx/libqtx.la \ - $(top_builddir)/idl/libSalomeIDLGUI.la \ - libSalomeSession.la + $(top_builddir)/idl/libSalomeIDLGUI.la libSalomeSession.la \ + $(HDF5_LIBS) $(PYTHON_LIBS) $(OMNIORB_LIBS) if ENABLE_TESTRECORDER SALOME_Session_Server_LDADD+= $(TESTRECORDER_LIBS) diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index 920e3b08c..5118c4390 100755 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -79,7 +79,7 @@ VTKViewer_Actor myTransformFilter(VTKViewer_TransformFilter::New()) { vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, - myPolygonOffsetUnits); + myPolygonOffsetUnits); for(int i = 0; i < 6; i++) myPassFilter.push_back(vtkPassThroughFilter::New()); @@ -233,7 +233,7 @@ VTKViewer_Actor vtkMapper::SetResolveCoincidentTopologyToPolygonOffset(); vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, - myPolygonOffsetUnits); + myPolygonOffsetUnits); Superclass::Render(ren,m); vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit); @@ -261,7 +261,7 @@ VTKViewer_Actor void VTKViewer_Actor ::SetPolygonOffsetParameters(vtkFloatingPointType factor, - vtkFloatingPointType units) + vtkFloatingPointType units) { myPolygonOffsetFactor = factor; myPolygonOffsetUnits = units; @@ -274,7 +274,7 @@ VTKViewer_Actor void VTKViewer_Actor ::GetPolygonOffsetParameters(vtkFloatingPointType& factor, - vtkFloatingPointType& units) + vtkFloatingPointType& units) { factor = myPolygonOffsetFactor; units = myPolygonOffsetUnits; @@ -578,8 +578,8 @@ VTKViewer_Actor void VTKViewer_Actor ::SetColor(vtkFloatingPointType r, - vtkFloatingPointType g, - vtkFloatingPointType b) + vtkFloatingPointType g, + vtkFloatingPointType b) { GetProperty()->SetColor(r,g,b); } @@ -600,8 +600,8 @@ VTKViewer_Actor void VTKViewer_Actor ::GetColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b) + vtkFloatingPointType& g, + vtkFloatingPointType& b) { vtkFloatingPointType aColor[3]; GetProperty()->GetColor(aColor); diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index 439e45dbf..d41760d9f 100755 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -91,15 +91,15 @@ class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor virtual void SetColor(vtkFloatingPointType r, - vtkFloatingPointType g, - vtkFloatingPointType b); + vtkFloatingPointType g, + vtkFloatingPointType b); //! Get current color virtual void GetColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b); + vtkFloatingPointType& g, + vtkFloatingPointType& b); //! Change color virtual @@ -223,12 +223,12 @@ class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor //! Set ResolveCoincidentTopology parameters void SetPolygonOffsetParameters(vtkFloatingPointType factor, - vtkFloatingPointType units); + vtkFloatingPointType units); //! Get current ResolveCoincidentTopology parameters void GetPolygonOffsetParameters(vtkFloatingPointType& factor, - vtkFloatingPointType& units); + vtkFloatingPointType& units); virtual void diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index ccde1876d..fe6550c82 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -99,9 +99,9 @@ VTKViewer_AppendFilter int VTKViewer_AppendFilter ::RequestData( - vtkInformation *request, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) + vtkInformation *request, + vtkInformationVector **inputVector, + vtkInformationVector *outputVector) { int aRet = 0; if(GetSharedPointsDataSet()) @@ -146,8 +146,8 @@ namespace inline vtkIdType GetOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID, - const VTKViewer_AppendFilter::TVectorIds& theRanges) + vtkIdType theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) { theInputID = theInputDataSetID = -1; @@ -163,7 +163,7 @@ namespace vtkIdType VTKViewer_AppendFilter ::GetPointOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID) + vtkIdType theInputDataSetID) { if(GetSharedPointsDataSet()) return theInputID; @@ -175,7 +175,7 @@ VTKViewer_AppendFilter vtkIdType VTKViewer_AppendFilter ::GetCellOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID) + vtkIdType theInputDataSetID) { if(GetSharedPointsDataSet()) return theInputID; @@ -188,10 +188,10 @@ namespace { void GetInputID(vtkIdType theOutputID, - vtkIdType& theInputID, - vtkIdType& theStartID, - vtkIdType& theInputDataSetID, - const VTKViewer_AppendFilter::TVectorIds& theRanges) + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) { theInputID = theStartID = theInputDataSetID = -1; @@ -207,10 +207,10 @@ namespace for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){ vtkIdType aRange = theRanges[aDataSetId]; if(aRange > theOutputID){ - theInputID = theOutputID - aStartId; - theInputDataSetID = aDataSetId; - theStartID = aStartId; - break; + theInputID = theOutputID - aStartId; + theInputDataSetID = aDataSetId; + theStartID = aStartId; + break; } aStartId = aRange; } @@ -220,9 +220,9 @@ namespace void VTKViewer_AppendFilter ::GetPointInputID(vtkIdType theOutputID, - vtkIdType& theInputID, - vtkIdType& theStartID, - vtkIdType& theInputDataSetID) + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID) { if(GetSharedPointsDataSet()) { theStartID = theInputDataSetID = 0; @@ -231,25 +231,25 @@ VTKViewer_AppendFilter } ::GetInputID(theOutputID, - theInputID, - theStartID, - theInputDataSetID, - myNodeRanges); + theInputID, + theStartID, + theInputDataSetID, + myNodeRanges); } void VTKViewer_AppendFilter ::GetCellInputID(vtkIdType theOutputID, - vtkIdType& theInputID, - vtkIdType& theStartID, - vtkIdType& theInputDataSetID) + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID) { ::GetInputID(theOutputID, - theInputID, - theStartID, - theInputDataSetID, - myCellRanges); + theInputID, + theStartID, + theInputDataSetID, + myCellRanges); } diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h index 9f90c6658..5531d38d6 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.h +++ b/src/VTKViewer/VTKViewer_AppendFilter.h @@ -62,23 +62,23 @@ public: vtkIdType GetPointOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID); + vtkIdType theInputDataSetID); vtkIdType GetCellOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID); + vtkIdType theInputDataSetID); void GetPointInputID(vtkIdType theOutputID, - vtkIdType& theInputID, - vtkIdType& theStartID, - vtkIdType& theInputDataSetID); + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); void GetCellInputID(vtkIdType theOutputID, - vtkIdType& theInputID, - vtkIdType& theStartID, - vtkIdType& theInputDataSetID); + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); typedef std::vector TVectorIds; diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.cxx b/src/VTKViewer/VTKViewer_ArcBuilder.cxx index e8cd9e479..392cbd187 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.cxx +++ b/src/VTKViewer/VTKViewer_ArcBuilder.cxx @@ -89,7 +89,7 @@ double XYZ::Modulus () const { Pnt::Pnt(double X, double Y, double Z, - double ScalarValue): + double ScalarValue): coord(X,Y,Z), scalarValue(ScalarValue) { @@ -617,7 +617,7 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, for(vtkIdType idx = 1; idx < aNbPts-1;idx++) { curID = output->GetPoints()->InsertNextPoint(aPoints->GetPoint(idx)); if( outputScalars ) - outputScalars->InsertNextTuple1(aScalarValues[idx]); + outputScalars->InsertNextTuple1(aScalarValues[idx]); aNewPoints[idx] = curID; } aNewPoints[aNbPts-1] = pts[1]; @@ -632,10 +632,10 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkUnstructuredGrid* input, * Array theIds - it is array with ids of added points. */ vtkIdType MergevtkPoints(const std::vector& theCollection, - const std::vector< std::vector >& theScalarCollection, - vtkPoints* thePoints, - std::map& thePntId2ScalarValue, - vtkIdType* &theIds){ + const std::vector< std::vector >& theScalarCollection, + vtkPoints* thePoints, + std::map& thePntId2ScalarValue, + vtkIdType* &theIds){ vtkIdType aNbPoints = 0; vtkIdType anIdCounter = 0; vtkIdType aNewPntId = 0; @@ -660,7 +660,7 @@ vtkIdType MergevtkPoints(const std::vector& theCollection, for(vtkIdType idx = 0;idx < aPoints->GetNumberOfPoints()-1;idx++){ aNewPntId = thePoints->InsertNextPoint(aPoints->GetPoint(idx)); theIds[anIdCounter] = aNewPntId; - thePntId2ScalarValue[ aNewPntId ] = aScalarValues[idx]; + thePntId2ScalarValue[ aNewPntId ] = aScalarValues[idx]; anIdCounter++; } } diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.h b/src/VTKViewer/VTKViewer_ArcBuilder.h index 4ad39dc5f..4362b6df0 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.h +++ b/src/VTKViewer/VTKViewer_ArcBuilder.h @@ -38,9 +38,9 @@ class Pnt; typedef std::list PntList; vtkIdType MergevtkPoints(const std::vector& theCollection, - const std::vector< std::vector >& theScalarCollection, + const std::vector< std::vector >& theScalarCollection, vtkPoints* thePoints, - std::map& thePntId2ScalarValue, + std::map& thePntId2ScalarValue, vtkIdType* &theIds); vtkIdType Build1DArc(vtkIdType cellId, @@ -50,8 +50,8 @@ vtkIdType Build1DArc(vtkIdType cellId, vtkFloatingPointType myMaxArcAngle); Pnt CreatePnt(vtkCell* cell, - vtkDataArray* scalars, - vtkIdType index); + vtkDataArray* scalars, + vtkIdType index); /*! * Class for represenation coordinates X,Y,Z @@ -138,9 +138,9 @@ class Plane{ void CalculatePlane(const Pnt& thePnt1, const Pnt& thePnt2, const Pnt& thePnt3); private: - double myA; - double myB; - double myC; + double myA; + double myB; + double myC; }; @@ -148,9 +148,9 @@ class VTKViewer_ArcBuilder{ public: enum ArcStatus {Arc_Done=0, Arc_Error}; VTKViewer_ArcBuilder(const Pnt& thePnt1, - const Pnt& thePnt2, - const Pnt& thePnt3, - double theAngle); + const Pnt& thePnt2, + const Pnt& thePnt3, + double theAngle); ~VTKViewer_ArcBuilder(); @@ -161,7 +161,7 @@ class VTKViewer_ArcBuilder{ void GetAngle(const double theAngle); static double GetPointAngleOnCircle(const double theXCenter, const double theYCenter, - const double theXPoint, const double theYPoint); + const double theXPoint, const double theYPoint); vtkPoints* GetPoints(); const std::vector& GetScalarValues(); diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index 96b6bec33..229f28e1b 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -56,8 +56,8 @@ namespace vtkFloatingPointType myOrigin[3]; vtkFloatingPointType myNormal[3]; TPolygon(const TConnectivities& theConnectivities, - vtkFloatingPointType theOrigin[3], - vtkFloatingPointType theNormal[3]): + vtkFloatingPointType theOrigin[3], + vtkFloatingPointType theNormal[3]): myConnectivities(theConnectivities) { myOrigin[0] = theOrigin[0]; @@ -98,7 +98,7 @@ VTKViewer_Triangulator vtkPoints* VTKViewer_Triangulator ::InitPoints(vtkUnstructuredGrid *theInput, - vtkIdType theCellId) + vtkIdType theCellId) { myPoints->Reset(); myPoints->Modified(); // the VTK bug @@ -151,8 +151,8 @@ VTKViewer_Triangulator aCoordDiff[2] = (aBounds[5] - aBounds[4]); return sqrt(aCoordDiff[0]*aCoordDiff[0] + - aCoordDiff[1]*aCoordDiff[1] + - aCoordDiff[2]*aCoordDiff[2]); + aCoordDiff[1]*aCoordDiff[1] + + aCoordDiff[2]*aCoordDiff[2]); } @@ -160,9 +160,9 @@ VTKViewer_Triangulator void VTKViewer_Triangulator ::GetCellNeighbors(vtkUnstructuredGrid *theInput, - vtkIdType theCellId, - vtkCell* theFace, - vtkIdList* theCellIds) + vtkIdType theCellId, + vtkCell* theFace, + vtkIdList* theCellIds) { myFaceIds->Reset(); vtkIdList *anIdList = theFace->PointIds; @@ -187,16 +187,16 @@ VTKViewer_Triangulator bool VTKViewer_Triangulator ::Execute(vtkUnstructuredGrid *theInput, - vtkCellData* thInputCD, - vtkIdType theCellId, - int theShowInside, - int theAllVisible, - const char* theCellsVisibility, - vtkPolyData *theOutput, - vtkCellData* theOutputCD, - int theStoreMapping, - std::vector& theVTK2ObjIds, - bool theIsCheckConvex) + vtkCellData* thInputCD, + vtkIdType theCellId, + int theShowInside, + int theAllVisible, + const char* theCellsVisibility, + vtkPolyData *theOutput, + vtkCellData* theOutputCD, + int theStoreMapping, + std::vector& theVTK2ObjIds, + bool theIsCheckConvex) { vtkPoints *aPoints = InitPoints(theInput, theCellId); vtkIdType aNumPts = GetNbOfPoints(); @@ -270,7 +270,7 @@ VTKViewer_Triangulator vtkIdList *anIdList = aFace->PointIds; vtkIdType aNewPts[3] = {anIdList->GetId(0), anIdList->GetId(1), anIdList->GetId(2)}; - + // To initialize set of points for the plane where the trinangle face belong to TPointIds aPointIds; aPointIds.insert(aNewPts[0]); @@ -294,21 +294,21 @@ VTKViewer_Triangulator /* To calculate plane normal for face (aFace) - ^ aNormal - | - | ^ aVector01 - | / - /_________> aVector02 + ^ aNormal + | + | ^ aVector01 + | / + /_________> aVector02 */ vtkFloatingPointType aVector01[3] = { aCoord[1][0] - aCoord[0][0], - aCoord[1][1] - aCoord[0][1], - aCoord[1][2] - aCoord[0][2] }; + aCoord[1][1] - aCoord[0][1], + aCoord[1][2] - aCoord[0][2] }; vtkFloatingPointType aVector02[3] = { aCoord[2][0] - aCoord[0][0], - aCoord[2][1] - aCoord[0][1], - aCoord[2][2] - aCoord[0][2] }; + aCoord[2][1] - aCoord[0][1], + aCoord[2][2] - aCoord[0][2] }; vtkMath::Normalize(aVector01); vtkMath::Normalize(aVector02); @@ -323,211 +323,211 @@ VTKViewer_Triangulator // To calculate bounds of the point set vtkFloatingPointType aCenter[3] = {0.0, 0.0, 0.0}; { - TPointIds::const_iterator anIter = anInitialPointIds.begin(); - TPointIds::const_iterator anEndIter = anInitialPointIds.end(); - for(; anIter != anEndIter; anIter++){ - vtkFloatingPointType aPntCoord[3]; - vtkIdType aPntId = *anIter; - aPoints->GetPoint(aPntId,aPntCoord); - - vtkFloatingPointType aVector0Pnt[3] = { aPntCoord[0] - aCoord[0][0], - aPntCoord[1] - aCoord[0][1], - aPntCoord[2] - aCoord[0][2] }; - - - vtkMath::Normalize(aVector0Pnt); - - vtkFloatingPointType aNormalPnt[3]; - // calculate aNormalPnt - { - vtkFloatingPointType aCosPnt01 = vtkMath::Dot(aVector0Pnt,aVector01); - vtkFloatingPointType aCosPnt02 = vtkMath::Dot(aVector0Pnt,aVector02); - if(aCosPnt01<-1) - aCosPnt01 = -1; - if(aCosPnt01>1) - aCosPnt01 = 1; - if(aCosPnt02<-1) - aCosPnt02 = -1; - if(aCosPnt02>1) - aCosPnt02 = 1; - - vtkFloatingPointType aDist01,aDist02;// deflection from Pi/3 angle (equilateral triangle) - vtkFloatingPointType aAngPnt01 = fabs(acos(aCosPnt01)); - vtkFloatingPointType aAngPnt02 = fabs(acos(aCosPnt02)); - - /* check that triangle similar to equilateral triangle - AOC or COB ? - aVector0Pnt = (OC) - aVector01 = (OB) - aVector02 = (OA) - - B - ^ aVector01 C - | ^ aVector0Pnt - | _____/ - | ___/ - |/________> aVector02 - O A - */ - aDist01 = fabs(aAngPnt01-(vtkMath::Pi())/3.0); - aDist02 = fabs(aAngPnt02-(vtkMath::Pi())/3.0); - - // caculate a normal for best triangle - if(aDist01 <= aDist02) - vtkMath::Cross(aVector0Pnt,aVector01,aNormalPnt); - else - vtkMath::Cross(aVector0Pnt,aVector02,aNormalPnt); - - } - - vtkMath::Normalize(aNormalPnt); - - if(DEBUG_TRIA_EXECUTE) - cout<<"\t\taPntId = "<GetPoint(aPntId,aPntCoord); + + vtkFloatingPointType aVector0Pnt[3] = { aPntCoord[0] - aCoord[0][0], + aPntCoord[1] - aCoord[0][1], + aPntCoord[2] - aCoord[0][2] }; + + + vtkMath::Normalize(aVector0Pnt); + + vtkFloatingPointType aNormalPnt[3]; + // calculate aNormalPnt + { + vtkFloatingPointType aCosPnt01 = vtkMath::Dot(aVector0Pnt,aVector01); + vtkFloatingPointType aCosPnt02 = vtkMath::Dot(aVector0Pnt,aVector02); + if(aCosPnt01<-1) + aCosPnt01 = -1; + if(aCosPnt01>1) + aCosPnt01 = 1; + if(aCosPnt02<-1) + aCosPnt02 = -1; + if(aCosPnt02>1) + aCosPnt02 = 1; + + vtkFloatingPointType aDist01,aDist02;// deflection from Pi/3 angle (equilateral triangle) + vtkFloatingPointType aAngPnt01 = fabs(acos(aCosPnt01)); + vtkFloatingPointType aAngPnt02 = fabs(acos(aCosPnt02)); + + /* check that triangle similar to equilateral triangle + AOC or COB ? + aVector0Pnt = (OC) + aVector01 = (OB) + aVector02 = (OA) + + B + ^ aVector01 C + | ^ aVector0Pnt + | _____/ + | ___/ + |/________> aVector02 + O A + */ + aDist01 = fabs(aAngPnt01-(vtkMath::Pi())/3.0); + aDist02 = fabs(aAngPnt02-(vtkMath::Pi())/3.0); + + // caculate a normal for best triangle + if(aDist01 <= aDist02) + vtkMath::Cross(aVector0Pnt,aVector01,aNormalPnt); + else + vtkMath::Cross(aVector0Pnt,aVector02,aNormalPnt); + + } + + vtkMath::Normalize(aNormalPnt); + + if(DEBUG_TRIA_EXECUTE) + cout<<"\t\taPntId = "< 0){ - aNormal[0] = -aNormal[0]; - aNormal[1] = -aNormal[1]; - aNormal[2] = -aNormal[2]; + aNormal[0] = -aNormal[0]; + aNormal[1] = -aNormal[1]; + aNormal[2] = -aNormal[2]; } // To calculate the primary direction for point set vtkFloatingPointType aVector0[3] = { aCoord[0][0] - aCenter[0], - aCoord[0][1] - aCenter[1], - aCoord[0][2] - aCenter[2] }; + aCoord[0][1] - aCenter[1], + aCoord[0][2] - aCenter[2] }; vtkMath::Normalize(aVector0); if(DEBUG_TRIA_EXECUTE) { - cout<<"\t\taCenter = {"< TSortedPointIds; - TSortedPointIds aSortedPointIds; - - TPointIds::const_iterator anIter = aPointIds.begin(); - TPointIds::const_iterator anEndIter = aPointIds.end(); - for(; anIter != anEndIter; anIter++){ - vtkFloatingPointType aPntCoord[3]; - vtkIdType aPntId = *anIter; - aPoints->GetPoint(aPntId,aPntCoord); - vtkFloatingPointType aVector[3] = { aPntCoord[0] - aCenter[0], - aPntCoord[1] - aCenter[1], - aPntCoord[2] - aCenter[2] }; - vtkMath::Normalize(aVector); - - vtkFloatingPointType aCross[3]; - vtkMath::Cross(aVector,aVector0,aCross); - vtkFloatingPointType aCr = vtkMath::Dot(aCross,aNormal); - bool aGreaterThanPi = aCr < 0; - vtkFloatingPointType aCosinus = vtkMath::Dot(aVector,aVector0); - vtkFloatingPointType anAngle = 0.0; - if(aCosinus >= 1.0){ - aCosinus = 1.0; - } else if (aCosinus <= -1.0){ - aCosinus = -1.0; - anAngle = vtkMath::Pi(); - } else { - anAngle = acos(aCosinus); - if(aGreaterThanPi) - anAngle = 2*vtkMath::Pi() - anAngle; - } - - if(DEBUG_TRIA_EXECUTE) { - cout << "\t\t\t vtkMath::Dot(aCross,aNormal)="<second; - aConnectivities[anId] = GetConnectivity(aPntId); - if(DEBUG_TRIA_EXECUTE) cout << aPntId << ","; - } - if(DEBUG_TRIA_EXECUTE) cout << endl; - aPolygons.push_back(::TPolygon(aConnectivities,aCenter,aNormal)); - } + typedef std::map TSortedPointIds; + TSortedPointIds aSortedPointIds; + + TPointIds::const_iterator anIter = aPointIds.begin(); + TPointIds::const_iterator anEndIter = aPointIds.end(); + for(; anIter != anEndIter; anIter++){ + vtkFloatingPointType aPntCoord[3]; + vtkIdType aPntId = *anIter; + aPoints->GetPoint(aPntId,aPntCoord); + vtkFloatingPointType aVector[3] = { aPntCoord[0] - aCenter[0], + aPntCoord[1] - aCenter[1], + aPntCoord[2] - aCenter[2] }; + vtkMath::Normalize(aVector); + + vtkFloatingPointType aCross[3]; + vtkMath::Cross(aVector,aVector0,aCross); + vtkFloatingPointType aCr = vtkMath::Dot(aCross,aNormal); + bool aGreaterThanPi = aCr < 0; + vtkFloatingPointType aCosinus = vtkMath::Dot(aVector,aVector0); + vtkFloatingPointType anAngle = 0.0; + if(aCosinus >= 1.0){ + aCosinus = 1.0; + } else if (aCosinus <= -1.0){ + aCosinus = -1.0; + anAngle = vtkMath::Pi(); + } else { + anAngle = acos(aCosinus); + if(aGreaterThanPi) + anAngle = 2*vtkMath::Pi() - anAngle; + } + + if(DEBUG_TRIA_EXECUTE) { + cout << "\t\t\t vtkMath::Dot(aCross,aNormal)="<second; + aConnectivities[anId] = GetConnectivity(aPntId); + if(DEBUG_TRIA_EXECUTE) cout << aPntId << ","; + } + if(DEBUG_TRIA_EXECUTE) cout << endl; + aPolygons.push_back(::TPolygon(aConnectivities,aCenter,aNormal)); + } } } } @@ -542,18 +542,18 @@ VTKViewer_Triangulator vtkFloatingPointType* aNormal = aPolygon.myNormal; vtkFloatingPointType* anOrigin = aPolygon.myOrigin; if(DEBUG_TRIA_EXECUTE) { - cout<<"\taPolygonId = "<GetPoint(anId,aPntCoord); - vtkFloatingPointType aDist = vtkPlane::Evaluate(aNormal,anOrigin,aPntCoord); - if(DEBUG_TRIA_EXECUTE) cout<<"\t\taPntId = "<GetPoint(anId,aPntCoord); + vtkFloatingPointType aDist = vtkPlane::Evaluate(aNormal,anOrigin,aPntCoord); + if(DEBUG_TRIA_EXECUTE) cout<<"\t\taPntId = "<InsertNextCell(VTK_POLYGON,aNbPoints,&aConnectivities[0]); if(theStoreMapping) - theVTK2ObjIds.push_back(theCellId); + theVTK2ObjIds.push_back(theCellId); theOutputCD->CopyData(thInputCD,theCellId,aNewCellId); } } @@ -611,7 +611,7 @@ VTKViewer_OrderedTriangulator vtkPoints* VTKViewer_OrderedTriangulator ::InitPoints(vtkUnstructuredGrid *theInput, - vtkIdType theCellId) + vtkIdType theCellId) { myBoundaryTris->Reset(); @@ -709,7 +709,7 @@ VTKViewer_DelaunayTriangulator vtkPoints* VTKViewer_DelaunayTriangulator ::InitPoints(vtkUnstructuredGrid *theInput, - vtkIdType theCellId) + vtkIdType theCellId) { vtkPoints* aPoints = VTKViewer_Triangulator::InitPoints(theInput, theCellId); diff --git a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx index 0203f97f1..cb326fff6 100755 --- a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx +++ b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx @@ -99,14 +99,14 @@ vtkIdType VTKViewer_ExtractUnstructuredGrid::GetOutputId(int theInId) const{ inline void InsertCell(vtkUnstructuredGrid *theInput, - vtkCellArray *theConnectivity, - vtkUnsignedCharArray* theCellTypesArray, - vtkIdType theCellId, - vtkIdList *theIdList, - bool theStoreMapping, - vtkIdType theOutId, - VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId, - VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId) + vtkCellArray *theConnectivity, + vtkUnsignedCharArray* theCellTypesArray, + vtkIdType theCellId, + vtkIdList *theIdList, + bool theStoreMapping, + vtkIdType theOutId, + VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId, + VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId) { vtkCell *aCell = theInput->GetCell(theCellId); vtkIdList *aPntIds = aCell->GetPointIds(); @@ -126,13 +126,13 @@ inline void InsertCell(vtkUnstructuredGrid *theInput, } inline void InsertPointCell(vtkCellArray *theConnectivity, - vtkUnsignedCharArray* theCellTypesArray, - vtkIdType theCellId, - vtkIdList *theIdList, - bool theStoreMapping, - vtkIdType theOutId, - VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId, - VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId) + vtkUnsignedCharArray* theCellTypesArray, + vtkIdType theCellId, + vtkIdList *theIdList, + bool theStoreMapping, + vtkIdType theOutId, + VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId, + VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId) { theIdList->SetId(0,theCellId); theConnectivity->InsertNextCell(theIdList); diff --git a/src/VTKViewer/VTKViewer_FramedTextActor.cxx b/src/VTKViewer/VTKViewer_FramedTextActor.cxx index 50600be31..bd20dc84b 100644 --- a/src/VTKViewer/VTKViewer_FramedTextActor.cxx +++ b/src/VTKViewer/VTKViewer_FramedTextActor.cxx @@ -162,8 +162,8 @@ void VTKViewer_FramedTextActor::GetSize(vtkRenderer* theRenderer, int theSize[2] // purpose : //================================================================== void VTKViewer_FramedTextActor::SetForegroundColor(const vtkFloatingPointType r, - const vtkFloatingPointType g, - const vtkFloatingPointType b) + const vtkFloatingPointType g, + const vtkFloatingPointType b) { myTextProperty->SetColor(r, g, b); myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); @@ -175,8 +175,8 @@ void VTKViewer_FramedTextActor::SetForegroundColor(const vtkFloatingPointType r, // purpose : //================================================================== void VTKViewer_FramedTextActor::GetForegroundColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b) + vtkFloatingPointType& g, + vtkFloatingPointType& b) { vtkFloatingPointType aColor[3]; myTextProperty->GetColor(aColor); @@ -190,8 +190,8 @@ void VTKViewer_FramedTextActor::GetForegroundColor(vtkFloatingPointType& r, // purpose : //================================================================== void VTKViewer_FramedTextActor::SetBackgroundColor(const vtkFloatingPointType r, - const vtkFloatingPointType g, - const vtkFloatingPointType b) + const vtkFloatingPointType g, + const vtkFloatingPointType b) { myBarActor->GetProperty()->SetColor(r, g, b); Modified(); @@ -202,8 +202,8 @@ void VTKViewer_FramedTextActor::SetBackgroundColor(const vtkFloatingPointType r, // purpose : //================================================================== void VTKViewer_FramedTextActor::GetBackgroundColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b) + vtkFloatingPointType& g, + vtkFloatingPointType& b) { vtkFloatingPointType aColor[3]; myBarActor->GetProperty()->GetColor(aColor); @@ -485,7 +485,7 @@ VTKViewer_FramedTextActor } PositionCoordinate->SetValue(x / (vtkFloatingPointType)aViewPortWidth, - y / (vtkFloatingPointType)aViewPortHeight); + y / (vtkFloatingPointType)aViewPortHeight); } aPoints->SetPoint(0, xMin, yMax, 0.0); diff --git a/src/VTKViewer/VTKViewer_FramedTextActor.h b/src/VTKViewer/VTKViewer_FramedTextActor.h index 71130ac40..abc93cb40 100644 --- a/src/VTKViewer/VTKViewer_FramedTextActor.h +++ b/src/VTKViewer/VTKViewer_FramedTextActor.h @@ -73,18 +73,18 @@ public: vtkFloatingPointType GetDistance() const; void SetForegroundColor(const vtkFloatingPointType r, - const vtkFloatingPointType g, - const vtkFloatingPointType b); + const vtkFloatingPointType g, + const vtkFloatingPointType b); void GetForegroundColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b); + vtkFloatingPointType& g, + vtkFloatingPointType& b); void SetBackgroundColor(const vtkFloatingPointType r, - const vtkFloatingPointType g, - const vtkFloatingPointType b); + const vtkFloatingPointType g, + const vtkFloatingPointType b); void GetBackgroundColor(vtkFloatingPointType& r, - vtkFloatingPointType& g, - vtkFloatingPointType& b); + vtkFloatingPointType& g, + vtkFloatingPointType& b); void SetTransparency(const vtkFloatingPointType theTransparency); vtkFloatingPointType GetTransparency() const; diff --git a/src/VTKViewer/VTKViewer_Functor.h b/src/VTKViewer/VTKViewer_Functor.h index e1bb57b17..b0cdf1483 100644 --- a/src/VTKViewer/VTKViewer_Functor.h +++ b/src/VTKViewer/VTKViewer_Functor.h @@ -43,14 +43,14 @@ namespace VTK {} void operator()(TActor* theActor) { - (theActor->*myAction)(myArg); + (theActor->*myAction)(myArg); } }; template struct TSetVisibility: TSetFunction { TSetVisibility(TArg theArg): - TSetFunction(&TActor::SetVisibility,theArg) + TSetFunction(&TActor::SetVisibility,theArg) {} }; } diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index be5781ae0..b5f44058c 100755 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -117,9 +117,9 @@ VTKViewer_GeometryFilter int VTKViewer_GeometryFilter ::UnstructuredGridExecute( - vtkDataSet *dataSetInput, - vtkPolyData *output, - vtkInformation *outInfo) + vtkDataSet *dataSetInput, + vtkPolyData *output, + vtkInformation *outInfo) { vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput; @@ -281,17 +281,17 @@ VTKViewer_GeometryFilter case VTK_VERTEX: case VTK_POLY_VERTEX: newCellId = output->InsertNextCell(aCellType,npts,pts); - if(myStoreMapping){ - myVTK2ObjIds.push_back(cellId); //apo - } + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + } outputCD->CopyData(cd,cellId,newCellId); break; case VTK_LINE: case VTK_POLY_LINE: newCellId = output->InsertNextCell(aCellType,npts,pts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); break; @@ -299,52 +299,52 @@ VTKViewer_GeometryFilter case VTK_QUAD: case VTK_POLYGON: newCellId = output->InsertNextCell(aCellType,npts,pts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); break; case VTK_TRIANGLE_STRIP: newCellId = output->InsertNextCell(aCellType,npts,pts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); break; case VTK_PIXEL: newCellId = output->InsertNextCell(aCellType,npts,pts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - outputCD->CopyData(cd,cellId,newCellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); + break; + + case VTK_CONVEX_POINT_SET: { + bool anIsOk = anOrderedTriangulator.Execute(input, + cd, + cellId, + myShowInside, + allVisible, + cellVis, + output, + outputCD, + myStoreMapping, + myVTK2ObjIds, + true); + if(!anIsOk) + aDelaunayTriangulator.Execute(input, + cd, + cellId, + myShowInside, + allVisible, + cellVis, + output, + outputCD, + myStoreMapping, + myVTK2ObjIds, + false); + break; - - case VTK_CONVEX_POINT_SET: { - bool anIsOk = anOrderedTriangulator.Execute(input, - cd, - cellId, - myShowInside, - allVisible, - cellVis, - output, - outputCD, - myStoreMapping, - myVTK2ObjIds, - true); - if(!anIsOk) - aDelaunayTriangulator.Execute(input, - cd, - cellId, - myShowInside, - allVisible, - cellVis, - output, - outputCD, - myStoreMapping, - myVTK2ObjIds, - false); - - break; - } + } case VTK_TETRA: { for (faceId = 0; faceId < 4; faceId++) { @@ -353,7 +353,7 @@ VTKViewer_GeometryFilter faceIds->InsertNextId(pts[faceVerts[0]]); faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); - aCellType = VTK_TRIANGLE; + aCellType = VTK_TRIANGLE; numFacePts = 3; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside || @@ -362,13 +362,13 @@ VTKViewer_GeometryFilter for ( i=0; i < numFacePts; i++) aNewPts[i] = pts[faceVerts[i]]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); } } break; - } + } case VTK_VOXEL: { for (faceId = 0; faceId < 6; faceId++) { @@ -378,7 +378,7 @@ VTKViewer_GeometryFilter faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); faceIds->InsertNextId(pts[faceVerts[3]]); - aCellType = VTK_QUAD; + aCellType = VTK_QUAD; numFacePts = 4; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside || @@ -387,13 +387,13 @@ VTKViewer_GeometryFilter for ( i=0; i < numFacePts; i++) aNewPts[i] = pts[faceVerts[PixelConvert[i]]]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); } } break; - } + } case VTK_HEXAHEDRON: { for (faceId = 0; faceId < 6; faceId++) { @@ -403,7 +403,7 @@ VTKViewer_GeometryFilter faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); faceIds->InsertNextId(pts[faceVerts[3]]); - aCellType = VTK_QUAD; + aCellType = VTK_QUAD; numFacePts = 4; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside || @@ -412,13 +412,13 @@ VTKViewer_GeometryFilter for ( i=0; i < numFacePts; i++) aNewPts[i] = pts[faceVerts[i]]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); } } break; - } + } case VTK_WEDGE: { for (faceId = 0; faceId < 5; faceId++) { @@ -427,12 +427,12 @@ VTKViewer_GeometryFilter faceIds->InsertNextId(pts[faceVerts[0]]); faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); - aCellType = VTK_TRIANGLE; + aCellType = VTK_TRIANGLE; numFacePts = 3; if (faceVerts[3] >= 0) { faceIds->InsertNextId(pts[faceVerts[3]]); - aCellType = VTK_QUAD; + aCellType = VTK_QUAD; numFacePts = 4; } input->GetCellNeighbors(cellId, faceIds, cellIds); @@ -442,13 +442,13 @@ VTKViewer_GeometryFilter for ( i=0; i < numFacePts; i++) aNewPts[i] = pts[faceVerts[i]]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); } } break; - } + } case VTK_PYRAMID: { for (faceId = 0; faceId < 5; faceId++) { @@ -457,12 +457,12 @@ VTKViewer_GeometryFilter faceIds->InsertNextId(pts[faceVerts[0]]); faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); - aCellType = VTK_TRIANGLE; + aCellType = VTK_TRIANGLE; numFacePts = 3; if (faceVerts[3] >= 0) { faceIds->InsertNextId(pts[faceVerts[3]]); - aCellType = VTK_QUAD; + aCellType = VTK_QUAD; numFacePts = 4; } input->GetCellNeighbors(cellId, faceIds, cellIds); @@ -472,13 +472,13 @@ VTKViewer_GeometryFilter for ( i=0; i < numFacePts; i++) aNewPts[i] = pts[faceVerts[i]]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); } } break; - } + } //Quadratic cells case VTK_QUADRATIC_EDGE: case VTK_QUADRATIC_TRIANGLE: @@ -487,14 +487,14 @@ VTKViewer_GeometryFilter case VTK_QUADRATIC_HEXAHEDRON: case VTK_QUADRATIC_WEDGE: case VTK_QUADRATIC_PYRAMID: - if(!myIsWireframeMode){ - input->GetCell(cellId,cell); - vtkIdList *lpts = vtkIdList::New(); - vtkPoints *coords = vtkPoints::New(); - vtkIdList *cellIds = vtkIdList::New(); - vtkIdType newCellId; - - if ( cell->GetCellDimension() == 1 ) { + if(!myIsWireframeMode){ + input->GetCell(cellId,cell); + vtkIdList *lpts = vtkIdList::New(); + vtkPoints *coords = vtkPoints::New(); + vtkIdList *cellIds = vtkIdList::New(); + vtkIdType newCellId; + + if ( cell->GetCellDimension() == 1 ) { vtkIdType arcResult = -1; if(myIsBuildArc) { arcResult = Build1DArc(cellId, input, output, pts, myMaxArcAngle); @@ -520,7 +520,7 @@ VTKViewer_GeometryFilter outputCD->CopyData(cd,cellId,newCellId); } } - else if ( cell->GetCellDimension() == 2 ) { + else if ( cell->GetCellDimension() == 2 ) { if(!myIsBuildArc) { aCellType = VTK_TRIANGLE; numFacePts = 3; @@ -539,34 +539,34 @@ VTKViewer_GeometryFilter BuildArcedPolygon(cellId,input,output,true); } } - else //3D nonlinear cell + else //3D nonlinear cell { - aCellType = VTK_TRIANGLE; - numFacePts = 3; - for (int j=0; j < cell->GetNumberOfFaces(); j++){ - vtkCell *face = cell->GetFace(j); - input->GetCellNeighbors(cellId, face->PointIds, cellIds); - if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) { - face->Triangulate(0,lpts,coords); - for (i=0; i < lpts->GetNumberOfIds(); i+=3) { - aNewPts[0] = lpts->GetId(i); - aNewPts[1] = lpts->GetId(i+1); - aNewPts[2] = lpts->GetId(i+2); - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - outputCD->CopyData(cd,cellId,newCellId); + aCellType = VTK_TRIANGLE; + numFacePts = 3; + for (int j=0; j < cell->GetNumberOfFaces(); j++){ + vtkCell *face = cell->GetFace(j); + input->GetCellNeighbors(cellId, face->PointIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) { + face->Triangulate(0,lpts,coords); + for (i=0; i < lpts->GetNumberOfIds(); i+=3) { + aNewPts[0] = lpts->GetId(i); + aNewPts[1] = lpts->GetId(i+1); + aNewPts[2] = lpts->GetId(i+2); + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); } } } } //3d nonlinear cell - cellIds->Delete(); - coords->Delete(); - lpts->Delete(); - break; + cellIds->Delete(); + coords->Delete(); + lpts->Delete(); + break; }else{ - switch(aCellType){ - case VTK_QUADRATIC_EDGE: { + switch(aCellType){ + case VTK_QUADRATIC_EDGE: { vtkIdType arcResult =-1; if(myIsBuildArc) { arcResult = Build1DArc(cellId, input, output, pts,myMaxArcAngle); @@ -575,21 +575,21 @@ VTKViewer_GeometryFilter if(!myIsBuildArc || arcResult == -1) { aCellType = VTK_POLY_LINE; numFacePts = 3; - + aNewPts[0] = pts[0]; aNewPts[2] = pts[1]; aNewPts[1] = pts[2]; - + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); } if(myStoreMapping) myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - break; - } - case VTK_QUADRATIC_TRIANGLE: { + + outputCD->CopyData(cd,cellId,newCellId); + break; + } + case VTK_QUADRATIC_TRIANGLE: { if(!myIsBuildArc) { aCellType = VTK_POLYGON; numFacePts = 6; @@ -600,18 +600,18 @@ VTKViewer_GeometryFilter aNewPts[3] = pts[4]; aNewPts[4] = pts[2]; aNewPts[5] = pts[5]; - + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); } else BuildArcedPolygon(cellId,input,output); break; - } - case VTK_QUADRATIC_QUAD: { + } + case VTK_QUADRATIC_QUAD: { if(!myIsBuildArc) { aCellType = VTK_POLYGON; numFacePts = 8; @@ -624,338 +624,338 @@ VTKViewer_GeometryFilter aNewPts[5] = pts[6]; aNewPts[6] = pts[3]; aNewPts[7] = pts[7]; - + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); } else BuildArcedPolygon(cellId,input,output); break; - } - case VTK_QUADRATIC_TETRA: { - aCellType = VTK_POLYGON; - numFacePts = 6; - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[4]; - aNewPts[2] = pts[1]; - aNewPts[3] = pts[5]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[6]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[7]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[8]; - aNewPts[4] = pts[1]; - aNewPts[5] = pts[4]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[1]; - aNewPts[1] = pts[8]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[9]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[5]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[2]; - aNewPts[1] = pts[9]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[7]; - aNewPts[4] = pts[0]; - aNewPts[5] = pts[6]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - break; - } + } + case VTK_QUADRATIC_TETRA: { + aCellType = VTK_POLYGON; + numFacePts = 6; + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[4]; + aNewPts[2] = pts[1]; + aNewPts[3] = pts[5]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[6]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[7]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[8]; + aNewPts[4] = pts[1]; + aNewPts[5] = pts[4]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[1]; + aNewPts[1] = pts[8]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[9]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[5]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[2]; + aNewPts[1] = pts[9]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[7]; + aNewPts[4] = pts[0]; + aNewPts[5] = pts[6]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + break; + } case VTK_QUADRATIC_WEDGE: { aCellType = VTK_POLYGON; - numFacePts = 6; + numFacePts = 6; //--------------------------------------------------------------- //Face 1 - aNewPts[0] = pts[0]; - aNewPts[1] = pts[6]; - aNewPts[2] = pts[1]; - aNewPts[3] = pts[7]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[8]; + aNewPts[0] = pts[0]; + aNewPts[1] = pts[6]; + aNewPts[2] = pts[1]; + aNewPts[3] = pts[7]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[8]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); //--------------------------------------------------------------- //Face 2 aNewPts[0] = pts[3]; - aNewPts[1] = pts[9]; - aNewPts[2] = pts[4]; - aNewPts[3] = pts[10]; - aNewPts[4] = pts[5]; - aNewPts[5] = pts[11]; + aNewPts[1] = pts[9]; + aNewPts[2] = pts[4]; + aNewPts[3] = pts[10]; + aNewPts[4] = pts[5]; + aNewPts[5] = pts[11]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); //--------------------------------------------------------------- //Face 3 numFacePts = 8; aNewPts[0] = pts[0]; - aNewPts[1] = pts[8]; - aNewPts[2] = pts[2]; - aNewPts[3] = pts[14]; - aNewPts[4] = pts[5]; - aNewPts[5] = pts[11]; - aNewPts[6] = pts[3]; - aNewPts[7] = pts[12]; + aNewPts[1] = pts[8]; + aNewPts[2] = pts[2]; + aNewPts[3] = pts[14]; + aNewPts[4] = pts[5]; + aNewPts[5] = pts[11]; + aNewPts[6] = pts[3]; + aNewPts[7] = pts[12]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); //--------------------------------------------------------------- //Face 4 aNewPts[0] = pts[1]; - aNewPts[1] = pts[13]; - aNewPts[2] = pts[4]; - aNewPts[3] = pts[10]; - aNewPts[4] = pts[5]; - aNewPts[5] = pts[14]; - aNewPts[6] = pts[2]; - aNewPts[7] = pts[7]; + aNewPts[1] = pts[13]; + aNewPts[2] = pts[4]; + aNewPts[3] = pts[10]; + aNewPts[4] = pts[5]; + aNewPts[5] = pts[14]; + aNewPts[6] = pts[2]; + aNewPts[7] = pts[7]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,newCellId); //--------------------------------------------------------------- //Face 5 aNewPts[0] = pts[0]; - aNewPts[1] = pts[12]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[9]; - aNewPts[4] = pts[4]; - aNewPts[5] = pts[13]; + aNewPts[1] = pts[12]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[9]; + aNewPts[4] = pts[4]; + aNewPts[5] = pts[13]; aNewPts[6] = pts[1]; aNewPts[7] = pts[6]; newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); + break; + } + case VTK_QUADRATIC_HEXAHEDRON: { + aCellType = VTK_POLYGON; + numFacePts = 8; + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[8]; + aNewPts[2] = pts[1]; + aNewPts[3] = pts[17]; + aNewPts[4] = pts[5]; + aNewPts[5] = pts[12]; + aNewPts[6] = pts[4]; + aNewPts[7] = pts[16]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[1]; + aNewPts[1] = pts[9]; + aNewPts[2] = pts[2]; + aNewPts[3] = pts[18]; + aNewPts[4] = pts[6]; + aNewPts[5] = pts[13]; + aNewPts[6] = pts[5]; + aNewPts[7] = pts[17]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[2]; + aNewPts[1] = pts[10]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[19]; + aNewPts[4] = pts[7]; + aNewPts[5] = pts[14]; + aNewPts[6] = pts[6]; + aNewPts[7] = pts[18]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[3]; + aNewPts[1] = pts[11]; + aNewPts[2] = pts[0]; + aNewPts[3] = pts[16]; + aNewPts[4] = pts[4]; + aNewPts[5] = pts[15]; + aNewPts[6] = pts[7]; + aNewPts[7] = pts[19]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[8]; + aNewPts[2] = pts[1]; + aNewPts[3] = pts[9]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[10]; + aNewPts[6] = pts[3]; + aNewPts[7] = pts[11]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[4]; + aNewPts[1] = pts[12]; + aNewPts[2] = pts[5]; + aNewPts[3] = pts[13]; + aNewPts[4] = pts[6]; + aNewPts[5] = pts[14]; + aNewPts[6] = pts[7]; + aNewPts[7] = pts[15]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + break; } - case VTK_QUADRATIC_HEXAHEDRON: { - aCellType = VTK_POLYGON; - numFacePts = 8; - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[8]; - aNewPts[2] = pts[1]; - aNewPts[3] = pts[17]; - aNewPts[4] = pts[5]; - aNewPts[5] = pts[12]; - aNewPts[6] = pts[4]; - aNewPts[7] = pts[16]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[1]; - aNewPts[1] = pts[9]; - aNewPts[2] = pts[2]; - aNewPts[3] = pts[18]; - aNewPts[4] = pts[6]; - aNewPts[5] = pts[13]; - aNewPts[6] = pts[5]; - aNewPts[7] = pts[17]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[2]; - aNewPts[1] = pts[10]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[19]; - aNewPts[4] = pts[7]; - aNewPts[5] = pts[14]; - aNewPts[6] = pts[6]; - aNewPts[7] = pts[18]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[3]; - aNewPts[1] = pts[11]; - aNewPts[2] = pts[0]; - aNewPts[3] = pts[16]; - aNewPts[4] = pts[4]; - aNewPts[5] = pts[15]; - aNewPts[6] = pts[7]; - aNewPts[7] = pts[19]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[8]; - aNewPts[2] = pts[1]; - aNewPts[3] = pts[9]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[10]; - aNewPts[6] = pts[3]; - aNewPts[7] = pts[11]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[4]; - aNewPts[1] = pts[12]; - aNewPts[2] = pts[5]; - aNewPts[3] = pts[13]; - aNewPts[4] = pts[6]; - aNewPts[5] = pts[14]; - aNewPts[6] = pts[7]; - aNewPts[7] = pts[15]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - break; - } - case VTK_QUADRATIC_PYRAMID: { - aCellType = VTK_POLYGON; - numFacePts = 6; - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[8]; - aNewPts[2] = pts[3]; - aNewPts[3] = pts[12]; - aNewPts[4] = pts[4]; - aNewPts[5] = pts[9]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[0]; - aNewPts[1] = pts[9]; - aNewPts[2] = pts[4]; - aNewPts[3] = pts[10]; - aNewPts[4] = pts[1]; - aNewPts[5] = pts[5]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[1]; - aNewPts[1] = pts[10]; - aNewPts[2] = pts[4]; - aNewPts[3] = pts[11]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[6]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- - aNewPts[0] = pts[2]; - aNewPts[1] = pts[11]; - aNewPts[2] = pts[4]; - aNewPts[3] = pts[12]; - aNewPts[4] = pts[3]; - aNewPts[5] = pts[7]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - //--------------------------------------------------------------- + case VTK_QUADRATIC_PYRAMID: { + aCellType = VTK_POLYGON; + numFacePts = 6; + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[8]; + aNewPts[2] = pts[3]; + aNewPts[3] = pts[12]; + aNewPts[4] = pts[4]; + aNewPts[5] = pts[9]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[0]; + aNewPts[1] = pts[9]; + aNewPts[2] = pts[4]; + aNewPts[3] = pts[10]; + aNewPts[4] = pts[1]; + aNewPts[5] = pts[5]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[1]; + aNewPts[1] = pts[10]; + aNewPts[2] = pts[4]; + aNewPts[3] = pts[11]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[6]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- + aNewPts[0] = pts[2]; + aNewPts[1] = pts[11]; + aNewPts[2] = pts[4]; + aNewPts[3] = pts[12]; + aNewPts[4] = pts[3]; + aNewPts[5] = pts[7]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + //--------------------------------------------------------------- numFacePts = 8; - aNewPts[0] = pts[0]; - aNewPts[1] = pts[5]; - aNewPts[2] = pts[1]; - aNewPts[3] = pts[6]; - aNewPts[4] = pts[2]; - aNewPts[5] = pts[7]; - aNewPts[6] = pts[3]; - aNewPts[7] = pts[8]; - - newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); - if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); - - outputCD->CopyData(cd,cellId,newCellId); - - break; - }} - } - } //switch + aNewPts[0] = pts[0]; + aNewPts[1] = pts[5]; + aNewPts[2] = pts[1]; + aNewPts[3] = pts[6]; + aNewPts[4] = pts[2]; + aNewPts[5] = pts[7]; + aNewPts[6] = pts[3]; + aNewPts[7] = pts[8]; + + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + + outputCD->CopyData(cd,cellId,newCellId); + + break; + }} + } + } //switch } //if visible } //for all cells @@ -1168,15 +1168,15 @@ void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId, vtkUnstructur aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2)); if(outputScalars) { - outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]); - outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]); - outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]); } aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping) - myVTK2ObjIds.push_back(cellId); + myVTK2ObjIds.push_back(cellId); outputCD->CopyData(cd,cellId,aTriangleId); } pts->Delete(); @@ -1188,7 +1188,7 @@ void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId, vtkUnstructur aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints); if(outputScalars) for(vtkIdType i = 0; i < aNbPoints; i++) - outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]); + outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]); newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints); outputCD->CopyData(cd,cellId,newCellId); diff --git a/src/VTKViewer/VTKViewer_InteractorStyle.cxx b/src/VTKViewer/VTKViewer_InteractorStyle.cxx index e69a47edf..6a11d6eda 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyle.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyle.cxx @@ -68,12 +68,12 @@ static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId) float aMinDist = 1000000.0, aDist = 0; for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){ - int subId; float pcoords[3], closestPoint[3], weights[3]; - aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); - if (aDist < aMinDist) { - aMinDist = aDist; - anEdgeId = i; - } + int subId; float pcoords[3], closestPoint[3], weights[3]; + aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); + if (aDist < aMinDist) { + aMinDist = aDist; + anEdgeId = i; + } } } } @@ -120,7 +120,7 @@ VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() *\param theWidth - width.. */ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen, - const double& theBlue, const int& theWidth) + const double& theBlue, const int& theWidth) { if ( myPreSelectionActor->GetProperty() == 0 ) return; @@ -235,9 +235,9 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) } double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]), - (double)(x - this->CurrentRenderer->GetCenter()[0])); + (double)(x - this->CurrentRenderer->GetCenter()[0])); double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]), - (double)(oldX - this->CurrentRenderer->GetCenter()[0])); + (double)(oldX - this->CurrentRenderer->GetCenter()[0])); newAngle *= this->RadianToDegree; oldAngle *= this->RadianToDegree; @@ -258,8 +258,8 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), - int shift, - int x, int y) + int shift, + int x, int y) { myShiftState = shift; if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) @@ -276,7 +276,7 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, - int x, int y) + int x, int y) { if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) { this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL); @@ -312,9 +312,9 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -332,8 +332,8 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl, - int shift, - int x, int y) + int shift, + int x, int y) { if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) { @@ -369,9 +369,9 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -389,8 +389,8 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), *\param y - y coordinate */ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl, - int shift, - int x, int y) + int shift, + int x, int y) { if (this->HasObserver(vtkCommand::RightButtonPressEvent)) { @@ -425,9 +425,9 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl, *\param y - y coordinate (not used) */ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -863,256 +863,256 @@ void VTKViewer_InteractorStyle::onFinishOperation() } else { if (myPoint == myOtherPoint) { - // process point selection + // process point selection int w, h, x, y; m_Interactor->GetSize(w, h); x = myPoint.x(); y = h - myPoint.y() - 1; this->FindPokedRenderer(x, y); - m_Interactor->StartPickCallback(); + m_Interactor->StartPickCallback(); - vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker()); + vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker()); aPicker->Pick(x, y, 0.0, this->CurrentRenderer); - SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor()); + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor()); if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) { - int aVtkId = picker->GetCellId(); - if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { - int anObjId = SActor->GetElemObjId(aVtkId); - if(anObjId >= 0){ - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(aSelectionMode != EdgeOfCellSelection) { - if(CheckDimensionId(aSelectionMode,SActor,anObjId)){ - if (IsSelected(IO,aSel)) { - // This IO is already in the selection - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - } else { - if (!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - aSel->AddIObject( IO, false ); - } - } - }else{ - if (!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - int anEdgeId = GetEdgeId(picker,SActor,anObjId); - if (anEdgeId >= 0) { - aSel->AddOrRemoveIndex( IO, anObjId, true, false); - aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true ); - aSel->AddIObject( IO, false ); - } - } - } - } else { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } + int aVtkId = picker->GetCellId(); + if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { + int anObjId = SActor->GetElemObjId(aVtkId); + if(anObjId >= 0){ + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(aSelectionMode != EdgeOfCellSelection) { + if(CheckDimensionId(aSelectionMode,SActor,anObjId)){ + if (IsSelected(IO,aSel)) { + // This IO is already in the selection + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + } else { + if (!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + aSel->AddIObject( IO, false ); + } + } + }else{ + if (!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + int anEdgeId = GetEdgeId(picker,SActor,anObjId); + if (anEdgeId >= 0) { + aSel->AddOrRemoveIndex( IO, anObjId, true, false); + aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true ); + aSel->AddIObject( IO, false ); + } + } + } + } else { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) { - int aVtkId = picker->GetPointId(); - if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { - if ( SActor && SActor->hasIO() ) { - int anObjId = SActor->GetNodeObjId(aVtkId); - if(anObjId >= 0){ - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(IsSelected(IO,aSel)) { - // This IO is already in the selection - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - } else { - if(!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); - aSel->AddIObject( IO, false ); - } - } - } - } else { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - } else { - if ( SActor && SActor->hasIO() ) { - this->PropPicked++; - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(IsSelected(IO,aSel)) { - // This IO is already in the selection - if(myShiftState) { - aSel->RemoveIObject(IO); - } - } - else { - if(!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - aSel->AddIObject( IO, false ); - } - }else{ - // No selection clear all - this->PropPicked = 0; - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - } - m_Interactor->EndPickCallback(); + int aVtkId = picker->GetPointId(); + if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { + if ( SActor && SActor->hasIO() ) { + int anObjId = SActor->GetNodeObjId(aVtkId); + if(anObjId >= 0){ + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(IsSelected(IO,aSel)) { + // This IO is already in the selection + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + } else { + if(!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false ); + aSel->AddIObject( IO, false ); + } + } + } + } else { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + } else { + if ( SActor && SActor->hasIO() ) { + this->PropPicked++; + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if(IsSelected(IO,aSel)) { + // This IO is already in the selection + if(myShiftState) { + aSel->RemoveIObject(IO); + } + } + else { + if(!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + aSel->AddIObject( IO, false ); + } + }else{ + // No selection clear all + this->PropPicked = 0; + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + } + m_Interactor->EndPickCallback(); } else { //processing rectangle selection - QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType(); - if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return; - m_Interactor->StartPickCallback(); - - if (!myShiftState) { - this->PropPicked = 0; - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - - // Compute bounds - // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); - QRect rect(myPoint, myOtherPoint); - rect = rect.normalize(); - int w, h; - m_Interactor->GetSize(w, h); - int x1, y1, x2, y2; - x1 = rect.left(); - y1 = h - rect.top() - 1; - x2 = rect.right(); - y2 = h - rect.bottom() - 1; - - switch (aSelectionMode) { - case NodeSelection: { - if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) { - vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); - aListActors->InitTraversal(); - while (vtkActor* aActor = aListActors->GetNextActor()) { - if (!aActor->GetVisibility()) - continue; - if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) { - if (SActor->hasIO()) { - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if (IO.IsNull()) - continue; - if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType()) - continue; - if (vtkDataSet* aDataSet = SActor->GetInput()) { - SALOME_Selection::TContainerOfId anIndices; - for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) { - float aPoint[3]; - aDataSet->GetPoint(i,aPoint); - if (IsInRect(aPoint,x1,y1,x2,y2)){ - float aDisp[3]; - ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp); - if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){ - if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){ - if(anActorCollection->IsItemPresent(SActor)){ - float aPickedPoint[3]; - aPointPicker->GetMapperPosition(aPickedPoint); - vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint); - if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){ - int anObjId = SActor->GetNodeObjId(aVtkId); - anIndices.insert(anObjId); - } - } - } - } - } - } - if (!anIndices.empty()) { - aSel->AddOrRemoveIndex(IO, anIndices, true, false); - aSel->AddIObject(IO, false); - anIndices.clear(); - }else{ - aSel->RemoveIObject(IO, false); - } - } - } - } - } - } - break; - } - case CellSelection: - case EdgeOfCellSelection: - case EdgeSelection: - case FaceSelection: - case VolumeSelection: - { - vtkSmartPointer picker = VTKViewer_CellRectPicker::New(); - picker->SetTolerance(0.001); - picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); - - vtkActorCollection* aListActors = picker->GetActors(); - aListActors->InitTraversal(); - while(vtkActor* aActor = aListActors->GetNextActor()) { - if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { - if (aSActor->hasIO()) { - Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); - if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType()) - continue; - VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); - if ( !cellList.empty() ) { - SALOME_Selection::TContainerOfId anIndexes; - VTKViewer_CellDataSet::iterator it; - for ( it = cellList.begin(); it != cellList.end(); ++it ) { - int aCellId = (*it).cellId; - - if ( !IsValid( aSActor, aCellId ) ) - continue; - - int anObjId = aSActor->GetElemObjId(aCellId); - if (anObjId != -1){ - if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) { - anIndexes.insert(anObjId); - } - } - } - aSel->AddOrRemoveIndex(aIO, anIndexes, true, false); - aSel->AddIObject(aIO, false); - } - } - } - } - } - break; - case ActorSelection: // objects selection - { - vtkSmartPointer picker = VTKViewer_RectPicker::New(); - picker->SetTolerance(0.001); - picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); - - vtkActorCollection* aListActors = picker->GetActors(); - SALOME_ListIO aListIO; - aListActors->InitTraversal(); - while(vtkActor* aActor = aListActors->GetNextActor()) { - if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { - if (aSActor->hasIO()) { - Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); - if (!IsStored(aIO,aListIO)) - aListIO.Append(aIO); - } - } - } - if (!aListIO.IsEmpty()) { - SALOME_ListIteratorOfListIO It(aListIO); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - this->PropPicked++; - aSel->AddIObject( IOS, false ); - } - } - } // end case 4 - } //end switch - m_Interactor->EndPickCallback(); - } - aActiveStudy->update3dViewers(); + QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType(); + if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return; + m_Interactor->StartPickCallback(); + + if (!myShiftState) { + this->PropPicked = 0; + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + + // Compute bounds + // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + QRect rect(myPoint, myOtherPoint); + rect = rect.normalize(); + int w, h; + m_Interactor->GetSize(w, h); + int x1, y1, x2, y2; + x1 = rect.left(); + y1 = h - rect.top() - 1; + x2 = rect.right(); + y2 = h - rect.bottom() - 1; + + switch (aSelectionMode) { + case NodeSelection: { + if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) { + vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); + aListActors->InitTraversal(); + while (vtkActor* aActor = aListActors->GetNextActor()) { + if (!aActor->GetVisibility()) + continue; + if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) { + if (SActor->hasIO()) { + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if (IO.IsNull()) + continue; + if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType()) + continue; + if (vtkDataSet* aDataSet = SActor->GetInput()) { + SALOME_Selection::TContainerOfId anIndices; + for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) { + float aPoint[3]; + aDataSet->GetPoint(i,aPoint); + if (IsInRect(aPoint,x1,y1,x2,y2)){ + float aDisp[3]; + ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp); + if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){ + if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){ + if(anActorCollection->IsItemPresent(SActor)){ + float aPickedPoint[3]; + aPointPicker->GetMapperPosition(aPickedPoint); + vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint); + if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){ + int anObjId = SActor->GetNodeObjId(aVtkId); + anIndices.insert(anObjId); + } + } + } + } + } + } + if (!anIndices.empty()) { + aSel->AddOrRemoveIndex(IO, anIndices, true, false); + aSel->AddIObject(IO, false); + anIndices.clear(); + }else{ + aSel->RemoveIObject(IO, false); + } + } + } + } + } + } + break; + } + case CellSelection: + case EdgeOfCellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: + { + vtkSmartPointer picker = VTKViewer_CellRectPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); + aListActors->InitTraversal(); + while(vtkActor* aActor = aListActors->GetNextActor()) { + if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType()) + continue; + VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); + if ( !cellList.empty() ) { + SALOME_Selection::TContainerOfId anIndexes; + VTKViewer_CellDataSet::iterator it; + for ( it = cellList.begin(); it != cellList.end(); ++it ) { + int aCellId = (*it).cellId; + + if ( !IsValid( aSActor, aCellId ) ) + continue; + + int anObjId = aSActor->GetElemObjId(aCellId); + if (anObjId != -1){ + if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) { + anIndexes.insert(anObjId); + } + } + } + aSel->AddOrRemoveIndex(aIO, anIndexes, true, false); + aSel->AddIObject(aIO, false); + } + } + } + } + } + break; + case ActorSelection: // objects selection + { + vtkSmartPointer picker = VTKViewer_RectPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); + SALOME_ListIO aListIO; + aListActors->InitTraversal(); + while(vtkActor* aActor = aListActors->GetNextActor()) { + if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) { + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + if (!IsStored(aIO,aListIO)) + aListIO.Append(aIO); + } + } + } + if (!aListIO.IsEmpty()) { + SALOME_ListIteratorOfListIO It(aListIO); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + this->PropPicked++; + aSel->AddIObject( IOS, false ); + } + } + } // end case 4 + } //end switch + m_Interactor->EndPickCallback(); + } + aActiveStudy->update3dViewers(); } } break; @@ -1230,36 +1230,36 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { if ( aVtkId >= 0 ) { int anObjId = SActor->GetElemObjId(aVtkId); if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) { - bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId); - bool aResult = anIsSameObjId; - if(!anIsSameObjId) { - if(aSelectionMode != EdgeOfCellSelection) { - aResult = CheckDimensionId(aSelectionMode,SActor,anObjId); - if(aResult){ - mySelectedActor = SActor; - myElemId = anObjId; - m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor); - } - } - } - if(aSelectionMode == EdgeOfCellSelection){ - int anEdgeId = GetEdgeId(picker,SActor,anObjId); - bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId; - aResult = anIsSameEdgeId; - if(!anIsSameEdgeId) { - aResult = (anEdgeId >= 0); - if (aResult) { - mySelectedActor = SActor; - myEdgeId = anEdgeId; - myElemId = anObjId; - m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor); - } - } - } - if(aResult) { - myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); - myPreSelectionActor->SetVisibility(true); - } + bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId); + bool aResult = anIsSameObjId; + if(!anIsSameObjId) { + if(aSelectionMode != EdgeOfCellSelection) { + aResult = CheckDimensionId(aSelectionMode,SActor,anObjId); + if(aResult){ + mySelectedActor = SActor; + myElemId = anObjId; + m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor); + } + } + } + if(aSelectionMode == EdgeOfCellSelection){ + int anEdgeId = GetEdgeId(picker,SActor,anObjId); + bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId; + aResult = anIsSameEdgeId; + if(!anIsSameEdgeId) { + aResult = (anEdgeId >= 0); + if (aResult) { + mySelectedActor = SActor; + myEdgeId = anEdgeId; + myElemId = anObjId; + m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor); + } + } + } + if(aResult) { + myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); + myPreSelectionActor->SetVisibility(true); + } } } } @@ -1267,44 +1267,44 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) { int aVtkId = picker->GetPointId(); if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) { if ( SActor && SActor->hasIO() ) { - int anObjId = SActor->GetNodeObjId(aVtkId); - bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId); - if(!anIsSameObjId) { - mySelectedActor = SActor; - myNodeId = anObjId; - m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor); - } - myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); - myPreSelectionActor->SetVisibility(true); + int anObjId = SActor->GetNodeObjId(aVtkId); + bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId); + if(!anIsSameObjId) { + mySelectedActor = SActor; + myNodeId = anObjId; + m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor); + } + myPreSelectionActor->GetProperty()->SetRepresentationToSurface(); + myPreSelectionActor->SetVisibility(true); } } } else if ( vtkPicker::SafeDownCast(aPicker) ) { if ( SActor ) { if ( myPreViewActor != SActor ) { - if ( myPreViewActor != NULL ) { - myPreViewActor->SetPreSelected( false ); - } - myPreViewActor = SActor; - - if ( SActor->hasIO() ) { - Handle( SALOME_InteractiveObject) IO = SActor->getIO(); - if ( !IsSelected(IO,Sel) ) { + if ( myPreViewActor != NULL ) { + myPreViewActor->SetPreSelected( false ); + } + myPreViewActor = SActor; + + if ( SActor->hasIO() ) { + Handle( SALOME_InteractiveObject) IO = SActor->getIO(); + if ( !IsSelected(IO,Sel) ) { // Find All actors with same IO - vtkActorCollection* theActors = this->CurrentRenderer->GetActors(); - theActors->InitTraversal(); - while( vtkActor *ac = theActors->GetNextActor() ) { - if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) { - if ( anActor->hasIO() ) { - Handle(SALOME_InteractiveObject) IOS = anActor->getIO(); - if(IO->isSame(IOS)) { - anActor->SetPreSelected( true ); - } - } - } - } - } - } + vtkActorCollection* theActors = this->CurrentRenderer->GetActors(); + theActors->InitTraversal(); + while( vtkActor *ac = theActors->GetNextActor() ) { + if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) { + if ( anActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IOS = anActor->getIO(); + if(IO->isSame(IOS)) { + anActor->SetPreSelected( true ); + } + } + } + } + } + } } } else { myPreViewActor = NULL; @@ -1359,13 +1359,13 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f cam->GetFocalPoint(viewFocus); this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], - viewFocus[2], viewFocus); + viewFocus[2], viewFocus); focalDepth = viewFocus[2]; this->ComputeDisplayToWorld(vtkFloatingPointType(toX), vtkFloatingPointType(toY), - focalDepth, newPickPoint); + focalDepth, newPickPoint); this->ComputeDisplayToWorld(vtkFloatingPointType(fromX),vtkFloatingPointType(fromY), - focalDepth, oldPickPoint); + focalDepth, oldPickPoint); // camera motion is reversed motionVector[0] = oldPickPoint[0] - newPickPoint[0]; @@ -1375,18 +1375,18 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f cam->GetFocalPoint(viewFocus); cam->GetPosition(viewPoint); cam->SetFocalPoint(motionVector[0] + viewFocus[0], - motionVector[1] + viewFocus[1], - motionVector[2] + viewFocus[2]); + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2]); cam->SetPosition(motionVector[0] + viewPoint[0], - motionVector[1] + viewPoint[1], - motionVector[2] + viewPoint[2]); + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2]); } /*! Checks: is the given Actor within display coordinates?*/ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor, - const int left, const int top, - const int right, const int bottom) + const int left, const int top, + const int right, const int bottom) { vtkFloatingPointType* aBounds = theActor->GetBounds(); vtkFloatingPointType aMin[3], aMax[3]; @@ -1409,8 +1409,8 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor, /*! Checks: is the given Cell within display coordinates?*/ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell, - const int left, const int top, - const int right, const int bottom) + const int left, const int top, + const int right, const int bottom) { vtkFloatingPointType* aBounds = theCell->GetBounds(); vtkFloatingPointType aMin[3], aMax[3]; @@ -1432,8 +1432,8 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell, /*!Checks: is given point \a thePoint in rectangle*/ bool VTKViewer_InteractorStyle::IsInRect(vtkFloatingPointType* thePoint, - const int left, const int top, - const int right, const int bottom) + const int left, const int top, + const int right, const int bottom) { vtkFloatingPointType aPnt[3]; ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt); diff --git a/src/VTKViewer/VTKViewer_InteractorStyle.h b/src/VTKViewer/VTKViewer_InteractorStyle.h index a3e36e097..f7391b19c 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyle.h +++ b/src/VTKViewer/VTKViewer_InteractorStyle.h @@ -78,7 +78,7 @@ class VTKVIEWER_EXPORT VTKViewer_InteractorStyle : public QObject, public vtkInt void setTriedron(VTKViewer_Trihedron* theTrihedron); void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1, - const double& theBlue = 1, const int& theWidth = 5); + const double& theBlue = 1, const int& theWidth = 5); // Generic event bindings must be overridden in subclasses void OnMouseMove (int ctrl, int shift, int x, int y); @@ -121,14 +121,14 @@ class VTKVIEWER_EXPORT VTKViewer_InteractorStyle : public QObject, public vtkInt void Place(const int theX, const int theY); void TranslateView(int toX, int toY, int fromX, int fromY); bool IsInRect(vtkActor* theActor, - const int left, const int top, - const int right, const int bottom); + const int left, const int top, + const int right, const int bottom); bool IsInRect(vtkCell* theCell, - const int left, const int top, - const int right, const int bottom); + const int left, const int top, + const int right, const int bottom); bool IsInRect(vtkFloatingPointType* thePoint, - const int left, const int top, - const int right, const int bottom); + const int left, const int top, + const int right, const int bottom); int State; vtkFloatingPointType MotionFactor; diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index e3039a3a4..62ad380d2 100755 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -150,7 +150,7 @@ void VTKViewer_RenderWindow::onChangeBackgroundColor() vtkRenderer * theRenderer = theRenderers->GetNextItem(); theRenderer->GetBackground(backint); - QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); + QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); if ( selColor.isValid() ) { theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. ); /* VSR : PAL5420 --------------------------------------------------- diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 4bb2dfab7..8e6a7faef 100755 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -391,8 +391,8 @@ void VTKViewer_RenderWindowInteractor::LeftButtonPressed(const QMouseEvent *even return ; } myInteractorStyle->OnLeftButtonDown((event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y()); + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y()); } /*!Reaction on left button releases.\n @@ -404,8 +404,8 @@ void VTKViewer_RenderWindowInteractor::LeftButtonReleased(const QMouseEvent *eve return ; } myInteractorStyle->OnLeftButtonUp( (event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y() ) ; + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y() ) ; } /*!Reaction on middle button pressed.\n @@ -417,8 +417,8 @@ void VTKViewer_RenderWindowInteractor::MiddleButtonPressed(const QMouseEvent *ev return ; } myInteractorStyle->OnMiddleButtonDown((event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y() ) ; + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y() ) ; } /*!Reaction on middle button released.\n @@ -430,8 +430,8 @@ void VTKViewer_RenderWindowInteractor::MiddleButtonReleased(const QMouseEvent *e return ; } myInteractorStyle->OnMiddleButtonUp( (event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y() ) ; + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y() ) ; } /*!Reaction on right button pressed.\n @@ -443,8 +443,8 @@ void VTKViewer_RenderWindowInteractor::RightButtonPressed(const QMouseEvent *eve return ; } myInteractorStyle->OnRightButtonDown( (event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y() ) ; + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y() ) ; } /*!Reaction on right button released.\n @@ -457,8 +457,8 @@ void VTKViewer_RenderWindowInteractor::RightButtonReleased(const QMouseEvent *ev } bool isOperation = myInteractorStyle->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE; myInteractorStyle->OnRightButtonUp( (event->modifiers() & Qt::ControlModifier), - (event->modifiers() & Qt::ShiftModifier), - event->x(), event->y() ); + (event->modifiers() & Qt::ShiftModifier), + event->x(), event->y() ); if ( !isOperation ) { QContextMenuEvent aEvent( QContextMenuEvent::Mouse, @@ -518,8 +518,8 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorC { using namespace VTK; ForEach(theCollection, - TSetFunction - (&VTKViewer_Actor::setDisplayMode,0)); + TSetFunction + (&VTKViewer_Actor::setDisplayMode,0)); emit RenderWindowModified(); } @@ -530,8 +530,8 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCol { using namespace VTK; ForEach(theCollection, - TSetFunction - (&VTKViewer_Actor::setDisplayMode,1)); + TSetFunction + (&VTKViewer_Actor::setDisplayMode,1)); emit RenderWindowModified(); } @@ -664,8 +664,8 @@ bool VTKViewer_RenderWindowInteractor::unHighlightAll(){ * \li Emit render window modified, if flag \a update - true. */ bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex, - VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, - TUpdateActor theFun, bool hilight, bool update) + VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, + TUpdateActor theFun, bool hilight, bool update) { if(theMapIndex.Extent() == 0) return false; @@ -687,9 +687,9 @@ bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteg /*!Sets actors data.*/ void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex, - VTKViewer_Actor * theMapActor, - VTKViewer_Actor * theActor, - TUpdateActor theFun) + VTKViewer_Actor * theMapActor, + VTKViewer_Actor * theActor, + TUpdateActor theFun) { (*theFun)(theMapIndex,theMapActor,theActor); vtkFloatingPointType aPos[3]; diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h index 3edf9c8e3..18d58645c 100755 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -104,24 +104,24 @@ public: /** @name Selection Management */ //@{ bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex, - VTKViewer_Actor* theMapActor, - bool hilight, - bool update = true ); + VTKViewer_Actor* theMapActor, + bool hilight, + bool update = true ); bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex, - VTKViewer_Actor* theMapActor, - bool hilight, - bool update = true ); + VTKViewer_Actor* theMapActor, + bool hilight, + bool update = true ); bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex, - VTKViewer_Actor* theMapActor, - bool hilight, - bool update = true ); + VTKViewer_Actor* theMapActor, + bool hilight, + bool update = true ); void unHighlightSubSelection(); bool unHighlightAll(); //void SetSelectionMode(Selection_Mode mode); void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1, - const double& theBlue = 0, const int& theWidth = 5); + const double& theBlue = 0, const int& theWidth = 5); void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001); //@} @@ -161,19 +161,19 @@ public: void setViewWindow( VTKViewer_ViewWindow* theViewWnd ); void setCellData(const int& theIndex, - VTKViewer_Actor* theMapActor, - VTKViewer_Actor* theActor) {} + VTKViewer_Actor* theMapActor, + VTKViewer_Actor* theActor) {} void setEdgeData(const int& theCellIndex, - VTKViewer_Actor* theMapActor, - const int& theEdgeIndex, - VTKViewer_Actor* theActor ) {} //NB + VTKViewer_Actor* theMapActor, + const int& theEdgeIndex, + VTKViewer_Actor* theActor ) {} //NB void setPointData(const int& theIndex, - VTKViewer_Actor* theMapActor, - VTKViewer_Actor* theActor) {} + VTKViewer_Actor* theMapActor, + VTKViewer_Actor* theActor) {} typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex, - VTKViewer_Actor* theMapActor, - VTKViewer_Actor* theActor); + VTKViewer_Actor* theMapActor, + VTKViewer_Actor* theActor); protected: VTKViewer_RenderWindowInteractor(); @@ -182,12 +182,12 @@ public: VTKViewer_InteractorStyle* myInteractorStyle; bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex, - VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, - TUpdateActor theFun, bool hilight, bool update); + VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, + TUpdateActor theFun, bool hilight, bool update); void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex, - VTKViewer_Actor* theMapActor, - VTKViewer_Actor *theActor, - TUpdateActor theFun); + VTKViewer_Actor* theMapActor, + VTKViewer_Actor *theActor, + TUpdateActor theFun); /*! Timer used during various mouse events to figure * out mouse movements. diff --git a/src/VTKViewer/VTKViewer_ShrinkFilter.cxx b/src/VTKViewer/VTKViewer_ShrinkFilter.cxx index 0084d939d..8abd09202 100755 --- a/src/VTKViewer/VTKViewer_ShrinkFilter.cxx +++ b/src/VTKViewer/VTKViewer_ShrinkFilter.cxx @@ -148,7 +148,7 @@ int VTKViewer_ShrinkFilter::RequestData( oldId = ptIds->GetId(i); newId = newPts->InsertNextPoint(pt); if(myStoreMapping) - myVTK2ObjIds.push_back(oldId); + myVTK2ObjIds.push_back(oldId); newPtIds->InsertId(i,newId); outPD->CopyData(pd, oldId, newId); diff --git a/src/VTKViewer/VTKViewer_Transform.cxx b/src/VTKViewer/VTKViewer_Transform.cxx index 7b2f92767..2385a2309 100755 --- a/src/VTKViewer/VTKViewer_Transform.cxx +++ b/src/VTKViewer/VTKViewer_Transform.cxx @@ -61,6 +61,6 @@ int VTKViewer_Transform::IsIdentity(){ double aScale[3]; this->GetMatrixScale(aScale); return (fabs(aScale[0] - 1.0) < EPS && - fabs(aScale[1] - 1.0) < EPS && - fabs(aScale[2] - 1.0) < EPS); + fabs(aScale[1] - 1.0) < EPS && + fabs(aScale[2] - 1.0) < EPS); } diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index f847ad91b..b0a608231 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -24,6 +24,7 @@ #include "VTKViewer_Algorithm.h" // VTK Includes +#include #include #include #include @@ -36,7 +37,11 @@ #include #include #include +#include #include +#include +#include +#include // QT includes #include @@ -78,8 +83,8 @@ void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer) theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]); theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]); vtkFloatingPointType aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+ - (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+ - (P[1][2]-P[0][2])*(P[1][2]-P[0][2])); + (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+ + (P[1][2]-P[0][2])*(P[1][2]-P[0][2])); int* aSize = theRenderer->GetRenderWindow()->GetSize(); vtkFloatingPointType aWinDiag = sqrt(vtkFloatingPointType(aSize[0]*aSize[0]+aSize[1]*aSize[1])); vtkDataSet* aDataSet = GetMapper()->GetInput(); @@ -101,16 +106,22 @@ void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer) vtkStandardNewMacro(VTKViewer_LineActor); +#ifdef IPAL21440 +vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,vtkTextActor); +#else vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,VTKViewer_UnScaledActor); +#endif vtkCxxSetObjectMacro(VTKViewer_LineActor,ArrowActor,vtkFollower); /*!Adds Label and Arrow actors to \a theRenderer.*/ void VTKViewer_LineActor::Render(vtkRenderer *theRenderer) { +#ifndef IPAL21440 if(LabelActor && LabelActor->GetVisibility()){ LabelActor->Modified(); LabelActor->Render(theRenderer); } +#endif if(ArrowActor && ArrowActor->GetVisibility()){ ArrowActor->Modified(); ArrowActor->Render(theRenderer); @@ -152,6 +163,18 @@ VTKViewer_Axis::VTKViewer_Axis() myLineActor->SetArrowActor(myArrowActor); /*! \li Initialize the Label pipe-line representation */ +#ifdef IPAL21440 + myTextMapper = vtkTextMapper::New(); + + myLabelActor = vtkTextActor::New(); + myLabelActor->SetMapper(myTextMapper); + myLabelActor->ScaledTextOff(); + myLabelActor->PickableOff(); + + vtkCoordinate* aCoord = vtkCoordinate::New(); + myLabelActor->GetPositionCoordinate()->SetReferenceCoordinate( aCoord ); + aCoord->Delete(); +#else myVectorText = vtkVectorText::New(); myMapper[2] = vtkPolyDataMapper::New(); @@ -163,6 +186,7 @@ VTKViewer_Axis::VTKViewer_Axis() myLabelActor->SetSize(aLabelActorSize); myLabelActor->PickableOff(); //myLabelActor->DebugOn(); +#endif myLineActor->SetLabelActor(myLabelActor); @@ -181,8 +205,6 @@ VTKViewer_Axis::~VTKViewer_Axis() myMapper[0]->RemoveAllInputs(); myMapper[0]->Delete(); - myVectorText->Delete(); - /*! \li Destroy of the Arrow pipe-line representation */ myArrowActor->Delete(); @@ -194,8 +216,15 @@ VTKViewer_Axis::~VTKViewer_Axis() /*! \li Destroy of the Line pipe-line representation */ myLineActor->Delete(); +#ifdef IPAL21440 + myTextMapper->RemoveAllInputs(); + myTextMapper->Delete(); +#else + myVectorText->Delete(); + myMapper[2]->RemoveAllInputs(); myMapper[2]->Delete(); +#endif myLineSource->Delete(); } @@ -244,15 +273,36 @@ void VTKViewer_Axis::SetVisibility(VTKViewer_Trihedron::TVisibility theVis) /*! Set camera for myLabelActor */ void VTKViewer_Axis::SetCamera(vtkCamera* theCamera){ +#ifndef IPAL21440 myLabelActor->SetCamera(theCamera); +#endif } -/*! Sets \a theProperty for actors: myLineActor,myLabelActor,myArrowActor +/*! Sets color for actors: myLineActor,myLabelActor,myArrowActor */ -void VTKViewer_Axis::SetProperty(vtkProperty* theProperty){ - myLabelActor->SetProperty(theProperty); - myArrowActor->SetProperty(theProperty); - myLineActor->SetProperty(theProperty); +void VTKViewer_Axis::SetColor(double theRed, double theGreen, double theBlue) +{ + // Set color property for arrow and line actors + vtkProperty* aProperty = vtkProperty::New(); + aProperty->SetColor(theRed, theGreen, theBlue); + + myArrowActor->SetProperty(aProperty); + myLineActor->SetProperty(aProperty); +#ifndef IPAL21440 + myLabelActor->SetProperty(aProperty); +#endif + + aProperty->Delete(); + + // Set color property for label actor +#ifdef IPAL21440 + vtkTextProperty* aTextProperty = vtkTextProperty::New(); + aTextProperty->SetColor(theRed, theGreen, theBlue); + + myLabelActor->SetTextProperty(aTextProperty); + + aTextProperty->Delete(); +#endif } /*! Set size of VTKViewer_Axis @@ -270,8 +320,13 @@ void VTKViewer_Axis::SetSize(vtkFloatingPointType theSize) myArrowActor->SetOrientation(myRot); myArrowActor->SetScale(theSize / 10.); +#ifdef IPAL21440 + if( vtkCoordinate* aCoord = myLabelActor->GetPositionCoordinate()->GetReferenceCoordinate() ) + aCoord->SetValue( aPosition ); +#else myLabelActor->SetPosition(0.0,0.0,0.0); myLabelActor->AddPosition(aPosition); +#endif } /*! Check if actor belongs to the axis object @@ -282,7 +337,11 @@ bool VTKViewer_Axis::OwnActor(const vtkActor* theActor) { return theActor == myLineActor || theActor == myArrowActor || +#ifdef IPAL21440 + false; +#else theActor == myLabelActor; +#endif } /*! \class VTKViewer_XAxis @@ -304,11 +363,12 @@ vtkStandardNewMacro(VTKViewer_XAxis); VTKViewer_XAxis::VTKViewer_XAxis(){ myDir[0] = 1.0; myDir[1] = 0.0; myDir[2] = 0.0; myRot[0] = 0.0; myRot[1] = 0.0; myRot[2] = 0.0; +#ifdef IPAL21440 + myTextMapper->SetInput("X"); +#else myVectorText->SetText("X"); - vtkProperty* aProperty = vtkProperty::New(); - aProperty->SetColor(1.0,0.0,0.0); - SetProperty(aProperty); - aProperty->Delete(); +#endif + SetColor(1.0,0.0,0.0); } /*! \class VTKViewer_YAxis @@ -330,11 +390,12 @@ VTKViewer_YAxis::VTKViewer_YAxis() { myDir[0] = 0.0; myDir[1] = 1.0; myDir[2] = 0.0; myRot[0] = 0.0; myRot[1] = 0.0; myRot[2] = 90.; +#ifdef IPAL21440 + myTextMapper->SetInput("Y"); +#else myVectorText->SetText("Y"); - vtkProperty* aProperty = vtkProperty::New(); - aProperty->SetColor(0.0,1.0,0.0); - SetProperty(aProperty); - aProperty->Delete(); +#endif + SetColor(0.0,1.0,0.0); } /*! \class VTKViewer_ZAxis @@ -357,11 +418,12 @@ VTKViewer_ZAxis::VTKViewer_ZAxis() { myDir[0] = 0.0; myDir[1] = 0.0; myDir[2] = 1.0; myRot[0] = 0.0; myRot[1] = -90; myRot[2] = 0.0; +#ifdef IPAL21440 + myTextMapper->SetInput("Z"); +#else myVectorText->SetText("Z"); - vtkProperty* aProperty = vtkProperty::New(); - aProperty->SetColor(0.0,0.0,1.0); - SetProperty(aProperty); - aProperty->Delete(); +#endif + SetColor(0.0,0.0,1.0); } vtkStandardNewMacro(VTKViewer_Trihedron); @@ -451,16 +513,17 @@ int VTKViewer_Trihedron::GetVisibleActorCount(vtkRenderer* theRenderer) aCollection->InitTraversal(); int aCount = 0; while(vtkActor* prop = aCollection->GetNextActor()) { - if( prop->GetVisibility()) + if( prop->GetVisibility()) { if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop)) { if(!anActor->IsInfinitive()) - aCount++; + aCount++; } else if ( !OwnActor( anActor ) ) { - aCount++; + aCount++; } //int aCount = theRenderer->VisibleActorCount(); //SetVisibility(aVis); + } } return aCount; } diff --git a/src/VTKViewer/VTKViewer_Trihedron.h b/src/VTKViewer/VTKViewer_Trihedron.h index f1bf77d3e..dab330e61 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.h +++ b/src/VTKViewer/VTKViewer_Trihedron.h @@ -35,9 +35,22 @@ class vtkPolyDataMapper; class vtkLineSource; class vtkConeSource; class vtkVectorText; +class vtkTextActor; +class vtkTextMapper; class VTKViewer_Axis; +#if !defined(VTK_XVERSION) +#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION) +#endif + +// VTKViewer_UnScaledActor is temporarily replaced with simple vtkTextActor +// This workaround caused by the bug with disappeared labels of the trihedron +// reproduced after migration from qt-4.4.3 to qt-4.5.2 +#if (VTK_XVERSION < 0x050200) +#define IPAL21440 +#endif + /*! \class vtkFollower * See vtk documentation */ @@ -81,10 +94,17 @@ public: /*!Create new instance of VTKViewer_LineActor.*/ static VTKViewer_LineActor *New(); - /*! Sets Lable actor. +#ifdef IPAL21440 + /*! Sets Label actor. + * \param theLabelActor - vtkTextActor + */ + void SetLabelActor(vtkTextActor* theLabelActor); +#else + /*! Sets Label actor. * \param theLabelActor - VTKViewer_UnScaledActor */ void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor); +#endif /*! Sets Arrow actor. * \param theLabelActor - VTKViewer_UnScaledActor @@ -108,7 +128,11 @@ protected: } /*!Label actor pointer*/ +#ifdef IPAL21440 + vtkTextActor* LabelActor; +#else VTKViewer_UnScaledActor* LabelActor; +#endif /*!Arrow actor pointer*/ vtkFollower* ArrowActor; @@ -226,9 +250,12 @@ public: */ virtual void SetCamera(vtkCamera* theCamera); - /*! Sets \a theProperty for actors: myLineActor,myLabelActor,myArrowActor + /*! Sets color for actors: myLineActor,myLabelActor,myArrowActor + * \param theRed - red component of the color + * \param theGreen - green component of the color + * \param theBlue - blue component of the color */ - virtual void SetProperty(vtkProperty* theProperty); + virtual void SetColor(double theRed, double theGreen, double theBlue); /*! Set size of VTKViewer_Axis */ @@ -237,7 +264,11 @@ public: /*! Get label actor. * \retval Return myLabelActor. */ +#ifdef IPAL21440 + virtual vtkTextActor* GetLabel() { return myLabelActor; } +#else virtual VTKViewer_UnScaledActor* GetLabel() { return myLabelActor; } +#endif /*! Get arrow actor. * \retval Return myArrowActor @@ -273,7 +304,11 @@ protected: /*! VTKViewer_UnScaledActor actor pointer */ +#ifdef IPAL21440 + vtkTextActor *myLabelActor; +#else VTKViewer_UnScaledActor *myLabelActor; +#endif /*! \li myMapper[0] - for the Line pipe-line representation * \li myMapper[1] - for the Arrow pipe-line representation @@ -289,9 +324,15 @@ protected: */ vtkConeSource *myConeSource; +#ifdef IPAL21440 + /*! vtkTextMapper pointer (Label) + */ + vtkTextMapper *myTextMapper; +#else /*! VTKViewer_VectorText pointer (Label) */ vtkVectorText* myVectorText; +#endif }; #endif diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index 3714c74aa..01e6e4ebe 100755 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -36,7 +36,7 @@ using namespace std; /*!@see vtkRenderer::ResetCamera(vtkFloatingPointType bounds[6]) method*/ void ResetCamera(vtkRenderer* theRenderer, - int theUsingZeroFocalPoint) + int theUsingZeroFocalPoint) { if(!theRenderer) return; @@ -60,8 +60,8 @@ ResetCamera(vtkRenderer* theRenderer, vtkFloatingPointType aWidth = sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) + - (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) + - (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4])); + (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) + + (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4])); if(aWidth < MIN_DISTANCE) return; @@ -88,8 +88,8 @@ ResetCamera(vtkRenderer* theRenderer, // update the camera aCamera->SetPosition(aCenter[0]+aDistance*aViewPlaneNormal[0], - aCenter[1]+aDistance*aViewPlaneNormal[1], - aCenter[2]+aDistance*aViewPlaneNormal[2]); + aCenter[1]+aDistance*aViewPlaneNormal[1], + aCenter[2]+aDistance*aViewPlaneNormal[2]); // find size of the window int* aWinSize = theRenderer->GetSize(); @@ -108,7 +108,7 @@ ResetCamera(vtkRenderer* theRenderer, /*! Compute the bounds of the visible props*/ int ComputeVisiblePropBounds(vtkRenderer* theRenderer, - vtkFloatingPointType theBounds[6]) + vtkFloatingPointType theBounds[6]) { int aCount = 0; @@ -124,25 +124,25 @@ ComputeVisiblePropBounds(vtkRenderer* theRenderer, if(aProp->GetVisibility() && aProp->GetMapper() && vtkMath::AreBoundsInitialized(aProp->GetBounds())){ if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(aProp)) if(anActor->IsInfinitive()) - continue; - + continue; + vtkFloatingPointType *aBounds = aProp->GetBounds(); static vtkFloatingPointType MAX_DISTANCE = 0.9*VTK_LARGE_FLOAT; // make sure we haven't got bogus bounds if ( aBounds != NULL && - aBounds[0] > -MAX_DISTANCE && aBounds[1] < MAX_DISTANCE && - aBounds[2] > -MAX_DISTANCE && aBounds[3] < MAX_DISTANCE && - aBounds[4] > -MAX_DISTANCE && aBounds[5] < MAX_DISTANCE ) + aBounds[0] > -MAX_DISTANCE && aBounds[1] < MAX_DISTANCE && + aBounds[2] > -MAX_DISTANCE && aBounds[3] < MAX_DISTANCE && + aBounds[4] > -MAX_DISTANCE && aBounds[5] < MAX_DISTANCE ) { - aCount++; + aCount++; - theBounds[0] = min(aBounds[0],theBounds[0]); - theBounds[2] = min(aBounds[2],theBounds[2]); - theBounds[4] = min(aBounds[4],theBounds[4]); + theBounds[0] = min(aBounds[0],theBounds[0]); + theBounds[2] = min(aBounds[2],theBounds[2]); + theBounds[4] = min(aBounds[4],theBounds[4]); - theBounds[1] = max(aBounds[1],theBounds[1]); - theBounds[3] = max(aBounds[3],theBounds[3]); - theBounds[5] = max(aBounds[5],theBounds[5]); + theBounds[1] = max(aBounds[1],theBounds[1]); + theBounds[3] = max(aBounds[3],theBounds[3]); + theBounds[5] = max(aBounds[5],theBounds[5]); }//not bogus } @@ -194,9 +194,9 @@ ResetCameraClippingRange(vtkRenderer* theRenderer) /*!Compute trihedron size.*/ bool ComputeTrihedronSize( vtkRenderer* theRenderer, - vtkFloatingPointType& theNewSize, - const vtkFloatingPointType theSize, - const vtkFloatingPointType theSizeInPercents ) + vtkFloatingPointType& theNewSize, + const vtkFloatingPointType theSize, + const vtkFloatingPointType theSizeInPercents ) { // calculating diagonal of visible props of the renderer vtkFloatingPointType bnd[ 6 ]; @@ -238,11 +238,11 @@ bool IsBBEmpty(vtkRenderer* theRenderer) if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(anAct)) if(anActor->GetVisibility() && !anActor->IsInfinitive()) { - vtkFloatingPointType *aBounds = anActor->GetBounds(); - if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT && - aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT && - aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT) - isAny = true; + vtkFloatingPointType *aBounds = anActor->GetBounds(); + if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT && + aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT && + aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT) + isAny = true; } return !isAny; @@ -271,19 +271,19 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3] { if(anActor->GetVisibility() && !anActor->IsInfinitive()) { - vtkFloatingPointType *aBounds = anActor->GetBounds(); - if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT && - aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT && - aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT) - { - for(int i = 0; i < 5; i = i + 2){ - if(aBounds[i] < aNewBndBox[i]) - aNewBndBox[i] = aBounds[i]; - if(aBounds[i+1] > aNewBndBox[i+1]) - aNewBndBox[i+1] = aBounds[i+1]; - } - isAny = true; - } + vtkFloatingPointType *aBounds = anActor->GetBounds(); + if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT && + aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT && + aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT) + { + for(int i = 0; i < 5; i = i + 2){ + if(aBounds[i] < aNewBndBox[i]) + aNewBndBox[i] = aBounds[i]; + if(aBounds[i+1] > aNewBndBox[i+1]) + aNewBndBox[i+1] = aBounds[i+1]; + } + isAny = true; + } } } } @@ -309,8 +309,8 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3] vtkFloatingPointType aWidth = sqrt((aNewBndBox[1]-aNewBndBox[0])*(aNewBndBox[1]-aNewBndBox[0]) + - (aNewBndBox[3]-aNewBndBox[2])*(aNewBndBox[3]-aNewBndBox[2]) + - (aNewBndBox[5]-aNewBndBox[4])*(aNewBndBox[5]-aNewBndBox[4])); + (aNewBndBox[3]-aNewBndBox[2])*(aNewBndBox[3]-aNewBndBox[2]) + + (aNewBndBox[5]-aNewBndBox[4])*(aNewBndBox[5]-aNewBndBox[4])); if(aWidth < MIN_DISTANCE) return false; @@ -327,7 +327,7 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3] vtkFloatingPointType aBounds[6]; int aCount = ComputeVisiblePropBounds(theRenderer,aBounds); printf("aNewBndBox[0] = %f, aNewBndBox[1] = %f,\naNewBndBox[2] = %f, aNewBndBox[3] = %f,\naNewBndBox[4] = %f, aNewBndBox[5] = %f\n", - aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]); + aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]); printf("aCount = %d\n",aCount); if(aCount){ @@ -342,8 +342,8 @@ bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3] vtkFloatingPointType aWidth = sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) + - (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) + - (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4])); + (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) + + (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4])); if(aWidth < MIN_DISTANCE) return false; diff --git a/src/VTKViewer/VTKViewer_Utilities.h b/src/VTKViewer/VTKViewer_Utilities.h index a9074da59..b52ff5cbe 100755 --- a/src/VTKViewer/VTKViewer_Utilities.h +++ b/src/VTKViewer/VTKViewer_Utilities.h @@ -30,13 +30,13 @@ VTKVIEWER_EXPORT extern void ResetCamera(vtkRenderer* theRenderer, - int theUsingZeroFocalPoint = false); + int theUsingZeroFocalPoint = false); VTKVIEWER_EXPORT extern int ComputeVisiblePropBounds(vtkRenderer* theRenderer, - vtkFloatingPointType theBounds[6]); + vtkFloatingPointType theBounds[6]); VTKVIEWER_EXPORT extern @@ -46,9 +46,9 @@ VTKVIEWER_EXPORT extern bool ComputeTrihedronSize(vtkRenderer* theRenderer, - vtkFloatingPointType& theNewSize, - const vtkFloatingPointType theSize, - const vtkFloatingPointType theSizeInPercents); + vtkFloatingPointType& theNewSize, + const vtkFloatingPointType theSize, + const vtkFloatingPointType theSizeInPercents); VTKVIEWER_EXPORT extern @@ -56,5 +56,5 @@ bool IsBBEmpty(vtkRenderer* theRenderer); VTKVIEWER_EXPORT extern bool ComputeBBCenter(vtkRenderer* theRenderer, - vtkFloatingPointType theCenter[3]); + vtkFloatingPointType theCenter[3]); #endif diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index 20185b38a..58238ca4a 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -44,8 +44,8 @@ /*! Construction*/ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, VTKViewer_Viewer* theModel, - VTKViewer_InteractorStyle* iStyle, - VTKViewer_RenderWindowInteractor* rw ) + VTKViewer_InteractorStyle* iStyle, + VTKViewer_RenderWindowInteractor* rw ) : SUIT_ViewWindow( theDesktop ) { myModel = theModel; @@ -92,6 +92,7 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, setCentralWidget( myRenderWindow ); myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this ); + myToolBar->setFloatable( false ); createActions(); createToolBar(); @@ -579,8 +580,8 @@ QString VTKViewer_ViewWindow::getVisualParameters() QString retStr; retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", - pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], - viewUp[2], parScale, scale[0], scale[1], scale[2] ); + pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], + viewUp[2], parScale, scale[0], scale[1], scale[2] ); return retStr; } diff --git a/src/VTKViewer/VTKViewer_ViewWindow.h b/src/VTKViewer/VTKViewer_ViewWindow.h index 3bceda6c5..56b139837 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.h +++ b/src/VTKViewer/VTKViewer_ViewWindow.h @@ -49,7 +49,7 @@ class VTKVIEWER_EXPORT VTKViewer_ViewWindow : public SUIT_ViewWindow public: VTKViewer_ViewWindow( SUIT_Desktop*, VTKViewer_Viewer*, VTKViewer_InteractorStyle* = 0, - VTKViewer_RenderWindowInteractor* = 0 ); + VTKViewer_RenderWindowInteractor* = 0 ); virtual ~VTKViewer_ViewWindow(); /*!Gets tool bar.*/ @@ -61,7 +61,7 @@ public: /*!Gets renderer.*/ vtkRenderer* getRenderer() { return myRenderer; } /*!Gets render window.*/ - VTKViewer_RenderWindow* getRenderWindow() { return myRenderWindow; } + VTKViewer_RenderWindow* getRenderWindow() { return myRenderWindow; } /*!Gets render window interactor.*/ VTKViewer_RenderWindowInteractor* getRWInteractor() { return myRWInteractor; } bool isTrihedronDisplayed();