tahoma2d/toonz/sources/include/toonzqt/schematicviewer.h

197 lines
4.2 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef SCHEMATICVIEWER_H
#define SCHEMATICVIEWER_H
// TnzLib includes
#include "toonz/tstageobjectid.h"
// TnzBase includes
#include "tfx.h"
// Qt includes
#include <QGraphicsScene>
#include <QGraphicsView>
// STD includes
#include <set>
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//====================================================
// Forward declarations
class SchematicNode;
class SchematicPort;
class SchematicLink;
class ToonzScene;
class StageSchematicScene;
class FxSchematicScene;
class TXsheetHandle;
class TObjectHandle;
class TColumnHandle;
class TFxHandle;
class TSceneHandle;
class TFrameHandle;
class TFx;
class TLevel;
class TSelection;
class TApplication;
class QToolBar;
class QToolButton;
class QAction;
//====================================================
//==================================================================
//
// SchematicScene
//
//==================================================================
2016-06-15 18:43:10 +12:00
class DVAPI SchematicScene : public QGraphicsScene {
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SchematicScene(QWidget *parent);
~SchematicScene();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void clearAllItems();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual QGraphicsItem *getCurrentNode() { return 0; }
virtual void reorderScene() = 0;
virtual void updateScene() = 0;
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
QList<SchematicLink *> m_highlightedLinks;
enum GridDimension { eLarge, eSmall };
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
//! Returns \b true if no nodes intersects \b rect.
bool isAnEmptyZone(const QRectF &rect);
//! Returns a vector containing all nodes which had their bounding rects
//! conatined in \b node bounding
//! rect enlarged of 10.
QVector<SchematicNode *> getPlacedNode(SchematicNode *node);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void showEvent(QShowEvent *se);
void hideEvent(QHideEvent *se);
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
virtual void onSelectionSwitched(TSelection *, TSelection *) {}
2016-03-19 06:57:51 +13:00
};
//==================================================================
//
// SchematicSceneViewer
//
//==================================================================
class DVAPI SchematicSceneViewer final : public QGraphicsView {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SchematicSceneViewer(QWidget *parent);
~SchematicSceneViewer();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void zoomQt(bool zoomin, bool resetZoom);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QPointF getOldScenePos() { return m_oldScenePos; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mousePressEvent(QMouseEvent *me) override;
void mouseMoveEvent(QMouseEvent *me) override;
void mouseReleaseEvent(QMouseEvent *me) override;
void keyPressEvent(QKeyEvent *ke) override;
void wheelEvent(QWheelEvent *me) override;
void showEvent(QShowEvent *se) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void fitScene();
void centerOnCurrent();
void reorderScene();
void normalizeScene();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
Qt::MouseButton m_buttonState;
QPoint m_oldWinPos;
QPointF m_oldScenePos;
bool m_firstShowing;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void changeScale(const QPoint &winPos, qreal scaleFactor);
2016-03-19 06:57:51 +13:00
};
//==================================================================
//
// SchematicViewer
//
//==================================================================
class DVAPI SchematicViewer final : public QWidget {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SchematicViewer(QWidget *parent);
~SchematicViewer();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setSchematicScene(SchematicScene *scene);
void setApplication(TApplication *app);
bool isStageSchematicViewed();
void setStageSchematicViewed(bool isStageSchematic);
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
void updateSchematic();
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void showPreview(TFxP);
void doCollapse(const QList<TFxP> &);
void doCollapse(QList<TStageObjectId>);
void doExplodeChild(const QList<TFxP> &);
void doExplodeChild(QList<TStageObjectId>);
void editObject();
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onSceneChanged();
void onSceneSwitched();
void updateScenes();
void changeNodeSize();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
SchematicSceneViewer *m_viewer;
StageSchematicScene *m_stageScene;
FxSchematicScene *m_fxScene;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TSceneHandle *m_sceneHandle;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QToolBar *m_stageToolbar, *m_commonToolbar, *m_fxToolbar, *m_swapToolbar;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QAction *m_fitSchematic, *m_centerOn, *m_reorder, *m_normalize, *m_nodeSize,
*m_changeScene;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_fullSchematic, m_maximizedNode;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void createToolbars();
void createActions();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setStageSchematic();
void setFxSchematic();
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // SCHEMATICVIEWER_H