Commit 1bf8a720 authored by Ralf Habacker's avatar Ralf Habacker

Ported class UMLScene and UMLView to QGraphicsScene and QGraphivsView.

This was possible because of the reduced soc2008 and trunk difference approach
performed in the last months by Andy Fischer an me.

The gsoc 2008 branch still contains several fixes and enhancements which may be merged
from now on.

Qt4 related fixes (the most important):
- Usage of QGraphicsItem based event handling
- Usage of QGraphicsScene based rubberband
- Usage of QGraphicsScene/View based item selection

Qt4 unrelated (most important):
- The QPainter based AssocationLine refactoring, which is required for spline based
  line style and auto layouts.
- AssociationSpaceManager class for optimized association line drawings.
- The TextItem/TextItemGroup classes, which refactores widgets content setup
- Widget Color gradients, which are useful enhancements of the widget style engine

BUG: 290952

svn path=/trunk/KDE/kdesdk/umbrello/; revision=1314540
parent e72aded7
......@@ -20,6 +20,7 @@
#include "seqlinewidget.h"
#include "uml.h"
#include "umldoc.h"
#include "umlscene.h"
#include "umlview.h"
#include "umlwidget.h"
#include "umlwidgetlist.h"
......@@ -80,7 +81,7 @@ void ObjectWidgetController::mousePressEvent(UMLSceneMouseEvent *me)
m_isOnDestructionBox = false;
SeqLineWidget * pLine = dynamic_cast<ObjectWidget*>(m_widget)->sequentialLine();
if (pLine->onDestructionBox(me->pos())) {
if (pLine->onDestructionBox(me->scenePos())) {
m_isOnDestructionBox = true;
m_oldX = dynamic_cast<ObjectWidget*>(m_widget)->x() + dynamic_cast<ObjectWidget*>(m_widget)->width() / 2;
m_oldY = dynamic_cast<ObjectWidget*>(m_widget)->getEndLineY() - 10;
......@@ -101,7 +102,7 @@ void ObjectWidgetController::mouseMoveEvent(UMLSceneMouseEvent* me)
return;
}
int diffY = me->y() - m_oldY;
int diffY = me->scenePos().y() - m_oldY;
if (m_isOnDestructionBox) {
moveDestructionBy (diffY);
......
......@@ -43,7 +43,7 @@ protected:
virtual void resizeWidget(UMLSceneValue newW, UMLSceneValue newH);
virtual void mousePressEvent(UMLSceneMouseEvent *me);
virtual void mouseMoveEvent(UMLSceneMouseEvent* me);
virtual void mouseMoveEvent(UMLSceneMouseEvent *me);
virtual void moveWidgetBy(UMLSceneValue diffX, UMLSceneValue diffY);
......
......@@ -21,6 +21,7 @@
#include "listpopupmenu.h"
#include "associationwidget.h"
#include "cmds.h"
#include "debug_utils.h"
// kde includes
#include <kcursor.h>
......@@ -28,7 +29,6 @@
// qt includes
#include <QEvent>
#include <QPoint>
/**
* Constructor for UMLWidgetController.
......@@ -334,7 +334,7 @@ void UMLWidgetController::mouseReleaseEvent(UMLSceneMouseEvent *me)
}
if (m_inResizeArea) {
m_inResizeArea = false;
m_inResizeArea = false;
m_widget->m_scene->activeView()->setCursor(Qt::ArrowCursor);
} else {
m_inMoveArea = false;
......@@ -345,6 +345,7 @@ void UMLWidgetController::mouseReleaseEvent(UMLSceneMouseEvent *me)
m_rightButtonDown = false;
showPopupMenu(me);
} else if (m_leftButtonDown) {
#ifdef Q3CANVAS_IMPLEMENTATION
//Cancel move/edit
UMLSceneMouseEvent move(UMLSceneMouseEvent::MouseMove,
QPoint(m_oldX + m_pressOffsetX, m_oldY + m_pressOffsetY),
......@@ -354,11 +355,26 @@ void UMLWidgetController::mouseReleaseEvent(UMLSceneMouseEvent *me)
QPoint(m_oldX + m_pressOffsetX, m_oldY + m_pressOffsetY),
Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
mouseReleaseEvent(&release);
#endif
#ifdef QGRAPHICS_IMPLEMENTATION
UMLSceneMouseEvent move = new UMLSceneMouseEvent(type);
move->setPos(me->pos());
move->setScenePosome->scenePos());
move->setScreenPos(me->screenPos());
move->setLastPos(me->lastPos());
move->setLastScenePos(me->lastScenePos());
move->setLastScreenPos(me->lastScreenPos());
move->setButtons(me->buttons());
move->setButton(me->button());
move->setModifiers(me->modifiers());
mouseMoveEvent(&move);
mouseReleaseEvent(&move);
#endif
}
}
//TODO Copied from old code. Does it really work as intended?
UMLWidget *bkgnd = m_widget->m_scene->widgetAt(me->pos());
UMLWidget *bkgnd = m_widget->m_scene->widgetAt(me->scenePos());
if (bkgnd) {
//uDebug() << "setting Z to " << bkgnd->z() + 1;
m_widget->setZ(bkgnd->z() + 1);
......@@ -412,8 +428,8 @@ bool UMLWidgetController::isInResizeArea(UMLSceneMouseEvent *me)
m = 2;
if (m_widget->m_resizable &&
me->x() >= (m_widget->x() + w - m) &&
me->y() >= (m_widget->y() + h - m)) {
me->scenePos().x() >= (m_widget->x() + w - m) &&
me->scenePos().y() >= (m_widget->y() + h - m)) {
m_widget->m_scene->activeView()->setCursor(getResizeCursor());
return true;
} else {
......@@ -522,7 +538,7 @@ void UMLWidgetController::doMouseDoubleClick(UMLSceneMouseEvent *)
void UMLWidgetController::resetSelection()
{
m_widget->m_scene->clearSelected();
m_widget->m_scene->activeView()->resetToolbar();
m_widget->m_scene->resetToolbar();
m_widget->setSelected(false);
m_wasSelected = false;
......@@ -549,8 +565,7 @@ void UMLWidgetController::selectSingle(UMLSceneMouseEvent *me)
*/
void UMLWidgetController::selectMultiple(UMLSceneMouseEvent *me)
{
m_widget->m_selected = true;
m_widget->setSelected(m_widget->m_selected);
m_widget->setSelected(true);
m_widget->m_scene->setSelected(m_widget, me);
m_wasSelected = true;
......@@ -563,8 +578,7 @@ void UMLWidgetController::selectMultiple(UMLSceneMouseEvent *me)
*/
void UMLWidgetController::deselect(UMLSceneMouseEvent *me)
{
m_widget->m_selected = false;
m_widget->setSelected(m_widget->m_selected);
m_widget->setSelected(false);
m_widget->m_scene->setSelected(m_widget, me);
//m_wasSelected is false implicitly, no need to set it again
}
......@@ -583,8 +597,8 @@ void UMLWidgetController::deselect(UMLSceneMouseEvent *me)
*/
void UMLWidgetController::saveWidgetValues(UMLSceneMouseEvent *me)
{
m_pressOffsetX = me->x() - m_widget->x();
m_pressOffsetY = me->y() - m_widget->y();
m_pressOffsetX = me->scenePos().x() - m_widget->x();
m_pressOffsetY = me->scenePos().y() - m_widget->y();
m_prevX = m_oldX = m_widget->x();
m_prevY = m_oldY = m_widget->y();
......@@ -669,8 +683,8 @@ void UMLWidgetController::resize(UMLSceneMouseEvent *me)
m_resized = true;
int newW = m_oldW + me->x() - m_widget->x() - m_pressOffsetX;
int newH = m_oldH + me->y() - m_widget->y() - m_pressOffsetY;
UMLSceneValue newW = m_oldW + me->scenePos().x() - m_widget->x() - m_pressOffsetX;
UMLSceneValue newH = m_oldH + me->scenePos().y() - m_widget->y() - m_pressOffsetY;
if ((me->modifiers() & Qt::ShiftModifier) && (me->modifiers() & Qt::ControlModifier)) {
//Move in Y axis
......@@ -802,9 +816,9 @@ int UMLWidgetController::getBiggestY(const UMLWidgetList &widgetList)
* mouse press offset m_pressOffset{X,Y}.
*
* @param me The UMLSceneMouseEvent for which to get the adjusted position.
* @return A QPoint with the adjusted position.
* @return A UMLScenePoint with the adjusted position.
*/
QPoint UMLWidgetController::getPosition(UMLSceneMouseEvent* me)
UMLScenePoint UMLWidgetController::getPosition(UMLSceneMouseEvent* me)
{
/*
uDebug() << "me->x=" << me->x()
......@@ -814,10 +828,10 @@ QPoint UMLWidgetController::getPosition(UMLSceneMouseEvent* me)
<< " m_widget->getY=" << m_widget->y() << ", m_oldY=" << m_oldY
<< ", m_pressOffsetY=" << m_pressOffsetY << endl;
*/
int newX = me->x() + m_widget->x() - m_prevX - m_pressOffsetX;
int newY = me->y() + m_widget->y() - m_prevY - m_pressOffsetY;
int maxX = m_widget->m_scene->width();
int maxY = m_widget->m_scene->height();
UMLSceneValue newX = me->scenePos().x() + m_widget->x() - m_prevX - m_pressOffsetX;
UMLSceneValue newY = me->scenePos().y() + m_widget->y() - m_prevY - m_pressOffsetY;
UMLSceneValue maxX = m_widget->m_scene->width();
UMLSceneValue maxY = m_widget->m_scene->height();
m_prevX = newX;
m_prevY = newY;
......@@ -838,22 +852,22 @@ QPoint UMLWidgetController::getPosition(UMLSceneMouseEvent* me)
//uDebug() << "got into cond.4";
newY = maxY - (m_maxSelectedY - m_widget->y());
}
return QPoint(newX, newY);
return UMLScenePoint(newX, newY);
}
/**
* Returns a QPoint with the new X and Y position difference of the mouse event
* Returns a UMLScenePoint with the new X and Y position difference of the mouse event
* respect to the position of the widget.
*
* @param me The UMLSceneMouseEvent to get the position to compare.
* @return A QPoint with the position difference.
* @return A UMLScenePoint with the position difference.
*/
QPoint UMLWidgetController::getPositionDifference(UMLSceneMouseEvent* me)
UMLScenePoint UMLWidgetController::getPositionDifference(UMLSceneMouseEvent* me)
{
QPoint newPoint = getPosition(me);
UMLScenePoint newPoint = getPosition(me);
const int diffX = newPoint.x() - m_widget->x();
const int diffY = newPoint.y() - m_widget->y();
return QPoint(diffX, diffY);
return UMLScenePoint(diffX, diffY);
}
/**
......@@ -868,7 +882,7 @@ void UMLWidgetController::showPopupMenu(UMLSceneMouseEvent *me)
return;
}
ListPopupMenu* menu = m_widget->setupPopupMenu();
menu->popup(me->globalPos());
menu->popup(me->screenPos());
}
/**
......
......@@ -68,7 +68,7 @@ public:
virtual ~UMLWidgetController();
virtual void mousePressEvent(UMLSceneMouseEvent *me);
virtual void mouseMoveEvent(UMLSceneMouseEvent* me);
virtual void mouseMoveEvent(UMLSceneMouseEvent *me);
virtual void mouseReleaseEvent(UMLSceneMouseEvent * me);
virtual void mouseDoubleClickEvent(UMLSceneMouseEvent *me);
......@@ -118,8 +118,8 @@ protected:
int getBiggestX(const UMLWidgetList &widgetList);
int getBiggestY(const UMLWidgetList &widgetList);
QPoint getPosition(UMLSceneMouseEvent *me);
QPoint getPositionDifference(UMLSceneMouseEvent *me);
UMLScenePoint getPosition(UMLSceneMouseEvent *me);
UMLScenePoint getPositionDifference(UMLSceneMouseEvent *me);
void showPopupMenu(UMLSceneMouseEvent *me);
......
......@@ -186,7 +186,7 @@ void UMLViewDialog::applyPage(KPageWidgetItem *item)
m_pScene->setTextColor(m_options.uiState.textColor);
m_pScene->setLineColor(m_options.uiState.lineColor);
m_pScene->setFillColor(m_options.uiState.fillColor);
m_pScene->setBackgroundColor(m_options.uiState.backgroundColor);
m_pScene->setBackgroundBrush(m_options.uiState.backgroundColor);
m_pScene->setGridDotColor(m_options.uiState.gridDotColor);
//:TODO: gridCrossColor, gridTextColor, gridTextFont, gridTextIsVisible
}
......
......@@ -49,7 +49,7 @@ UMLWidgetStylePage::UMLWidgetStylePage(QWidget *pParent, WidgetBase *pWidget)
if (view) {
UMLScene* scene = view->umlScene();
if (scene) {
m_BackgroundColorB->setColor(scene->backgroundColor());
m_BackgroundColorB->setColor(scene->backgroundBrush().color());
m_GridDotColorB->setColor(scene->gridDotColor());
}
}
......@@ -261,7 +261,7 @@ void UMLWidgetStylePage::updateUMLWidget()
UMLScene* scene = view->umlScene();
if (scene) {
uDebug() << "Setting background and grid dot color.";
scene->setBackgroundColor(m_BackgroundColorB->color());
scene->setBackgroundBrush(m_BackgroundColorB->color());
scene->setGridDotColor(m_GridDotColorB->color());
}
}
......
......@@ -337,7 +337,7 @@ bool DotGenerator::createDotFile(UMLScene *scene, const QString &fileName, const
else {
DotPaintDevice d;
QPainter p(&d);
widget->paint(p, 0, 0);
widget->draw(p, 0, 0);
label = d.data().join("\\n");
}
......
......@@ -13,6 +13,7 @@
// app includes
#include "associationwidget.h"
#include "debug_utils.h"
#include "messagewidget.h"
#include "floatingdashlinewidget.h"
#include "objectwidget.h"
......@@ -22,6 +23,7 @@
// qt includes
#include <QWMatrix> // need for inverseWorldMatrix.map
#include <QScrollBar>
/**
* Destroys this ToolBarState.
......@@ -84,7 +86,7 @@ void ToolBarState::mousePress(UMLSceneMouseEvent* ome)
m_pUMLScene->emitRemovePopupMenu();
// TODO: Check who needs this.
m_pUMLScene->setPos(m_pMouseEvent->pos());
m_pUMLScene->setPos(m_pMouseEvent->scenePos());
//TODO check why
m_pUMLScene->setPaste(false);
......@@ -115,7 +117,7 @@ void ToolBarState::mouseRelease(UMLSceneMouseEvent* ome)
// Set the position of the mouse
// TODO, should only be available in this state?
m_pUMLScene->setPos(m_pMouseEvent->pos());
m_pUMLScene->setPos(m_pMouseEvent->scenePos());
m_pUMLScene->activeView()->viewport()->setMouseTracking(false);
......@@ -146,8 +148,8 @@ void ToolBarState::mouseDoubleClick(UMLSceneMouseEvent* ome)
{
setMouseEvent(ome, QEvent::MouseButtonDblClick);
UMLWidget* currentWidget = m_pUMLScene->widgetAt(m_pMouseEvent->pos());
AssociationWidget* currentAssociation = associationAt(m_pMouseEvent->pos());
UMLWidget* currentWidget = m_pUMLScene->widgetAt(m_pMouseEvent->scenePos());
AssociationWidget* currentAssociation = associationAt(m_pMouseEvent->scenePos());
if (currentWidget) {
setCurrentWidget(currentWidget);
mouseDoubleClickWidget();
......@@ -176,6 +178,8 @@ void ToolBarState::mouseDoubleClick(UMLSceneMouseEvent* ome)
*/
void ToolBarState::mouseMove(UMLSceneMouseEvent* ome)
{
static int mouseCount = 0;
setMouseEvent(ome, QEvent::MouseMove);
if (currentWidget()) {
......@@ -186,21 +190,32 @@ void ToolBarState::mouseMove(UMLSceneMouseEvent* ome)
mouseMoveEmpty();
}
//Scrolls the view
int vx = ome->x();
int vy = ome->y();
int contsX = m_pUMLScene->activeView()->contentsX();
int contsY = m_pUMLScene->activeView()->contentsY();
int visw = m_pUMLScene->activeView()->visibleWidth();
int vish = m_pUMLScene->activeView()->visibleHeight();
int dtr = visw - (vx-contsX);
int dtb = vish - (vy-contsY);
int dtt = (vy-contsY);
int dtl = (vx-contsX);
if (dtr < 30) m_pUMLScene->activeView()->scrollBy(30-dtr,0);
if (dtb < 30) m_pUMLScene->activeView()->scrollBy(0,30-dtb);
if (dtl < 30) m_pUMLScene->activeView()->scrollBy(-(30-dtl),0);
if (dtt < 30) m_pUMLScene->activeView()->scrollBy(0,-(30-dtt));
// scrolls the view
int vx = ome->scenePos().x();
int vy = ome->scenePos().y();
UMLView* view = m_pUMLScene->activeView();
// QRectF maxArea = view->sceneRect();
QRectF visibleArea = view->mapToScene(view->rect()).boundingRect();
int dtr = visibleArea.x() + visibleArea.width() - vx; // delta right
int dtb = visibleArea.y() + visibleArea.height() - vy; // delta bottom
int dtt = vy - visibleArea.y(); // delta top
int dtl = vx - visibleArea.x(); // delta left
// uDebug() << "mouse [x, y] = [ " << vx << ", " << vy << "] / "
// << "visibleArea [x, y, w, h] = [ " << visibleArea.x() << ", " << visibleArea.y() << ", " << visibleArea.width() << ", " << visibleArea.height() << "] / "
// << "maxArea [x, y, w, h] = [ " << maxArea.x() << ", " << maxArea.y() << ", " << maxArea.width() << ", " << maxArea.height() << "] / "
// << "delta right=" << dtr << ", bottom=" << dtb << ", top=" << dtt << ", left=" << dtl;
if (dtr < 30) { uDebug() << "translate RIGHT"; view->ensureVisible(vx, vy, 0.1 /*30-dtr*/, 0, 2, 2); }
if (dtb < 30) {
mouseCount++;
uDebug() << "translate BOTTOM " << mouseCount;
// view->ensureVisible(vx, vy, 0, 0.1 /*30-dtb*/, 2, 2);
if (mouseCount > 30) {
view->verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd);
mouseCount = 0;
}
}
if (dtl < 30) { uDebug() << "translate LEFT"; view->ensureVisible(vx, vy, -0.1 /*-(30-dtl)*/, 0, 2, 2); }
if (dtt < 30) { uDebug() << "translate TOP"; view->ensureVisible(vx, vy, 0, -0.1 /*-(30-dtt)*/, 2, 2); }
}
/**
......@@ -256,7 +271,7 @@ ToolBarState::ToolBarState(UMLScene *umlScene)
void ToolBarState::setCurrentElement()
{
// Check associations.
AssociationWidget* association = associationAt(m_pMouseEvent->pos());
AssociationWidget* association = associationAt(m_pMouseEvent->scenePos());
if (association) {
setCurrentAssociation(association);
return;
......@@ -264,27 +279,27 @@ void ToolBarState::setCurrentElement()
// Check messages.
//TODO check why message widgets are treated different
MessageWidget* message = messageAt(m_pMouseEvent->pos());
MessageWidget* message = messageAt(m_pMouseEvent->scenePos());
if (message) {
setCurrentWidget(message);
return;
}
//TODO check why message widgets are treated different
FloatingDashLineWidget* floatingline = floatingLineAt(m_pMouseEvent->pos());
FloatingDashLineWidget* floatingline = floatingLineAt(m_pMouseEvent->scenePos());
if (floatingline) {
setCurrentWidget(floatingline);
return;
}
ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetDestructionBox(m_pMouseEvent->pos());
ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetDestructionBox(m_pMouseEvent->scenePos());
if (objectWidgetLine) {
setCurrentWidget(objectWidgetLine);
return;
}
// Check widgets.
UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->pos());
UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->scenePos());
if (widget) {
setCurrentWidget(widget);
return;
......@@ -463,8 +478,18 @@ void ToolBarState::setMouseEvent(UMLSceneMouseEvent* ome, const QEvent::Type &ty
{
delete m_pMouseEvent;
m_pMouseEvent = new UMLSceneMouseEvent(type, m_pUMLScene->activeView()->inverseWorldMatrix().map(ome->pos()),
ome->button(),ome->buttons(),ome->modifiers());
uDebug() << "[PORT] Check if scenePos works like view->inverseWorldMatrix().map()";
// Using copy constructor here.
m_pMouseEvent = new UMLSceneMouseEvent(type);
m_pMouseEvent->setPos(ome->pos());
m_pMouseEvent->setScenePos(ome->scenePos());
m_pMouseEvent->setScreenPos(ome->screenPos());
m_pMouseEvent->setLastPos(ome->lastPos());
m_pMouseEvent->setLastScenePos(ome->lastScenePos());
m_pMouseEvent->setLastScreenPos(ome->lastScreenPos());
m_pMouseEvent->setButtons(ome->buttons());
m_pMouseEvent->setButton(ome->button());
m_pMouseEvent->setModifiers(ome->modifiers());
}
/**
......
......@@ -81,13 +81,13 @@ void ToolBarStateArrow::mousePressEmpty()
// Starts the selection rectangle
if (m_selectionRect.count() == 0) {
m_startPosition = m_pMouseEvent->pos();
m_startPosition = m_pMouseEvent->scenePos();
for (int i = 0; i < 4; i++) {
UMLSceneLineItem* line = new UMLSceneLineItem;
line->setCanvas((m_pUMLScene->canvas()));
line->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(),
m_pMouseEvent->x(), m_pMouseEvent->y());
line->setPoints(m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y(),
m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
line->setPen(QPen(QColor("grey"), 0, Qt::DotLine));
line->setVisible(true);
line->setZ(100);
......@@ -181,22 +181,22 @@ void ToolBarStateArrow::mouseMoveEmpty()
if (m_selectionRect.count() == 4) {
UMLSceneLineItem* line = m_selectionRect.at(0);
line->setPoints(m_startPosition.x(), m_startPosition.y(),
m_pMouseEvent->x(), m_startPosition.y());
m_pMouseEvent->scenePos().x(), m_startPosition.y());
line = m_selectionRect.at(1);
line->setPoints(m_pMouseEvent->x(), m_startPosition.y(),
m_pMouseEvent->x(), m_pMouseEvent->y());
line->setPoints(m_pMouseEvent->scenePos().x(), m_startPosition.y(),
m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
line = m_selectionRect.at(2);
line->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(),
m_startPosition.x(), m_pMouseEvent->y());
line->setPoints(m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y(),
m_startPosition.x(), m_pMouseEvent->scenePos().y());
line = m_selectionRect.at(3);
line->setPoints(m_startPosition.x(), m_pMouseEvent->y(),
line->setPoints(m_startPosition.x(), m_pMouseEvent->scenePos().y(),
m_startPosition.x(), m_startPosition.y());
m_pUMLScene->selectWidgets(m_startPosition.x(), m_startPosition.y(),
m_pMouseEvent->x(), m_pMouseEvent->y());
m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
}
}
......
......@@ -81,7 +81,7 @@ void ToolBarStateAssociation::mouseMove(UMLSceneMouseEvent* ome)
if (m_associationLine) {
UMLScenePoint sp = m_associationLine->startPoint();
m_associationLine->setPoints(sp.x(), sp.y(), m_pMouseEvent->x(), m_pMouseEvent->y());
m_associationLine->setPoints(sp.x(), sp.y(), m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
}
}
......@@ -117,7 +117,7 @@ void ToolBarStateAssociation::mouseReleaseAssociation()
currentAssociation()->createAssocClassLine(
static_cast<ClassifierWidget*>(m_firstWidget),
currentAssociation()->associationLine()->closestPointIndex(m_pMouseEvent->pos()));
currentAssociation()->associationLine()->closestPointIndex(m_pMouseEvent->scenePos()));
m_firstWidget->addAssoc( currentAssociation() );
cleanAssociation();
}
......
......@@ -80,7 +80,7 @@ void ToolBarStateMessages::mouseMove(UMLSceneMouseEvent* ome)
if (m_messageLine) {
UMLScenePoint sp = m_messageLine->startPoint();
m_messageLine->setPoints(sp.x(), sp.y(), m_pMouseEvent->x(), m_pMouseEvent->y());
m_messageLine->setPoints(sp.x(), sp.y(), m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
}
}
......@@ -110,7 +110,7 @@ void ToolBarStateMessages::setCurrentElement()
{
m_isObjectWidgetLine = false;
ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetLine(m_pMouseEvent->pos());
ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetLine(m_pMouseEvent->scenePos());
if (objectWidgetLine) {
uDebug() << Q_FUNC_INFO << "Object detected";
setCurrentWidget(objectWidgetLine);
......@@ -122,7 +122,7 @@ void ToolBarStateMessages::setCurrentElement()
//However, the applied patch doesn't seem to be necessary no more, so it was removed
//The widgets weren't got from UMLView, but from a method in this class similarto the
//one in UMLView but containing special code to handle the zoom
UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->pos());
UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->scenePos());
if (widget) {
setCurrentWidget(widget);
return;
......@@ -176,8 +176,8 @@ void ToolBarStateMessages::mouseReleaseEmpty()
Uml::Sequence_Message_Type msgType = getMessageType();
if (m_firstObject && msgType == Uml::sequence_message_lost) {
xclick = m_pMouseEvent->pos().x();
yclick = m_pMouseEvent->pos().y();
xclick = m_pMouseEvent->scenePos().x();
yclick = m_pMouseEvent->scenePos().y();
MessageWidget* message = new MessageWidget(m_pUMLScene, m_firstObject, xclick, yclick, msgType);
setupMessageWidget(message);
......@@ -187,12 +187,12 @@ void ToolBarStateMessages::mouseReleaseEmpty()
}
else if (!m_firstObject && msgType == Uml::sequence_message_found && xclick == 0 && yclick == 0) {
xclick = m_pMouseEvent->pos().x();
yclick = m_pMouseEvent->pos().y();
xclick = m_pMouseEvent->scenePos().x();
yclick = m_pMouseEvent->scenePos().y();
m_messageLine = new UMLSceneLineItem();
m_messageLine->setCanvas(m_pUMLScene->canvas());
m_messageLine->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(), m_pMouseEvent->x(), m_pMouseEvent->y());
m_messageLine->setPoints(m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y(), m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
m_messageLine->setPen(QPen(m_pUMLScene->lineColor(), m_pUMLScene->lineWidth(), Qt::DashLine));
m_messageLine->setVisible(true);
......@@ -226,7 +226,7 @@ void ToolBarStateMessages::setFirstWidget(ObjectWidget* firstObject)
else {
m_messageLine = new UMLSceneLineItem();
m_messageLine->setCanvas(m_pUMLScene->canvas());
m_messageLine->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(), m_pMouseEvent->x(), m_pMouseEvent->y());
m_messageLine->setPoints(m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y(), m_pMouseEvent->scenePos().x(), m_pMouseEvent->scenePos().y());
m_messageLine->setPen(QPen(m_pUMLScene->lineColor(), m_pUMLScene->lineWidth(), Qt::DashLine));
m_messageLine->setVisible(true);
......@@ -257,7 +257,7 @@ void ToolBarStateMessages::setSecondWidget(ObjectWidget* secondObject, MessageTy
}
//TODO shouldn't start position in the first widget be used also for normal messages
//and not only for creation?
int y = m_pMouseEvent->y();
UMLSceneValue y = m_pMouseEvent->scenePos().y();
if (messageType == CreationMessage) {
msgType = Uml::sequence_message_creation;
y = m_messageLine->startPoint().y();
......
......@@ -561,12 +561,12 @@ void UMLApp::slotZoomSliderMoved(int value)
void UMLApp::slotZoomFit()
{
currentView()->setZoom(100); // bring it first to the original values
DEBUG(DBG_SRC) << "canvas width=" << currentView()->umlScene()->width()
DEBUG(DBG_SRC) << "viewport width=" << currentView()->viewport()->width()
<< ", height=" << currentView()->viewport()->height();
DEBUG(DBG_SRC) << "scene width=" << currentView()->umlScene()->width()
<< ", height=" << currentView()->umlScene()->height();
DEBUG(DBG_SRC) << "visible width=" << currentView()->visibleWidth()
<< ", height=" << currentView()->visibleHeight();
int scaleW = ceil(100.0 * currentView()->visibleWidth() / currentView()->umlScene()->width());
int scaleH = ceil(100.0 * currentView()->visibleHeight() / currentView()->umlScene()->height());
int scaleW = ceil(100.0 * currentView()->viewport()->width() / currentView()->umlScene()->width());
int scaleH = ceil(100.0 * currentView()->viewport()->height() / currentView()->umlScene()->height());
DEBUG(DBG_SRC) << "scale width: " << scaleW << ", height: " << scaleH;
int scale = 100;
if (scaleW < scaleH) {
......@@ -576,7 +576,7 @@ void UMLApp::slotZoomFit()
scale = scaleH;
}