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

 

         

hydrolibs/hydroqgui/worldview.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, Ben Upcroft
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 HYDROQGUI_WORLDVIEW_H
00012 #define HYDROQGUI_WORLDVIEW_H
00013 
00014 #include <QString>
00015 #include <QLabel>
00016 
00017 #include <hydroqgui/zoomwidget.h>
00018 #include <hydroqgui/guielementset.h>
00019 #include <hydroqgui/platformfocusmanager.h>
00020 #include <hydroqgui/coordinateframemanager.h>
00021 #include <hydroqguielementutil/mouseeventmanager.h>
00022 #include <hydroqguielementutil/ihumanmanager.h>
00023 
00024 
00025 namespace hydroqgui {
00026 
00027 class PlatformCSFinder;
00028 
00029 class XYDisplay : public QLabel
00030 {
00031 public:
00032     XYDisplay();
00033     void setCoordinates( double x, double y );
00034 private:
00035 };
00036 
00040 class WorldView : public hydroqgui::ZoomWidget
00041 {
00042    Q_OBJECT
00043 public:
00044 
00045     struct Config {
00046         Config()
00047             : initWithTransparency(false),
00048               initWithAntiAliasing(false),
00049               initialWorldWidth(20.0)
00050             {
00051             }
00052 
00053         bool initWithTransparency;
00054         bool initWithAntiAliasing;
00055 
00056         // Sets initial zoom settings
00057         double initialWorldWidth;
00058     };
00059     
00060     WorldView(  PlatformCSFinder                          &platformCSFinder,
00061                 ::hydroqguielementutil::MouseEventManager &mouseEventManager,
00062                 GuiElementSet                             &guiElementSet,
00063                 CoordinateFrameManager                    &coordinateFrameManager,
00064                 ::hydroqguielementutil::IHumanManager     &humanManager,
00065                 PlatformFocusManager                      &platformFocusManager,
00066                 int                                        displayRefreshTime,
00067                 const Config                              &cfg,
00068                 QWidget                                   *parent = NULL );
00069 
00070     virtual QSize sizeHint() const { return QSize( 400, 400 ); }
00071   
00072 public slots:
00073     // abstract zoom functions
00074     void zoomFitWin( double width=20.0 );
00075     void zoomAllPix();
00076     void setAntiAliasing(bool antiAliasing);
00077     void setUseTransparency(bool useTransparency);
00078 
00079 private slots:
00080 
00081     // this function gives each guielement a chance to update its internal
00082     // state and then issues a paint event (which will result in all guielements
00083     // getting a chance to repaint themselves).
00084     // it is driven off a clock.
00085     void reDisplay();
00086 
00087 private:
00088 
00089     void setupInterface( const Config &cfg );
00090 
00091     // handles distribution of mouse events to GuiElements
00092     ::hydroqguielementutil::MouseEventManager &mouseEventManager_;
00093 
00094     GuiElementSet          &guiElementSet_;
00095 
00096     // finds coord system of a platform
00097     const PlatformCSFinder &platformCSFinder_;
00098     CoordinateFrameManager &coordinateFrameManager_;
00099 
00100     ::hydroqguielementutil::IHumanManager &humanManager_;
00101     PlatformFocusManager &platformFocusManager_;
00102 
00103     void updateAllGuiElements();
00104     void paintAllGuiElements( QPainter *painter, int z, bool isCoordinateFramePlatformLocalised );
00105     
00106     // finds the nearest platform to the click, pclick and pixelRadius are in window CS
00107     QString nearestComponent( const QPointF& pclick, const double & pixelRadius );
00108 
00109     // Returns true if the platform which owns the coordinate system is localised
00110     // or if "global" owns the coordinate system 
00111     bool transformToPlatformOwningCS( QPainter *p );
00112 
00113     // Qt event handlers
00114     virtual void paintEvent( QPaintEvent* paintEvent );
00115     virtual void mousePressEvent( QMouseEvent* );
00116     virtual void mouseMoveEvent( QMouseEvent* );
00117     virtual void mouseReleaseEvent( QMouseEvent* );
00118     virtual void mouseDoubleClickEvent( QMouseEvent* );
00119 //     virtual bool event(QEvent *event);
00120 
00121     QPointF mouseDownPnt_;
00122 //     QPointF mouseMovePnt_;
00123     QPoint prevDragPos_;
00124     
00125     bool antiAliasing_;
00126 
00127     XYDisplay* xyDisplay_;
00128     QTimer *displayTimer_;
00129 };
00130 
00131 }
00132 
00133 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5