aTransform.scale( aZoom, aZoom );
double aM11 = aTransform.m11();
double aM22 = aTransform.m22();
+
+
+ QGraphicsView::ViewportAnchor old_anchor = transformationAnchor();
+ setTransformationAnchor( QGraphicsView::AnchorUnderMouse );
+
// increasing of diagonal coefficients (>300) leads to a crash sometimes
// at the values of 100 some primitives are drawn incorrectly
if( qMax( aM11, aM22 ) < 100 )
myIsTransforming = false;
applyTransform();
+
+ setTransformationAnchor( old_anchor );
}
//================================================================
DraggingByMiddleButton = 0x0010,
ImmediateContextMenu = 0x0020,
ImmediateSelection = 0x0040,
- Sketching = 0x0080
+ Sketching = 0x0080,
+
+ GlobalWheelScaling = 0x0100
};
Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag )
#include <QKeyEvent>
#include <QMenu>
+#include <math.h>
+
// testing ImageViewer
/*
#include "GraphicsView_PrsImage.h"
{
if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
{
+ if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling ) )
+ {
+ const double d = 1.05;
+ double q = pow( d, e->delta()/120 );
+ QGraphicsView::ViewportAnchor old_anchor = aViewPort->transformationAnchor();
+ aViewPort->setTransformationAnchor( QGraphicsView::AnchorUnderMouse );
+ aViewPort->scale( q, q );
+ aViewPort->setTransformationAnchor( old_anchor );
+ }
+
if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::WheelScaling ) )
{
bool anIsScaleUp = e->delta() > 0;
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) ),
+ myIsChainedOperations( false )
{
setTitle( tr( "OCC_VIEW_TITLE" ) );
}
// if it is necessary invoke method CreatePopup of ViewPort
// be sure that existing QPopupMenu menu is used for that.
}
+
+bool OCCViewer_ViewManager::isChainedOperations() const
+{
+ return myIsChainedOperations;
+}
+
+void OCCViewer_ViewManager::setChainedOperations( bool isChainedOperations )
+{
+ myIsChainedOperations = isChainedOperations;
+}
OCCViewer_Viewer* getOCCViewer() { return (OCCViewer_Viewer*) myViewModel; }
virtual void contextMenuPopup( QMenu* );
+
+ bool isChainedOperations() const;
+ void setChainedOperations( bool );
+
+private:
+ bool myIsChainedOperations;
};
#endif
QApplication::syncX();
#endif
QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
+ emit vpResizeEvent( e );
}
/*!
void vpChangeBackground( const Qtx::BackgroundData& );
void vpClosed(OCCViewer_ViewPort3d*);
void vpMapped(OCCViewer_ViewPort3d*);
+ void vpResizeEvent( QResizeEvent* );
public slots:
virtual bool synchronize( OCCViewer_ViewPort* );
mySelectionEnabled = true;
myCursorIsHand = false;
+ myPanningByBtn = false;
clearViewAspects();
}
}
+void OCCViewer_ViewWindow::onPanning()
+{
+ myPanningByBtn = true;
+ activatePanning();
+}
+
/*!
\brief Start panning operation.
#if OCC_VERSION_LARGE <= 0x07000000
myViewPort->getView()->ZFitAll();
#endif
- resetState();
- break;
+ {
+ OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager() );
+ bool isChained = aMgr->isChainedOperations();
+ bool isReset = !( myOperation==PANVIEW && myPanningByBtn && isChained ) || theEvent->button() == Qt::RightButton;
+ if( isReset )
+ resetState();
+ break;
+ }
case PANGLOBAL:
if ( theEvent->button() == Qt::LeftButton ) {
aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onPanning()));
toolMgr()->registerAction( aAction, PanId );
// Global Panning
virtual void onRayTracing();
virtual void onEnvTexture();
virtual void onLightSource();
+ virtual void onPanning();
virtual void activateSetRotationGravity();
virtual void activateSetRotationSelected( double theX, double theY, double theZ );
Handle(V3d_Plane) myReserveClipPlane;
viewAspectList myViewAspects;
+ bool myPanningByBtn;
};
#ifdef WIN32