![]() |
TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
|
00001 /**************************************************************************** 00002 00003 Copyright (c) 2008 Deepak Chandran 00004 Contact: Deepak Chandran (dchandran1@gmail.com) 00005 See COPYRIGHT.TXT 00006 00007 The tool class is the parent class for all plugins. 00008 A Tool is a Qt Widget with a name and pointer to the Tinkercell MainWindow. 00009 00010 00011 ****************************************************************************/ 00012 00013 #ifndef TINKERCELL_TOOLDEF_H 00014 #define TINKERCELL_TOOLDEF_H 00015 00016 #include <QWidget> 00017 #include <QList> 00018 #include <QHash> 00019 #include <QAction> 00020 #include <QActionGroup> 00021 #include <QToolButton> 00022 #include <QUndoCommand> 00023 #include <QGraphicsItem> 00024 #include <QGraphicsItemGroup> 00025 00026 #include "MainWindow.h" 00027 00028 namespace Tinkercell 00029 { 00030 class MainWindow; 00031 class GraphicsScene; 00032 class NetworkHandle; 00033 class TextEditor; 00034 class ConsoleWindow; 00035 class ToolGraphicsItem; 00036 00040 class TINKERCELLCOREEXPORT Tool : public QWidget 00041 { 00042 00043 Q_OBJECT 00044 00045 public: 00047 QString name; 00049 QString category; 00051 QString description; 00053 MainWindow * mainWindow; 00055 Tool(); 00057 ~Tool(); 00063 Tool(const QString& Name, const QString& category = QString(), QWidget * parent = 0); 00065 virtual bool setMainWindow(MainWindow * main); 00067 ConsoleWindow* console(); 00069 GraphicsScene* currentScene() const; 00071 TextEditor* currentTextEditor() const; 00076 NetworkHandle* currentNetwork() const; 00081 NetworkWindow* currentWindow() const; 00090 QPair< QList<ItemHandle*>, QList<QGraphicsItem*> > getItemsFromFile(const QString& filename); 00094 static QString homeDir(); 00098 static QString tempDir(); 00099 00100 public slots: 00104 virtual void select(int i=0); 00108 virtual void deselect(int i=0); 00112 virtual void addAction(const QIcon&, const QString& text=QString(), const QString& tooltip=QString()); 00116 virtual void addGraphicsItem(ToolGraphicsItem*); 00117 00118 protected slots: 00122 virtual void actionTriggered( QAction * action ); 00123 00124 signals: 00126 void selected(); 00128 void deselected(); 00129 00130 private: 00132 QList<ToolGraphicsItem*> graphicsItems; 00134 QActionGroup actionsGroup; 00135 00136 friend class GraphicsScene; 00137 friend class TextEditor; 00138 friend class MainWindow; 00139 friend class NetworkHandle; 00140 friend class ToolGraphicsItem; 00141 }; 00142 00146 class TINKERCELLCOREEXPORT ToolGraphicsItem : public QGraphicsItemGroup 00147 { 00148 00149 public: 00151 ToolGraphicsItem(Tool*); 00153 virtual void select(); 00155 virtual void deselect(); 00157 Tool * tool; 00159 enum { Type = UserType + 9 }; 00161 int type() const 00162 { 00163 // Enable the use of dynamic_cast with this item. 00164 return Type; 00165 } 00167 virtual void visible(bool); 00170 static ToolGraphicsItem* cast(QGraphicsItem*); 00171 }; 00172 00173 } 00174 00175 #endif