GraphicsView.h
GraphicsView_Defs.h
GraphicsView_Object.h
- GraphicsView_ViewTransformer.h
+# GraphicsView_ViewTransformer.h
)
# header files / to install
GraphicsView_ViewFrame.cxx
GraphicsView_ViewManager.cxx
GraphicsView_ViewPort.cxx
- GraphicsView_ViewTransformer.cxx
+# GraphicsView_ViewTransformer.cxx
GraphicsView_Viewer.cxx
)
//================================================================
void GraphicsView_ViewFrame::onViewPan()
{
- myViewer->activateTransform( GraphicsView_Viewer::Pan );
+// myViewer->activateTransform( GraphicsView_Viewer::Pan );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewZoom()
{
- myViewer->activateTransform( GraphicsView_Viewer::Zoom );
+// myViewer->activateTransform( GraphicsView_Viewer::Zoom );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewFitAll()
{
- myViewer->activateTransform( GraphicsView_Viewer::FitAll );
+ myViewer->fitAll();
+// myViewer->activateTransform( GraphicsView_Viewer::FitAll );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewFitArea()
{
- myViewer->activateTransform( GraphicsView_Viewer::FitRect );
+ myViewer->fitArea();
+// myViewer->activateTransform( GraphicsView_Viewer::FitRect );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewFitSelect()
{
- myViewer->activateTransform( GraphicsView_Viewer::FitSelect );
+ myViewer->fitSelect();
+// myViewer->activateTransform( GraphicsView_Viewer::FitSelect );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewGlobalPan()
{
- myViewer->activateTransform( GraphicsView_Viewer::PanGlobal );
+// myViewer->activateTransform( GraphicsView_Viewer::PanGlobal );
}
//================================================================
//================================================================
void GraphicsView_ViewFrame::onViewReset()
{
- myViewer->activateTransform( GraphicsView_Viewer::Reset );
+// myViewer->activateTransform( GraphicsView_Viewer::Reset );
}
//================================================================
myRectBand = nullptr;
myRectBandStart = QPoint();
myRectBandEnd = QPoint();
+ fittingArea = false;
}
#include<iostream>
//=======================================================================
myRectBand->hide();
QRectF selectionRect = mapToScene(myRectBand->geometry()).boundingRect();
-// fitInView(selectionRect, Qt::KeepAspectRatio);
+ if (fittingArea)
+ fitInView(selectionRect, Qt::KeepAspectRatio);
+ else
+ {
QList<QGraphicsItem *> selectedItems = scene()->items(selectionRect, Qt::IntersectsItemShape);
for (QGraphicsItem *item : selectedItems)
item->setSelected(true);
+ }
+ fittingArea = false;
myRectBandStart = QPoint();
myRectBandEnd = QPoint();
delete myRectBand;
void drawSelectByRect( int x, int y );
void finishSelectByRect();
QRect selectionRect();
+ void setFitArea(bool isFitting) { fittingArea = isFitting; }
signals:
void vpMouseEvent(QMouseEvent*);
QRubberBand* myRectBand;
QPoint myRectBandStart;
QPoint myRectBandEnd;
+
+ bool fittingArea;
};
#endif
#include "GraphicsView_Scene.h"
#include "GraphicsView_ViewFrame.h"
#include "GraphicsView_ViewPort.h"
-#include "GraphicsView_ViewTransformer.h"
+//#include "GraphicsView_ViewTransformer.h"
#include <SUIT_ViewManager.h>
GraphicsView_Viewer::GraphicsView_Viewer( const QString& /*title*/, QWidget* widget )
: SUIT_ViewModel(),
mySelector( 0 ),
- myTransformer( 0 ),
+// myTransformer( 0 ),
myWidget( widget ),
myIsInitialized( false )
{
// Function : activateTransform
// Purpose :
//================================================================
+/*
void GraphicsView_Viewer::activateTransform( int theType )
{
if( theType == NoTransform ) // finish current transform
//================================================================
void GraphicsView_Viewer::onTransformationStarted()
{
-/*
+
if( GraphicsView_Selector* aSelector = getSelector() )
{
aSelector->undetectAll();
// watch events: any mouse/key event outside the
// viewport will be considered as the end of transform
-*/
+
if( myTransformer )
qApp->installEventFilter( this );
//================================================================
void GraphicsView_Viewer::onTransformationFinished()
{
-/*
+
if( GraphicsView_Selector* aSelector = getSelector() )
aSelector->lock( false ); // enable selection
-*/
+
// stop watching events
if( myTransformer )
qApp->removeEventFilter( this );
}
+*/
//================================================================
// Function : onKeyEvent
{
emit selectionChanged( GVSCS_Invalid );
}
+
+void GraphicsView_Viewer::fitAll()
+{
+ if (GraphicsView_ViewPort* aViewPort = getActiveViewPort())
+ aViewPort->fitAll();
+}
+
+void GraphicsView_Viewer::fitSelect()
+{
+ if (GraphicsView_ViewPort* aViewPort = getActiveViewPort())
+ aViewPort->fitSelect();
+}
+
+void GraphicsView_Viewer::fitArea()
+{
+ if (GraphicsView_ViewPort* aViewPort = getActiveViewPort())
+ aViewPort->setFitArea(true);
+}
class GraphicsView_Selector;
class GraphicsView_Scene;
-class GraphicsView_ViewTransformer;
+//class GraphicsView_ViewTransformer;
class GraphicsView_ViewFrame;
class GraphicsView_ViewPort;
Q_OBJECT
public:
- enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
- Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
+// enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
+// Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
public:
GraphicsView_Viewer( const QString& title, QWidget* widget = NULL );
~GraphicsView_Viewer();
GraphicsView_ViewPort* getActiveViewPort() const;
GraphicsView_Scene* getActiveScene() const;
- void activateTransform( int );
+ //void activateTransform( int );
+
+ void fitAll();
+ void fitSelect();
+ void fitArea();
bool isInitialized() const { return myIsInitialized; }
void setIsInitialized( bool );
void wheelScaleChanged();
protected:
- virtual GraphicsView_ViewTransformer* createTransformer( int );
+// virtual GraphicsView_ViewTransformer* createTransformer( int );
virtual GraphicsView_ViewFrame* createViewFrame( SUIT_Desktop* theDesktop, QWidget* theWidget );
- virtual void onTransformationStarted();
- virtual void onTransformationFinished();
+// virtual void onTransformationStarted();
+// virtual void onTransformationFinished();
protected slots:
virtual void onKeyEvent( QKeyEvent* );
protected:
GraphicsView_Selector* mySelector;
- GraphicsView_ViewTransformer* myTransformer;
+// GraphicsView_ViewTransformer* myTransformer;
QWidget* myWidget;
bool myIsInitialized;