umbrello API Documentation

umlview.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #ifndef UMLVIEW_H
00013 #define UMLVIEW_H
00014 
00015 #ifdef HAVE_CONFIG_H
00016 #include <config.h>
00017 #endif
00018 
00019 // system includes
00020 #include <kurl.h>
00021 #include <qdom.h>
00022 #include <qcanvas.h>
00023 
00024 //local includes
00025 #include "umlobjectlist.h"
00026 #include "umlwidgetlist.h"
00027 #include "associationwidgetlist.h"
00028 #include "messagewidgetlist.h"
00029 #include "optionstate.h"
00030 #include "worktoolbar.h"
00031 
00032 // forward declarations
00033 class ClassOptionsPage;
00034 class IDChangeLog;
00035 class ListPopupMenu;
00036 class FloatingTextWidget;
00037 class ObjectWidget;
00038 class UMLFolder;
00039 class UMLApp;
00040 class UMLDoc;
00041 class UMLAttribute;
00042 class UMLCanvasObject;
00043 class UMLClassifier;
00044 class UMLViewImageExporter;
00045 
00046 class KPrinter;
00047 class ToolBarState;
00048 class ToolBarStateFactory;
00049 
00060 class UMLView : public QCanvasView {
00061     Q_OBJECT
00062 public:
00063     friend class UMLViewImageExporterModel;
00064 
00068     UMLView(UMLFolder *parentFolder);
00069 
00073     virtual ~UMLView();
00074 
00075     // Accessors and other methods dealing with loaded/saved data
00076 
00080     UMLFolder *getFolder() {
00081         return m_pFolder;
00082     }
00083 
00087     void setFolder(UMLFolder *folder) {
00088         m_pFolder = folder;
00089     }
00090 
00094     QString getDoc() const {
00095         return m_Documentation;
00096     }
00097 
00101     void setDoc( const QString &doc ) {
00102         m_Documentation = doc;
00103     }
00104 
00108     QString getName() const;
00109 
00113     void setName(const QString &name);
00114 
00118     Uml::Diagram_Type getType() const {
00119         return m_Type;
00120     }
00121 
00125     void setType( Uml::Diagram_Type type ) {
00126         m_Type = type;
00127     }
00128 
00132     QColor getFillColor() const;
00133 
00139     void setFillColor( const QColor &color );
00140 
00144     QColor getLineColor() const;
00145 
00151     void setLineColor( const QColor &color );
00152 
00156     uint getLineWidth() const;
00157 
00163     void setLineWidth( uint width );
00164 
00168     Uml::IDType getID() const {
00169         return m_nID;
00170     }
00171 
00175     void setID( Uml::IDType id ) {
00176         m_nID = id;
00177     }
00178 
00182     int getZoom() const {
00183         return m_nZoom;
00184     }
00185 
00189     void setZoom(int zoom);
00190 
00194     int getCanvasHeight() const {
00195         return m_nCanvasHeight;
00196     }
00197 
00201     void setCanvasHeight(int height) {
00202         m_nCanvasHeight = height;
00203     }
00204 
00208     int getCanvasWidth() const {
00209         return m_nCanvasWidth;
00210     }
00211 
00215     void setCanvasWidth(int width) {
00216         m_nCanvasWidth = width;
00217     }
00218 
00222     bool getSnapToGrid() const {
00223         return m_bUseSnapToGrid;
00224     }
00225 
00229     void setSnapToGrid( bool bSnap );
00230 
00234     bool getSnapComponentSizeToGrid() const {
00235         return m_bUseSnapComponentSizeToGrid;
00236     }
00237 
00241     int getSnapX() const {
00242         return m_nSnapX;
00243     }
00244 
00248     int getSnapY() const {
00249         return m_nSnapY;
00250     }
00251 
00255     int snappedX(int x);
00256 
00260     int snappedY(int y);
00261 
00265     bool getShowSnapGrid() const;
00266 
00270     void setShowSnapGrid( bool bShow );
00271 
00275     void setSnapComponentSizeToGrid( bool bSnap );
00276 
00280     bool getUseFillColor() const;
00281 
00285     void setUseFillColor(bool ufc);
00286 
00290     QFont getFont() const;
00291 
00295     void setFont(QFont font, bool changeAllWidgets = false);
00296 
00300     bool getShowOpSig() const;
00301 
00305     void setShowOpSig(bool bShowOpSig);
00306 
00310     const Settings::OptionState& getOptionState() const {
00311         return m_Options;
00312     }
00313 
00317     void setOptionState( const Settings::OptionState& options) {
00318         m_Options = options;
00319     }
00320 
00324     AssociationWidgetList& getAssociationList() {
00325         return m_AssociationList;
00326     }
00327 
00331     UMLWidgetList& getWidgetList() {
00332         return m_WidgetList;
00333     }
00334 
00338     MessageWidgetList& getMessageList() {
00339         return m_MessageList;
00340     }
00341 
00342     // End of accessors and methods that only deal with loaded/saved data
00344 
00348     int currentZoom();
00349 
00353     void print(KPrinter *pPrinter, QPainter & pPainter);
00354 
00358     void hideEvent(QHideEvent *he);
00359 
00363     void showEvent(QShowEvent *se);
00364 
00369     void checkMessages(ObjectWidget * w);
00370 
00378     UMLWidget * findWidget(Uml::IDType id);
00379 
00387     AssociationWidget * findAssocWidget(Uml::IDType id);
00388 
00398     AssociationWidget * findAssocWidget(Uml::Association_Type at,
00399                                         UMLWidget *pWidgetA, UMLWidget *pWidgetB);
00400 
00413     AssociationWidget * findAssocWidget(UMLWidget *pWidgetA,
00414                                         UMLWidget *pWidgetB, const QString& roleNameB);
00415 
00421     void removeWidget(UMLWidget * o);
00422 
00429     void setSelected(UMLWidget * w, QMouseEvent * me);
00430 
00434     void clearSelected();
00435 
00442     void moveSelectedBy(int dX, int dY);
00443 
00452     int getSelectCount(bool filterText = false) const;
00453 
00459     void selectionUseFillColor(bool useFC);
00460 
00464     void selectionSetFont( const QFont &font );
00465 
00469     void selectionSetLineColor( const QColor &color );
00470 
00474     void selectionSetLineWidth( uint width );
00475 
00479     void selectionSetFillColor( const QColor &color );
00480 
00484     void selectionToggleShow(int sel);
00485 
00489     void deleteSelection();
00490 
00494     void selectAll();
00495 
00501     Uml::IDType getLocalID();
00502 
00510     bool widgetOnDiagram(Uml::IDType id);
00511 
00516     bool isSavedInSeparateFile();
00517 
00521     QPoint & getPos() {
00522         return m_Pos;
00523     }
00524 
00530     void setPos(const QPoint &_pos) {
00531         m_Pos = _pos;
00532     }
00533 
00538     void setMenu();
00539 
00543     void resetToolbar() {
00544         emit sigResetToolBar();
00545     }
00546 
00552     bool getPaste() const {
00553         return m_bPaste;
00554     }
00555 
00559     void setPaste(bool paste) {
00560         m_bPaste = paste;
00561     }
00562 
00566     UMLObjectList getUMLObjects();
00567 
00571     void activate();
00572 
00576     AssociationWidgetList getSelectedAssocs();
00577 
00586     bool getSelectedWidgets(UMLWidgetList& WidgetList, bool filterText = true);
00587 
00591     void activateAfterLoad( bool bUseLog = false );
00592 
00593     void endPartialWidgetPaste();
00594     void beginPartialWidgetPaste();
00595 
00601     void removeAssoc(AssociationWidget* pAssoc);
00602 
00608     void removeAssociations(UMLWidget* pWidget);
00609 
00613     void selectAssociations(bool bSelect);
00614 
00618     void getWidgetAssocs(UMLObject* Obj, AssociationWidgetList & Associations);
00619 
00623     void removeAllAssociations();
00624 
00628     void removeAllWidgets();
00629 
00633     void showDocumentation( UMLObject * object, bool overwrite );
00634 
00638     void showDocumentation( UMLWidget * widget, bool overwrite );
00639 
00643     void showDocumentation( AssociationWidget * widget, bool overwrite );
00644 
00648     void updateDocumentation( bool clear );
00649 
00656     void getDiagram(const QRect &rect, QPixmap & diagram);
00657 
00661     void  getDiagram(const QRect &area, QPainter & painter);
00662 
00666     void copyAsImage(QPixmap*& pix);
00667 
00673     UMLViewImageExporter* getImageExporter();
00674 
00679     bool addAssociation( AssociationWidget* pAssoc , bool isPasteOperation = false);
00680 
00685     void removeAssocInViewAndDoc(AssociationWidget* assoc);
00686 
00691     bool addWidget( UMLWidget * pWidget , bool isPasteOperation = false);
00692 
00699     QPoint getPastePoint();
00700 
00704     void resetPastePoint();
00705 
00710     void setStartedCut() {
00711         m_bStartedCut = true;
00712     }
00713 
00719     void createAutoAssociations( UMLWidget * widget );
00720 
00727     void createAutoAttributeAssociations(UMLWidget *widget);
00728 
00737     void updateContainment(UMLCanvasObject *self);
00738 
00742     void setSnapX( int x) {
00743         m_nSnapX = x;
00744         canvas() -> setAllChanged();
00745     }
00746 
00750     void setSnapY( int y) {
00751         m_nSnapY = y;
00752         canvas() -> setAllChanged();
00753     }
00754 
00758     bool showPropDialog();
00759 
00763     void setClassWidgetOptions( ClassOptionsPage * page );
00764 
00770     void checkSelections();
00771 
00778     bool checkUniqueSelection();
00779 
00784     void clearDiagram();
00785 
00790     void toggleSnapToGrid();
00791 
00796     void toggleSnapComponentSizeToGrid();
00797 
00802     void toggleShowGrid();
00803 
00808     void fileLoaded();
00809 
00813     void setCanvasSize(int width, int height);
00814 
00818     void resizeCanvasToItems();
00819 
00823     static const int defaultCanvasSize;
00824 
00825     // Load/Save interface:
00826 
00830     virtual void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
00831 
00835     virtual bool loadFromXMI( QDomElement & qElement );
00836 
00840     bool loadUISDiagram(QDomElement & qElement);
00841 
00845     UMLWidget* loadWidgetFromXMI(QDomElement& widgetElement);
00846 
00850     void addObject(UMLObject *object);
00851 
00855     void selectWidgets(int px, int py, int qx, int qy);
00856 
00864     ObjectWidget * onWidgetLine( const QPoint &point );
00865 
00869     UMLWidget* getFirstMultiSelectedWidget() {
00870         return m_SelectedList.first();
00871     }
00872 
00880     UMLWidget *getWidgetAt(QPoint p);
00881 
00886     void setupNewWidget(UMLWidget *w);
00887 
00891     bool getCreateObject() const {
00892         return m_bCreateObject;
00893     }
00894 
00898     void setCreateObject(bool bCreate) {
00899         m_bCreateObject = bCreate;
00900     }
00901 
00905     void emitRemovePopupMenu() {
00906         emit sigRemovePopupMenu();
00907     }
00908 
00912     int generateCollaborationId();
00913 
00914 protected:
00915 
00916     // Methods and members related to loading/saving
00917 
00918     bool loadWidgetsFromXMI( QDomElement & qElement );
00919 
00920     bool loadMessagesFromXMI( QDomElement & qElement );
00921 
00922     bool loadAssociationsFromXMI( QDomElement & qElement );
00923 
00924     bool loadUisDiagramPresentation(QDomElement & qElement);
00925 
00930     Uml::IDType m_nLocalID;
00931 
00935     Uml::IDType m_nID;
00936 
00940     Uml::Diagram_Type m_Type;
00941 
00945     QString m_Name;
00946 
00950     QString m_Documentation;
00951 
00955     Settings::OptionState m_Options;
00956 
00960     MessageWidgetList m_MessageList;
00961 
00965     UMLWidgetList m_WidgetList;
00966 
00970     AssociationWidgetList m_AssociationList;
00971 
00975     int m_nSnapX;
00976 
00980     int m_nSnapY;
00981 
00985     bool m_bUseSnapToGrid;
00986 
00991     bool m_bUseSnapComponentSizeToGrid;
00992 
00996     bool m_bShowSnapGrid;
00997 
01001     int m_nZoom;
01002 
01006     int m_nCanvasWidth;
01007 
01011     int m_nCanvasHeight;
01012 
01013     // End of methods and members related to loading/saving
01015 
01019     void closeEvent ( QCloseEvent * e );
01020 
01024     void contentsDragEnterEvent(QDragEnterEvent* mouseEvent);
01025 
01029     void contentsDropEvent(QDropEvent* mouseEvent);
01030 
01031 
01037     QRect getDiagramRect();
01038 
01039 
01043     void init();
01044 
01049     void contentsMouseReleaseEvent(QMouseEvent* mouseEvent);
01050 
01055     void contentsMouseMoveEvent(QMouseEvent* mouseEvent);
01056 
01061     void contentsMouseDoubleClickEvent(QMouseEvent* mouseEvent);
01062 
01067     void contentsMousePressEvent(QMouseEvent* mouseEvent);
01068 
01069 
01073     void selectWidgetsOfAssoc (AssociationWidget * a);
01074 
01080     void makeSelected (UMLWidget * uw);
01081 
01085     void updateComponentSizes();
01086 
01105     void findMaxBoundingRectangle(const FloatingTextWidget* ft,
01106                                   int& px, int& py, int& qx, int& qy);
01107 
01108     void forceUpdateWidgetFontMetrics(QPainter *painter);
01109 
01113     int m_nCollaborationId;
01114 
01115     QPoint m_Pos;
01116     bool m_bCreateObject, m_bDrawSelectedOnly, m_bPaste;
01117     ListPopupMenu * m_pMenu;
01118     UMLWidgetList m_SelectedList;
01119 
01123     bool m_bStartedCut;
01124 
01125 private:
01129     UMLFolder *m_pFolder;
01130 
01136     bool m_bChildDisplayedDoc;
01137 
01138     ToolBarStateFactory* m_pToolBarStateFactory;
01139     ToolBarState* m_pToolBarState;
01140 
01144     IDChangeLog * m_pIDChangesLog;
01145 
01150     bool m_bActivated;
01151 
01156     bool m_bPopupShowing;
01157 
01161     QPoint m_PastePoint;
01162 
01166     UMLDoc* m_pDoc;
01167 
01171     UMLViewImageExporter* m_pImageExporter;
01172 
01177     void createAutoAttributeAssociation(UMLClassifier *type,
01178                                         UMLAttribute *attr,
01179                                         UMLWidget *widget);
01180 
01181 public slots:
01182 
01183     void zoomIn();
01184     void zoomOut();
01185 
01190     void slotToolBarChanged(int c);
01191     void slotObjectCreated(UMLObject * o);
01192     void slotObjectRemoved(UMLObject * o);
01193 
01198     void slotMenuSelection(int sel);
01199 
01206     void slotRemovePopupMenu();
01207 
01211     void slotActivate();
01212 
01220     void slotCutSuccessful();
01221 
01225     void slotShowView();
01226 
01231     void show();
01232 
01233 signals:
01234     void sigResetToolBar();
01235     void sigColorChanged( Uml::IDType );
01236     void sigRemovePopupMenu();
01237     void sigClearAllSelected();
01238     void sigLineWidthChanged( Uml::IDType );
01239     void sigSnapToGridToggled(bool);
01240     void sigSnapComponentSizeToGridToggled(bool);
01241     void sigShowGridToggled(bool);
01242 
01246     void sigAssociationRemoved(AssociationWidget*);
01247 
01251     void sigWidgetRemoved(UMLWidget*);
01252 };
01253 
01254 #endif // UMLVIEW_H
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:01 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003