[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Florence Mattler
florence.mattler at libertysurf.fr
Tue Feb 13 17:50:45 UTC 2007
SVN commit 633278 by mattler:
add th exceptions in activity diagram. it's represented by a broken arrow and it's considered like an association between
two normals activities.
M +2 -0 association.cpp
M +110 -5 associationwidget.cpp
M +8 -0 associationwidget.h
M +4 -0 assocrules.cpp
M +6 -3 linepath.cpp
M +2 -1 pics/CMakeLists.txt
AM pics/cursor-exception.png
AM pics/exception.png
M +1 -0 toolbarstateassociation.cpp
M +1 -0 toolbarstatefactory.cpp
M +1 -0 umlnamespace.h
M +4 -1 worktoolbar.cpp
M +3 -1 worktoolbar.h
--- branches/work/isi-umbrello/umbrello/umbrello/association.cpp #633277:633278
@@ -97,6 +97,7 @@
i18n("Anchor"), // at_Anchor
i18n("State Transition"), // at_State
i18n("Activity"), // at_Activity
+ i18n("Exception"), // at_Activity
};
Uml::Association_Type UMLAssociation::getAssocType() const {
@@ -373,6 +374,7 @@
"anchor", // at_Anchor
"state", // at_State
"activity", // at_Activity
+ "exception", // at_Exception
"relationship" // at_Relationship
};
--- branches/work/isi-umbrello/umbrello/umbrello/associationwidget.cpp #633277:633278
@@ -25,6 +25,7 @@
#include <kinputdialog.h>
#include <kcolordialog.h>
#include <kapplication.h>
+
// app includes
#include "activitywidget.h"
#include "uml.h"
@@ -106,7 +107,7 @@
setAssocType(assocType);
calculateEndingPoints();
-
+
//The AssociationWidget is set to Activated because it already has its side widgets
setActivated(true);
@@ -1100,7 +1101,8 @@
m_role[A].m_OldCorner.setY( pWidgetA->getY() );
m_role[B].m_OldCorner.setX( pWidgetB->getX() );
m_role[B].m_OldCorner.setY( pWidgetB->getY() );
- uint size = m_LinePath.count();
+
+ int size = m_LinePath.count();
if(size < 2)
m_LinePath.setStartEndPoints( m_role[A].m_OldCorner, m_role[B].m_OldCorner );
@@ -1129,7 +1131,53 @@
}
return;
}//end a == b
+ if (getAssocType() == at_Exception && size < 4) {
+ int xa = pWidgetA -> getX();
+ int ya = pWidgetA -> getY();
+ int ha = pWidgetA -> getHeight();
+ int wa = pWidgetA -> getWidth();
+ int xb = pWidgetB -> getX();
+ int yb = pWidgetB -> getY();
+ int hb = pWidgetB -> getHeight();
+ int wb = pWidgetB -> getWidth();
+
+ // calcul des coordonnées du point au milieu de la feche eclair
+ int xmil;
+ int ymil;
+ if ( xb > xa )
+ xmil = xa + wa + (xb - xa - wa) / 2;
+ else
+ xmil = xb + wb + (xa - xb - wb) / 2;
+ if ( yb > ya )
+ ymil = ya + ha/2 + ((yb + hb/2) - (ya + ha/2)) / 2;
+ else
+ ymil = yb + hb/2 + ((ya + ha/2) - (yb + hb/2)) / 2;
+
+ if( xb > xa ) {
+ m_LinePath.setStartEndPoints( QPoint( xa + wa , ya + ha/2 ) , QPoint( xb , yb + hb/2 ) );
+
+ if ( yb > ya ) {
+ m_LinePath.insertPoint( 1, QPoint( xmil + (xb - xmil)*2/3 , ymil + ((yb + hb /2) - ymil)*1/3));
+ m_LinePath.insertPoint( 2 ,QPoint( xmil - (xmil - xa - wa)*2/3 , ymil - (ymil - ya - ha/2)*1/3));
+ } else {
+ m_LinePath.insertPoint( 1, QPoint( xmil + (xb - xmil)*1/3 , ymil - (ymil - yb - hb /2)*2/3));
+ m_LinePath.insertPoint( 2 ,QPoint( xmil - (xmil - xa - wa)*1/3 , ymil + (ya + ha/2 - ymil)*2/3));
+ }
+ m_role[A].m_WidgetRegion = m_role[B].m_WidgetRegion = North;
+ } else {
+ m_LinePath.setStartEndPoints( QPoint( xa , ya + ha/2 ) , QPoint( xb + wb, yb + hb/2 ) );
+ if ( ya > yb ) {
+ m_LinePath.insertPoint( 1, QPoint( xmil - (xmil - xb - wb)*1/3 , ymil - (ymil - yb - hb/2)*2/3));
+ m_LinePath.insertPoint( 2 ,QPoint( xmil + (xa - xmil)*1/3 , ymil + (ya + ha/2 - ymil)*2/3));
+ } else {
+ m_LinePath.insertPoint( 1, QPoint( xmil - (xmil - xb - wb)*2/3 , ymil + (yb + hb/2 - ymil)*1/3));
+ m_LinePath.insertPoint( 2 ,QPoint( xmil + (xa - xmil)*2/3 , ymil - (ymil - ya - ha/2)*1/3));
+ }
+ m_role[A].m_WidgetRegion = m_role[B].m_WidgetRegion = North;
+ }
+ return;
+ }
// If the line has more than one segment change the values to calculate
// from widget to point 1.
int xB = pWidgetB->getX() + pWidgetB->getWidth() / 2;
@@ -1274,6 +1322,7 @@
// 2004-04-30: Achim Spangler
// Simple Approach to block moveEvent during load of
// XMI
+
/// @todo avoid trigger of this event during load
if ( m_umldoc->loading() ) {
// hmmh - change of position during load of XMI
@@ -1297,10 +1346,14 @@
int dy = m_role[A].m_OldCorner.y() - y;
uint size = m_LinePath.count();
uint pos = size - 1;
- calculateEndingPoints();
-
+ if (getAssocType() == at_Exception) {
+ updatePointsException ();
+ }
+ else
+ calculateEndingPoints();
+
// Assoc to self - move all points:
- if( m_role[A].m_pWidget == m_role[B].m_pWidget ) {
+ if( m_role[A].m_pWidget == m_role[B].m_pWidget) {
for( int i=1 ; i < (int)pos ; i++ ) {
QPoint p = m_LinePath.getPoint( i );
int newX = p.x() - dx;
@@ -1356,6 +1409,58 @@
}
}//end method widgetMoved
+void AssociationWidget::updatePointsException () {
+ UMLWidget *pWidgetA = m_role[A].m_pWidget;
+ UMLWidget *pWidgetB = m_role[B].m_pWidget;
+
+ int xa = pWidgetA -> getX();
+ int ya = pWidgetA -> getY();
+ int ha = pWidgetA -> getHeight();
+ int wa = pWidgetA -> getWidth();
+
+ int xb = pWidgetB -> getX();
+ int yb = pWidgetB -> getY();
+ int hb = pWidgetB -> getHeight();
+ int wb = pWidgetB -> getWidth();
+ int xmil;
+ int ymil;
+
+ //calcul des coordonnées au milieu de la flèche eclair
+ if ( xb > xa )
+ xmil = xa + wa + (xb - xa - wa) / 2;
+ else
+ xmil = xb + wb + (xa - xb - wb) / 2;
+ if ( yb > ya )
+ ymil = ya + ha/2 + ((yb + hb/2) - (ya + ha/2)) / 2;
+ else
+ ymil = yb + hb/2 + ((ya + ha/2) - (yb + hb/2)) / 2;
+
+ if( xb > xa ) {
+ m_LinePath.setStartEndPoints( QPoint( xa + wa , ya + ha/2 ) , QPoint( xb , yb + hb/2 ) );
+
+ if ( yb > ya ) {
+ m_LinePath.setPoint( 1, QPoint( xmil + (xb - xmil)*2/3 , ymil + ((yb + hb /2) - ymil)*1/3));
+ m_LinePath.setPoint( 2 ,QPoint( xmil - (xmil - xa - wa)*2/3 , ymil - (ymil - ya - ha/2)*1/3));
+ } else {
+ m_LinePath.setPoint( 1, QPoint( xmil + (xb - xmil)*1/3 , ymil - (ymil - yb - hb /2)*2/3));
+ m_LinePath.setPoint( 2 ,QPoint( xmil - (xmil - xa - wa)*1/3 , ymil + (ya + ha/2 - ymil)*2/3));
+ }
+ m_role[A].m_WidgetRegion = m_role[B].m_WidgetRegion = North;
+ } else {
+ m_LinePath.setStartEndPoints( QPoint( xa , ya + ha/2 ) , QPoint( xb + wb, yb + hb/2 ) );
+ if ( ya > yb ) {
+ m_LinePath.setPoint( 1, QPoint( xmil - (xmil - xb - wb)*1/3 , ymil - (ymil - yb - hb/2)*2/3));
+ m_LinePath.setPoint( 2 ,QPoint( xmil + (xa - xmil)*1/3 , ymil + (ya + ha/2 - ymil)*2/3));
+ } else {
+ m_LinePath.setPoint( 1, QPoint( xmil - (xmil - xb - wb)*2/3 , ymil + (yb + hb/2 - ymil)*1/3));
+ m_LinePath.setPoint( 2 ,QPoint( xmil + (xa - xmil)*2/3 , ymil - (ymil - ya - ha/2)*1/3));
+ }
+ m_role[A].m_WidgetRegion = m_role[B].m_WidgetRegion = North;
+ }
+
+}
+
+
/** Finds out in which region of rectangle Rect contains the Point (PosX, PosY) and returns the region
number:
1 = Region 1
--- branches/work/isi-umbrello/umbrello/umbrello/associationwidget.h #633277:633278
@@ -318,8 +318,16 @@
* @param y New Y coordinate of the widget.
*/
void widgetMoved(UMLWidget* widget, int x, int y);
+
/**
+ * Adjusts the points of the association exception.
+ * Method called when a widget was moved by widgetMoved(widget,x,y)
+ */
+ void updatePointsException ();
+
+
+ /**
* Calculates the m_unNameLineSegment value according to the new
* NameText topleft corner PT.
* It iterates through all LinePath's segments and for each one
--- branches/work/isi-umbrello/umbrello/umbrello/assocrules.cpp #633277:633278
@@ -11,6 +11,7 @@
#include <kdebug.h>
#include <typeinfo>
+#include <kmessagebox.h>
#include "assocrules.h"
#include "umlwidget.h"
@@ -84,6 +85,7 @@
break;
case at_Activity:
+ case at_Exception:
{
ActivityWidget *pActivity = dynamic_cast<ActivityWidget*>(widget);
return (pActivity == NULL || pActivity->getActivityType() != ActivityWidget::End);
@@ -184,6 +186,7 @@
break;
case at_Activity:
+ case at_Exception:
{
ActivityWidget *actA = dynamic_cast<ActivityWidget*>(widgetA);
ActivityWidget *actB = dynamic_cast<ActivityWidget*>(widgetB);
@@ -363,6 +366,7 @@
{ at_Anchor, wt_State, wt_Note, false, false, false, false },
{ at_Anchor, wt_Activity, wt_Note, false, false, false, false },
{ at_Relationship, wt_Entity, wt_Entity, true, false, true, false },
+ { at_Exception, wt_Activity, wt_Activity, true, false, true, true },
};
int AssocRules::m_nNumRules = sizeof( m_AssocRules ) / sizeof( AssocRules::Assoc_Rule );
--- branches/work/isi-umbrello/umbrello/umbrello/linepath.cpp #633277:633278
@@ -263,10 +263,10 @@
bool LinePath::setStartEndPoints( const QPoint &start, const QPoint &end ) {
int count = m_LineList.count();
-
+ kDebug() << "setStartEndPoints!!!!!!!!!!!!! " <<count <<endl;
if( count == 0 ) {
Q3CanvasLine * line = new Q3CanvasLine(getCanvas() );
- line -> setPoints( start.x(), start.y(), end.x(), end.y() );
+ line -> setPoints( start.x(), start.y(),end.x(),end.y() );
line -> setZ( -2 );
line -> setPen( getPen() );
line -> setVisible( true );
@@ -275,7 +275,7 @@
}
bool status = setPoint( 0, start );
if( status)
- return setPoint( count , end );
+ return setPoint(count,end);
return false;
}
@@ -552,10 +552,12 @@
switch( getAssocType() ) {
case Uml::at_State:
case Uml::at_Activity:
+ case Uml::at_Exception:
case Uml::at_UniAssociation:
case Uml::at_Dependency:
if( count < 2)
return;
+
line = m_HeadList.at( 0 );
line -> setPoints( m_EgdePoint.x(), m_EgdePoint.y(), m_ArrowPointA.x(), m_ArrowPointA.y() );
@@ -646,6 +648,7 @@
Q3Canvas * canvas = getCanvas();
switch( getAssocType() ) {
case Uml::at_Activity:
+ case Uml::at_Exception:
case Uml::at_State:
case Uml::at_Dependency:
case Uml::at_UniAssociation:
--- branches/work/isi-umbrello/umbrello/umbrello/pics/CMakeLists.txt #633277:633278
@@ -19,7 +19,8 @@
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 cursor-send_signal.png cursor-accept_signal.png cursor-accept_time_event.png
-cursor-message-found.png message-lost.png cursor-message-lost.png end_of_life.png cursor-end_of_life.png DESTINATION
+cursor-message-found.png message-lost.png cursor-message-lost.png end_of_life.png cursor-end_of_life.png exception.png
+cursor-exception.png DESTINATION
${DATA_INSTALL_DIR}/umbrello/pics )
kde4_install_icons( ${ICON_INSTALL_DIR} )
** branches/work/isi-umbrello/umbrello/umbrello/pics/cursor-exception.png #property svn:mime-type
+ application/octet-stream
** branches/work/isi-umbrello/umbrello/umbrello/pics/exception.png #property svn:mime-type
+ application/octet-stream
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateassociation.cpp #633277:633278
@@ -198,6 +198,7 @@
case WorkToolBar::tbb_Coll_Message: at = at_Coll_Message; break;
case WorkToolBar::tbb_State_Transition: at = at_State; break;
case WorkToolBar::tbb_Activity_Transition: at = at_Activity; break;
+ case WorkToolBar::tbb_Exception: at = at_Exception; break;
default: at = at_Unknown; break;
}
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstatefactory.cpp #633277:633278
@@ -83,6 +83,7 @@
case WorkToolBar::tbb_Coll_Message: return 1;
case WorkToolBar::tbb_State_Transition: return 1;
case WorkToolBar::tbb_Activity_Transition: return 1;
+ case WorkToolBar::tbb_Exception: return 1;
// Messages
case WorkToolBar::tbb_Seq_Message_Synchronous: return 2;
--- branches/work/isi-umbrello/umbrello/umbrello/umlnamespace.h #633277:633278
@@ -146,6 +146,7 @@
at_Anchor,
at_State,
at_Activity,
+ at_Exception,
at_Relationship,
at_Unknown = - 1
};
--- branches/work/isi-umbrello/umbrello/umbrello/worktoolbar.cpp #633277:633278
@@ -145,6 +145,7 @@
insertHotBtn(tbb_Branch);
insertHotBtn(tbb_Fork);
insertHotBtn(tbb_Activity_Transition);
+ insertHotBtn(tbb_Exception);
insertHotBtn(tbb_Object_Flow);
insertHotBtn(tbb_Send_Signal);
insertHotBtn(tbb_Accept_Signal);
@@ -308,7 +309,8 @@
{ tbb_End_Activity, i18n("End Activity"), "end_state.png", SLOT(slotEnd_Activity()) },
{ tbb_Object_Flow, i18n("Object Flow"), "object_flow.png", SLOT(slotObject_Flow()) },
{ tbb_Initial_Activity, i18n("Initial Activity"), "initial_state.png", SLOT(slotInitial_Activity()) },
- { tbb_Coll_Message, i18n("Message"), "message-asynchronous.png", SLOT(slotColl_Message()) }
+ { tbb_Coll_Message, i18n("Message"), "message-asynchronous.png", SLOT(slotColl_Message()) },
+ { tbb_Exception, i18n("Exception"), "exception.png", SLOT(slotException()) }
};
KStandardDirs * dirs = KGlobal::dirs();
@@ -392,6 +394,7 @@
void WorkToolBar::slotJunction() {buttonChanged(tbb_Junction);}
void WorkToolBar::slotChoice() {buttonChanged(tbb_Choice);}
void WorkToolBar::slotAndline() {buttonChanged(tbb_Andline);}
+void WorkToolBar::slotException() {buttonChanged(tbb_Exception);}
#include "worktoolbar.moc"
--- branches/work/isi-umbrello/umbrello/umbrello/worktoolbar.h #633277:633278
@@ -126,7 +126,8 @@
tbb_StateFork,
tbb_Junction,
tbb_Choice,
- tbb_Andline
+ tbb_Andline,
+ tbb_Exception
};
private:
@@ -249,6 +250,7 @@
void slotJunction();
void slotChoice();
void slotAndline();
+ void slotException();
};
More information about the umbrello-devel
mailing list