• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

step/stepcore

tool.h

Go to the documentation of this file.
00001 /* This file is part of StepCore library.
00002    Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
00003 
00004    StepCore library is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2 of the License, or
00007    (at your option) any later version.
00008 
00009    StepCore library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with StepCore; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 */
00018 
00023 // TODO: split this file
00024 
00025 #ifndef STEPCORE_TOOL_H
00026 #define STEPCORE_TOOL_H
00027 
00028 #include "world.h"
00029 #include "types.h"
00030 #include <QHash>
00031 #include <QByteArray>
00032 #include <QStringList>
00033 
00034 namespace StepCore
00035 {
00036 
00040 class NoteImage: public Item
00041 {
00042     STEPCORE_OBJECT(NoteImage)
00043 
00044 public:
00046     explicit NoteImage(const QString& name = QString(),
00047                        const QByteArray& image = QByteArray())
00048                             : Item(name), _image(image) {}
00049 
00051     const QByteArray& image() const { return _image; }
00052 
00054     void setImage(const QByteArray& image) { _image = image; }
00055 
00056 protected:
00057     QByteArray _image;
00058 };
00059 
00063 class NoteFormula: public NoteImage
00064 {
00065     STEPCORE_OBJECT(NoteFormula)
00066 
00067 public:
00069     explicit NoteFormula(const QString& name = QString(),
00070                          const QByteArray& image = QByteArray(),
00071                          const QString& code = QString())
00072                             : NoteImage(name, image), _code(code) {}
00073 
00075     const QString& code() const { return _code; }
00077     void setCode(const QString& code) { _code = code; }
00078 
00079 protected:
00080     QString    _code;
00081 };
00082 
00089 class Note: public ItemGroup, public Tool
00090 {
00091     STEPCORE_OBJECT(Note)
00092 
00093 public:
00095     explicit Note(Vector2d position = Vector2d(0),
00096             Vector2d size = Vector2d(250,100), QString text = QString());
00097 
00099     const Vector2d& position() const { return _position; }
00101     void setPosition(const Vector2d& position) { _position = position; }
00102 
00104     const Vector2d& size() const { return _size; }
00106     void setSize(const Vector2d& size) { _size = size.cAbs(); }
00107 
00109     const QString& text() const { return _text; }
00111     void setText(const QString& text) { _text = text; }
00112 
00113 protected:
00114     Vector2d _position;
00115     Vector2d _size;
00116     QString  _text;
00117 };
00118 
00125 class Graph: public Item, public Tool
00126 {
00127     STEPCORE_OBJECT(Graph)
00128 
00129 public:
00131     explicit Graph(Vector2d position = Vector2d(0), Vector2d size = Vector2d(400,300));
00132 
00134     const Vector2d& position() const { return _position; }
00136     void setPosition(const Vector2d& position) { _position = position; }
00137 
00139     const Vector2d& size() const { return _size; }
00141     void setSize(const Vector2d& size) { _size = size.cAbs(); }
00142 
00144     Object* objectX() const { return _objectX; }
00146     void setObjectX(Object* objectX) { _objectX = objectX; }
00147 
00149     QString propertyX() const { return _propertyX; }
00151     void setPropertyX(const QString& propertyX) { _propertyX = propertyX; }
00152 
00154     int indexX() const { return _indexX; }
00156     void setIndexX(int indexX) { _indexX = indexX; }
00157 
00159     Object* objectY() const { return _objectY; }
00161     void setObjectY(Object* objectY) { _objectY = objectY; }
00162 
00164     QString propertyY() const { return _propertyY; }
00166     void setPropertyY(const QString& propertyY) { _propertyY = propertyY; }
00167 
00169     int indexY() const { return _indexY; }
00171     void setIndexY(int indexY) { _indexY = indexY; }
00172 
00174     bool autoLimitsX() const { return _autoLimitsX; }
00176     void setAutoLimitsX(bool autoLimitsX) { _autoLimitsX = autoLimitsX; }
00177 
00179     bool autoLimitsY() const { return _autoLimitsY; }
00181     void setAutoLimitsY(bool autoLimitsY) { _autoLimitsY = autoLimitsY; }
00182 
00184     const Vector2d& limitsX() const { return _limitsX; }
00186     void setLimitsX(const Vector2d& limitsX) { _limitsX = limitsX; }
00187 
00189     const Vector2d& limitsY() const { return _limitsY; }
00191     void setLimitsY(const Vector2d& limitsY) { _limitsY = limitsY; }
00192 
00194     bool showLines() const { return _showLines; }
00196     void setShowLines(bool showLines) { _showLines = showLines; }
00197 
00199     bool showPoints() const { return _showPoints; }
00201     void setShowPoints(bool showPoints) { _showPoints = showPoints; }
00202 
00204     const Vector2dList& points() const { return _points; }
00206     void setPoints(const Vector2dList& points) { _points = points; }
00207 
00209     const MetaProperty* propertyXPtr() const {
00210         return _objectX ? _objectX->metaObject()->property(_propertyX) : 0;
00211     }
00212 
00214     const MetaProperty* propertyYPtr() const {
00215         return _objectY ? _objectY->metaObject()->property(_propertyY) : 0;
00216     }
00217 
00219     bool isValidX() const;
00221     bool isValidY() const;
00223     bool isValid() const { return isValidX() && isValidY(); }
00224 
00226     Vector2d currentValue() const { return currentValue(0); }
00227 
00230     Vector2d currentValue(bool* ok) const;
00231 
00234     Vector2d recordPoint(bool* ok = 0);
00235 
00237     void clearPoints() { _points.clear(); }
00238 
00240     QString unitsX() const;
00241 
00243     QString unitsY() const;
00244 
00245     //void worldItemRemoved(Item* item);
00246     //void setWorld(World* world);
00247 
00248 protected:
00249     Vector2d _position;
00250     Vector2d _size;
00251 
00252     Object* _objectX;
00253     QString       _propertyX;
00254     int           _indexX;
00255 
00256     Object* _objectY;
00257     QString       _propertyY;
00258     int           _indexY;
00259 
00260     bool        _autoLimitsX;
00261     bool        _autoLimitsY;
00262 
00263     Vector2d    _limitsX;
00264     Vector2d    _limitsY;
00265 
00266     bool _showLines;
00267     bool _showPoints;
00268 
00269     Vector2dList _points;
00270 };
00271 
00278 class Meter: public Item, public Tool
00279 {
00280     STEPCORE_OBJECT(Meter)
00281 
00282 public:
00284     explicit Meter(Vector2d position = Vector2d(0), Vector2d size = Vector2d(70,24));
00285 
00287     const Vector2d& position() const { return _position; }
00289     void setPosition(const Vector2d& position) { _position = position; }
00290 
00292     const Vector2d& size() const { return _size; }
00294     void setSize(const Vector2d& size) { _size = size.cAbs(); }
00295 
00297     Object* object() const { return _object; }
00299     void setObject(Object* object) { _object = object; }
00300 
00302     QString property() const { return _property; }
00304     void setProperty(const QString& property) { _property = property; }
00305 
00307     int index() const { return _index; }
00309     void setIndex(int index) { _index = index; }
00310 
00312     int digits() const { return _digits; }
00314     void setDigits(int digits) { _digits = digits; }
00315 
00317     bool isValid() const;
00318 
00320     const MetaProperty* propertyPtr() const {
00321         return _object ? _object->metaObject()->property(_property) : 0;
00322     }
00323 
00325     double value() const { return value(0); }
00326 
00328     virtual void setValue(double) {}
00329 
00332     double value(bool* ok) const;
00333 
00335     QString units() const;
00336 
00337     //void worldItemRemoved(Item* item);
00338     //void setWorld(World* world);
00339 
00340 protected:
00341     Vector2d _position;
00342     Vector2d _size;
00343 
00344     Object*  _object;
00345     QString  _property;
00346     int      _index;
00347 
00348     int      _digits;
00349 };
00350 
00357 class Controller: public Item, public Tool
00358 {
00359     STEPCORE_OBJECT(Controller)
00360 
00361 public:
00363     explicit Controller(Vector2d position = Vector2d(0), Vector2d size = Vector2d(200,60));
00364 
00366     const Vector2d& position() const { return _position; }
00368     void setPosition(const Vector2d& position) { _position = position; }
00369 
00371     const Vector2d& size() const { return _size; }
00373     void setSize(const Vector2d& size) { _size = size.cAbs(); }
00374 
00376     Object* object() const { return _object; }
00378     void setObject(Object* object) { _object = object; }
00379 
00381     QString property() const { return _property; }
00383     void setProperty(const QString& property) { _property = property; }
00384 
00386     int index() const { return _index; }
00388     void setIndex(int index) { _index = index; }
00389 
00391     const Vector2d& limits() const { return _limits; }
00393     void setLimits(const Vector2d& limits) { _limits = limits; }
00394 
00396     const QString& decreaseShortcut() const { return _decreaseShortcut; }
00398     void setDecreaseShortcut(const QString& decreaseShortcut) { _decreaseShortcut = decreaseShortcut; }
00399 
00401     const QString& increaseShortcut() const { return _increaseShortcut; }
00403     void setIncreaseShortcut(const QString& increaseShortcut) { _increaseShortcut = increaseShortcut; }
00404 
00406     double increment() const { return _increment; }
00408     void setIncrement(double increment) { _increment = increment; }
00409 
00411     bool isValid() const;
00412 
00414     const MetaProperty* propertyPtr() const {
00415         return _object ? _object->metaObject()->property(_property) : 0;
00416     }
00417 
00419     double value() const { return value(0); }
00421     void setValue(double value) { setValue(value, 0); }
00422 
00425     double value(bool* ok) const;
00429     void setValue(double value, bool* ok);
00430 
00432     QString units() const;
00433 
00434     //void worldItemRemoved(Item* item);
00435     //void setWorld(World* world);
00436 
00437 protected:
00438     Vector2d _position;
00439     Vector2d _size;
00440 
00441     Object*  _object;
00442     QString  _property;
00443     int      _index;
00444 
00445     Vector2d _limits;
00446     QString  _decreaseShortcut;
00447     QString  _increaseShortcut;
00448 
00449     double   _increment;
00450 };
00451 
00452 class Particle;
00453 class RigidBody;
00454 
00461 class Tracer: public Item, public Tool
00462 {
00463     STEPCORE_OBJECT(Tracer)
00464 
00465 public:
00467     explicit Tracer(Object* body = 0, const Vector2d& localPosition = Vector2d(0));
00468 
00470     Object* body() const { return _body; }
00472     void setBody(Object* body);
00473 
00476     Vector2d localPosition() const { return _localPosition; }
00479     void setLocalPosition(const Vector2d& localPosition) { _localPosition = localPosition; }
00480 
00482     Vector2d position() const;
00483 
00485     const Vector2dList& points() const { return _points; }
00487     void setPoints(const Vector2dList& points) { _points = points; }
00488 
00490     Vector2d recordPoint() { Vector2d p = position(); _points.push_back(p); return p; }
00491 
00493     void clearPoints() { _points.clear(); }
00494 
00495     //void worldItemRemoved(Item* item);
00496     //void setWorld(World* world);
00497 
00498 protected:
00499     Object* _body;
00500     Vector2d _localPosition;
00501     Vector2dList _points;
00502 
00503     Particle*  _p;
00504     RigidBody* _r;
00505 };
00506 
00507 } // namespace StepCore
00508 
00509 #endif

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal