[Uml-devel] KDE/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Sat Mar 24 07:22:05 UTC 2012


SVN commit 1286840 by habacker:

Merged UMLCanvasView into into UMLscene; it was based on Q3Canvas too.

CCBUG: 290952

 M  +0 -1      CMakeLists.txt  
 M  +12 -11    dialogs/umlviewdialog.cpp  
 M  +4 -10     dialogs/umlwidgetstylepage.cpp  
 M  +43 -24    umlscene.cpp  
 M  +6 -3      umlscene.h  
 D             umlviewcanvas.cpp  
 D             umlviewcanvas.h  
 M  +1 -2      widgets/associationline.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1286839:1286840
@@ -461,7 +461,6 @@
     umlrole.cpp
     umlscene.cpp
     umlview.cpp
-    umlviewcanvas.cpp
     umlviewimageexporter.cpp
     umlviewimageexporterall.cpp
     umlviewimageexportermodel.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlviewdialog.cpp #1286839:1286840
@@ -167,22 +167,23 @@
     {
         checkName();
         m_pView->setZoom( m_diagramProperties->ui_zoom->value() );
-        m_pView->setDocumentation( m_diagramProperties->ui_documentation->toPlainText() );
-        m_pView->setSnapX( m_diagramProperties->ui_gridSpaceX->value() );
-        m_pView->setSnapY( m_diagramProperties->ui_gridSpaceY->value() );
-        m_pView->setLineWidth( m_diagramProperties->ui_lineWidth->value() );
-        m_pView->setSnapToGrid( m_diagramProperties->ui_snapToGrid->isChecked() );
-        m_pView->setSnapComponentSizeToGrid( m_diagramProperties->ui_snapComponentSizeToGrid->isChecked() );
-        m_pView->setShowSnapGrid( m_diagramProperties->ui_checkBoxShowGrid->isChecked() );
-        m_pView->setShowOpSig( m_diagramProperties->ui_showOpSigs->isChecked() );
+        m_pView->umlScene()->setDocumentation( m_diagramProperties->ui_documentation->toPlainText() );
+        m_pView->umlScene()->setSnapX( m_diagramProperties->ui_gridSpaceX->value() );
+        m_pView->umlScene()->setSnapY( m_diagramProperties->ui_gridSpaceY->value() );
+        m_pView->umlScene()->setLineWidth( m_diagramProperties->ui_lineWidth->value() );
+        m_pView->umlScene()->setSnapToGrid( m_diagramProperties->ui_snapToGrid->isChecked() );
+        m_pView->umlScene()->setSnapComponentSizeToGrid( m_diagramProperties->ui_snapComponentSizeToGrid->isChecked() );
+        m_pView->umlScene()->setShowSnapGrid( m_diagramProperties->ui_checkBoxShowGrid->isChecked() );
+        m_pView->umlScene()->setShowOpSig( m_diagramProperties->ui_showOpSigs->isChecked() );
     }
     else if ( item == m_pageStyleItem )
     {
         uDebug() << "setting colors ";
         m_pStylePage->updateUMLWidget();
-        m_pView->setUseFillColor( m_options.uiState.useFillColor );
-        m_pView->setLineColor( m_options.uiState.lineColor );
-        m_pView->setFillColor( m_options.uiState.fillColor );
+        m_pView->umlScene()->setUseFillColor( m_options.uiState.useFillColor );
+        m_pView->umlScene()->setLineColor( m_options.uiState.lineColor );
+        m_pView->umlScene()->setFillColor( m_options.uiState.fillColor );
+        m_pView->umlScene()->setGridDotColor( m_options.uiState.gridDotColor );
     }
     else if ( item == m_pageFontItem )
     {
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umlwidgetstylepage.cpp #1286839:1286840
@@ -14,7 +14,6 @@
 #include "uml.h"
 #include "umlscene.h"
 #include "umlview.h"
-#include "umlviewcanvas.h"
 #include "widgetbase.h"
 
 #include <klocale.h>
@@ -47,14 +46,11 @@
     if (!m_pUMLWidget) {  //  when we are on the diagram
         UMLView * view = UMLApp::app()->currentView();
         if (view) {
-            UMLViewCanvas* canvas = dynamic_cast<UMLViewCanvas*>(view->canvas());
-            if (canvas) {
-                m_BackgroundColorB->setColor(canvas->backgroundColor());
-                m_GridDotColorB->setColor(canvas->gridDotColor());
+            m_BackgroundColorB->setColor(view->umlScene()->backgroundColor());
+            m_GridDotColorB->setColor(view->umlScene()->gridDotColor());
             }
         }
     }
-}
 
 /**
  *   Constructor - Observe an OptionState structure.
@@ -258,12 +254,10 @@
     if (!m_pUMLWidget) {  // when we are on the diagram
         UMLView * view = UMLApp::app()->currentView();
         if (view) {
-            UMLViewCanvas* canvas = dynamic_cast<UMLViewCanvas*>(view->canvas());
-            if (canvas) {
-                canvas->setColors(m_BackgroundColorB->color(), m_GridDotColorB->color());
+            view->umlScene()->setBackgroundColor(m_BackgroundColorB->color());
+            view->umlScene()->setGridDotColor(m_GridDotColorB->color());
             }
         }
     }
-}
 
 #include "umlwidgetstylepage.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.cpp #1286839:1286840
@@ -54,7 +54,6 @@
 #include "umlobject.h"
 #include "docwindow.h"
 #include "umlrole.h"
-#include "umlviewcanvas.h"
 #include "classoptionspage.h"
 #include "umlviewdialog.h"
 #include "idchangelog.h"
@@ -154,7 +153,6 @@
     m_pImageExporter = new UMLViewImageExporter(this);
 
     //setup graphical items
-    setCanvas(new UMLViewCanvas(this,m_Options));
     // don't set the quite frequent update rate for each
     // diagram, as that causes also an update of invisible
     // diagrams, which can cost high CPU load for many
@@ -209,11 +207,6 @@
 
     delete m_pToolBarStateFactory;
     m_pToolBarStateFactory = NULL;
-
-    // Qt Doc for QCanvasView::~QCanvasView () states:
-    // "Destroys the canvas view. The associated canvas is not deleted."
-    // we should do it now
-    delete canvas();
 }
 
 /**
@@ -1098,10 +1091,32 @@
 {
     m_Options.uiState.textColor = color;
     emit sigColorChanged(getID());
-    canvas()->setAllChanged();
+    setAllChanged();
 }
 
 /**
+ * return grid dot color
+ *
+ * @return Color
+ */
+QColor UMLScene::gridDotColor() const
+{
+    return m_Options.uiState.gridDotColor;
+}
+
+/**
+ * set grid dot color
+ *
+ * @param color grid dot color
+ */
+void UMLScene::setGridDotColor(const QColor& color)
+{
+    m_Options.uiState.gridDotColor = color;
+    emit sigColorChanged(getID());
+    setAllChanged();
+}
+
+/**
  * Override standard method.
  * Calls the same method in the current tool bar state.
  */
