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-09-21 12:35:28 +00:00
|
|
|
#ifndef QET_DIAGRAM_EDITOR_H
|
|
|
|
#define QET_DIAGRAM_EDITOR_H
|
2007-04-12 03:13:13 +00:00
|
|
|
#include <QtGui>
|
2012-02-13 22:12:37 +00:00
|
|
|
#include "qetmainwindow.h"
|
2008-08-14 22:51:08 +00:00
|
|
|
#include "borderproperties.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "conductorproperties.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
#include "titleblockproperties.h"
|
2009-08-09 12:51:02 +00:00
|
|
|
#include "exportproperties.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
class QETProject;
|
2012-07-13 07:21:19 +00:00
|
|
|
class QETResult;
|
2009-04-03 19:30:25 +00:00
|
|
|
class ProjectView;
|
2013-02-12 18:37:08 +00:00
|
|
|
class CustomElement;
|
2009-04-03 19:30:25 +00:00
|
|
|
class Diagram;
|
2007-04-12 03:13:13 +00:00
|
|
|
class DiagramView;
|
2013-02-12 18:37:08 +00:00
|
|
|
class Element;
|
2007-04-12 03:13:13 +00:00
|
|
|
class ElementsPanelWidget;
|
2009-05-19 19:00:37 +00:00
|
|
|
class ElementsLocation;
|
2008-07-30 11:51:27 +00:00
|
|
|
class RecentFiles;
|
2007-04-12 03:13:13 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents the main window of the QElectroTech diagram editor and,
|
|
|
|
ipso facto, the most important part of the QElectroTech user interface.
|
2007-04-12 03:13:13 +00:00
|
|
|
*/
|
2012-02-13 22:12:37 +00:00
|
|
|
class QETDiagramEditor : public QETMainWindow {
|
2007-04-12 03:13:13 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-04-12 03:13:13 +00:00
|
|
|
public:
|
2007-09-22 13:27:14 +00:00
|
|
|
QETDiagramEditor(const QStringList & = QStringList(), QWidget * = 0);
|
2007-09-21 12:35:28 +00:00
|
|
|
virtual ~QETDiagramEditor();
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private:
|
2007-09-21 12:35:28 +00:00
|
|
|
QETDiagramEditor(const QETDiagramEditor &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-04-12 03:13:13 +00:00
|
|
|
public:
|
|
|
|
void closeEvent(QCloseEvent *);
|
2009-04-03 19:30:25 +00:00
|
|
|
QList<ProjectView *> openedProjects() const;
|
|
|
|
void addProjectView(ProjectView *);
|
2011-03-15 20:06:40 +00:00
|
|
|
bool openAndAddProject(const QString &, bool = true, bool = true);
|
2009-04-03 19:30:25 +00:00
|
|
|
QList<DiagramView *> projectViews() const;
|
2008-07-20 11:37:31 +00:00
|
|
|
QList<QString> editedFiles() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
ProjectView *viewForFile(const QString &) const;
|
2010-12-20 02:45:36 +00:00
|
|
|
static TitleBlockProperties defaultTitleBlockProperties();
|
2009-08-09 12:51:02 +00:00
|
|
|
static BorderProperties defaultBorderProperties();
|
2009-04-03 19:30:25 +00:00
|
|
|
static ConductorProperties defaultConductorProperties();
|
2009-08-09 12:51:02 +00:00
|
|
|
static ExportProperties defaultExportProperties();
|
2009-11-22 16:12:22 +00:00
|
|
|
static ExportProperties defaultPrintProperties();
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void actions();
|
2009-04-03 19:30:25 +00:00
|
|
|
virtual bool event(QEvent *);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-15 20:06:40 +00:00
|
|
|
bool addProject(QETProject *, bool = true);
|
2009-04-03 19:30:25 +00:00
|
|
|
ProjectView *currentProject() const;
|
2007-09-25 23:24:36 +00:00
|
|
|
DiagramView *currentDiagram() const;
|
2013-02-12 18:37:08 +00:00
|
|
|
Element *currentElement() const;
|
|
|
|
CustomElement * currentCustomElement() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
ProjectView *findProject(DiagramView *) const;
|
|
|
|
ProjectView *findProject(Diagram *) const;
|
|
|
|
ProjectView *findProject(QETProject *) const;
|
|
|
|
ProjectView *findProject(const QString &) const;
|
|
|
|
QMdiSubWindow *subWindowForWidget(QWidget *) const;
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
void menus();
|
|
|
|
void toolbar();
|
|
|
|
|
|
|
|
public slots:
|
2007-09-29 12:54:01 +00:00
|
|
|
void printDialog();
|
|
|
|
void exportDialog();
|
2012-07-13 07:21:19 +00:00
|
|
|
void save();
|
|
|
|
void saveAs();
|
|
|
|
void saveCurrentDiagram();
|
2009-04-03 19:30:25 +00:00
|
|
|
bool newProject();
|
|
|
|
bool openProject();
|
2008-07-30 11:51:27 +00:00
|
|
|
bool openRecentFile(const QString &);
|
2009-04-03 19:30:25 +00:00
|
|
|
bool closeProject(ProjectView *);
|
|
|
|
bool closeProject(QETProject *);
|
|
|
|
bool closeCurrentProject();
|
2007-09-29 12:54:01 +00:00
|
|
|
void slot_cut();
|
|
|
|
void slot_copy();
|
|
|
|
void slot_paste();
|
|
|
|
void slot_zoomIn();
|
|
|
|
void slot_zoomOut();
|
2007-04-12 03:13:13 +00:00
|
|
|
void slot_zoomFit();
|
2012-08-12 11:46:42 +00:00
|
|
|
void slot_zoomContent();
|
2007-04-12 03:13:13 +00:00
|
|
|
void slot_zoomReset();
|
|
|
|
void slot_selectAll();
|
|
|
|
void slot_selectNothing();
|
|
|
|
void slot_selectInvert();
|
2007-09-29 12:54:01 +00:00
|
|
|
void slot_delete();
|
|
|
|
void slot_rotate();
|
2010-02-11 23:35:04 +00:00
|
|
|
void slot_rotateTexts();
|
2007-04-12 03:13:13 +00:00
|
|
|
void slot_setSelectionMode();
|
|
|
|
void slot_setVisualisationMode();
|
|
|
|
void slot_updateActions();
|
2007-10-28 00:16:32 +00:00
|
|
|
void slot_updateModeActions();
|
|
|
|
void slot_updateComplexActions();
|
|
|
|
void slot_updatePasteAction();
|
2007-09-29 12:54:01 +00:00
|
|
|
void slot_updateWindowsMenu();
|
2007-04-12 03:13:13 +00:00
|
|
|
void slot_addColumn();
|
|
|
|
void slot_removeColumn();
|
2008-08-10 15:07:59 +00:00
|
|
|
void slot_addRow();
|
|
|
|
void slot_removeRow();
|
2009-05-17 02:13:40 +00:00
|
|
|
void editSelectionProperties();
|
2007-10-03 17:02:39 +00:00
|
|
|
void slot_editConductor();
|
2007-10-06 18:37:21 +00:00
|
|
|
void slot_resetConductors();
|
2007-10-27 13:18:17 +00:00
|
|
|
void slot_addText();
|
2013-08-24 15:18:45 +00:00
|
|
|
void slot_addImage();
|
2013-09-10 14:44:25 +00:00
|
|
|
void slot_editSelection();
|
2009-04-03 19:30:25 +00:00
|
|
|
void setWindowedMode();
|
|
|
|
void setTabbedMode();
|
2007-11-12 15:21:14 +00:00
|
|
|
void readSettings();
|
|
|
|
void writeSettings();
|
2009-04-03 19:30:25 +00:00
|
|
|
void activateDiagram(Diagram *);
|
|
|
|
void activateProject(QETProject *);
|
|
|
|
void activateProject(ProjectView *);
|
|
|
|
void activateWidget(QWidget *);
|
|
|
|
void projectWasClosed(ProjectView *);
|
|
|
|
void editCurrentProjectProperties();
|
|
|
|
void editProjectProperties(ProjectView *);
|
|
|
|
void editProjectProperties(QETProject *);
|
|
|
|
void editCurrentDiagramProperties();
|
|
|
|
void editDiagramProperties(DiagramView *);
|
|
|
|
void editDiagramProperties(Diagram *);
|
|
|
|
void addDiagramToProject();
|
|
|
|
void addDiagramToProject(QETProject *);
|
|
|
|
void removeDiagram(Diagram *);
|
|
|
|
void removeDiagramFromProject();
|
2010-02-28 16:13:45 +00:00
|
|
|
void moveDiagramUp(Diagram *);
|
|
|
|
void moveDiagramDown(Diagram *);
|
2009-04-03 19:30:25 +00:00
|
|
|
void cleanCurrentProject();
|
2013-05-07 13:17:57 +00:00
|
|
|
void diagramNumProject();
|
2013-04-11 09:35:10 +00:00
|
|
|
void nomenclatureProject();
|
2009-04-03 19:30:25 +00:00
|
|
|
void diagramWasAdded(DiagramView *);
|
|
|
|
void diagramIsAboutToBeRemoved(DiagramView *);
|
|
|
|
void diagramWasRemoved(DiagramView *);
|
2009-05-19 19:00:37 +00:00
|
|
|
void findElementInPanel(const ElementsLocation &);
|
2013-02-12 18:37:08 +00:00
|
|
|
void findSelectedElementInPanel();
|
2009-07-08 09:41:20 +00:00
|
|
|
void editElementInEditor(const ElementsLocation &);
|
2013-02-12 18:37:08 +00:00
|
|
|
void editSelectedElementInEditor();
|
2012-07-13 07:21:19 +00:00
|
|
|
void showError(const QETResult &);
|
|
|
|
void showError(const QString &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-11-02 18:04:13 +00:00
|
|
|
public:
|
2012-11-09 21:09:24 +00:00
|
|
|
// Actions reachable through menus within QElectroTech
|
|
|
|
QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode
|
|
|
|
QActionGroup *grp_view_mode; ///< Action group for project
|
|
|
|
QAction *tabbed_view_mode; ///< Display projects as tabs
|
|
|
|
QAction *windowed_view_mode; ///< Display projects as windows
|
|
|
|
QAction *mode_selection; ///< Set edition mode
|
|
|
|
QAction *mode_visualise; ///< Set visualisation mode
|
|
|
|
QAction *new_file; ///< Create new project file
|
|
|
|
QAction *open_file; ///< Open project file
|
|
|
|
QAction *close_file; ///< Close current project file
|
2012-07-13 07:21:19 +00:00
|
|
|
QAction *save_file; ///< Save current project
|
|
|
|
QAction *save_file_as; ///< Save current project as a specific file
|
|
|
|
QAction *save_cur_diagram; ///< Save current diagram of the current project only
|
2012-11-09 21:09:24 +00:00
|
|
|
QAction *import_diagram; ///< Importe an existing diagram (not implemented)
|
|
|
|
QAction *export_diagram; ///< Export diagrams of the current project as imagess
|
|
|
|
QAction *print; ///< Print diagrams of the current project
|
|
|
|
QAction *quit_editor; ///< Quit the diagram editor
|
|
|
|
QAction *undo; ///< Cancel the latest action
|
|
|
|
QAction *redo; ///< Redo the latest cancelled operation
|
|
|
|
QAction *cut; ///< Cut selection to clipboard
|
|
|
|
QAction *copy; ///< Copy selection to clipboard
|
|
|
|
QAction *paste; ///< Paste clipboard content on the current diagram
|
|
|
|
QAction *select_all; ///< Select all
|
|
|
|
QAction *select_nothing; ///< Cancel selection
|
|
|
|
QAction *select_invert; ///< Invest selection
|
|
|
|
QAction *delete_selection; ///< Delete selection
|
|
|
|
QAction *rotate_selection; ///< Rotate selected elements and text items by 90 degrees
|
|
|
|
QAction *rotate_texts; ///< Direct selected text items to a specific angle
|
2013-02-12 18:37:08 +00:00
|
|
|
QAction *find_element; ///< Find the selected element in the panel
|
2012-11-09 21:09:24 +00:00
|
|
|
QAction *selection_prop; ///< Show a dialog describing the selection
|
|
|
|
QAction *conductor_reset; ///< Reset paths of selected conductors
|
|
|
|
QAction *conductor_default; ///< Show a dialog to edit default conductor properties
|
|
|
|
QAction *infos_diagram; ///< Show a dialog to edit diagram properties
|
|
|
|
QAction *add_text; ///< Tool to add an independent text item on diagrams
|
|
|
|
QAction *add_column; ///< Increase diagram width by adding an extra column
|
|
|
|
QAction *remove_column; ///< Decrease diagram width by removing the last column
|
|
|
|
QAction *add_row; ///< Increase diagram height by adding an extra row
|
|
|
|
QAction *remove_row; ///< Decrease diagram height by removing the last row
|
|
|
|
QAction *prj_edit_prop; ///< Edit the properties of the current project.
|
|
|
|
QAction *prj_add_diagram; ///< Add a diagram to the current project.
|
|
|
|
QAction *prj_del_diagram; ///< Delete a diagram from the current project
|
|
|
|
QAction *prj_clean; ///< Clean the content of the curent project by removing useless items
|
2013-05-07 13:17:57 +00:00
|
|
|
QAction *prj_diagramNum; ///< Numerotation des schemas
|
2013-04-11 09:35:10 +00:00
|
|
|
QAction *prj_nomenclature; ///< generate nomenclature
|
2012-11-09 21:09:24 +00:00
|
|
|
QAction *zoom_in; ///< Zoom in
|
|
|
|
QAction *zoom_out; ///< Zoom out
|
2012-08-12 11:46:42 +00:00
|
|
|
QAction *zoom_fit; ///< Adjust zoom to fit the whole diagram, including potential elements outside its borders, in the view
|
|
|
|
QAction *zoom_content; ///< Adjust zoom to fit all elements in the view, regardless of diagram borders
|
2012-11-09 21:09:24 +00:00
|
|
|
QAction *zoom_reset; ///< Reset zoom to 1:1
|
|
|
|
QAction *tile_window; ///< Show MDI subwindows as tile
|
|
|
|
QAction *cascade_window; ///< Show MDI subwindows as cascade
|
|
|
|
QAction *prev_window; ///< Switch to the previous document
|
|
|
|
QAction *next_window; ///< Switch to the next document
|
2013-09-10 14:44:25 +00:00
|
|
|
QAction *add_image; ///< Tool to add an independent image item on diagrams
|
|
|
|
QAction *edit_selection; ///< To edit selected item
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
private:
|
2009-04-03 19:30:25 +00:00
|
|
|
QMdiArea workspace;
|
2007-04-12 03:13:13 +00:00
|
|
|
QSignalMapper windowMapper;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Directory to use for file dialogs such as File > save
|
2007-10-21 12:53:57 +00:00
|
|
|
QDir open_dialog_dir;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Dock for the elements panel
|
2007-04-12 03:13:13 +00:00
|
|
|
QDockWidget *qdw_pa;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Dock for the undo list
|
2007-11-09 15:16:54 +00:00
|
|
|
QDockWidget *qdw_undo;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Elements panel
|
2007-04-12 03:13:13 +00:00
|
|
|
ElementsPanelWidget *pa;
|
2007-09-29 12:54:01 +00:00
|
|
|
QMenu *windows_menu;
|
2007-10-13 17:04:52 +00:00
|
|
|
QToolBar *main_bar;
|
|
|
|
QToolBar *view_bar;
|
|
|
|
QToolBar *diagram_bar;
|
2007-09-25 23:24:36 +00:00
|
|
|
QUndoGroup undo_group;
|
2009-04-03 19:30:25 +00:00
|
|
|
bool can_update_actions;
|
2007-04-12 03:13:13 +00:00
|
|
|
};
|
2006-10-27 15:47:22 +00:00
|
|
|
#endif
|