[GME-commit] GMESRC/GME/MgaDecorators DecoratorDefs.h,1.9,1.10
DecoratorUtil.cpp,1.8,1.9 StereotypeDecorators.cpp,1.14,1.15
StereotypeDecorators.h,1.5,1.6
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Fri Jun 17 04:20:42 CDT 2005
Update of /project/gme-repository/GMESRC/GME/MgaDecorators
In directory escher:/tmp/cvs-serv4351
Modified Files:
DecoratorDefs.h DecoratorUtil.cpp StereotypeDecorators.cpp
StereotypeDecorators.h
Log Message:
PortLabels may be shown outside of the container.
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: StereotypeDecorators.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaDecorators/StereotypeDecorators.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** StereotypeDecorators.cpp 26 Jan 2005 17:30:51 -0000 1.14
--- StereotypeDecorators.cpp 17 Jun 2005 03:20:39 -0000 1.15
***************
*** 459,462 ****
--- 459,463 ----
PortDecorator::PortDecorator( CComPtr<IMgaFCO> spFCO, const CPoint& ptInner )
: DecoratorBase( NULL, spFCO ), m_ptInner( ptInner )
+ , m_bInsideContainer( true), m_eAdjust(L_WEST)
{
}
***************
*** 491,498 ****
mapPrefs[ PREF_TILESUNDEF ] = PreferenceVariant( getFacilities().getTileVector( TILE_PORTDEFAULT ) );
// Label Font
! mapPrefs[ PREF_LABELFONT ] = PreferenceVariant( (long) FONT_PORT );
DecoratorBase::initialize( mapPrefs );
}
--- 492,506 ----
mapPrefs[ PREF_TILESUNDEF ] = PreferenceVariant( getFacilities().getTileVector( TILE_PORTDEFAULT ) );
+ // port label displayed inside or outside container?
+ m_bInsideContainer = mapPrefs[ PREF_PORTLABELINSIDE ].uValue.bValue;
+
// Label Font
! if( m_bInsideContainer)
! mapPrefs[ PREF_LABELFONT ] = PreferenceVariant( (long) FONT_PORT );
! else
! mapPrefs[ PREF_LABELFONT ] = PreferenceVariant( (long) FONT_PORT_OUTSIDE );
+ m_eAdjust = mapPrefs[ PREF_LABELLOCATION ].uValue.eLocation;
DecoratorBase::initialize( mapPrefs );
}
***************
*** 520,523 ****
--- 528,552 ----
}
+ CPoint PortDecorator::getLabelPosition() const
+ {
+ int d = (m_eAdjust == L_EAST)? 1: -1;
+ CPoint pt = DecoratorBase::getLabelPosition();
+ if( !m_bInsideContainer)
+ pt += CPoint(d*7, -7);
+
+ return pt;
+ }
+
+ long PortDecorator::getLongest() const
+ {
+ long maxv = 0;
+ for ( unsigned int i = 0 ; i < m_vecName.size() ; i++ ) {
+ long ilen = m_vecName[i].GetLength();
+ if( maxv < ilen)
+ maxv = ilen;
+ }
+ return maxv;
+ }
+
struct PortLess
{
***************
*** 787,790 ****
--- 816,820 ----
ModelDecorator::ModelDecorator( CComPtr<IMgaMetaPart> spPart, CComPtr<IMgaFCO> spFCO )
: TypeableDecorator( spPart, spFCO ), m_iMaxPortTextLength( MAX_PORT_LENGTH ), m_crPortText( COLOR_BLACK )
+ , m_bPrtLabInside( true), m_iLongestPortTextLength( 0)
{
}
***************
*** 803,811 ****
getFacilities().getPreference( m_spFCO, PREF_PORTLABELCOLOR, m_crPortText );
it = mapPrefs.find( PREF_PORTLABELLENGTH );
if ( it != mapPrefs.end() )
m_iMaxPortTextLength = it->second.uValue.lValue;
else
! getFacilities().getPreference( m_spFCO, PREF_PORTLABELLENGTH, m_iMaxPortTextLength );
it = mapPrefs.find( PREF_BORDERCOLOR );
--- 833,855 ----
getFacilities().getPreference( m_spFCO, PREF_PORTLABELCOLOR, m_crPortText );
+ it = mapPrefs.find( PREF_PORTLABELINSIDE );
+ if ( it != mapPrefs.end() )
+ m_bPrtLabInside = it->second.uValue.bValue;
+ else
+ getFacilities().getPreference( m_spFCO, PREF_PORTLABELINSIDE, m_bPrtLabInside );
+
+ long o = m_iMaxPortTextLength ;
it = mapPrefs.find( PREF_PORTLABELLENGTH );
if ( it != mapPrefs.end() )
m_iMaxPortTextLength = it->second.uValue.lValue;
else
! {
! if( getFacilities().getPreference( m_spFCO, PREF_PORTLABELLENGTH, m_iMaxPortTextLength ))
! m_iMaxPortTextLength = abs( m_iMaxPortTextLength);//convert any negative value to positive
! else //if not found in registry
! m_iMaxPortTextLength = MAX_PORT_LENGTH; // the default value in Preferences
! }
! if( m_iMaxPortTextLength == 0) //if 0 it means it has to show all way long
! m_iMaxPortTextLength = 999; // so we set a huge value
it = mapPrefs.find( PREF_BORDERCOLOR );
***************
*** 913,927 ****
mapPrefs[ PREF_LABELCOLOR ] = PreferenceVariant( m_crPortText );
mapPrefs[ PREF_LABELLENGTH ] = PreferenceVariant( (long) m_iMaxPortTextLength );
if ( vecPorts[ i ]->getInnerPosition().x <= WIDTH_MODELSIDE || vecPorts[ i ]->getInnerPosition().x < lMax / 2 ) {
! mapPrefs[ PREF_LABELLOCATION ] = PreferenceVariant( L_EAST );
m_vecLeftPorts.push_back( vecPorts[ i ] );
}
else {
! mapPrefs[ PREF_LABELLOCATION ] = PreferenceVariant( L_WEST );
m_vecRightPorts.push_back( vecPorts[ i ] );
}
vecPorts[ i ]->initialize( mapPrefs );
}
--- 957,975 ----
mapPrefs[ PREF_LABELCOLOR ] = PreferenceVariant( m_crPortText );
mapPrefs[ PREF_LABELLENGTH ] = PreferenceVariant( (long) m_iMaxPortTextLength );
+ mapPrefs[PREF_PORTLABELINSIDE] = PreferenceVariant( m_bPrtLabInside );
if ( vecPorts[ i ]->getInnerPosition().x <= WIDTH_MODELSIDE || vecPorts[ i ]->getInnerPosition().x < lMax / 2 ) {
! mapPrefs[ PREF_LABELLOCATION ] = PreferenceVariant( m_bPrtLabInside? L_EAST : L_WEST);
m_vecLeftPorts.push_back( vecPorts[ i ] );
}
else {
! mapPrefs[ PREF_LABELLOCATION ] = PreferenceVariant( m_bPrtLabInside? L_WEST: L_EAST);
m_vecRightPorts.push_back( vecPorts[ i ] );
}
vecPorts[ i ]->initialize( mapPrefs );
+ long k = vecPorts[ i ]->getLongest();
+ if ( m_iLongestPortTextLength < k)
+ m_iLongestPortTextLength = k;
}
***************
*** 937,941 ****
LOGFONT logFont;
getFacilities().getFont( FONT_PORT )->pFont->GetLogFont( &logFont );
! long lWidth = ( 8 * m_iMaxPortTextLength + GAP_LABEL + WIDTH_PORT + GAP_XMODELPORT ) * 2 + GAP_PORTLABEL;
long lHeight = GAP_YMODELPORT * 2 + max( m_vecLeftPorts.size(), m_vecRightPorts.size() ) * ( HEIGHT_PORT + GAP_PORT ) - GAP_PORT;
--- 985,1000 ----
LOGFONT logFont;
getFacilities().getFont( FONT_PORT )->pFont->GetLogFont( &logFont );
! long lWidth = 0;
! if (m_bPrtLabInside )
! {
! ASSERT( m_iLongestPortTextLength >= 0 && m_iLongestPortTextLength <= 1000);
! ASSERT( m_iMaxPortTextLength >= 0 && m_iMaxPortTextLength <= 1000);
! ASSERT( m_iMaxPortTextLength); // m_iMaxPortTextLength > 0 !!! since
! long lw = min(m_iMaxPortTextLength, m_iLongestPortTextLength);
! lWidth = ( 24 + 5 * (lw-3) + GAP_LABEL + WIDTH_PORT + GAP_XMODELPORT ) * 2 + GAP_PORTLABEL;
! }
! else
! lWidth = ( 8*3 + GAP_LABEL + WIDTH_PORT + GAP_XMODELPORT ) * 2 + GAP_PORTLABEL;
!
long lHeight = GAP_YMODELPORT * 2 + max( m_vecLeftPorts.size(), m_vecRightPorts.size() ) * ( HEIGHT_PORT + GAP_PORT ) - GAP_PORT;
***************
*** 1036,1039 ****
--- 1095,1099 ----
void ReferenceDecorator::initialize( PreferenceMap& mapPrefs )
{
+ bool model_ref = false;
if ( m_spFCO ) {
CComPtr<IMgaFCO> spReferenced;
***************
*** 1066,1069 ****
--- 1126,1130 ----
break;
case OBJTYPE_MODEL :
+ model_ref = true;
m_pReferenced = new Decorator::ModelDecorator( m_spPart, spReferenced );
break;
***************
*** 1107,1110 ****
--- 1168,1200 ----
getFacilities().getPreference( m_pReferenced->getFCO(), PREF_BORDERCOLOR, m_crBorder );
+ if( m_spFCO && model_ref)
+ {
+ // these values will be get from the old PrefMap: mapPrefs or from the m_spFCO's registry (most likely)
+ bool port_lab_inside;
+ long port_lab_len;
+
+ PreferenceMap::iterator it;
+ it = mapPrefs.find( PREF_PORTLABELINSIDE );
+ if ( it != mapPrefs.end() ) // the mapRefs map is not expected to contain the value
+ port_lab_inside = it->second.uValue.bValue;
+ else // the object's registry may contain it
+ getFacilities().getPreference( m_spFCO, PREF_PORTLABELINSIDE, port_lab_inside );
+
+ it = mapPrefs.find( PREF_PORTLABELLENGTH );
+ if ( it != mapPrefs.end() )
+ port_lab_len = it->second.uValue.lValue;
+ else
+ {
+ // if not found in registry use MAX_PORT_LENGTH
+ if( !getFacilities().getPreference( m_spFCO, PREF_PORTLABELLENGTH, port_lab_len ))
+ port_lab_len = MAX_PORT_LENGTH; // the default value in Preferences
+ }
+
+ ASSERT ( port_lab_len >= 0 && port_lab_len <= 1000);
+
+ // store the values in the new map: mapRefPrefs
+ mapRefPrefs[ PREF_PORTLABELINSIDE ] = PreferenceVariant( port_lab_inside );
+ mapRefPrefs[ PREF_PORTLABELLENGTH ] = PreferenceVariant( (long) port_lab_len );
+ }
mapRefPrefs[ PREF_VIOLATED ] = PreferenceVariant( false );
Index: DecoratorDefs.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaDecorators/DecoratorDefs.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** DecoratorDefs.h 3 Nov 2003 23:46:31 -0000 1.9
--- DecoratorDefs.h 17 Jun 2005 03:20:39 -0000 1.10
***************
*** 36,39 ****
--- 36,40 ----
static const char* PREF_LABELCOLOR = "nameColor";
static const char* PREF_PORTLABELCOLOR = "portColor";
+ static const char* PREF_PORTLABELINSIDE = "portLabelInside";
static const char* PREF_TYPESHOWN = "isTypeShown";
static const char* PREF_TYPEINFOSHOWN = "isTypeInfoShown";
***************
*** 59,62 ****
--- 60,64 ----
static const int FONT_PORT = 1;
static const int FONT_TYPE = 2;
+ static const int FONT_PORT_OUTSIDE = 3;
static const int GAP_LABEL = 2;
Index: StereotypeDecorators.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaDecorators/StereotypeDecorators.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** StereotypeDecorators.h 13 Oct 2004 15:17:55 -0000 1.5
--- StereotypeDecorators.h 17 Jun 2005 03:20:39 -0000 1.6
***************
*** 145,148 ****
--- 145,150 ----
private :
CPoint m_ptInner;
+ bool m_bInsideContainer;
+ ELocation m_eAdjust;
public :
***************
*** 153,156 ****
--- 155,160 ----
virtual CSize getPreferredSize() const;
virtual void drawBackground( CDC* pDC ) const;
+ virtual CPoint getLabelPosition() const;
+ virtual long getLongest() const;
};
***************
*** 229,232 ****
--- 233,238 ----
long m_iMaxPortTextLength;
COLORREF m_crPortText;
+ bool m_bPrtLabInside;
+ long m_iLongestPortTextLength;
public :
Index: DecoratorUtil.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/MgaDecorators/DecoratorUtil.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DecoratorUtil.cpp 26 Jan 2005 17:30:50 -0000 1.8
--- DecoratorUtil.cpp 17 Jun 2005 03:20:39 -0000 1.9
***************
*** 101,104 ****
--- 101,105 ----
createFont( FONT_PORT, "Arial", false, 12 );
createFont( FONT_TYPE, "Arial", true, 12 );
+ createFont( FONT_PORT_OUTSIDE, "Arial", false, 11);
TileVector* pTileVector = new TileVector( 1, BackgroundTile() );
More information about the GME-commit
mailing list