Relationshipd on ERDs

graeme foster <[email protected]> Sat, 18 Jun 2005 21:25:49 +0600
Newsgroups gmane.linux.umbrello.user
Message-ID <[email protected]>
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


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click