2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2012-01-01 22:51:51 +00:00
|
|
|
Copyright 2006-2012 Xavier Guerrin
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-01-29 00:41:12 +00:00
|
|
|
#ifndef DIAGRAMVIEW_H
|
2007-04-12 03:13:13 +00:00
|
|
|
#define DIAGRAMVIEW_H
|
|
|
|
#include <QtGui>
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "elementslocation.h"
|
2012-01-22 10:40:37 +00:00
|
|
|
#include "templatelocation.h"
|
2009-05-17 02:13:40 +00:00
|
|
|
class Conductor;
|
2007-04-12 03:13:13 +00:00
|
|
|
class Diagram;
|
2009-05-17 02:13:40 +00:00
|
|
|
class Element;
|
2010-04-18 17:59:54 +00:00
|
|
|
class IndependentTextItem;
|
2007-11-02 18:04:13 +00:00
|
|
|
class QETDiagramEditor;
|
2007-04-12 03:13:13 +00:00
|
|
|
/**
|
|
|
|
Classe representant graphiquement un schema electrique
|
|
|
|
*/
|
|
|
|
class DiagramView : public QGraphicsView {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2009-04-03 19:30:25 +00:00
|
|
|
DiagramView(Diagram * = 0, QWidget * = 0);
|
2007-04-12 03:13:13 +00:00
|
|
|
virtual ~DiagramView();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DiagramView(const DiagramView &);
|
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
Diagram *scene;
|
2007-11-02 18:04:13 +00:00
|
|
|
QMenu *context_menu;
|
|
|
|
QAction *paste_here;
|
2009-05-19 19:00:37 +00:00
|
|
|
QAction *find_element_;
|
2007-11-02 18:04:13 +00:00
|
|
|
QPoint paste_here_pos;
|
2007-10-27 13:18:17 +00:00
|
|
|
bool is_adding_text;
|
2012-03-24 14:34:25 +00:00
|
|
|
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
|
|
|
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
2009-04-03 19:30:25 +00:00
|
|
|
ElementsLocation next_location_;
|
|
|
|
QPoint next_position_;
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
2009-04-03 19:30:25 +00:00
|
|
|
QString title() const;
|
|
|
|
void editDiagramProperties();
|
2007-04-12 03:13:13 +00:00
|
|
|
void addColumn();
|
|
|
|
void removeColumn();
|
2008-08-10 15:07:59 +00:00
|
|
|
void addRow();
|
|
|
|
void removeRow();
|
2007-12-16 13:21:28 +00:00
|
|
|
/// @return Le schema visualise par ce DiagramView
|
2007-04-12 03:13:13 +00:00
|
|
|
Diagram *diagram() { return(scene); }
|
2007-11-02 18:04:13 +00:00
|
|
|
QETDiagramEditor *diagramEditor() const;
|
2007-04-12 03:13:13 +00:00
|
|
|
bool hasSelectedItems();
|
2010-04-24 22:37:45 +00:00
|
|
|
bool hasCopiableItems();
|
|
|
|
bool hasDeletableItems();
|
2007-10-27 13:18:17 +00:00
|
|
|
void addText();
|
2010-04-18 17:59:54 +00:00
|
|
|
IndependentTextItem *addDiagramTextAtPos(const QPointF &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2007-10-04 14:30:52 +00:00
|
|
|
protected:
|
2007-12-01 12:42:31 +00:00
|
|
|
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
2007-11-02 18:04:13 +00:00
|
|
|
virtual void contextMenuEvent(QContextMenuEvent *);
|
2007-10-04 14:30:52 +00:00
|
|
|
virtual void wheelEvent(QWheelEvent *);
|
2012-03-24 14:34:25 +00:00
|
|
|
virtual void focusInEvent(QFocusEvent *);
|
|
|
|
virtual void keyPressEvent(QKeyEvent *);
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent *);
|
2007-10-12 10:58:57 +00:00
|
|
|
virtual bool event(QEvent *);
|
2012-03-24 14:34:25 +00:00
|
|
|
virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e);
|
|
|
|
virtual bool switchToSelectionModeIfNeeded(QInputEvent *e);
|
|
|
|
virtual bool isCtrlShifting(QInputEvent *);
|
|
|
|
virtual bool selectedItemHasFocus();
|
2007-10-04 14:30:52 +00:00
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
private:
|
|
|
|
void mousePressEvent(QMouseEvent *);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *);
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *);
|
|
|
|
void dragMoveEvent(QDragMoveEvent *);
|
|
|
|
void dropEvent(QDropEvent *);
|
2012-01-22 10:40:37 +00:00
|
|
|
void handleElementDrop(QDropEvent *);
|
|
|
|
void handleTitleBlockDrop(QDropEvent *);
|
2007-09-04 18:15:41 +00:00
|
|
|
QRectF viewedSceneRect() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
bool mustIntegrateElement(const ElementsLocation &) const;
|
2012-01-22 10:40:37 +00:00
|
|
|
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
|
2009-04-03 19:30:25 +00:00
|
|
|
bool addElementAtPos(const ElementsLocation &, const QPoint &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
signals:
|
2007-10-21 16:10:21 +00:00
|
|
|
/// Signal emis lorsque la selection change
|
2007-04-12 03:13:13 +00:00
|
|
|
void selectionChanged();
|
2007-10-21 16:10:21 +00:00
|
|
|
/// Signal emis lorsque le mode de selection change
|
2007-04-12 03:13:13 +00:00
|
|
|
void modeChanged();
|
2007-10-27 13:18:17 +00:00
|
|
|
/// Signal emis lorsqu'un texte a ete pose
|
|
|
|
void textAdded(bool);
|
2009-04-03 19:30:25 +00:00
|
|
|
/// Signal emis lorsque le titre du schema change
|
|
|
|
void titleChanged(DiagramView *, const QString &);
|
|
|
|
/// Signal emis avant l'integration d'un element
|
|
|
|
void aboutToAddElement();
|
2012-01-22 10:40:37 +00:00
|
|
|
/// Signal emitted before integrating a title block template
|
|
|
|
void aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
2009-05-19 19:00:37 +00:00
|
|
|
/// Signal emis lorsque l'utilisateur souhaite retrouver un element du schema dans les collections
|
|
|
|
void findElementRequired(const ElementsLocation &);
|
2009-07-08 09:41:20 +00:00
|
|
|
/// Signal emis lorsque l'utilisateur souhaite editer un element du schema
|
|
|
|
void editElementRequired(const ElementsLocation &);
|
2012-01-25 07:29:50 +00:00
|
|
|
/// Signal emitted when the user wants to edit and/or duplicate an existing title block template
|
|
|
|
void editTitleBlockTemplate(const QString &, bool);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void selectNothing();
|
|
|
|
void selectAll();
|
|
|
|
void selectInvert();
|
2007-09-29 12:54:01 +00:00
|
|
|
void deleteSelection();
|
|
|
|
void rotateSelection();
|
2010-02-11 23:35:04 +00:00
|
|
|
void rotateTexts();
|
2007-04-12 03:13:13 +00:00
|
|
|
void setVisualisationMode();
|
|
|
|
void setSelectionMode();
|
2007-09-29 12:54:01 +00:00
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
2007-04-12 03:13:13 +00:00
|
|
|
void zoomFit();
|
|
|
|
void zoomReset();
|
2007-09-29 12:54:01 +00:00
|
|
|
void cut();
|
|
|
|
void copy();
|
2007-11-02 18:04:13 +00:00
|
|
|
void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
|
|
|
|
void pasteHere();
|
2007-09-28 21:02:53 +00:00
|
|
|
void adjustSceneRect();
|
2007-09-29 09:52:35 +00:00
|
|
|
void updateWindowTitle();
|
2009-05-17 02:13:40 +00:00
|
|
|
void editSelectionProperties();
|
2011-08-22 11:17:10 +00:00
|
|
|
void editSelectedConductorColor();
|
2009-05-17 02:13:40 +00:00
|
|
|
void editElement(Element *);
|
2007-10-03 17:02:39 +00:00
|
|
|
void editConductor();
|
2007-12-02 20:41:19 +00:00
|
|
|
void editConductor(Conductor *);
|
2011-08-22 11:17:10 +00:00
|
|
|
void editConductorColor(Conductor *);
|
2007-10-06 18:37:21 +00:00
|
|
|
void resetConductors();
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private slots:
|
2009-04-03 19:30:25 +00:00
|
|
|
void addDroppedElement();
|
2012-01-22 10:40:37 +00:00
|
|
|
void setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
2007-09-04 18:15:41 +00:00
|
|
|
void adjustGridToZoom();
|
2009-04-03 19:30:25 +00:00
|
|
|
void applyReadOnly();
|
2007-04-12 03:13:13 +00:00
|
|
|
};
|
2006-10-27 15:47:22 +00:00
|
|
|
#endif
|