@@ -3637,6 +3652,24 @@
 }
 
 /**
+ * Sets the color of the background and the grid dots.
+ */
+void UMLScene::drawBackground(QPainter & painter, const QRect & clip)
+{
+    Q_UNUSED(clip);
+    if( getShowSnapGrid() ) {
+        painter.setPen( gridDotColor() );
+        int gridX = getSnapX();
+        int gridY = getSnapY();
+        int numX = view()->width() / gridX;
+        int numY = view()->height() / gridY;
+        for( int x = 0; x <= numX; x++ )
+            for( int y = 0; y < numY; y++ )
+                painter.drawPoint( x * gridX, y * gridY );
+    }
+}
+
+/**
  * Creates the "diagram" tag and fills it with the contents of the diagram.
  */
 void UMLScene::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
@@ -3652,15 +3685,8 @@
     viewElement.setAttribute("linewidth", m_Options.uiState.lineWidth);
     viewElement.setAttribute("usefillcolor", m_Options.uiState.useFillColor);
     viewElement.setAttribute("font", m_Options.uiState.font.toString());
-    QString backgroundColor = m_Options.uiState.backgroundColor.name();
-    QString gridDotColor    = m_Options.uiState.gridDotColor.name();
-    UMLViewCanvas* canvs = dynamic_cast<UMLViewCanvas*>(canvas());
-    if (canvs) {
-        backgroundColor = canvs->backgroundColor().name();
-        gridDotColor    = canvs->gridDotColor().name();
-    }
-    viewElement.setAttribute("backgroundcolor", backgroundColor);
-    viewElement.setAttribute("griddotcolor",    gridDotColor);
+    viewElement.setAttribute("backgroundcolor", m_Options.uiState.backgroundColor.name());
+    viewElement.setAttribute("griddotcolor", m_Options.uiState.gridDotColor.name());
     //optionstate classstate
     viewElement.setAttribute("showattsig", m_Options.classState.showAttSig);
     viewElement.setAttribute("showatts", m_Options.classState.showAtts);
@@ -3849,13 +3875,6 @@
         m_Options.uiState.backgroundColor = QColor(backgroundColor);
     if (!gridDotColor.isEmpty())
         m_Options.uiState.gridDotColor = QColor(gridDotColor);
-    if (!backgroundColor.isEmpty() & !gridDotColor.isEmpty()) {
-        UMLViewCanvas* canvs = dynamic_cast<UMLViewCanvas*>(canvas());
-        if (canvs) {
-            DEBUG(DBG_SRC) << "Set background color to [" << backgroundColor << "] and grid dot color to [" << gridDotColor << "]";
-            canvs->setColors(QColor(backgroundColor), QColor(gridDotColor));
-        }
-    }
     m_nLocalID = STR2ID(localid);
 
     QDomNode node = qElement.firstChild();
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.h #1286839:1286840
@@ -10,16 +10,14 @@
 #ifndef UMLSCENE_H
 #define UMLSCENE_H
 
-#include "umlscene.h"
-
 #include <QMouseEvent>
 #include <QKeyEvent>
 
 // system includes
 #include <kurl.h>
 #include <qdom.h>
-#include <umlviewcanvas.h>
 #include <QtGui/QPixmap>
+#include <Q3Canvas>
 
 //local includes
 #include "umlobjectlist.h"
@@ -143,6 +141,9 @@
     QColor textColor() const;
     void setTextColor( const QColor &color );
 
+    QColor gridDotColor() const;
+    void setGridDotColor( const QColor& color );
+
     /**
      * Returns the ID of the diagram.
      */
@@ -632,6 +633,8 @@
                                   int& px, int& py, int& qx, int& qy);
     void forceUpdateWidgetFontMetrics(QPainter *painter);
 
+    virtual void drawBackground(QPainter & painter, const QRect & clip);
+
     /**
      * Used for creating unique name of collaboration messages.
      */
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationline.h #1286839:1286840
@@ -17,7 +17,6 @@
 #include <QtCore/QObject>
 #include <QtCore/QList>
 #include <QtCore/QPoint>
-#include <umlviewcanvas.h>
 
 /* how many pixels a user could click around a point */
 #define POINT_DELTA 5
@@ -146,7 +145,7 @@
         int inclination;
     };
 
-    UMLViewCanvas * canvas();
+    Q3Canvas * canvas();
 
     void moveSelected(int pointIndex);
 




More information about the umbrello-devel mailing list