[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello

Hassan Kouch hkouch at hotmail.com
Mon Jan 22 20:30:14 UTC 2007


SVN commit 626316 by kouch:

class to draw a combined fragment


 M  +38 -73    combinedfragmentwidget.cpp  
 M  +6 -7      combinedfragmentwidget.h  
 M  +0 -2      toolbarstatefactory.cpp  
 M  +5 -0      toolbarstateother.cpp  
 M  +2 -1      umlnamespace.h  


--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.cpp #626315:626316
@@ -32,74 +32,52 @@
 #include <QMouseEvent>
 #include <QPolygon>
 
-combinedFragmentWidget::combinedFragmentWidget(UMLView * view, CombinedFragmentType combfragmentType, Uml::IDType id ) : UMLWidget(view, id)
+CombinedFragmentWidget::CombinedFragmentWidget(UMLView * view, CombinedFragmentType combfragmentType, Uml::IDType id ) : UMLWidget(view, id)
 {
-    UMLWidget::setBaseType( Uml::wt_Activity );
+    UMLWidget::setBaseType( Uml::wt_Combined_Fragment );
     setCombinedFragmentType( combfragmentType );
     updateComponentSize();
 }
 
-combinedFragmentWidget::~combinedFragmentWidget() {}
+CombinedFragmentWidget::~CombinedFragmentWidget() {}
 
-void combinedFragmentWidget::draw(QPainter & p, int offsetX, int offsetY) {
+void CombinedFragmentWidget::draw(QPainter & p, int offsetX, int offsetY) {
+    
     int w = width();
     int h = height();
+    UMLWidget::setPen(p);
+	if ( UMLWidget::getUseFillColour() ) {
+		p.setBrush( UMLWidget::getFillColour() );
+	}
+	{
+		const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+		const int fontHeight  = fm.lineSpacing();
+		//int middleX = w / 2;
+		int textStartY = (h / 2) - (fontHeight / 2);
+		p.drawRect(offsetX, offsetY, w + 100, h + 100);
+		p.drawLine(offsetX, offsetY + 20, offsetX + 30, offsetY + 20);
+		p.drawLine(offsetX + 30, offsetY + 20, offsetX + 35, offsetY + 10);
+		p.drawLine(offsetX + 35, offsetY + 10, offsetX + 35, offsetY);
+		p.setPen(Qt::black);
+		p.setFont( UMLWidget::getFont() );
     switch ( m_CombinedFragment )
     {
     case Normal :
+
+            p.drawText(offsetX + ACTIVITY_MARGIN, offsetY + 5,
+                       w - ACTIVITY_MARGIN * 2, fontHeight, Qt::AlignLeft, "ref");
+        
         UMLWidget::setPen(p);
-        if ( UMLWidget::getUseFillColour() ) {
-            p.setBrush( UMLWidget::getFillColour() );
-        }
-        {
-            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
-            const int fontHeight  = fm.lineSpacing();
-            //int middleX = w / 2;
-            int textStartY = (h / 2) - (fontHeight / 2);
-            p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
-            p.setPen(Qt::black);
-            p.setFont( UMLWidget::getFont() );
-            p.drawText(offsetX + ACTIVITY_MARGIN, offsetY + textStartY,
-                       w - ACTIVITY_MARGIN * 2, fontHeight, Qt::AlignCenter, getName());
-        }
-        UMLWidget::setPen(p);
         break;
-    case Initial :
-        UMLWidget::setPen(p);
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX, offsetY, w, h );
-        break;
-    case End :
-        UMLWidget::setPen(p);
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX, offsetY, w, h );
-        p.setBrush( Qt::white );
-        p.drawEllipse( offsetX + 1, offsetY + 1, w - 2, h - 2 );
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX + 3, offsetY + 3, w - 6, h - 6 );
-        break;
-    case Branch :
-        UMLWidget::setPen(p);
-        p.setBrush( UMLWidget::getFillColour() );
-        {
-            QPolygon array( 4 );
-            array[ 0 ] = QPoint( offsetX + w / 2, offsetY );
-            array[ 1 ] = QPoint( offsetX + w, offsetY  + h / 2 );
-            array[ 2 ] = QPoint( offsetX + w / 2, offsetY + h );
-            array[ 3 ] = QPoint( offsetX, offsetY + h / 2 );
-            p.drawPolygon( array );
-            p.drawPolyline( array );
-        }
-        break;
-    case Fork_DEPRECATED :  // to be removed
-        p.fillRect( offsetX, offsetY, width(), height(), QBrush( Qt::darkYellow ));
-        break;
+	default : break;
     }
+}
+
     if(m_bSelected)
         drawSelected(&p, offsetX, offsetY);
 }
 
-QSize combinedFragmentWidget::calculateSize() {
+QSize CombinedFragmentWidget::calculateSize() {
     int width = 10, height = 10;
     if ( m_CombinedFragment == Normal ) {
         const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
@@ -110,22 +88,20 @@
         height = height > ACTIVITY_HEIGHT ? height : ACTIVITY_HEIGHT;
         width += ACTIVITY_MARGIN * 2;
         height += ACTIVITY_MARGIN * 2;
-    } else if ( m_CombinedFragment == Branch ) {
-        width = height = 20;
-    }
+    } 
     return QSize(width, height);
 }
 
