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/interface.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_INTERFACE_H
00012 #define ORCAQUML_INTERFACE_H
00013 
00014 #include <QAbstractGraphicsShapeItem>
00015 #include <orcaquml/model.h>
00016 // #include <orcaquml/debuggable.h>
00017 
00018 // Can't just do forward declaration because we need to keep a list of pointers.
00019 // Qt will complain and gcc-3.4 produce an error.
00020 #include <orcaquml/link.h>
00021 
00022 namespace orcaquml
00023 {
00024 
00025 class Component;
00026 
00027 class Interface: public QAbstractGraphicsShapeItem //, public QorcaDebuggable
00028 {
00029 public:
00030     Interface( Component* parent, 
00031                 QGraphicsScene* scene,
00032                 orcadef::InterfaceDef &def,
00033                 orcadef::InterfaceCfg &cfg,
00034                 InterfaceGeom &geom );
00035 
00036     virtual QRectF boundingRect() const;
00037     // paint() is implemented in derived classes
00038     virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
00039     
00040     void setBearingConstrained( double theta );
00041     void snapToParent();
00042     void prepareToDie();
00043     
00044     enum Orientation{ OrientUp, OrientDown, OrientLeft, OrientRight };
00045     Orientation orientation() const { return orientation_; };
00046 
00047     bool isLinked() const {
00048         return !( inLinks_.isEmpty() && outLinks_.isEmpty()) ;
00049     };
00050     int linkCount() const {
00051         return inLinks_.count() + outLinks_.count();
00052     };
00053 
00054     // Hide itself and the label
00055     void reallyHide();
00056     // Show itself and the label
00057     void reallyShow();
00058 
00059     // A unique ID to identify a port. Used to reconnect component links after
00060     // save/load operation.
00061     int id() const {
00062         return id_;
00063     };
00064 
00065     virtual bool isClient() const = 0;
00066     virtual void checkValid() = 0;
00067 //     virtual void getConfig( QDomElement & ) = 0;
00068 //     virtual void writeConfig( QDomElement & ) = 0;
00069     virtual void setLabel() = 0;
00070 
00071     // Returns a human-readable description (useful for debugging)
00072 //     virtual const std::string description() const;
00073 
00074     void getNaming( QString & platform, QString & name ) { platform=nsPlatform_; name=nsName_; };
00075 
00076     // provided and requried will respond to this event differently
00077     virtual void linkEvent( Interface &toInterface ) {};
00078     
00079     void addInEdge( Link* link );
00080     void addOutEdge( Link* link );
00081 
00082     void removeInEdge( Link* link );
00083     void removeOutEdge( Link* link );
00084 
00085     static void toggleTag() {
00086         _showTag = !_showTag;
00087     };
00088     static void toggleSignature() {
00089         _showInterfaceName = !_showInterfaceName;
00090     };
00091     static void toggleServiceName() {
00092         _showServiceName = !_showServiceName;
00093     };
00094 
00095     QPointF bubblePos() const;
00096 
00097     Component &parent() const { return *parent_; }
00098     const orcadef::InterfaceCfg &cfg() const { return cfg_; }
00099 
00100     // obsolete
00101 //     QString signature() const {
00102 //         return ( QString("dummy") + "<" + object_ + ">");
00103 //     };
00104 
00105 protected:
00106 
00107     virtual void setValid( bool yes ) = 0;
00108 
00109     void drawDebug( QPainter* p );
00110     void drawStem( QPainter* p );
00111 
00112     // geometry functions
00113     double rangeToParent() const;
00114     double bearingToParent() const;
00115     
00116     Orientation orientation_;
00117     
00118     void moveLinksBy( double dx, double dy );
00119     void placeLabelAuto();
00120 
00121     // a unique ID to reconnect links after save/load operation
00122     int id_;
00123     QString tag_;
00124     QString interface;
00125     // this is my platform/name, only makes sense for servers, but put it here so we can set label_ appropriately
00126     QString nsPlatform_;
00127     QString nsName_;
00128     Component* parent_;
00129 
00130     // Hook into the model
00131     orcadef::InterfaceDef  &def_;
00132     orcadef::InterfaceCfg  &cfg_;
00133     InterfaceGeom &geom_;
00134 
00135     QList<Link*> inLinks_;
00136     QList<Link*> outLinks_;
00137 
00138     QGraphicsSimpleTextItem *label_;
00139 
00140     static double _stemSize;
00141     static double _bubbleRadius;
00142     static bool _showTag;
00143     static bool _showInterfaceName;
00144     static bool _showServiceName;
00145 };
00146 
00147 }
00148 
00149 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5