INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

libs/orcaquml/component.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef ORCAQUML_COMPONENT_H
00012 #define ORCAQUML_COMPONENT_H
00013 
00014 #include <QGraphicsItem>
00015 #include <QFont>
00016 #include <QColor>
00017 
00018 #include <orcadef/componentdefinition.h>
00019 #include <orcaquml/interface.h>
00020 
00021 namespace orcaquml
00022 {
00023 
00024 class ComponentModel;
00025 class ComponentGeom;
00026 
00030 class Component: public QGraphicsRectItem
00031 {
00032 public:
00034     Component( ComponentModel & model, QGraphicsScene* scene );
00035 
00036     virtual int rtti () const { return 5555; };
00037 
00038     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00039 
00040     const orcadef::ComponentDef& def() const { return def_; };
00041     const orcadef::ComponentCfg& cfg() const { return cfg_; };
00042     const ComponentGeom &geom() const { return geom_; }; // Geometry( id_, (int)x(), (int)y() ); };
00043 
00044     QString tag() const { return QString::fromStdString(def_.tag); };
00045     QString name() const { return QString::fromStdString(cfg_.fqname.component); };
00046     QString platformName() const { return QString::fromStdString(cfg_.fqname.platform); };
00047     QString hostName() const { return QString::fromStdString(cfg_.fqexecutable.host); };
00048     QString exeFileName() const { return QString::fromStdString(cfg_.fqexecutable.executable); };
00049     
00050     void setPlatformName( const QString &s );
00051     void setHostName( const QString &s );
00052     void toggleHighlighted();
00053 
00054     QString configFileName() const { return QString( exeFileName() + QString::number( id_ ) + ".xml" ); };
00055 
00056     bool hasInterface( const QString &name, const QString &pat, const QString &role );
00057     void prepareToDie();
00058 
00059     void setSelected( bool yes );
00060     void toggleSelected();
00061     void setColor();
00062 
00063     // Hide itself and the children
00064     void reallyHide();
00065     // Show itself and the children
00066     void reallyShow();
00067 
00068     static void resetCounter() { _count = 0; };
00069 
00070     static void toggleColorScheme();
00071     static void toggleNaming();
00072     static void toggleDeployment();
00073 
00074     void placeInterfaceAuto();
00075 
00076     // Need to be public so we can link them.
00077     QList<Interface*> provided_;
00078     QList<Interface*> required_;
00079 
00080 //     virtual const std::string description() const { return "Component (tag " + def_.tag + ")"; }
00081 
00082 private:
00083 
00084     void initInterfaces();
00085 
00086     void drawDebug( QPainter *p );
00087     void drawUmlSymbol( QPainter *p );
00088     void drawLabel( QPainter *p );
00089     
00090     int id_;
00091 
00092     ComponentModel &model_;
00093 
00094     // Convenient access to fields of model_.
00095     orcadef::ComponentDef &def_;
00096     orcadef::ComponentCfg &cfg_;
00097     ComponentGeom         &geom_;
00098 
00099     bool isHighlighted_;
00100 
00101     // a system may have multiple instances of the same component running on the same
00102     // platform. Standard filenames (e.g. mycomponent.xml) will overwrite each other in
00103     // this case. Need to add something unique (e.g. mycomponent0.xml, mycomponent1.xml)
00104     // It's easier to make a number unique to all components, e.g. by having a counter.
00105     static int _count;
00106 
00107     // 0 = all default colors, 1 = color-coded by hostname, 2 = color-coded by platform name
00108     static int _colorScheme;
00109     
00110     static bool _showNamingInfo;
00111     static bool _showDeploymentInfo;
00112     
00113     static double _defaultWidth;
00114     static double _defaultHeight;
00115     static QPen _defaultPen;
00116     static QPen _selectedPen;
00117     static QBrush _defaultBrush;
00118     static QPen _highlightedPen;
00119     static QBrush _highlightedBrush;
00120     
00121     static QFont _normalFont;
00122     static QFont _typeFont;
00123 
00124 };
00125 
00126 } // namespace
00127 
00128 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5