[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Hassan Kouch
hkouch at hotmail.com
Fri Mar 2 20:18:29 UTC 2007
SVN commit 638660 by kouch:
Work on the Pin Widget : when we click in the superior part of an activity, a pin is created there, and when we click in the
inferior part, a pin is created down...and we can create a pin just when clicking on an activity.
M +1 -1 CMakeLists.txt
M +68 -100 pinwidget.cpp
M +33 -28 pinwidget.h
M +3 -2 toolbarstatefactory.cpp
A toolbarstateonewidget.cpp [License: GPL (v2+)]
A toolbarstateonewidget.h [License: GPL (v2+)]
M +0 -5 toolbarstateother.cpp
D toolbarstatesequence.cpp
D toolbarstatesequence.h
--- branches/work/isi-umbrello/umbrello/umbrello/CMakeLists.txt #638659:638660
@@ -337,9 +337,9 @@
toolbarstateassociation.cpp
toolbarstatefactory.cpp
toolbarstatemessages.cpp
+ toolbarstateonewidget.cpp
toolbarstateother.cpp
toolbarstatepool.cpp
- toolbarstatesequence.cpp
uml.cpp
umlattributelist.cpp
umlentityattributelist.cpp
--- branches/work/isi-umbrello/umbrello/umbrello/pinwidget.cpp #638659:638660
@@ -32,132 +32,100 @@
#include <QMouseEvent>
#include <QPolygon>
-PinWidget::PinWidget(UMLView * view, Uml::IDType id ): UMLWidget(view, id)
-{
- UMLWidget::setBaseType( Uml::wt_Pin );
- updateComponentSize();
+PinWidget::PinWidget(UMLView * view, ActivityWidget* a, Uml::IDType id ): UMLWidget(view, id){
+
+ init();
+ m_pOw[Uml::A] = a;
+ int y = getY();
+ m_nY = y;
+ y = y < getMinY() ? getMinY() : y;
+ m_nY = y;
+ this->activate();
}
PinWidget::~PinWidget() {}
+void PinWidget::init() {
+ UMLWidget::setBaseType(Uml::wt_Pin);
+ m_bIgnoreSnapToGrid = true;
+ m_bIgnoreSnapComponentSizeToGrid = true;
+ m_bResizable = false ;
+ m_pOw[Uml::A] = NULL;
+ m_nY = 0;
+ setVisible(true);
+}
+
void PinWidget::draw(QPainter & p, int offsetX, int offsetY) {
- int w = width();
- int h = height();
-
+ int w = 10;
+ int h = 10;
+ int width_Activity = m_pOw[Uml::A]->getWidth();
+ int height_Activity = m_pOw[Uml::A]->getHeight();
+ int y;
+
+ int x = m_pOw[Uml::A]->getX() + (width_Activity/2);
+ setX(x);
+
+ if ( (offsetY + height_Activity/2) <= m_pOw[Uml::A]->getY() + height_Activity){
+ y = m_pOw[Uml::A]->getY()-5;
+ } else if((offsetY + height_Activity/2) > m_pOw[Uml::A]->getY() + height_Activity){
+ y = (m_pOw[Uml::A]->getY() + height_Activity)-5;
+ }
+ setY(y);
+
+
+//test if y isn't above the object
+// if ( y <= m_pOw[Uml::A]->getY() + height_Activity-5 && x == m_pOw[Uml::A]->getX() + (width_Activity/2) ) {
+// y = m_pOw[Uml::A]->getY() + height_Activity + 15;
+// }
+// if (y + h >= m_pOw[Uml::A]->getEndLineY()) {
+// y = m_pOw[Uml::A]->getEndLineY() - h;
+// }
+
+
UMLWidget::setPen(p);
if ( UMLWidget::getUseFillColour() ) {
p.setBrush( UMLWidget::getFillColour() );
}
-// {
-// const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
-// const int fontHeight = fm.lineSpacing();
-// int textStartY = (h / 2) - (fontHeight / 2);
- p.drawRect(offsetX, offsetY, w, h);
-// p.drawLine(offsetX + 10, offsetY + (h/2) +3 , (offsetX + w)-10, offsetY + (h/2) +3 );
-// p.setPen(Qt::black);
-// p.setFont( UMLWidget::getFont() );
-// p.drawText(offsetX + OBJECTFLOW_MARGIN, (offsetY + textStartY/2), w - OBJECTFLOW_MARGIN * 2, fontHeight, Qt::AlignHCenter, getName());
-// }
+
+ p.drawRect(x,y,w, h);
UMLWidget::setPen(p);
if(m_bSelected)
drawSelected(&p, offsetX, offsetY);
}
-QSize PinWidget::calculateSize() {
-// int width = 10, height = 10;
-// const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
-// const int fontHeight = fm.lineSpacing();
-// const int textWidth = fm.width(getName());
-// height = fontHeight;
-// width = textWidth > OBJECTFLOW_WIDTH ? textWidth : OBJECTFLOW_WIDTH;
-// height = height + 5 > OBJECTFLOW_HEIGHT ? height + 5 : OBJECTFLOW_HEIGHT;
-// width += OBJECTFLOW_MARGIN * 2;
-// height += (OBJECTFLOW_MARGIN * 2);
-
- return QSize(7,7);
+int PinWidget::getMinY() {
+ if (!m_pOw[Uml::A]) {
+ return 0;
+ }
+ int heightA = m_pOw[Uml::A]->getY() + m_pOw[Uml::A]->getHeight();
+ int height = heightA;
+ return height;
}
-// void ObjectFlowWidget::slotMenuSelection(int sel) {
-// bool done = false;
-//
-// bool ok = false;
-// QString name = m_Text;
-//
-// switch( sel ) {
-// case ListPopupMenu::mt_Rename:
-// name = KInputDialog::getText( i18n("Enter Object Flow Name"), i18n("Enter the name of the new Object Flow:"), m_Text, &ok );
-// if( ok && name.length() > 0 )
-// m_Text = name;
-// done = true;
-// break;
-//
-// case ListPopupMenu::mt_Properties:
-// showProperties();
-// done = true;
-// break;
+// int PinWidget::getMaxY() {
+// if( !m_pOw[Uml::A]) {
+// return 0;
// }
//
-// if( !done )
-// UMLWidget::slotMenuSelection( sel );
+// int heightA = (int)((ActivityWidget*)m_pOw[Uml::A])->getEndLineY();
+// int height = heightA;
+// return (height - this->height());
// }
-// bool ObjectFlowWidget::showProperties() {
-// // DocWindow *docwindow = UMLApp::app()->getDocWindow();
-// // docwindow->updateDocumentation(false);
-// //
-// // ObjectFlowDialog dialog(m_pView, this);
-// // bool modified = false;
-// // if (dialog.exec() && dialog.getChangesMade()) {
-// // docwindow->showDocumentation(this, true);
-// // UMLApp::app()->getDocument()->setModified(true);
-// // modified = true;
-// // }
-// //
-// return true;
- //}
-//
-// bool ObjectFlowWidget::isObjectFlow(WorkToolBar::ToolBar_Buttons tbb,
-// ObjectFlowType& resultType)
-// {
-// bool status = true;
-// switch (tbb) {
-// case WorkToolBar::tbb_Initial_ObjectFlow:
-// resultType = Initial;
-// break;
-// case WorkToolBar::tbb_ObjectFlow:
-// resultType = Normal;
-// break;
-// case WorkToolBar::tbb_End_ObjectFlow:
-// resultType = End;
-// break;
-// case WorkToolBar::tbb_Branch:
-// resultType = Branch;
-// break;
-// case WorkToolBar::tbb_Fork:
-// kError() << "ObjectFlowWidget::isObjectFlow returns Fork_DEPRECATED" << endl;
-// resultType = Fork_DEPRECATED;
-// break;
-// default:
-// status = false;
-// break;
-// }
-// return status;
-// }
-
void PinWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
- QDomElement ObjectFlowElement = qDoc.createElement( "objectflowwidget" );
- UMLWidget::saveToXMI( qDoc, ObjectFlowElement );
- ObjectFlowElement.setAttribute( "objectflowname", m_Text );
- ObjectFlowElement.setAttribute( "documentation", m_Doc );
- qElement.appendChild( ObjectFlowElement );
+ QDomElement PinElement = qDoc.createElement( "pinwidget" );
+ UMLWidget::saveToXMI( qDoc, PinElement );
+ //PinElement.setAttribute( "pinname", m_Text );
+ // PinElement.setAttribute( "documentation", m_Doc );
+ qElement.appendChild( PinElement );
}
bool PinWidget::loadFromXMI( QDomElement & qElement ) {
if( !UMLWidget::loadFromXMI( qElement ) )
return false;
- m_Text = qElement.attribute( "objectflowname", "" );
-kDebug() << "load objectflowwidget from xmi !!!! " << m_Text << endl;
- m_Doc = qElement.attribute( "documentation", "" );
+ //m_Text = qElement.attribute( "pinname", "" );
+//kDebug() << "load pinwidget from xmi !!!! " << m_Text << endl;
+ // m_Doc = qElement.attribute( "documentation", "" );
//QString type = qElement.attribute( "objectflowtype", "1" );
// setObjectFlowType( (ObjectFlowType)type.toInt() );
return true;
--- branches/work/isi-umbrello/umbrello/umbrello/pinwidget.h #638659:638660
@@ -14,11 +14,15 @@
#include "umlwidget.h"
#include "worktoolbar.h"
+#include "activitywidget.h"
-#define OBJECTFLOW_MARGIN 5
-#define OBJECTFLOW_WIDTH 30
-#define OBJECTFLOW_HEIGHT 10
+#define PIN_MARGIN 5
+#define PIN_WIDTH 1
+#define PIN_HEIGHT 1
+//class ActivityWidget;
+class UMLOperation;
+
/**
* This class is the graphical version of a UML Object Flow. A ObjectFlowWidget is created
* by a @ref UMLView. An ObjectFlowWidget belongs to only one @ref UMLView instance.
@@ -42,7 +46,7 @@
* @param view The parent of the widget.
* @param id The ID to assign (-1 will prompt a new ID.)
*/
- PinWidget( UMLView * view, Uml::IDType id = Uml::id_None );
+ PinWidget( UMLView * view, ActivityWidget* a, Uml::IDType id = Uml::id_None );
/**
* destructor
@@ -50,38 +54,35 @@
virtual ~PinWidget();
/**
+ * Initializes key variables of the class.
+ */
+ void init();
+
+ /**
* Overrides the standard paint event.
*/
void draw(QPainter & p, int offsetX, int offsetY);
+/*
+ * Activates a PreconditionWidget. Connects it m_pOw[] pointer
+ * to UMLObject
+ */
+
+// void activate(IDChangeLog * Log = 0);
+
/**
- * Returns the type of ObjectFlow.
+ * Returns the minimum height this widget should be set at on
+ * a sequence diagrams. Takes into account the widget positions
+ * it is related to.
*/
- // ObjectFlowType getObjectFlowType() const;
+ int getMinY();
/**
- * Sets the type of ObjectFlow.
+ * Returns the maximum height this widget should be set at on
+ * a sequence diagrams. Takes into account the widget positions
+ * it is related to.
*/
- // void setObjectFlowType( ObjectFlowType objectflowType );
-//
-// /**
-// * Show a properties dialog for an ObjectFlowWidget.
-// *
-// * @return True if we modified the ObjectFlow.
-
-// bool showProperties();
-//
-// /**
-// * Determines whether a toolbar button represents an ObjectFlow.
-// * CHECK: currently unused - can this be removed?
-// *
-// * @param tbb The toolbar button enum input value.
-// * @param resultType The ObjectFlowType corresponding to tbb.
-// * This is only set if tbb is an ObjectFlow.
-// * @return True if tbb represents an ObjectFlow.
-// */
-// static bool isObjectFlow( WorkToolBar::ToolBar_Buttons tbb,
-// ObjectFlow& resultType );
+ int getMaxY();
/**
* Saves the widget to the <objectflowwidget> XMI element.
@@ -97,7 +98,7 @@
/**
* Overrides method from UMLWidget
*/
- QSize calculateSize();
+ // QSize calculateSize();
/**
* Type of ObjectFlow.
@@ -110,6 +111,10 @@
* Captures any popup menu signals for menus it created.
*/
// void slotMenuSelection(int sel);
+
+private:
+ ActivityWidget * m_pOw[1];
+ int m_nY;
};
#endif
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatefactory.cpp #638659:638660
@@ -16,7 +16,7 @@
#include "toolbarstatearrow.h"
#include "toolbarstatemessages.h"
#include "toolbarstateassociation.h"
-#include "toolbarstatesequence.h"
+#include "toolbarstateonewidget.h"
#include "umlview.h"
@@ -55,7 +55,7 @@
// This case has no pool.
case 3: states[3] = new ToolBarStateArrow(m_pUMLView); break;
- case 4: states[4] = new ToolBarStateSequence(m_pUMLView); break;
+ case 4: states[4] = new ToolBarStateOneWidget(m_pUMLView); break;
}
}
@@ -93,6 +93,7 @@
case WorkToolBar::tbb_Seq_Precondition: return 4;
case WorkToolBar::tbb_Seq_End_Of_Life: return 4;
+ case WorkToolBar::tbb_Pin: return 4;
// Arrow pointer
case WorkToolBar::tbb_Arrow: return 3;
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateother.cpp #638659:638660
@@ -35,7 +35,6 @@
#include "umldoc.h"
#include "objectwidget.h"
#include "objectflowwidget.h"
-#include "pinwidget.h"
@@ -165,10 +164,6 @@
umlWidget = new ObjectFlowWidget(m_pUMLView);
break;
- case WorkToolBar::tbb_Pin:
- umlWidget = new PinWidget(m_pUMLView);
- break;
-
default:
break;
}
More information about the umbrello-devel
mailing list