[Uml-user] Relationshipd on ERDs

graeme foster foster.graeme at gmail.com
Sat Jun 18 08:26:04 UTC 2005


Hi,

The relationships on ERDs are not drawn correctly if the entities are
above each other. Here is the fix for this:

class associationWidget

Made getWidgetRegion public

changed the code from:

AssociationWidget::Region
AssociationWidget::getWidgetRegion(AssociationWidget * widget) const {
  if(widget -> getWidget(A) == m_role[A].m_pWidget)
      return m_role[A].m_WidgetRegion;
  if(widget -> getWidget(B) == m_role[B].m_pWidget)
      return m_role[B].m_WidgetRegion;
  return Error;
}

to:

AssociationWidget::Region
AssociationWidget::getWidgetRegion(AssociationWidget * widget) const {
  if(widget == (AssociationWidget *)m_role[A].m_pWidget)
      return m_role[A].m_WidgetRegion;
  if(widget == (AssociationWidget *)m_role[B].m_pWidget)
      return m_role[B].m_WidgetRegion;
  return Error;
}

I don't think this method was being used anywhere so I believe that this
change is alright.

class linepath

included

#include "associationwidget.h"
#include "umlrole.h"

changed updateHead():

added this declaration:

  // get the region for which RoleB connects to the entity. (RoleB is
the crows foot)
  AssociationWidget * roleB = (AssociationWidget*)
m_pAssociation->getWidget(Uml::B);
  const AssociationWidget::Region joinRegion =
m_pAssociation->getWidgetRegion(roleB);

and changed the following code around the FIXME comment

      case Uml::at_Relationship:
          if (count < 2) {
              return;
          }
          //FIXME fix for when association is on top/bottom of widget
          if (joinRegion == AssociationWidget::North || joinRegion ==
AssociationWidget::South)
          {
              line = m_HeadList.at( 0 );
              line->setPoints( m_PointArray[2].x(), m_PointArray[2].y(),
                       m_PointArray[0].x()-8, m_PointArray[0].y() );

              line = m_HeadList.at( 1 );
              line->setPoints( m_PointArray[2].x(), m_PointArray[2].y(),
                       m_PointArray[0].x()+8, m_PointArray[0].y() );
          }
          else
          {
              line = m_HeadList.at( 0 );
              line->setPoints( m_PointArray[2].x(), m_PointArray[2].y(),
                       m_PointArray[0].x(), m_PointArray[0].y()-8 );

              line = m_HeadList.at( 1 );
              line->setPoints( m_PointArray[2].x(), m_PointArray[2].y(),
                       m_PointArray[0].x(), m_PointArray[0].y()+8 );
          }
          break;

I can send you the changed files if you want.

hope this helps,

graeme




More information about the umbrello mailing list