*/
QString CAF_Tools::toQString ( const TCollection_ExtendedString& src )
{
- return QString( (const QChar*)src.ToExtString(), src.Length() );
+ return QString( (const QChar*)src.ToExtString(), src.Length() );
+}
+
+/*!
+ Converts TCollection_AsciiString'src' to Qt string. [ static ]
+*/
+QString CAF_Tools::toQString( const TCollection_AsciiString& src )
+{
+ return QString( src.ToCString() );
+}
+
+/*!
+ Converts Qt string to TCollection_AsciiString. [ static ]
+*/
+TCollection_AsciiString CAF_Tools::toAsciiString( const QString& src )
+{
+ TCollection_AsciiString res;
+ if ( !src.isEmpty() )
+ res = TCollection_AsciiString( (char*)src.latin1() );
+ return res;
}
/*!
*/
TCollection_ExtendedString CAF_Tools::toExtString ( const QString& src )
{
- TCollection_ExtendedString result;
- for ( int i = 0; i < (int)src.length(); i++ )
- result.Insert( i + 1, src[ i ].unicode() );
- return result;
+ TCollection_ExtendedString result;
+ for ( int i = 0; i < (int)src.length(); i++ )
+ result.Insert( i + 1, src[ i ].unicode() );
+ return result;
+}
+
+Quantity_Color CAF_Tools::color( const QColor& c )
+{
+ Quantity_Color aColor;
+ if ( c.isValid() )
+ aColor = Quantity_Color( c.red() / 255., c.green() / 255.,
+ c.blue() / 255., Quantity_TOC_RGB );
+ return aColor;
+}
+
+QColor CAF_Tools::color( const Quantity_Color& c )
+{
+ return QColor ( int( c.Red() * 255 ),
+ int( c.Green() * 255 ),
+ int( c.Blue() * 255 ) );
}
#include <SUIT_Tools.h>
+#include <qcolor.h>
+
+#include <Quantity_Color.hxx>
+
+#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
class CAF_EXPORT CAF_Tools : public SUIT_Tools
{
public:
+ static QString toQString( const TCollection_AsciiString& );
static QString toQString( const TCollection_ExtendedString& );
+
static TCollection_ExtendedString toExtString( const QString& );
+ static TCollection_AsciiString toAsciiString( const QString& );
+
+ static Quantity_Color color( const QColor& );
+ static QColor color( const Quantity_Color& );
};
#endif
Handle(DDS_DicItem) aDicItem = new DDS_DicItem();
aDicItem->myComponent = this;
- aDicItem->FillDataMap( anID, aQuantity, theDocElement, unitSystems );
+ aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems );
myDataMap.Add( anID, aDicItem );
}
}
Parse record in XML file and retrieve information relevant for this data dic item
*/
void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element& theDatum,
- const LDOM_Element& theDocElement, const TColStd_SequenceOfAsciiString& theSystems )
+ const LDOM_Element& theCompElement, const LDOM_Element& theDocElement,
+ const TColStd_SequenceOfAsciiString& theSystems )
{
TCollection_AsciiString aLabel = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_LABEL" ) );
TCollection_AsciiString aFormat = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FORMAT" ) );
LDOMString aListId = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VLR_LIST" ) );
aDefV = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
aDefV.RemoveAll( ' ' );
- for ( LDOM_Element aListItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
- aListItem != NULL; aListItem = aListItem.GetSiblingByTagName() )
+ LDOM_Element foundListItem;
+ for ( LDOM_Element aListItem = theCompElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
+ aListItem != NULL && foundListItem == NULL; aListItem = aListItem.GetSiblingByTagName() )
{
if ( aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
+ foundListItem = aListItem;
+
+ }
+ for ( LDOM_Element aLstItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
+ aLstItem != NULL && foundListItem == NULL; aLstItem = aLstItem.GetSiblingByTagName() )
+ {
+ if ( aLstItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
+ foundListItem = aLstItem;
+ }
+
+ if ( foundListItem != NULL )
+ {
+ // The appropriate list of values is found: store the list name
+ aListName = foundListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) );
+ // Iteration through the list of values
+ LDOM_Element aListItemValue = foundListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) );
+ while ( aListItemValue != NULL )
{
- // The appropriate list of values is found: store the list name
- aListName = aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) );
- // Iteration through the list of values
- LDOM_Element aListItemValue = aListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) );
- while ( aListItemValue != NULL )
+ // read value ID
+ TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) );
+ if ( aListValueID.IsIntegerValue() )
{
- // read value ID
- TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) );
- if ( aListValueID.IsIntegerValue() )
+ // Read the text in the element "value"
+ LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild();
+ if ( !aListItemTxt.isNull() )
{
- // Read the text in the element "value"
- LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild();
- if ( !aListItemTxt.isNull() )
- {
- // adding ID and text value to sequence
- aSeqOfValueID.Append( aListValueID.IntegerValue() );
- aSeqOfValue.Append( aListItemTxt.getData() );
- // adding icon file name (optional) to sequence
- TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) );
- aSeqOfValueIconName.Append( aListValueIcon );
- }
+ // adding ID and text value to sequence
+ aSeqOfValueID.Append( aListValueID.IntegerValue() );
+ aSeqOfValue.Append( aListItemTxt.getData() );
+ // adding icon file name (optional) to sequence
+ TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) );
+ aSeqOfValueIconName.Append( aListValueIcon );
}
aListItemValue = aListItemValue.GetSiblingByTagName();
}
void operator=( const DDS_DicItem& );
// Assignment operator
- void FillDataMap( TCollection_AsciiString,
- const LDOM_Element&,const LDOM_Element&,
+ void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
+ const LDOM_Element&, const LDOM_Element&,
const TColStd_SequenceOfAsciiString& );
// prepares formants for each unit systems
#include <GL/glx.h>
#endif
+#include <gp_Pnt2d.hxx>
+
#include <qimage.h>
#include <qpainter.h>
return result;
}
#endif
+
+//======================================================================
+// Function: drawRectangle
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap,
+ QColor color, bool filled, QColor fillingColor )
+{
+ if( !rect )
+ return;
+
+ float x1 = rect->left() - gap;
+ float x2 = rect->right() + gap;
+ float y1 = rect->bottom() - gap;
+ float y2 = rect->top() + gap;
+
+ if( filled )
+ {
+ glColor3f( ( GLfloat )fillingColor.red() / 255,
+ ( GLfloat )fillingColor.green() / 255,
+ ( GLfloat )fillingColor.blue() / 255 );
+ glBegin( GL_POLYGON );
+ glVertex2f( x1, y1 );
+ glVertex2f( x1, y2 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x2, y1 );
+ glEnd();
+ }
+
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+ glLineWidth( lineWidth );
+
+ glBegin( GL_LINE_LOOP );
+ glVertex2f( x1, y1 );
+ glVertex2f( x1, y2 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x2, y1 );
+ glEnd();
+}
+
+//======================================================================
+// Function: drawContour
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawContour( const GLViewer_PntList& pntList, QColor color, GLfloat lineWidth )
+{
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+ glLineWidth( lineWidth );
+
+ glBegin( GL_LINES );
+ QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
+ for( ; it != pntList.end(); ++it )
+ glVertex2f( (*it).x(), (*it).y() );
+ glEnd();
+}
+
+//======================================================================
+// Function: drawContour
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawContour( GLViewer_Rect* rect, QColor color, GLfloat lineWidth,
+ GLushort pattern, bool isStripe )
+{
+ float x1 = rect->left();
+ float x2 = rect->right();
+ float y1 = rect->bottom();
+ float y2 = rect->top();
+
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+ glLineWidth( lineWidth );
+
+ if ( isStripe )
+ {
+ glEnable( GL_LINE_STIPPLE );
+ glLineStipple( 1, pattern );
+ }
+
+ glBegin( GL_LINE_LOOP );
+
+ glVertex2f( x1, y1 );
+ glVertex2f( x1, y2 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x2, y1 );
+
+ glEnd();
+ glDisable( GL_LINE_STIPPLE );
+}
+
+//======================================================================
+// Function: drawPolygon
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawPolygon( const GLViewer_PntList& pntList, QColor color )
+{
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+ glBegin( GL_POLYGON );
+ QValueList<GLViewer_Pnt>::const_iterator it = pntList.begin();
+ for( ; it != pntList.end(); ++it )
+ glVertex2f( (*it).x(), (*it).y() );
+ glEnd();
+}
+
+//======================================================================
+// Function: drawPolygon
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawPolygon( GLViewer_Rect* rect, QColor color,
+ GLushort pattern, bool isStripe )
+{
+ float x1 = rect->left();
+ float x2 = rect->right();
+ float y1 = rect->bottom();
+ float y2 = rect->top();
+ glColor3f( ( GLfloat )color.red() / 255,
+ ( GLfloat )color.green() / 255,
+ ( GLfloat )color.blue() / 255 );
+
+ if ( isStripe )
+ {
+ glEnable( GL_LINE_STIPPLE );
+ glLineStipple( 1, pattern );
+ }
+ glBegin( GL_POLYGON );
+
+ glVertex2f( x1, y1 );
+ glVertex2f( x1, y2 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x2, y1 );
+
+ glEnd();
+ glDisable( GL_LINE_STIPPLE );
+}
+
+//======================================================================
+// Function: drawVertex
+// Purpose :
+//=======================================================================
+GLubyte rasterVertex[5] = { 0x70, 0xf8, 0xf8, 0xf8, 0x70 };
+void GLViewer_Drawer::drawVertex( GLfloat x, GLfloat y, QColor color )
+{
+ glColor3f( ( GLfloat )color.red() / 255, ( GLfloat )color.green() / 255, ( GLfloat )color.blue() / 255 );
+ glRasterPos2f( x, y );
+ glBitmap( 5, 5, 2, 2, 0, 0, rasterVertex );
+}
+
+//======================================================================
+// Function: drawCross
+// Purpose :
+//=======================================================================
+GLubyte rasterCross[7] = { 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82 };
+void GLViewer_Drawer::drawCross( GLfloat x, GLfloat y, QColor color )
+{
+ glColor3f( ( GLfloat )color.red() / 255, ( GLfloat )color.green() / 255, ( GLfloat )color.blue() / 255 );
+ glRasterPos2f( x, y );
+ glBitmap( 7, 7, 3, 3, 0, 0, rasterCross );
+}
+
+//======================================================================
+// Function: drawArrow
+// Purpose :
+//=======================================================================
+void GLViewer_Drawer::drawArrow( const GLfloat red, const GLfloat green, const GLfloat blue,
+ GLfloat lineWidth,
+ GLfloat staff, GLfloat length, GLfloat width,
+ GLfloat x, GLfloat y, GLfloat angle, GLboolean filled )
+{
+ GLfloat vx1 = x;
+ GLfloat vy1 = y + staff + length;
+ GLfloat vx2 = vx1 - width / 2;
+ GLfloat vy2 = vy1 - length;
+ GLfloat vx3 = vx1 + width / 2;
+ GLfloat vy3 = vy1 - length;
+
+ gp_Pnt2d p0( x, y );
+ gp_Pnt2d p1( vx1, vy1 );
+ gp_Pnt2d p2( vx2, vy2 );
+ gp_Pnt2d p3( vx3, vy3 );
+
+ p1.Rotate( p0, angle );
+ p2.Rotate( p0, angle );
+ p3.Rotate( p0, angle );
+
+ vx1 = p1.X(); vy1 = p1.Y();
+ vx2 = p2.X(); vy2 = p2.Y();
+ vx3 = p3.X(); vy3 = p3.Y();
+
+ glColor3f( red, green, blue );
+ glLineWidth( lineWidth );
+
+ glBegin( GL_LINES );
+ glVertex2f( x, y );
+ glVertex2f( vx1, vy1 );
+ glEnd();
+
+ filled = true;
+ if( !filled )
+ {
+ glBegin( GL_LINES );
+ glVertex2f( vx1, vy1 );
+ glVertex2f( vx2, vy2 );
+ glVertex2f( vx1, vy1 );
+ glVertex2f( vx3, vy3 );
+ glEnd();
+ }
+ else
+ {
+ glBegin( GL_POLYGON );
+ glVertex2f( vx1, vy1 );
+ glVertex2f( vx2, vy2 );
+ glVertex2f( vx3, vy3 );
+ glEnd();
+ }
+}
#include "GLViewer.h"
#include "GLViewer_Defs.h"
+#include "GLViewer_Geom.h"
class GLViewer_Object;
class GLViewer_Rect;
static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black );
protected:
+ //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow
+ //* with predefined color
+ static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black,
+ bool = false, QColor = Qt::white );
+ static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool );
+ static void drawContour( const GLViewer_PntList&, QColor, GLfloat );
+ static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool );
+ static void drawPolygon( const GLViewer_PntList&, QColor );
+ static void drawVertex( GLfloat, GLfloat, QColor );
+ static void drawCross( GLfloat, GLfloat, QColor );
+ static void drawArrow( const GLfloat red, const GLfloat green, const GLfloat blue,
+ GLfloat, GLfloat, GLfloat, GLfloat,
+ GLfloat, GLfloat, GLfloat, GLboolean = GL_FALSE );
+
//! Draw object text
virtual void drawText( GLViewer_Object* theObject );
QtxActionMenuMgr::~QtxActionMenuMgr()
{
- for ( NodeListIterator it( myRoot.children ); it.current(); ++it )
+ for ( NodeListIterator it( myRoot.children ); it.current() && myMenu; ++it )
{
QAction* a = itemAction( it.current()->id );
if ( !a )
#include <qmap.h>
#include <qobject.h>
+#include <qguardedptr.h>
class QAction;
class QDomNode;
int generateId() const;
private:
- typedef QMap<int, QAction*> ActionMap;
+ typedef QGuardedPtr<QAction> ActionPtr;
+ typedef QMap<int, ActionPtr> ActionMap;
private:
bool myUpdate;
myStack->show();
else
myStack->hide();
+
+ myList->setShown( myList->count() > 1 );
}
void QtxListResourceEdit::updateVisible()
{
Q_OBJECT
+ Q_PROPERTY( int visibleCount READ visibleCount WRITE setVisibleCount )
+
public:
- typedef enum { Items, SubMenu } PopupMode;
- typedef enum { MoveFirst, MoveLast, AddFirst, AddLast } InsertMode;
+ enum { Items, SubMenu };
+ enum { MoveFirst, MoveLast, AddFirst, AddLast };
public:
QtxMRUAction( QObject* = 0, const char* = 0 );
QtxResourceEdit::~QtxResourceEdit()
{
+ ItemMap items;
for ( ItemMap::ConstIterator it = myItems.begin(); it != myItems.end(); ++it )
- delete it.data();
+ items.insert( it.key(), it.data() );
+
+ for ( ItemMap::ConstIterator itr = items.begin(); itr != items.end(); ++itr )
+ if ( myItems.contains( itr.key() ) )
+ delete itr.data();
}
QtxResourceMgr* QtxResourceEdit::resourceMgr() const
#include <qmap.h>
#ifdef WIN32
+#pragma warning( disable:4251 )
#pragma warning( disable:4275 )
#endif
};
#ifdef WIN32
+#pragma warning( default:4251 )
#pragma warning( default:4275 )
#endif
drawGradient( p, rr, act ? cg.highlight() : cg.dark(), col,
horiz ? LeftToRight : UpToDown, linear );
-\r
- QRect rt = rr;\r
- if ( flags & Style_Horizontal )\r
- rt.addCoords( 0, 20, 0, 0 );\r
- else\r
- rt.addCoords( 0, 0, -20, 0 );\r
-\r
- int textW = flags & Style_Horizontal ? rt.height() : rt.width();\r
- int textH = flags & Style_Horizontal ? rt.width() : rt.height();\r
-\r
- QString title = titleText( wnd->caption(), textW, p->fontMetrics() );\r
-\r
- if ( wnd )\r
- {\r
- QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();\r
- p->setPen( cgroup.highlightedText() );\r
-\r
- if ( flags & Style_Horizontal )\r
- {\r
- p->rotate( 270.0 );\r
- p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );\r
- p->drawText( 0, 0, title );\r
- }\r
- else\r
- p->drawText( 2, 2, textW, textH, AlignLeft, title );\r
- }\r
- }\r
+
+ QRect rt = rr;
+ if ( flags & Style_Horizontal )
+ rt.addCoords( 0, 20, 0, 0 );
+ else
+ rt.addCoords( 0, 0, -20, 0 );
+
+ int textW = flags & Style_Horizontal ? rt.height() : rt.width();
+ int textH = flags & Style_Horizontal ? rt.width() : rt.height();
+
+ QString title = titleText( wnd->caption(), textW, p->fontMetrics() );
+
+ if ( wnd )
+ {
+ QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();
+ p->setPen( cgroup.highlightedText() );
+
+ if ( flags & Style_Horizontal )
+ {
+ p->rotate( 270.0 );
+ p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );
+ p->drawText( 0, 0, title );
+ }
+ else
+ p->drawText( 2, 2, textW, textH, AlignLeft, title );
+ }
+ }
break;
}
r2.setRect( r2.left(), r2.top(), r2.width() - 2, r2.height() - 1 );
p->setPen( cg.foreground() );
- drawGradient( p, QRect( r2.left(), r2.top(), r2.width(), r2.height() - 1 ),\r
- selected ? cg.highlight() : cg.dark(), cg.background(), UpToDown, linear );\r
+ drawGradient( p, QRect( r2.left(), r2.top(), r2.width(), r2.height() - 1 ),
+ selected ? cg.highlight() : cg.dark(), cg.background(), UpToDown, linear );
-// p->fillRect( r2.left(), r2.top(), r2.width(), r2.height() - 1, selected ? cg.highlight() : cg.background() );\r
+// p->fillRect( r2.left(), r2.top(), r2.width(), r2.height() - 1, selected ? cg.highlight() : cg.background() );
p->drawRect( r2.left(), r2.top(), r2.width(), r2.height() - 1 );
if ( selected )
break;
}
-\r
- case CE_TabBarLabel:\r
- {\r
- QColorGroup tmp( cg );\r
- if ( flags & Style_Selected )\r
- tmp.setColor( QColorGroup::Foreground, tmp.highlightedText() );\r
- PARENT_STYLE::drawControl( element, p, widget, r, tmp, flags, opt );\r
- }\r
- break;\r
+
+ case CE_TabBarLabel:
+ {
+ QColorGroup tmp( cg );
+ if ( flags & Style_Selected )
+ tmp.setColor( QColorGroup::Foreground, tmp.highlightedText() );
+ PARENT_STYLE::drawControl( element, p, widget, r, tmp, flags, opt );
+ }
+ break;
case CE_PushButton:
{