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

662 lines
19 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 FXSCHEMATICNODE_H
#define FXSCHEMATICNODE_H
// TnzQt includes
#include "fxtypes.h"
2016-03-19 06:57:51 +13:00
#include "schematicnode.h"
// Qt includes
#include <QGraphicsItem>
#include <QList>
//==============================================================
// Forward declarations
class TFx;
class TOutputFx;
class TXsheetFx;
class TZeraryColumnFx;
class TPaletteColumnFx;
class TLevelColumnFx;
class TStageObjectId;
class FxSchematicNode;
class FxSchematicScene;
class FxSchematicDock;
class FxSchematicColumnNode;
class FxSchematicPaletteNode;
class FxSchematicNormalFxNode;
class FxSchematicXSheetNode;
class FxSchematicOutputNode;
//*****************************************************
// FxColumnPainter
//*****************************************************
class FxColumnPainter final : public QObject, public QGraphicsItem {
2016-06-15 18:43:10 +12:00
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxSchematicColumnNode *m_parent;
double m_width, m_height;
QString m_name;
int m_type;
2018-09-11 17:43:04 +12:00
bool m_isReference = false;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxColumnPainter(FxSchematicColumnNode *parent, double width, double height,
const QString &name);
virtual ~FxColumnPainter();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
void setName(const QString &name) { m_name = name; }
2018-09-11 17:43:04 +12:00
void setIsReference(bool ref = true) { m_isReference = ref; }
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
void onIconGenerated();
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxPalettePainter
//*****************************************************
2019-08-19 21:52:45 +12:00
class FxPalettePainter final : public QObject, public QGraphicsItem {
Q_OBJECT
2016-06-15 18:43:10 +12:00
FxSchematicPaletteNode *m_parent;
double m_width, m_height;
QString m_name;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxPalettePainter(FxSchematicPaletteNode *parent, double width, double height,
const QString &name);
~FxPalettePainter();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
void setName(const QString &name) { m_name = name; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxPainter
//*****************************************************
class FxPainter final : public QObject, public QGraphicsItem {
2016-06-15 18:43:10 +12:00
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxSchematicNode *m_parent;
double m_width, m_height;
QString m_name, m_label;
eFxType m_type;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// to obtain the fx icons for zoom out view of the schematic
std::string m_fxType;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void paint_small(QPainter *painter);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxPainter(FxSchematicNode *parent, double width, double height,
const QString &name, eFxType type, std::string fxType);
~FxPainter();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
void setName(const QString &name) { m_name = name; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxXSheetPainter
//*****************************************************
class FxXSheetPainter final : public QObject, public QGraphicsItem {
2016-06-15 18:43:10 +12:00
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double m_width, m_height;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxSchematicXSheetNode *m_parent;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxXSheetPainter(FxSchematicXSheetNode *parent, double width, double height);
~FxXSheetPainter();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxOutputPainter
//*****************************************************
class FxOutputPainter final : public QObject, public QGraphicsItem {
2016-06-15 18:43:10 +12:00
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double m_width, m_height;
bool m_isActive;
FxSchematicOutputNode *m_parent;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxOutputPainter(FxSchematicOutputNode *parent, double width, double height);
~FxOutputPainter();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicLink
//*****************************************************
class FxSchematicLink final : public SchematicLink {
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
FxSchematicLink(QGraphicsItem *parent, QGraphicsScene *scene);
~FxSchematicLink();
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicPort
//*****************************************************
class FxSchematicPort final : public SchematicPort {
2019-08-19 21:52:45 +12:00
Q_OBJECT
2016-06-15 18:43:10 +12:00
TFx *m_ownerFx;
FxSchematicPort *m_currentTargetPort;
QList<SchematicLink *> m_hiddenLinks;
QList<SchematicLink *> m_ghostLinks;
2016-03-19 06:57:51 +13:00
2021-08-04 21:28:09 +12:00
bool m_isPassThrough;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicPort(FxSchematicDock *parent, int type);
~FxSchematicPort();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
bool linkTo(SchematicPort *port, bool checkOnly = false) override;
2016-06-15 18:43:10 +12:00
FxSchematicDock *getDock() const;
2016-06-19 20:06:29 +12:00
SchematicLink *makeLink(SchematicPort *port) override;
2016-03-19 06:57:51 +13:00
2021-08-04 21:28:09 +12:00
void setIsPassThrough();
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *me) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *me) override;
2016-06-15 18:43:10 +12:00
TFx *getOwnerFx() const;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void linkEffects(TFx *inputFx, TFx *fx, int inputId);
2016-06-19 20:06:29 +12:00
SchematicPort *searchPort(const QPointF &scenePos) override;
2016-06-15 18:43:10 +12:00
//! Handles hiding of existing link and showing of ghost links for snapping
//! after creation link only for fx having
//! dynamic ports.
//! If \b secondIndex is -1 consider the last port in the groupedPorts of the
//! node.
void handleSnappedLinksOnDynamicPortFx(
const std::vector<TFxPort *> &groupedPorts, int targetIndex,
int startIndex = -1);
void resetSnappedLinksOnDynamicPortFx();
void hideSnappedLinks(SchematicPort *) override;
void showSnappedLinks(SchematicPort *) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicDock
//*****************************************************
class FxSchematicDock final : public QGraphicsItem, public QObject {
2016-06-15 18:43:10 +12:00
QString m_name;
double m_width;
FxSchematicPort *m_port;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicDock(FxSchematicNode *parent, const QString &string, double width,
eFxSchematicPortType type);
~FxSchematicDock();
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
FxSchematicNode *getNode();
FxSchematicPort *getPort() { return m_port; }
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicNode
//*****************************************************
2016-06-15 18:43:10 +12:00
class FxSchematicNode : public SchematicNode {
Q_OBJECT
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
enum eDropActionMode { eShift, eNone };
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
QString m_name; //!< Node's name (displayed on top, editable)
TFxP
m_fx; //!< The node's associated fx (could be a wrapper to the actual fx)
TFxP m_actualFx; //!< The actual node's associated fx
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxSchematicNode *m_linkedNode;
QList<FxSchematicDock *> m_inDocks;
FxSchematicDock *m_outDock;
FxSchematicDock *m_linkDock;
SchematicName *m_nameItem;
eFxType m_type;
bool m_isCurrentFxLinked;
2016-03-19 06:57:51 +13:00
bool m_isNormalIconView;
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
//! If the fx has dynamic port groups, ensures that each group always has at
//! least one unlinked port
//! that users can attach to, while keeping the number of unlinked ports to
//! the minimum allowed by the
//! group's specifics.
virtual void checkDynamicInputPortSize() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Adds a dynamic group port to the associated fx.
void addDynamicInputPort(int groupIndex) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Removes the port with specified name from the associated fx. Returns false
//! (ie operation refused)
//! if the specified port does not exists, is connected, or is not in a
//! dynamic port group.
bool removeDynamicInputPort(const std::string &name) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Moves the port group links to the front ports.
void shiftLinks() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void updateOutputDockToolTips(const QString &name);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicNode(FxSchematicScene *parent, TFx *fx, qreal width, qreal height,
eFxType type);
void setWidth(const qreal &width) { m_width = width; }
void setHeight(const qreal &height) { m_height = height; }
2016-06-19 20:06:29 +12:00
void setSchematicNodePos(const QPointF &pos) const override;
2016-06-15 18:43:10 +12:00
TFx *getFx() const { return m_fx.getPointer(); }
bool isA(eFxType type) { return m_type == type; }
int getInputPortCount() { return m_inDocks.size(); }
int getInputDockId(FxSchematicDock *dock);
FxSchematicPort *getInputPort(int i) {
return m_inDocks[i] ? m_inDocks[i]->getPort() : 0;
}
FxSchematicPort *getOutputPort() {
return m_outDock ? m_outDock->getPort() : 0;
}
FxSchematicPort *getLinkPort() {
return m_linkDock ? m_linkDock->getPort() : 0;
}
bool isNameEditing() { return m_nameItem->isVisible(); }
2016-06-19 20:06:29 +12:00
void onClicked() override;
2016-06-15 18:43:10 +12:00
bool isCurrentFxLinked(SchematicNode *comingNode) {
return m_isCurrentFxLinked;
}
void setIsCurrentFxLinked(bool value, FxSchematicNode *comingNode);
2016-06-19 20:06:29 +12:00
void setPosition(const QPointF &newPos) override;
2016-06-15 18:43:10 +12:00
void updatePortsPosition();
virtual bool isOpened() { return true; }
virtual bool isEnabled() const;
virtual bool isCached() const;
virtual void resize(bool maximizeNode) {}
void toggleNormalIconView() { m_isNormalIconView = !m_isNormalIconView; }
bool isNormalIconView() { return m_isNormalIconView; }
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void switchCurrentFx(TFx *fx);
void currentColumnChanged(int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void fxNodeDoubleClicked();
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicOutputNode
//*****************************************************
class FxSchematicOutputNode final : public FxSchematicNode {
2019-08-19 21:52:45 +12:00
Q_OBJECT
2016-06-15 18:43:10 +12:00
FxOutputPainter *m_outputPainter;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicOutputNode(FxSchematicScene *scene, TOutputFx *fx);
~FxSchematicOutputNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicXSheetNode
//*****************************************************
class FxSchematicXSheetNode final : public FxSchematicNode {
2019-08-19 21:52:45 +12:00
Q_OBJECT
2016-06-15 18:43:10 +12:00
FxXSheetPainter *m_xsheetPainter;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicXSheetNode(FxSchematicScene *scene, TXsheetFx *fx);
~FxSchematicXSheetNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicNormalFxNode
//*****************************************************
class FxSchematicNormalFxNode final : public FxSchematicNode {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxPainter *m_painter;
SchematicToggle *m_renderToggle;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicNormalFxNode(FxSchematicScene *scene, TFx *fx);
~FxSchematicNormalFxNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void resize(bool maximizeNode) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onNameChanged();
void onRenderToggleClicked(bool);
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicZeraryNode
//*****************************************************
class FxSchematicZeraryNode final : public FxSchematicNode {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxPainter *m_painter;
int m_columnIndex;
SchematicToggle *m_renderToggle, *m_cameraStandToggle;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicZeraryNode(FxSchematicScene *scene, TZeraryColumnFx *fx);
~FxSchematicZeraryNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-20 14:23:05 +12:00
QWidget *widget = 0) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void resize(bool maximizeNode) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getColumnIndex() { return m_columnIndex; }
2016-06-19 20:06:29 +12:00
bool isCached() const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onRenderToggleClicked(bool);
void onCameraStandToggleClicked(int);
2016-06-15 18:43:10 +12:00
void onNameChanged();
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicColumnNode
//*****************************************************
class FxSchematicColumnNode final : public FxSchematicNode {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
SchematicThumbnailToggle *m_resizeItem;
SchematicToggle *m_renderToggle, *m_cameraStandToggle;
FxColumnPainter *m_columnPainter;
int m_columnIndex;
bool m_isOpened;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicColumnNode(FxSchematicScene *scene, TLevelColumnFx *fx);
~FxSchematicColumnNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
QPixmap getPixmap();
2016-06-19 20:06:29 +12:00
bool isOpened() override { return m_isOpened; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void getLevelTypeAndName(int &, QString &);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void resize(bool maximizeNode) override;
2016-06-15 18:43:10 +12:00
int getColumnIndex() { return m_columnIndex; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void renameObject(const TStageObjectId &id, std::string name);
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onRenderToggleClicked(bool);
void onCameraStandToggleClicked(int);
void onChangedSize(bool);
void onNameChanged();
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxSchematicPaletteNode
//*****************************************************
class FxSchematicPaletteNode final : public FxSchematicNode {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
SchematicToggle *m_renderToggle;
FxPalettePainter *m_palettePainter;
int m_columnIndex;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSchematicPaletteNode(FxSchematicScene *scene, TPaletteColumnFx *fx);
~FxSchematicPaletteNode();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
QPixmap getPixmap();
2016-06-19 20:06:29 +12:00
bool isOpened() override { return false; }
2016-06-15 18:43:10 +12:00
int getColumnIndex() { return m_columnIndex; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString getPaletteName();
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onRenderToggleClicked(bool);
void onNameChanged();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
void renameObject(const TStageObjectId &id, std::string name);
2016-03-19 06:57:51 +13:00
};
//*****************************************************
// FxGroupNode
//*****************************************************
class FxGroupNode final : public FxSchematicNode {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QList<TFxP> m_groupedFxs;
QList<TFxP> m_roots;
int m_groupId;
FxPainter *m_painter;
SchematicToggle *m_renderToggle;
bool m_isOpened;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxGroupNode(FxSchematicScene *scene, const QList<TFxP> &groupedFx,
const QList<TFxP> &roots, int groupId,
const std::wstring &groupName);
~FxGroupNode();
2016-06-19 20:06:29 +12:00
QRectF boundingRect() const override;
2016-06-15 18:43:10 +12:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
2016-06-19 20:06:29 +12:00
QWidget *widget = 0) override;
2016-06-15 18:43:10 +12:00
FxSchematicPort *getOutputPort() const {
return m_outDock ? m_outDock->getPort() : 0;
}
bool isNameEditing() const { return m_nameItem->isVisible(); }
QList<TFxP> getRootFxs() const { return m_roots; }
int getRootCount() { return m_roots.size(); }
int getFxCount() const { return m_groupedFxs.size(); }
TFx *getFx(int i) const {
return 0 <= i && i < m_groupedFxs.size() ? m_groupedFxs[i].getPointer() : 0;
}
QList<TFxP> getGroupedFxs() const { return m_groupedFxs; }
void updateFxsDagPosition(const TPointD &pos) const;
2016-06-19 20:06:29 +12:00
bool isOpened() override { return m_isOpened; }
void resize(bool maximized) override;
2016-06-15 18:43:10 +12:00
bool contains(TFxP fx);
// returns the number of ports that take the group in input... it consider
// also the node xsheet
int getOutputConnectionsCount() const;
2016-06-19 20:06:29 +12:00
bool isEnabled() const override;
bool isCached() const override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
2016-06-15 18:43:10 +12:00
QPointF computePos() const;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onNameChanged();
void onRenderToggleClicked(bool);
2016-03-19 06:57:51 +13:00
};
2021-08-04 21:28:09 +12:00
//*****************************************************
// FxPassThroughPainter
//*****************************************************
class FxSchematicPassThroughNode;
class FxPassThroughPainter final : public QObject, public QGraphicsItem {
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
double m_width, m_height;
QString m_name;
bool m_showName;
2021-08-04 21:28:09 +12:00
FxSchematicPassThroughNode *m_parent;
public:
FxPassThroughPainter(FxSchematicPassThroughNode *parent, double width,
double height, const QString &name, bool showName);
2021-08-04 21:28:09 +12:00
~FxPassThroughPainter();
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) override;
void setName(const QString &name) { m_name = name; }
void setShowName(bool showName) { m_showName = showName; }
2021-08-04 21:28:09 +12:00
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override;
};
//*****************************************************
// FxSchematicPassThroughNode
//*****************************************************
class FxSchematicPassThroughNode final : public FxSchematicNode {
Q_OBJECT
bool m_showName;
2021-08-04 21:28:09 +12:00
FxPassThroughPainter *m_passThroughPainter;
public:
FxSchematicPassThroughNode(FxSchematicScene *scene, TFx *fx);
~FxSchematicPassThroughNode();
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) override;
bool isOpened() override { return false; }
2021-08-04 21:28:09 +12:00
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;
2021-08-04 21:28:09 +12:00
void mousePressEvent(QGraphicsSceneMouseEvent *me) override;
protected slots:
void onNameChanged();
2021-08-04 21:28:09 +12:00
};
2016-06-15 18:43:10 +12:00
#endif // FXSCHEMATICNODE_H