-combinedFragmentWidget::CombinedFragmentType combinedFragmentWidget::getCombinedFragmentType() const {
+CombinedFragmentWidget::CombinedFragmentType CombinedFragmentWidget::getCombinedFragmentType() const {
     return m_CombinedFragment;
 }
 
-void combinedFragmentWidget::setCombinedFragmentType( CombinedFragmentType combinedfragmentType ) {
+void CombinedFragmentWidget::setCombinedFragmentType( CombinedFragmentType combinedfragmentType ) {
     m_CombinedFragment = combinedfragmentType;
     UMLWidget::m_bResizable = (m_CombinedFragment == Normal);
 }
 
-void combinedFragmentWidget::slotMenuSelection(int sel) {
+void CombinedFragmentWidget::slotMenuSelection(int sel) {
     bool done = false;
 
     bool ok = false;
@@ -149,7 +125,7 @@
         UMLWidget::slotMenuSelection( sel );
 }
 
-bool combinedFragmentWidget::showProperties() {
+bool CombinedFragmentWidget::showProperties() {
 //     DocWindow *docwindow = UMLApp::app()->getDocWindow();
 //     docwindow->updateDocumentation(false);
 // 
@@ -164,27 +140,15 @@
     return true;
 }
 
-bool combinedFragmentWidget::isCombinedFragment(WorkToolBar::ToolBar_Buttons tbb,
+bool CombinedFragmentWidget::isCombinedFragment(WorkToolBar::ToolBar_Buttons tbb,
                                 CombinedFragmentType& resultType)
 {
     bool status = true;
     switch (tbb) {
-    case WorkToolBar::tbb_Initial_Activity:
-        resultType = Initial;
-        break;
+;
     case WorkToolBar::tbb_Seq_Combined_Fragment:
         resultType = Normal;
         break;
-    case WorkToolBar::tbb_End_Activity:
-        resultType = End;
-        break;
-    case WorkToolBar::tbb_Branch:
-        resultType = Branch;
-        break;
-    case WorkToolBar::tbb_Fork:
-        kError() << "ActivityWidget::isActivity returns Fork_DEPRECATED" << endl;
-        resultType = Fork_DEPRECATED;
-        break;
     default:
         status = false;
         break;
@@ -192,7 +156,8 @@
     return status;
 }
 
-void combinedFragmentWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
+
+void CombinedFragmentWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
     QDomElement combinedFragmentElement = qDoc.createElement( "combinedFragmentwidget" );
     UMLWidget::saveToXMI( qDoc, combinedFragmentElement );
     combinedFragmentElement.setAttribute( "combinedFragmentname", m_Text );
@@ -201,7 +166,7 @@
     qElement.appendChild( combinedFragmentElement );
 }
 
-bool combinedFragmentWidget::loadFromXMI( QDomElement & qElement ) {
+bool CombinedFragmentWidget::loadFromXMI( QDomElement & qElement ) {
     if( !UMLWidget::loadFromXMI( qElement ) )
         return false;
     m_Text = qElement.attribute( "combinedFragmentname", "" );
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.h #626315:626316
@@ -31,17 +31,16 @@
  * @author Hassan KOUCH <hkouch at hotmail.com>
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-class combinedFragmentWidget : public UMLWidget {
+class CombinedFragmentWidget : public UMLWidget {
     Q_OBJECT
 
 public:
     enum CombinedFragmentType
     {
         Initial = 0,
-        Normal,
-        End,
-        Branch,
-        Fork_DEPRECATED  // use ForkJoinWidget instead
+	Normal,
+        Ref
+  
     };
 
     /**
@@ -51,13 +50,13 @@
      * @param combinedfragmentType      The type of combined fragment.
      * @param id                The ID to assign (-1 will prompt a new ID.)
      */
-    combinedFragmentWidget( UMLView * view, CombinedFragmentType combinedfragmentType = Normal, Uml::IDType id = Uml::id_None );
+    CombinedFragmentWidget( UMLView * view, CombinedFragmentType combinedfragmentType = Normal, Uml::IDType id = Uml::id_None );
 
 
     /**
      *  destructor
      */
-    virtual ~combinedFragmentWidget();
+    virtual ~CombinedFragmentWidget();
 
     /**
      * Overrides the standard paint event.
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatefactory.cpp #626315:626316
@@ -87,8 +87,6 @@
     case WorkToolBar::tbb_Seq_Message_Asynchronous: return 2;
     case WorkToolBar::tbb_Seq_Message_Found: 	    return 2;
     case WorkToolBar::tbb_Seq_Message_Lost: 	    return 2;
-    case WorkToolBar::tbb_Seq_Combined_Fragment:    return 2;
-    //case WorkToolBar::tbb_Seq_Precondition: return 2;
     
     	// Arrow pointer
     case WorkToolBar::tbb_Arrow: return 3;
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateother.cpp #626315:626316
@@ -26,6 +26,7 @@
 #include "notewidget.h"
 #include "object_factory.h"
 #include "preconditionwidget.h"
+#include "combinedfragmentwidget.h"
 #include "statewidget.h"
 #include "uml.h"
 #include "umlview.h"
@@ -133,6 +134,10 @@
             umlWidget = new StateWidget(m_pUMLView, StateWidget::End);
             break;
 
+	case WorkToolBar::tbb_Seq_Combined_Fragment:
+            umlWidget = new CombinedFragmentWidget(m_pUMLView);
+            break;
+
         default:
             break;
     }
--- branches/work/isi-umbrello/umbrello/umbrello/umlnamespace.h #626315:626316
@@ -105,7 +105,8 @@
     wt_Node,                    // has UMLObject representation
     wt_Association,             // has UMLObject representation
     wt_ForkJoin,                 // does not have UMLObject representation
-    wt_Precondition		// does not have UMLObject representation
+    wt_Precondition,		// does not have UMLObject representation
+    wt_Combined_Fragment	// does not have UMLObject representation
 };
 
 enum Diagram_Type




More information about the umbrello-devel mailing list