38 setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
60 return static_cast<UMLScene*
>(scene());
78 }
else if (zoom > 500) {
83 wm.scale(zoom / 100.0, zoom / 100.0);
95 return (
int)(matrix().m11()*100.0);
103 bool success =
false;
105 if (dlg->exec() == QDialog::Accepted) {
114 QMatrix wm = matrix();
116 setZoom((
int)(wm.m11()*100.0));
121 QMatrix wm = matrix();
122 wm.scale(2.0 / 3.0, 2.0 / 3.0);
123 setZoom((
int)(wm.m11()*100.0));
142 QPointF pointBeforeScale(mapToScene(event->pos()));
145 QPointF screenCenter =
center();
148 double scaleFactor = 1.15;
149 if (event->delta() > 0) {
152 scale(scaleFactor, scaleFactor);
157 scale(1.0 / scaleFactor, 1.0 / scaleFactor);
162 QPointF pointAfterScale(mapToScene(event->pos()));
165 QPointF offset = pointBeforeScale - pointAfterScale;
168 QPointF newCenter = screenCenter + offset;
182 QRectF visibleArea = mapToScene(rect()).boundingRect();
186 QGraphicsView::resizeEvent(event);
197 connect(tb, SIGNAL(sigButtonChanged(
int)), us, SLOT(slotToolBarChanged(
int)));
198 connect(us, SIGNAL(sigResetToolBar()), tb, SLOT(slotResetToolBar()));
212 disconnect(tb, SIGNAL(sigButtonChanged(
int)), us, SLOT(slotToolBarChanged(
int)));
213 disconnect(us, SIGNAL(sigResetToolBar()), tb, SLOT(slotResetToolBar()));
223 QWidget::closeEvent(ce);
236 QRectF visibleArea = mapToScene(rect()).boundingRect();
239 QRectF sceneBounds = sceneRect();
241 double boundX = visibleArea.width() / 2.0;
242 double boundY = visibleArea.height() / 2.0;
243 double boundWidth = sceneBounds.width() - 2.0 * boundX;
244 double boundHeight = sceneBounds.height() - 2.0 * boundY;
247 QRectF bounds(boundX, boundY, boundWidth, boundHeight);
249 if (bounds.contains(centerPoint)) {
254 if(visibleArea.contains(sceneBounds)) {
262 if (centerPoint.x() > bounds.x() + bounds.width()) {
264 }
else if (centerPoint.x() < bounds.x()) {
268 if (centerPoint.y() > bounds.y() + bounds.height()) {
270 }
else if (centerPoint.y() < bounds.y()) {
288 #include "umlview.moc"
virtual void closeEvent(QCloseEvent *ce)
Override standard method.
int m_nZoom
zoom level in percent, default 100
void resizeSceneToItems()
Sets the size of the scene to just fit on all the items.
virtual void resizeEvent(QResizeEvent *event)
Need to update the center so there is no jolt in the interaction after resizing the widget...
UMLView instances represent diagrams.
static UMLApp * app()
Get the last created instance of this class.
void setCenter(const QPointF ¢erPoint)
Sets the current centerpoint.
virtual void wheelEvent(QWheelEvent *event)
Zoom the view in and out.
virtual void showEvent(QShowEvent *se)
Overrides the standard operation.
QPointF m_currentCenterPoint
holds the current centerpoint for the view, used for panning and zooming
QPointF center()
Get the center.
void hideEvent(QHideEvent *he)
Overrides the standard operation.
virtual void hideEvent(QHideEvent *he)
Overrides the standard operation.
virtual ~UMLView()
Destructor.
void showEvent(QShowEvent *se)
Overrides the standard operation.
The base class for UML application windows.
This class manages the UMLObjects and UMLViews of a Folder.
void show()
Overrides standard method from QWidget to resize scene when it's shown.
void setZoom(int zoom)
Sets the zoom of the diagram.
void slotZoomSliderMoved(int value)
Connected to by the zoomAction, a value of between 300 and 2200 is scaled to zoom to between 9% and 5...
UMLScene * umlScene() const
Getter for the scene.
int zoom() const
Returns the zoom of the diagram.
WorkToolBar * workToolBar() const
Returns the toolbar being used.
#define DEBUG_REGISTER(src)
bool showPropDialog()
Shows the properties dialog for the view.
void resetToolbar()
Reset the toolbar.
int currentZoom()
Return the current zoom factor.
UMLScene instances represent diagrams.