[Uml-devel] branches/work/soc-umbrello-2011/umbrello
Camila San Martin Ayres
smayres at gmail.com
Thu May 12 02:20:22 UTC 2011
SVN commit 1231456 by ayres:
Splitting up UMLScene.
M +3 -0 CMakeLists.txt
A newcanvas/diagrams.cpp [License: GPL (v2+)]
A newcanvas/diagrams.h [License: GPL (v2+)]
A newcanvas/layoutgrid.cpp [License: GPL (v2+)]
A newcanvas/layoutgrid.h [License: GPL (v2+)]
M +93 -13 newcanvas/newscene.cpp
M +32 -2 newcanvas/newscene.h
A newcanvas/print.cpp [License: GPL (v2+)]
A newcanvas/print.h [License: GPL (v2+)]
--- branches/work/soc-umbrello-2011/umbrello/CMakeLists.txt #1231455:1231456
@@ -57,6 +57,9 @@
set(libnewcanvas_SRCS
newcanvas/newscene.cpp
newcanvas/newview.cpp
+ newcanvas/diagrams.cpp
+ newcanvas/print.cpp
+ newcanvas/layoutgrid.cpp
)
set(libcodegenerator_SRCS
--- branches/work/soc-umbrello-2011/umbrello/newcanvas/newscene.cpp #1231455:1231456
@@ -9,22 +9,38 @@
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
-
#include "newscene.h"
#include "newview.h"
+#include "print.h"
#include "folder.h"
+#include "associationwidget.h"
+#include <QtGui/QGraphicsItem>
+
+
+// static members
+const qreal DEFAULT_CANVAS_SIZE = 1300;
+
+using namespace Uml;
+
+
#include <QtGui/QPainter>
/**
* Constructor
*/
-NewScene::NewScene(UMLFolder *folder, NewView *view)
+NewScene::NewScene(UMLFolder *folder, NewView *view) :
+QGraphicsScene(0, 0, DEFAULT_CANVAS_SIZE, DEFAULT_CANVAS_SIZE),
+m_Options(Settings::optionState())
{
m_folder = folder;
m_view = view;
- setColors(QColor(195, 195, 195), Qt::gray);
+ m_diagrams = new Diagrams(this);
+ m_print = new Print(this);
+ setBackgroundBrush(QColor(195, 195, 195));
+ m_layoutgrid = new LayoutGrid();
+
}
/**
@@ -49,19 +65,83 @@
}
/**
- * Sets the color of the background and the grid dots.
+ * Returns the options being used.
*/
-void NewScene::drawBackground(QPainter &painter, const QRect &clip)
+const Settings::OptionState& NewScene::optionState() const
{
+ return m_Options;
+}
- painter.setPen( m_gridColor );
- int gridX = m_view->x();
- int gridY = m_view->y();
- int numX = width() / gridX;
- int numY = height() / gridY;
- for( int x = 0; x <= numX; x++ )
- for( int y = 0; y < numY; y++ )
- painter.drawPoint( x * gridX, y * gridY );
+/**
+ * Returns a reference to the widget list.
+ */
+UMLWidgetList& NewScene::widgetList()
+{
+ return m_WidgetList;
+}
+/**
+ * Returns a reference to the message list.
+ */
+MessageWidgetList& NewScene::messageList()
+{
+ return m_MessageList;
}
+/**
+ * Returns a list with all the selected associations from the diagram
+ */
+AssociationWidgetList NewScene::selectedAssocs()
+{
+ AssociationWidgetList assocWidgetList;
+
+ foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ //if (assocwidget->isSelected())
+ if (assocwidget)
+ assocWidgetList.append(assocwidget);
+ }
+ return assocWidgetList;
+}
+
+/**
+ * Returns whether to show snap grid or not.
+ */
+bool NewScene::isSnapGridVisible() const
+{
+ return m_layoutgrid->isVisible();
+}
+
+/**
+ * Returns a list of selected widgets.
+ *
+ * This method walks over all the selected items, tries to cast them to
+ * widget and on success adds it to widget only list.
+ * Finally it returns this list.
+ */
+UMLWidgetList NewScene::selectedWidgets() const
+{
+ UMLWidgetList list;
+ foreach(QGraphicsItem *item, selectedItems()) {
+ UMLWidget *wid = dynamic_cast<UMLWidget*>(item);
+ if(wid) {
+ list << wid;
+ }
+ }
+ return list;
+}
+
+/**
+ * Sets whether to show snap grid.
+ */
+void NewScene::setSnapGridVisible(bool bShow)
+{
+ m_layoutgrid->setVisible(bShow);
+ //emit sigShowGridToggled(bShow);
+}
+
+Diagrams *NewScene::diagrams() const
+{
+ return m_diagrams;
+}
+
+
--- branches/work/soc-umbrello-2011/umbrello/newcanvas/newscene.h #1231455:1231456
@@ -13,9 +13,20 @@
#include <QtGui/QGraphicsScene>
+#include "optionstate.h"
+#include "messagewidgetlist.h"
+#include "umlwidget.h"
+#include "umlwidgetlist.h"
+#include "associationwidgetlist.h"
+#include "layoutgrid.h"
+#include "diagrams.h"
+
class NewView;
+class Print;
class UMLFolder;
+class LayouGrid;
+
class NewScene : public QGraphicsScene
{
public:
@@ -25,13 +36,32 @@
void setColors(const QColor& backColor, const QColor& gridColor);
QColor gridDotColor() const;
-protected:
+ const Settings::OptionState& optionState() const;
+ MessageWidgetList& messageList();
+ UMLWidgetList& widgetList();
- virtual void drawBackground(QPainter & painter, const QRect & clip);
+ MessageWidgetList m_MessageList; ///< All the message widgets on the diagram.
+ UMLWidgetList m_WidgetList; ///< All the UMLWidgets on the diagram.
+ AssociationWidgetList m_AssociationList; ///< All the AssociationWidgets on the diagram.
+ UMLWidgetList selectedWidgets() const;
+ AssociationWidgetList selectedAssocs();
+ bool isSnapGridVisible() const;
+ void setSnapGridVisible(bool bShow);
+ Diagrams *diagrams() const;
+
+private:
+
+ LayoutGrid *m_layoutgrid;
UMLFolder *m_folder;
NewView * m_view; ///< The view the canvas is associated with.
QColor m_gridColor; ///< Color for the grid dots.
+ Diagrams *m_diagrams;
+ Print *m_print;
+ Settings::OptionState m_Options; ///< Options used by view.
+
+
+
};
#endif
More information about the umbrello-devel
mailing list