[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Florence Mattler
florence.mattler at libertysurf.fr
Thu Jan 18 22:24:51 UTC 2007
SVN commit 625094 by mattler:
Implementation for lost and found messages in sequence diagram for UML 2.0
M +174 -0 messagewidget.cpp
M +23 -2 messagewidget.h
M +2 -1 pics/CMakeLists.txt
AM pics/cursor-message-found.png
AM pics/cursor-message-lost.png
AM pics/message-found.png
AM pics/message-lost.png
M +3 -1 toolbarstatefactory.cpp
M +9 -1 toolbarstatemessages.cpp
M +3 -1 toolbarstatemessages.h
M +3 -1 umlnamespace.h
M +6 -0 worktoolbar.cpp
M +4 -0 worktoolbar.h
--- branches/work/isi-umbrello/umbrello/umbrello/messagewidget.cpp #625093:625094
@@ -92,6 +92,10 @@
drawAsynchronous(p, offsetX, offsetY);
} else if (m_sequenceMessageType == Uml::sequence_message_creation) {
drawCreation(p, offsetX, offsetY);
+ } else if (m_sequenceMessageType == Uml::sequence_message_lost) {
+ drawLost(p, offsetX, offsetY);
+ } else if (m_sequenceMessageType == Uml::sequence_message_found) {
+ drawFound(p, offsetX, offsetY);
} else {
kWarning() << "Unknown message type" << endl;
}
@@ -256,6 +260,106 @@
drawSelected(&p, offsetX, offsetY);
}
+
+void MessageWidget::drawLost(QPainter& p, int offsetX, int offsetY){
+ int x1 = m_pOw[Uml::A]->getX();
+ int x2 = m_pOw[Uml::B]->getX();
+ int w = getWidth() - 1;
+ int h = getHeight() - 1;
+ bool messageOverlapsA = m_pOw[Uml::A] -> messageOverlap( getY(), this );
+ //bool messageOverlapsB = m_pOw[Uml::B] -> messageOverlap( getY(), this );
+
+ if(m_pOw[Uml::A] == m_pOw[Uml::B]) {
+ if (messageOverlapsA) {
+ offsetX += 7;
+ w -= 7;
+ }
+ const int lowerLineY = offsetY + h - 3;
+ // draw upper line segment (leaving the life line)
+ p.drawLine(offsetX, offsetY, offsetX + w, offsetY);
+ // draw line segment parallel to (and at the right of) the life line
+ p.drawLine(offsetX + w, offsetY, offsetX + w, lowerLineY);
+ // draw lower line segment (back to the life line)
+ drawArrow(p, offsetX, lowerLineY, w, Qt::LeftArrow);
+ if (messageOverlapsA) {
+ offsetX -= 7; //reset for drawSelected()
+ }
+ } else if(x1 < x2) {
+ if (messageOverlapsA) {
+ offsetX += 7;
+ w -= 7;
+ }
+ UMLWidget::setPen(p);
+ p.setBrush( WidgetBase::getLineColor() );
+ drawArrow(p, offsetX, offsetY + 4, w, Qt::RightArrow);
+ p.drawEllipse(offsetX + w , offsetY - 3, h + 6, h + 6);
+ if (messageOverlapsA) {
+ offsetX -= 7;
+ }
+ } else {
+ if (messageOverlapsA) {
+ w -= 7;
+ }
+ drawArrow(p, offsetX , offsetY + 4, w, Qt::LeftArrow);
+ UMLWidget::setPen(p);
+ p.setBrush( WidgetBase::getLineColor() );
+ p.drawEllipse(offsetX - 12 , offsetY - 3, h + 6, h + 6);
+ }
+
+ if (m_bSelected)
+ drawSelected(&p, offsetX, offsetY);
+}
+
+void MessageWidget::drawFound(QPainter& p, int offsetX, int offsetY){
+ int x1 = m_pOw[Uml::A]->getX();
+ int x2 = m_pOw[Uml::B]->getX();
+ int w = getWidth() - 1;
+ int h = getHeight() - 1;
+ bool messageOverlapsA = m_pOw[Uml::A] -> messageOverlap( getY(), this );
+ //bool messageOverlapsB = m_pOw[Uml::B] -> messageOverlap( getY(), this );
+
+ if(m_pOw[Uml::A] == m_pOw[Uml::B]) {
+ if (messageOverlapsA) {
+ offsetX += 7;
+ w -= 7;
+ }
+ const int lowerLineY = offsetY + h - 3;
+ // draw upper line segment (leaving the life line)
+ p.drawLine(offsetX, offsetY, offsetX + w, offsetY);
+ // draw line segment parallel to (and at the right of) the life line
+ p.drawLine(offsetX + w, offsetY, offsetX + w, lowerLineY);
+ // draw lower line segment (back to the life line)
+ drawArrow(p, offsetX, lowerLineY, w, Qt::LeftArrow);
+ if (messageOverlapsA) {
+ offsetX -= 7; //reset for drawSelected()
+ }
+ } else if(x1 < x2) {
+ if (messageOverlapsA) {
+ offsetX += 7;
+ w -= 7;
+ }
+ UMLWidget::setPen(p);
+ p.setBrush( WidgetBase::getLineColor() );
+ p.drawEllipse(offsetX, offsetY - 3, h + 6, h + 6);
+ drawArrow(p, offsetX, offsetY + 4, w, Qt::RightArrow);
+ if (messageOverlapsA) {
+ offsetX -= 7;
+ }
+ } else {
+ if (messageOverlapsA) {
+ w -= 7;
+ }
+ UMLWidget::setPen(p);
+ p.setBrush( WidgetBase::getLineColor() );
+ p.drawEllipse(offsetX + w , offsetY - 3, h + 6, h + 6);
+ drawArrow(p, offsetX , offsetY + 4, w, Qt::LeftArrow);
+ }
+
+ if (m_bSelected)
+ drawSelected(&p, offsetX, offsetY);
+
+}
+
int MessageWidget::onWidget(const QPoint & p) {
if (m_sequenceMessageType != Uml::sequence_message_synchronous) {
return UMLWidget::onWidget(p);
@@ -520,6 +624,10 @@
calculateDimensionsAsynchronous();
} else if (m_sequenceMessageType == Uml::sequence_message_creation) {
calculateDimensionsCreation();
+ } else if (m_sequenceMessageType == Uml::sequence_message_lost) {
+ calculateDimensionsLost();
+ } else if (m_sequenceMessageType == Uml::sequence_message_found) {
+ calculateDimensionsFound();
} else {
kWarning() << "Unknown message type" << endl;
}
@@ -621,6 +729,72 @@
setSize(widgetWidth, widgetHeight);
}
+void MessageWidget::calculateDimensionsLost() {
+ int x = 0;
+
+ int x1 = m_pOw[Uml::A]->getX();
+ int x2 = m_pOw[Uml::B]->getX();
+ int w1 = m_pOw[Uml::A]->getWidth() / 2;
+ int w2 = m_pOw[Uml::B]->getWidth() / 2;
+ x1 += w1;
+ x2 += w2;
+
+ int widgetWidth = 0;
+ int widgetHeight = 8;
+ if( m_pOw[Uml::A] == m_pOw[Uml::B] ) {
+ widgetWidth = 50;
+ x = x1;
+ if( height() < 20 ) {
+ widgetHeight = 20;
+ } else {
+ widgetHeight = height();
+ }
+ } else if( x1 < x2 ) {
+ x = x1;
+ widgetWidth = (x2 - x1) / 2;
+ } else {
+ x = (x2 + x1)/2 ;
+ widgetWidth = (x1 - x2) / 2 ;
+ }
+ x += 1;
+ widgetWidth -= 2;
+ m_nPosX = x;
+ setSize(widgetWidth, widgetHeight);
+}
+
+void MessageWidget::calculateDimensionsFound() {
+ int x = 0;
+
+ int x1 = m_pOw[Uml::A]->getX();
+ int x2 = m_pOw[Uml::B]->getX();
+ int w1 = m_pOw[Uml::A]->getWidth() / 2;
+ int w2 = m_pOw[Uml::B]->getWidth() / 2;
+ x1 += w1;
+ x2 += w2;
+
+ int widgetWidth = 0;
+ int widgetHeight = 8;
+ if( m_pOw[Uml::A] == m_pOw[Uml::B] ) {
+ widgetWidth = 50;
+ x = x1;
+ if( height() < 20 ) {
+ widgetHeight = 20;
+ } else {
+ widgetHeight = height();
+ }
+ } else if( x1 < x2 ) {
+ x = (x1+x2)/2;
+ widgetWidth = (x2 - x1) / 2;
+ } else {
+ x = x2 ;
+ widgetWidth = (x1 - x2) / 2 ;
+ }
+ x += 1;
+ widgetWidth -= 2;
+ m_nPosX = x;
+ setSize(widgetWidth, widgetHeight);
+}
+
void MessageWidget::cleanup() {
if (m_pOw[Uml::A]) {
disconnect(this, SIGNAL(sigMessageMoved()), m_pOw[Uml::A], SLOT(slotMessageMoved()) );
--- branches/work/isi-umbrello/umbrello/umbrello/messagewidget.h #625093:625094
@@ -54,7 +54,7 @@
* @param a The role A widget for this message.
* @param b The role B widget for this message.
* @param y The vertical position to display this message.
- * @param sequenceMessageType Whether synchronous or asynchronous
+ * @param sequenceMessageType Whether synchronous or asynchronous or lost or found
* @param id A unique id used for deleting this object cleanly.
* The default (-1) will prompt generation of a new ID.
*/
@@ -62,7 +62,7 @@
int y, Uml::Sequence_Message_Type sequenceMessageType,
Uml::IDType id = Uml::id_None);
- /**
+ /**
* Constructs a MessageWidget.
*
* @param view The parent to this class.
@@ -244,6 +244,16 @@
void calculateDimensionsCreation();
/**
+ * Calculates and sets the size of the widget for a lost message
+ */
+ void calculateDimensionsLost();
+
+ /**
+ * Calculates and sets the size of the widget for a found message
+ */
+ void calculateDimensionsFound();
+
+ /**
* Calls drawSynchronous() or drawAsynchronous()
*/
void draw(QPainter& p, int offsetX, int offsetY);
@@ -267,6 +277,17 @@
*/
void drawCreation(QPainter& p, int offsetX, int offsetY);
+ /**
+ * Draws a solid arrow line and a stick arrow head
+ * and a circle
+ */
+ void drawLost(QPainter& p, int offsetX, int offsetY);
+
+ /**
+ * Draws a circle and a solid arrow line and a stick arrow head
+ */
+ void drawFound(QPainter& p, int offsetX, int offsetY);
+
/**
* Sets the text position relative to the sequence message.
*/
--- branches/work/isi-umbrello/umbrello/umbrello/pics/CMakeLists.txt #625093:625094
@@ -18,7 +18,8 @@
cursor-class.png cursor-artifact.png cursor-dependency.png cursor-message-synchronous.png
cursor-uniassociation.png cursor-association.png cursor-end_state.png cursor-node.png cursor-box.png
cursor-fork.png cursor-note.png cursor-branch.png cursor-generalisation.png cursor-object.png
-cursor-entity.png cursor-relationship.png precondition.png cursor-precondition.png DESTINATION
+cursor-entity.png cursor-relationship.png precondition.png cursor-precondition.png message-found.png
+cursor-message-found.png message-lost.png cursor-message-lost.png DESTINATION
${DATA_INSTALL_DIR}/umbrello/pics )
kde4_install_icons( ${ICON_INSTALL_DIR} )
** branches/work/isi-umbrello/umbrello/umbrello/pics/cursor-message-found.png #property svn:mime-type
+ application/octet-stream
** branches/work/isi-umbrello/umbrello/umbrello/pics/cursor-message-lost.png #property svn:mime-type
+ application/octet-stream
** branches/work/isi-umbrello/umbrello/umbrello/pics/message-found.png #property svn:mime-type
+ application/octet-stream
** branches/work/isi-umbrello/umbrello/umbrello/pics/message-lost.png #property svn:mime-type
+ application/octet-stream
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatefactory.cpp #625093:625094
@@ -85,7 +85,9 @@
// Messages
case WorkToolBar::tbb_Seq_Message_Synchronous: return 2;
case WorkToolBar::tbb_Seq_Message_Asynchronous: return 2;
- case WorkToolBar::tbb_Seq_Combined_Fragment: 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
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatemessages.cpp #625093:625094
@@ -23,6 +23,9 @@
#include "umldoc.h"
#include "umlview.h"
+#include <klocale.h>
+#include <kmessagebox.h>
+
ToolBarStateMessages::ToolBarStateMessages(UMLView *umlView) : ToolBarStatePool(umlView) {
m_firstObject = 0;
m_messageLine = 0;
@@ -155,7 +158,12 @@
if (getButton() == WorkToolBar::tbb_Seq_Message_Synchronous) {
return Uml::sequence_message_synchronous;
}
-
+ else if (getButton() == WorkToolBar::tbb_Seq_Message_Found) {
+ return Uml::sequence_message_found;
+ }
+ else if (getButton() == WorkToolBar::tbb_Seq_Message_Lost) {
+ return Uml::sequence_message_lost;
+ }
return Uml::sequence_message_asynchronous;
}
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatemessages.h #625093:625094
@@ -131,7 +131,9 @@
*/
enum MessageType {
NormalMessage,
- CreationMessage
+ CreationMessage,
+ FoundMessage,
+ LostMessage
};
/**
--- branches/work/isi-umbrello/umbrello/umbrello/umlnamespace.h #625093:625094
@@ -277,7 +277,9 @@
//This is saved out to the file so only add new entries at the end
sequence_message_synchronous = 1000,
sequence_message_asynchronous,
- sequence_message_creation
+ sequence_message_creation,
+ sequence_message_found,
+ sequence_message_lost
};
enum DBIndex_Type
--- branches/work/isi-umbrello/umbrello/umbrello/worktoolbar.cpp #625093:625094
@@ -112,6 +112,8 @@
insertHotBtn(tbb_Object);
insertHotBtn(tbb_Seq_Message_Synchronous);
insertHotBtn(tbb_Seq_Message_Asynchronous);
+ insertHotBtn(tbb_Seq_Message_Found);
+ insertHotBtn(tbb_Seq_Message_Lost);
insertHotBtn(tbb_Seq_Combined_Fragment);
insertHotBtn(tbb_Seq_Precondition);
break;
@@ -251,6 +253,8 @@
{ tbb_Object, i18n("Object"), "object.png", SLOT(slotObject()) },
{ tbb_Seq_Message_Synchronous, i18n("Synchronous Message"), "message-synchronous.png", SLOT(slotSeq_Message_Synchronous()) },
{ tbb_Seq_Message_Asynchronous, i18n("Asynchronous Message"), "message-asynchronous.png", SLOT(slotSeq_Message_Asynchronous()) },
+ { tbb_Seq_Message_Found, i18n("Found Message"), "message-found.png", SLOT(slotSeq_Message_Found()) },
+ { tbb_Seq_Message_Lost, i18n("Lost Message"), "message-lost.png", SLOT(slotSeq_Message_Lost()) },
{ tbb_Seq_Combined_Fragment, i18n("Combined Fragment"), "combined_fragment.png", SLOT(slotSeq_Combined_Fragment()) },
{ tbb_Seq_Precondition, i18n("Precondition"),"precondition.png",SLOT(slotSeq_Precondition()) },
{ tbb_Association, i18n("Association"), "association.png", SLOT(slotAssociation()) },
@@ -334,6 +338,8 @@
void WorkToolBar::slotColl_Message() {buttonChanged(tbb_Coll_Message);}
void WorkToolBar::slotSeq_Message_Synchronous() {buttonChanged(tbb_Seq_Message_Synchronous);}
void WorkToolBar::slotSeq_Message_Asynchronous(){buttonChanged(tbb_Seq_Message_Asynchronous);}
+void WorkToolBar::slotSeq_Message_Found(){buttonChanged(tbb_Seq_Message_Found);}
+void WorkToolBar::slotSeq_Message_Lost(){buttonChanged(tbb_Seq_Message_Lost);}
void WorkToolBar::slotSeq_Combined_Fragment(){buttonChanged(tbb_Seq_Combined_Fragment);}
void WorkToolBar::slotSeq_Precondition(){buttonChanged(tbb_Seq_Precondition);}
void WorkToolBar::slotComposition() {buttonChanged(tbb_Composition);}
--- branches/work/isi-umbrello/umbrello/umbrello/worktoolbar.h #625093:625094
@@ -82,6 +82,8 @@
tbb_Coll_Message,
tbb_Seq_Message_Synchronous,
tbb_Seq_Message_Asynchronous,
+ tbb_Seq_Message_Found,
+ tbb_Seq_Message_Lost,
tbb_Seq_Combined_Fragment,
tbb_Seq_Precondition,
tbb_Composition,
@@ -197,6 +199,8 @@
void slotColl_Message();
void slotSeq_Message_Synchronous();
void slotSeq_Message_Asynchronous();
+ void slotSeq_Message_Found();
+ void slotSeq_Message_Lost();
void slotSeq_Combined_Fragment();
void slotSeq_Precondition();
void slotComposition();
More information about the umbrello-devel
mailing list