Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FXNODESELECTION_H
Toshihiro Shimizu 890ddd
#define FXNODESELECTION_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/selection.h"
Toshihiro Shimizu 890ddd
#include "tfx.h"
Toshihiro Shimizu 890ddd
#include "toonz/fxcommand.h"
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
#include <qpair></qpair>
Toshihiro Shimizu 890ddd
#include <qmap></qmap>
Toshihiro Shimizu 890ddd
#include <qset></qset>
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//forward declaration
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class TFxHandle;
Toshihiro Shimizu 890ddd
class SchematicLink;
Toshihiro Shimizu 890ddd
class SchematicPort;
Toshihiro Shimizu 890ddd
class FxSchematicScene;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace TFxCommand;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FxSelection
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FxSelection : public QObject, public TSelection
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QList<link> m_selectedLinks;
Toshihiro Shimizu 890ddd
	QList<tfxp> m_selectedFxs;</tfxp>
Toshihiro Shimizu 890ddd
	QList<int> m_selectedColIndexes;</int>
Toshihiro Shimizu 890ddd
	TXsheetHandle *m_xshHandle;
Toshihiro Shimizu 890ddd
	TFxHandle *m_fxHandle;
Toshihiro Shimizu 890ddd
	TPointD m_pastePosition;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FxSchematicScene *m_schematicScene;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FxSelection();
Toshihiro Shimizu 890ddd
	FxSelection(const FxSelection &src);
