diagrameditor.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  diagrameditor.h
00004  *  Digest
00005  * 
00006  *  Created by Aidan Lane on Thu Jun 14 2005.
00007  *  Copyright (c) 2005-2006 Optimisation and Constraint Solving Group,
00008  *  Monash University. All rights reserved.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00023  */
00024 
00025 #ifndef DIAGRAMEDITOR_H
00026 #define DIAGRAMEDITOR_H
00027 
00028 
00029 #include <QWidget>
00030 #include "MvcDiagram/abstractdiagramview.h"
00031 #include "MvcDigestDb/abstractdigestdbview.h"
00032 #include "MvcSettings/abstractsettingsview.h"
00033 
00034 #include <QEvent> // TODO: remove me!
00035 #include <QPicture>
00036 #include <QPointer>
00037 #include <QTime>
00038 
00039 #include <jni.h>
00040 
00041 #include "Gesture/strokelist.h"
00042 #include "DigestGuiCore/strokespainterpath.h"
00043 
00044 #include "digest.h"
00045 
00046 
00047 class AbstractDiagramElement;
00048 class AbstractRecogniser;
00049 
00050 
00051 class DiagramEditor : public QWidget,
00052                       public AbstractDiagramView,
00053                       public AbstractDigestDbView,
00054                       public AbstractSettingsView {
00055 
00056   Q_OBJECT
00057 
00058 public:
00059   DiagramEditor( JavaVM* jvm, QWidget* parent = 0 );
00060   DiagramEditor( AbstractController* diagramController,
00061                  AbstractController* digestDbController,
00062                  AbstractController* settingsController,
00063                  JavaVM* jvm,
00064                  QWidget* parent = 0 );
00065 
00066   QSize sizeHint() const;
00067 
00068   Digest::Tool currentTool() const { return m_currentTool; }
00069   void setCurrentTool( Digest::Tool tool );
00070 
00071 
00072 public slots:
00073   virtual void copy();
00074   virtual void cut();
00075   virtual void del();
00076   virtual void paste();
00077   virtual void selectAll();
00078 
00079 
00080 protected slots:
00081   virtual bool tryBeginElementEditing( AbstractElement* );
00082   virtual void currentElementEditingFinished();
00083 
00084 
00085 protected:
00086 
00087   // TODO: remove me!
00088   enum GestureType {
00089     UnknownGesture,
00090     CircleGesture,
00091     LineGesture,
00092     SquareGesture,
00093   };
00094 
00095   virtual void customEvent( QEvent* );
00096 
00097   virtual void diagramResetEvent( VEvent* );
00098   virtual void elementAddedEvent( VElementEvent* );
00099   virtual void elementRemovedEvent( VElementEvent* );
00100   virtual void elementAttributeAddedEvent( VElementAttributeEvent* );
00101   virtual void elementAttributeRemovedEvent( VElementAttributeEvent* );
00102   virtual void elementAttributeDataChangedEvent( VElementAttributeEvent* );
00103   virtual void elementSelectionChangedEvent( VElementSelectionChangedEvent* );
00104   virtual void elementSetOrderChangedEvent( VElementSetOrderChangedEvent* );
00105 
00106   virtual void settingsResetEvent( VEvent* );
00107   virtual void settingsValueChangedEvent( VSettingsValueChangedEvent* );
00108 
00109   virtual void digestDbResetEvent( VEvent* );
00110   virtual void trainedRecogsEvent( VTrainedRecogsEvent* );
00111 
00112   virtual void keyPressEvent( QKeyEvent* );
00113   virtual void mouseDoubleClickEvent( QMouseEvent* );
00114   virtual void mousePressEvent( QMouseEvent* );
00115   virtual void mouseReleaseEvent ( QMouseEvent* );
00116   virtual void mouseMoveEvent( QMouseEvent* );
00117   virtual void tabletEvent( QTabletEvent* );
00118 
00119   virtual void paintEvent( QPaintEvent* );
00120 
00121   virtual void selectionPress( const QPointF& pos, Qt::KeyboardModifiers modifiers );
00122   virtual void selectionRelease();
00123   virtual void selectionMove( const QPointF& pos );
00124 
00125   virtual QPicture buildElementPicture( const AbstractElement* element ) const;
00126 
00127   AbstractElement* findElementAt( const QPointF& pos ) const;
00128 
00129   AbstractElement* addNewElement( int type );
00130   AbstractElementAttribute* addNewElementAttribute( int type,
00131                                                        AbstractElement* element );
00132 
00133   virtual void refreshRecogniser();
00134   virtual void recogniseCurrentStroke();
00135 
00136 private:
00137   void init();
00138 
00139   void elementAttributeModifiedWorker( AbstractElement* e,
00140                                        AbstractElementAttribute* a );
00141 
00142   void beginStroking( const StrokePoint& pt );
00143   void endStroking();
00144   void addPointToStroke( const StrokePoint& pt );
00145 
00146   JavaVM* m_jvm;
00147 
00148   Digest::Tool  m_currentTool;
00149   bool          m_mouseIsMovingSelection;
00150   QPointF       m_selectionMoveStartPos;
00151   QHash<AbstractElement*, QPointF> m_elementOriginsBeforeMove;
00152 
00153   bool   m_stroking;
00154   Stroke m_currentStroke;
00155   QTime  currentStrokeTime;
00156   StrokesPainterPath m_currentStrokePath;
00157 
00158   AbstractRecogniser* m_recogniser;
00159   int                 m_recogniserId;
00160 
00161   QPointer<QWidget> m_currentElementEditor;
00162   QPointer<AbstractElement> m_currentElementInEdit;
00163 
00164   // Caches:
00165   QHash<AbstractElement*, QPicture> c_elementPictures;
00166 };
00167 
00168 
00169 #endif  // ! DIAGRAMEDITOR_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2