20 #ifndef GRAPHICSVIEW_VIEWPORT_H
21 #define GRAPHICSVIEW_VIEWPORT_H
27 #include <QGraphicsView>
28 #include <QPainterPath>
52 WheelScaling = 0x0004,
53 EditFlags = Dragging | Pulling | WheelScaling,
55 TraceBoundingRect = 0x0008,
56 DraggingByMiddleButton = 0x0010,
57 ImmediateContextMenu = 0x0020,
58 ImmediateSelection = 0x0040,
61 GlobalWheelScaling = 0x0100
87 void addItem( QGraphicsItem* theItem );
88 bool isItemAdded( QGraphicsItem* theItem );
89 void removeItem( QGraphicsItem* theItem );
95 QRectF objectsBoundingRect(
bool theOnlyVisible =
false )
const;
97 QImage dumpView(
bool theWholeScene =
false,
98 QSizeF theSize = QSizeF() );
100 bool dumpViewToFormat(
const QString& fileName,
const QString& format);
104 void setSceneGap(
double theSceneGap );
105 void setFitAllGap(
double theFitAllGap );
108 int interactionFlags()
const;
109 bool hasInteractionFlag( InteractionFlag theFlag );
110 void setInteractionFlag( InteractionFlag theFlag,
111 bool theIsEnabled =
true );
112 void setInteractionFlags( InteractionFlags theFlags );
115 void setViewLabelPosition( ViewLabelPosition thePosition,
116 bool theIsForced =
false );
117 void setViewLabelText(
const QString& theText );
120 void setMousePositionEnabled(
bool theState );
123 QColor backgroundColor()
const;
124 void setBackgroundColor(
const QColor& theColor );
127 void setForegroundEnabled(
bool theState );
130 void setForegroundSize(
const QSizeF& theRect );
133 void setForegroundMargin(
double theMargin );
136 void setForegroundColor(
const QColor& theColor );
139 void setForegroundFrameColor(
const QColor& theColor );
142 void setForegroundFrameLineWidth(
double theLineWidth );
144 void updateForeground();
147 void setGridEnabled(
bool theState );
148 void setGridCellSize(
int theCellSize );
149 void setGridLineStyle(
int theLineStyle );
150 void setGridLineColor(
const QColor& theLineColor );
155 void pan(
double theDX,
double theDY );
156 void setCenter(
double theX,
double theY );
157 void zoom(
double theX1,
double theY1,
double theX2,
double theY2 );
158 void fitRect(
const QRectF& theRect );
160 void fitAll(
bool theKeepScale =
false );
165 void applyTransform();
168 void setZoomCoeff(
const int& theZoomCoeff );
171 void setUnlimitedPanning(
const bool& theValue );
177 virtual void highlight(
double theX,
double theY );
178 void clearHighlighted();
183 virtual int select(
const QRectF& theRect,
bool theIsAppend );
184 void clearSelected();
187 int nbSelected()
const;
196 void startSelectByRect(
int x,
int y );
197 void drawSelectByRect(
int x,
int y );
198 void finishSelectByRect();
199 bool isSelectByRect()
const;
200 QRect selectionRect();
203 void prepareToSketch(
bool theStatus );
204 bool isPrepareToSketch();
205 void startSketching(
const QPointF& thePoint,
207 void drawSketching(
const QPointF& thePoint );
208 void finishSketching(
bool theStatus );
209 bool isSketching(
bool* theIsPath = 0 )
const;
215 void setDraggingSelectedByLeftButton(
const bool& theValue );
218 bool startPulling(
const QPointF& );
219 void drawPulling(
const QPointF& );
220 void finishPulling(
bool theStatus );
224 bool cancelCurrentOperation();
227 static void createCursors();
228 static void destroyCursors();
237 void onBoundingRectChanged();
240 void onKeyEvent( QKeyEvent* );
241 void onMouseEvent( QGraphicsSceneMouseEvent* );
242 void onWheelEvent( QGraphicsSceneWheelEvent* );
243 void onContextMenuEvent( QGraphicsSceneContextMenuEvent* );
246 virtual void scrollContentsBy(
int theDX,
int theDY );
263 void dragObjects( QGraphicsSceneMouseEvent* );
356 Q_DECLARE_OPERATORS_FOR_FLAGS( GraphicsView_ViewPort::InteractionFlags )
BlockStatus
Definition: GLViewer_ViewPort.h:50
@ BS_NoBlock
Definition: GLViewer_ViewPort.h:51
@ BS_Dragging
Definition: GLViewer_ViewPort.h:54
@ BS_Selection
Definition: GLViewer_ViewPort.h:53
#define GRAPHICSVIEW_API
Definition: GraphicsView.h:29
QList< GraphicsView_Object * > GraphicsView_ObjectList
Definition: GraphicsView_Defs.h:25
Definition: GraphicsView_Object.h:36
Definition: GraphicsView_Scene.h:34
Definition: GraphicsView_ViewPort.cxx:61
Definition: GraphicsView_ViewPort.h:41
void vpContextMenuEvent(QGraphicsSceneContextMenuEvent *)
double foregroundFrameLineWidth() const
Definition: GraphicsView_ViewPort.h:141
QGraphicsRectItem * myForegroundItem
Definition: GraphicsView_ViewPort.h:299
static QCursor * panglCursor
Definition: GraphicsView_ViewPort.h:270
static QCursor * getSketchCursor()
Definition: GraphicsView_ViewPort.h:234
QSizeF myForegroundSize
Definition: GraphicsView_ViewPort.h:294
int myZoomCoeff
Definition: GraphicsView_ViewPort.h:353
bool myIsHighlighting
Definition: GraphicsView_ViewPort.h:320
static QCursor * zoomCursor
Definition: GraphicsView_ViewPort.h:271
bool myUnlimitedPanning
Definition: GraphicsView_ViewPort.h:312
static QCursor * handCursor
Definition: GraphicsView_ViewPort.h:268
int myGridLineStyle
Definition: GraphicsView_ViewPort.h:304
bool myIsSketching
Definition: GraphicsView_ViewPort.h:336
static QCursor * getPanglCursor()
Definition: GraphicsView_ViewPort.h:232
bool myIsSketchingByPath
Definition: GraphicsView_ViewPort.h:337
GraphicsView_Scene * myScene
Definition: GraphicsView_ViewPort.h:276
bool myIsDragPositionInitialized
Definition: GraphicsView_ViewPort.h:342
void vpSketchingFinished(QPainterPath)
double mySceneGap
Definition: GraphicsView_ViewPort.h:277
int zoomCoeff() const
Definition: GraphicsView_ViewPort.h:167
double myForegroundFrameLineWidth
Definition: GraphicsView_ViewPort.h:298
bool myIsPrepareToSketch
Definition: GraphicsView_ViewPort.h:335
SortType
Definition: GraphicsView_ViewPort.h:92
@ NoSorting
Definition: GraphicsView_ViewPort.h:92
double myForegroundMargin
Definition: GraphicsView_ViewPort.h:295
bool isForegroundEnabled() const
Definition: GraphicsView_ViewPort.h:126
double myHighlightY
Definition: GraphicsView_ViewPort.h:319
static QCursor * getPanCursor()
Definition: GraphicsView_ViewPort.h:231
QGridLayout * myViewLabelLayout
Definition: GraphicsView_ViewPort.h:287
void vpKeyEvent(QKeyEvent *)
bool myIsTransforming
Definition: GraphicsView_ViewPort.h:309
GraphicsView_Scene * getScene()
Definition: GraphicsView_ViewPort.h:86
InteractionFlag
Definition: GraphicsView_ViewPort.h:48
bool isDragging()
Definition: GraphicsView_ViewPort.h:212
void vpWheelEvent(QGraphicsSceneWheelEvent *)
Q_DECLARE_FLAGS(InteractionFlags, InteractionFlag) enum BlockStatus
Definition: GraphicsView_ViewPort.h:63
QGraphicsPathItem * mySketchingItem
Definition: GraphicsView_ViewPort.h:333
QPoint myFirstSelectionPoint
Definition: GraphicsView_ViewPort.h:328
void vpObjectBeforeMoving()
Qt::ScrollBarPolicy myHBarPolicy
Definition: GraphicsView_ViewPort.h:313
static QCursor * defCursor
Definition: GraphicsView_ViewPort.h:267
double myHighlightX
Definition: GraphicsView_ViewPort.h:318
static QCursor * sketchCursor
Definition: GraphicsView_ViewPort.h:272
int myGridCellSize
Definition: GraphicsView_ViewPort.h:303
bool myIsForegroundEnabled
Definition: GraphicsView_ViewPort.h:293
bool myIsPulling
Definition: GraphicsView_ViewPort.h:346
double foregroundMargin() const
Definition: GraphicsView_ViewPort.h:132
Qt::ScrollBarPolicy myVBarPolicy
Definition: GraphicsView_ViewPort.h:314
bool myAreSelectionPointsInitialized
Definition: GraphicsView_ViewPort.h:330
QSizeF foregroundSize() const
Definition: GraphicsView_ViewPort.h:129
GraphicsView_Object * getHighlightedObject() const
Definition: GraphicsView_ViewPort.h:180
static QCursor * getZoomCursor()
Definition: GraphicsView_ViewPort.h:233
QColor foregroundFrameColor() const
Definition: GraphicsView_ViewPort.h:138
InteractionFlags myInteractionFlags
Definition: GraphicsView_ViewPort.h:282
GraphicsView_Object * myPullingObject
Definition: GraphicsView_ViewPort.h:347
static QCursor * panCursor
Definition: GraphicsView_ViewPort.h:269
void vpMouseEvent(QGraphicsSceneMouseEvent *)
void vpObjectAfterMoving(bool)
QColor myForegroundFrameColor
Definition: GraphicsView_ViewPort.h:297
bool isUnlimitedPanning() const
Definition: GraphicsView_ViewPort.h:170
int mySelectionIterator
Definition: GraphicsView_ViewPort.h:324
bool myIsMousePositionEnabled
Definition: GraphicsView_ViewPort.h:290
bool myIsGridEnabled
Definition: GraphicsView_ViewPort.h:302
static QCursor * getHandCursor()
Definition: GraphicsView_ViewPort.h:230
QColor foregroundColor() const
Definition: GraphicsView_ViewPort.h:135
bool myDraggingSelectedByLeftButton
Definition: GraphicsView_ViewPort.h:343
QPointF myDragPosition
Definition: GraphicsView_ViewPort.h:341
QColor myGridLineColor
Definition: GraphicsView_ViewPort.h:305
bool isPulling() const
Definition: GraphicsView_ViewPort.h:221
QColor myForegroundColor
Definition: GraphicsView_ViewPort.h:296
ViewLabel * myViewLabel
Definition: GraphicsView_ViewPort.h:285
int myIsDragging
Definition: GraphicsView_ViewPort.h:340
static QCursor * getDefaultCursor()
Definition: GraphicsView_ViewPort.h:229
GraphicsView_Object * myHighlightedObject
Definition: GraphicsView_ViewPort.h:317
bool isDraggingSelectedByLeftButton() const
Definition: GraphicsView_ViewPort.h:214
QPoint myLastSelectionPoint
Definition: GraphicsView_ViewPort.h:329
const GraphicsView_ObjectList & getSelectedObjects() const
Definition: GraphicsView_ViewPort.h:193
QRubberBand * myRectBand
Definition: GraphicsView_ViewPort.h:327
double myFitAllGap
Definition: GraphicsView_ViewPort.h:278
GraphicsView_ObjectList myObjects
Definition: GraphicsView_ViewPort.h:279
bool isTransforming() const
Definition: GraphicsView_ViewPort.h:163
QPointF mySketchingPoint
Definition: GraphicsView_ViewPort.h:334
QTransform myCurrentTransform
Definition: GraphicsView_ViewPort.h:310
ViewLabelPosition
Definition: GraphicsView_ViewPort.h:73
QGraphicsPathItem * myGridItem
Definition: GraphicsView_ViewPort.h:306
QCursor myStoredCursor
Definition: GraphicsView_ViewPort.h:350
GraphicsView_ObjectList mySelectedObjects
Definition: GraphicsView_ViewPort.h:323
ViewLabelPosition myViewLabelPosition
Definition: GraphicsView_ViewPort.h:286
static int nCounter
Definition: GraphicsView_ViewPort.h:266