20 #ifndef GRAPHICSVIEW_VIEWPORT_H
21 #define GRAPHICSVIEW_VIEWPORT_H
27 #include <QGraphicsView>
51 WheelScaling = 0x0004,
52 EditFlags = Dragging | Pulling | WheelScaling,
54 TraceBoundingRect = 0x0008,
55 DraggingByMiddleButton = 0x0010,
56 ImmediateContextMenu = 0x0020,
57 ImmediateSelection = 0x0040,
84 void addItem( QGraphicsItem* theItem );
85 bool isItemAdded( QGraphicsItem* theItem );
86 void removeItem( QGraphicsItem* theItem );
88 enum SortType { NoSorting, SelectedFirst, SortByZLevel };
91 QRectF objectsBoundingRect(
bool theOnlyVisible =
false )
const;
93 QImage dumpView(
bool theWholeScene =
false,
94 QSizeF theSize = QSizeF() );
98 void setSceneGap(
double theSceneGap );
99 void setFitAllGap(
double theFitAllGap );
102 int interactionFlags()
const;
103 bool hasInteractionFlag( InteractionFlag theFlag );
104 void setInteractionFlag( InteractionFlag theFlag,
105 bool theIsEnabled =
true );
106 void setInteractionFlags( InteractionFlags theFlags );
109 void setViewLabelPosition( ViewLabelPosition thePosition,
110 bool theIsForced =
false );
111 void setViewLabelText(
const QString& theText );
114 void setMousePositionEnabled(
bool theState );
117 QColor backgroundColor()
const;
118 void setBackgroundColor(
const QColor& theColor );
121 void setForegroundEnabled(
bool theState );
124 void setForegroundSize(
const QSizeF& theRect );
127 void setForegroundMargin(
double theMargin );
130 void setForegroundColor(
const QColor& theColor );
133 void setForegroundFrameColor(
const QColor& theColor );
136 void setForegroundFrameLineWidth(
double theLineWidth );
138 void updateForeground();
141 void setGridEnabled(
bool theState );
142 void setGridCellSize(
int theCellSize );
143 void setGridLineStyle(
int theLineStyle );
144 void setGridLineColor(
const QColor& theLineColor );
149 void pan(
double theDX,
double theDY );
150 void setCenter(
double theX,
double theY );
151 void zoom(
double theX1,
double theY1,
double theX2,
double theY2 );
152 void fitRect(
const QRectF& theRect );
154 void fitAll(
bool theKeepScale =
false );
159 void applyTransform();
165 virtual void highlight(
double theX,
double theY );
166 void clearHighlighted();
171 virtual int select(
const QRectF& theRect,
bool theIsAppend );
172 void clearSelected();
175 int nbSelected()
const;
184 void startSelectByRect(
int x,
int y );
185 void drawSelectByRect(
int x,
int y );
186 void finishSelectByRect();
187 bool isSelectByRect()
const;
188 QRect selectionRect();
191 void prepareToSketch(
bool theStatus );
192 bool isPrepareToSketch();
193 void startSketching(
const QPointF& thePoint,
195 void drawSketching(
const QPointF& thePoint );
196 void finishSketching(
bool theStatus );
197 bool isSketching(
bool* theIsPath = 0 )
const;
203 bool startPulling(
const QPointF& );
204 void drawPulling(
const QPointF& );
205 void finishPulling(
bool theStatus );
209 bool cancelCurrentOperation();
212 static void createCursors();
213 static void destroyCursors();
222 void onBoundingRectChanged();
225 void onKeyEvent( QKeyEvent* );
226 void onMouseEvent( QGraphicsSceneMouseEvent* );
227 void onWheelEvent( QGraphicsSceneWheelEvent* );
228 void onContextMenuEvent( QGraphicsSceneContextMenuEvent* );
231 virtual void scrollContentsBy(
int theDX,
int theDY );
234 void vpKeyEvent( QKeyEvent* );
235 void vpMouseEvent( QGraphicsSceneMouseEvent* );
236 void vpWheelEvent( QGraphicsSceneWheelEvent* );
237 void vpContextMenuEvent( QGraphicsSceneContextMenuEvent* );
239 void vpSketchingFinished( QPainterPath );
241 void vpObjectBeforeMoving();
242 void vpObjectAfterMoving(
bool );
248 void dragObjects( QGraphicsSceneMouseEvent* );
333 Q_DECLARE_OPERATORS_FOR_FLAGS( GraphicsView_ViewPort::InteractionFlags )