Toshihiro Shimizu 890ddd
	~FxSelection();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TSelection *clone() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setPastePosition(const TPointD &pos) { m_pastePosition = pos; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void enableCommands();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return true if the selection is empty
Toshihiro Shimizu 890ddd
	bool isEmpty() const { return m_selectedFxs.empty() && m_selectedLinks.empty() && m_selectedColIndexes.isEmpty(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Empty the selection
Toshihiro Shimizu 890ddd
	void selectNone()
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_selectedFxs.clear();
Toshihiro Shimizu 890ddd
		m_selectedLinks.clear();
Toshihiro Shimizu 890ddd
		m_selectedColIndexes.clear();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Adds the \b fx to the m_selectedFxs container;
Toshihiro Shimizu 890ddd
	void select(TFxP fx);
Toshihiro Shimizu 890ddd
	//! Adds the \b colIndex to the m_selectedColIndexes container;
Toshihiro Shimizu 890ddd
	void select(int colIndex);
Toshihiro Shimizu 890ddd
	//! Removes the \b fx from the m_selectedFxs container;
Toshihiro Shimizu 890ddd
	void unselect(TFxP fx);
Toshihiro Shimizu 890ddd
	//! Removes the \b colIndex from the m_selectedColIndexes container;
Toshihiro Shimizu 890ddd
	void unselect(int colIndex);
Toshihiro Shimizu 890ddd
	//! Adds a QPair<tfxp,tfxp> to the m_selectedLinks container.</tfxp,tfxp>
Toshihiro Shimizu 890ddd
	//! The first element of of the QPair is the fx that has the link in input.
Toshihiro Shimizu 890ddd
	//! The second element of of the QPair is the fx that has the link in output
Toshihiro Shimizu 890ddd
	void select(SchematicLink *link);
Toshihiro Shimizu 890ddd
	//! Removes a QPair<tfxp,tfxp> from the m_selectedLinks container.</tfxp,tfxp>
Toshihiro Shimizu 890ddd
	void unselect(SchematicLink *link);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Returns true if the given \b fx is selected.
Toshihiro Shimizu 890ddd
	bool isSelected(TFxP fx) const;
Toshihiro Shimizu 890ddd
	//! Returns true if the given \b columnIndex is selected.
Toshihiro Shimizu 890ddd
	bool isSelected(int columnIndex) const;
Toshihiro Shimizu 890ddd
	//! Returns true if the QPair<tfxp,tfxp> of the fxs that bounds the given \b link is contained in the</tfxp,tfxp>
Toshihiro Shimizu 890ddd
	//! m_selectedLinks container.
Toshihiro Shimizu 890ddd
	bool isSelected(SchematicLink *link);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const QList<tfxp> &getFxs() const { return m_selectedFxs; }</tfxp>
Toshihiro Shimizu 890ddd
	const QList<link> &getLinks() const { return m_selectedLinks; }
Toshihiro Shimizu 890ddd
	const QList<int> &getColumnIndexes() const { return m_selectedColIndexes; }</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setXsheetHandle(TXsheetHandle *xshHandle) { m_xshHandle = xshHandle; }
Toshihiro Shimizu 890ddd
	void setFxHandle(TFxHandle *fxHandle) { m_fxHandle = fxHandle; }
Toshihiro Shimizu 890ddd
	//! Returns the size of the selection.
Toshihiro Shimizu 890ddd
	//! The size is the number of fxs and link selected.
Toshihiro Shimizu 890ddd
	int size() { return m_selectedFxs.size() + m_selectedLinks.size(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//Commands
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Calls the TFxCommand::deleteSelection() to remove selected links or fxs.
Toshihiro Shimizu 890ddd
	void deleteSelection();
Toshihiro Shimizu 890ddd
	//! Copy selected fxs in the clipboard.
Toshihiro Shimizu 890ddd
	void copySelection();
Toshihiro Shimizu 890ddd
	//! Copy selected fxs in the clipboard and alls the TFxCommand::deleteSelection()
Toshihiro Shimizu 890ddd
	//! to remove selected links or fxs.
Toshihiro Shimizu 890ddd
	void cutSelection();
Toshihiro Shimizu 890ddd
	//! Get fxs from the clipboards and calls the TFxCommand::pasteFxs(const QList<tfxp> &fxs, TXsheetHandle*)</tfxp>
Toshihiro Shimizu 890ddd
	//! to insert fxs in the scene.
Toshihiro Shimizu 890ddd
	void pasteSelection();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Get fxs from the clipboards and calls the TFxCommand::insertPasteFxs(const QList<tfxp> &fxs, TXsheetHandle*)</tfxp>
Toshihiro Shimizu 890ddd
	//! to insert fxs in the scene.
Toshihiro Shimizu 890ddd
	//! Fxs are pasted only if they are connected!
Toshihiro Shimizu 890ddd
	bool insertPasteSelection();
Toshihiro Shimizu 890ddd
	//! Get fxs from the clipboards and calls the TFxCommand::addPasteFxs(const QList<tfxp> &fxs, TXsheetHandle*)</tfxp>
Toshihiro Shimizu 890ddd
	//! to insert fxs in the scene.
Toshihiro Shimizu 890ddd
	//! Fxs are pasted only if they are connected!
Toshihiro Shimizu 890ddd
	bool addPasteSelection();
Toshihiro Shimizu 890ddd
	//! Get fxs from the clipboards and calls the TFxCommand::replacePasteFxs(const QList<tfxp> &fxs, TXsheetHandle*)</tfxp>
Toshihiro Shimizu 890ddd
	//! to insert fxs in the scene.
Toshihiro Shimizu 890ddd
	//! Fxs are pasted only if they are connected!
Toshihiro Shimizu 890ddd
	bool replacePasteSelection();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void groupSelection();
Toshihiro Shimizu 890ddd
	void ungroupSelection();
Toshihiro Shimizu 890ddd
	void collapseSelection();
Toshihiro Shimizu 890ddd
	void explodeChild();
Toshihiro Shimizu 890ddd
	Link getBoundingFxs(SchematicLink *link);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return true if the selection is connected;
Toshihiro Shimizu 890ddd
	//! A selection is connected if nodes and links selected create a connected graph
Toshihiro Shimizu 890ddd
	bool isConnected();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setFxSchematicScene(FxSchematicScene *schematicScene) { m_schematicScene = schematicScene; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	// not implemented
Toshihiro Shimizu 890ddd
	FxSelection &operator=(const FxSelection &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Link getBoundingFxs(SchematicPort *inputPort, SchematicPort *outputPort);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void visitFx(TFx *fx, QList<tfx *=""> &visitedFxs);</tfx>
Toshihiro Shimizu 890ddd
	bool areLinked(TFx *outFx, TFx *inFx);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
	void doCollapse(const QList<tfxp> &);</tfxp>
Toshihiro Shimizu 890ddd
	void doExplodeChild(const QList<tfxp> &);</tfxp>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif;