Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef PLASTICTOOL_H
Toshihiro Shimizu 890ddd
#define PLASTICTOOL_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tproperty.h"
Toshihiro Shimizu 890ddd
#include "tmeshimage.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "tparamchange.h"
Toshihiro Shimizu 890ddd
#include "tdoubleparamrelayproperty.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzExt includes
Toshihiro Shimizu 890ddd
#include "ext/plasticskeleton.h"
Toshihiro Shimizu 890ddd
#include "ext/plasticskeletondeformation.h"
Toshihiro Shimizu 890ddd
#include "ext/plasticvisualsettings.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/plasticvertexselection.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzTools includes
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
#include "tools/cursors.h"
Toshihiro Shimizu 890ddd
#include "tools/tooloptions.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// STD includes
Toshihiro Shimizu 890ddd
#include <memory></memory>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// tcg includes
Toshihiro Shimizu 890ddd
#include "tcg/tcg_base.h"
Toshihiro Shimizu 890ddd
#include "tcg/tcg_controlled_access.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qobject></qobject>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
//    Metric defines
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Skeleton primitives
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define HIGHLIGHT_DISTANCE 8						 // Pixels distance to highlight
Toshihiro Shimizu 890ddd
#define HANDLE_SIZE 4								 // Size of vertex handles
Toshihiro Shimizu 890ddd
#define HIGHLIGHTED_HANDLE_SIZE HIGHLIGHT_DISTANCE   // Size of handle highlights
Toshihiro Shimizu 890ddd
#define SELECTED_HANDLE_SIZE HIGHLIGHTED_HANDLE_SIZE // Size of handle selections
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Mesh primitives
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define MESH_HIGHLIGHT_DISTANCE 8
Toshihiro Shimizu 890ddd
#define MESH_HIGHLIGHTED_HANDLE_SIZE 4
Toshihiro Shimizu 890ddd
#define MESH_SELECTED_HANDLE_SIZE 2
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
//    PlasticTool  declaration
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class PlasticTool : public QObject, public TTool, public TParamObserver, public TSelection::View
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	friend class PlasticToolOptionsBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	class TemporaryActivation
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		bool m_activate;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	public:
Toshihiro Shimizu 890ddd
		TemporaryActivation(int row, int col);
Toshihiro Shimizu 890ddd
		~TemporaryActivation();
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	struct MeshIndex : public tcg::safe_bool<meshindex> {</meshindex>
Toshihiro Shimizu 890ddd
		int m_meshIdx, //!< Mesh index in a TMeshImage
Toshihiro Shimizu 890ddd
			m_idx;	 //!< Index in the referenced mesh
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		explicit MeshIndex(int meshIdx = -1, int idx = -1)
Toshihiro Shimizu 890ddd
			: m_meshIdx(meshIdx), m_idx(idx) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bool operator_bool() const { return (m_meshIdx >= 0) && (m_idx >= 0); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bool operator<(const MeshIndex &other) const
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			return (m_meshIdx == other.m_meshIdx) ? (m_idx < other.m_idx)
Toshihiro Shimizu 890ddd
												  : (m_meshIdx < other.m_meshIdx);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	typedef MultipleSelection<meshindex> MeshSelection;</meshindex>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	PlasticSkeletonDeformationP m_sd;					  //!< Current column's skeleton deformation
Toshihiro Shimizu 890ddd
	int m_skelId;										  //!< Current m_sd's skeleton id
Toshihiro Shimizu 890ddd
	tcg::invalidable<plasticskeleton> m_deformedSkeleton; //!< The interactively-deformed \a animation-mode skeleton</plasticskeleton>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TMeshImageP m_mi; //!< Current mesh image
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Property-related vars  (ie, tool options)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPropertyGroup *m_propGroup; //!< Tool properties groups (needed for toolbar-building)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TEnumProperty m_mode;		  //!< Editing mode (BUILD, ANIMATE, etc..)
Toshihiro Shimizu 890ddd
	TStringProperty m_vertexName; //!< Vertex name property
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TBoolProperty m_interpolate; //!< Strict vertex interpolation property
Toshihiro Shimizu 890ddd
	TBoolProperty m_snapToMesh;  //!< Snap to Mesh vertexes during skeleton build
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleProperty m_thickness; //!< Brush radius, from 1 to 100
Toshihiro Shimizu 890ddd
	TEnumProperty m_rigidValue;  //!< Rigidity drawing value (ie draw rigidity/flexibility)
Toshihiro Shimizu 890ddd
								 //!< put a keyframe at current frame
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TBoolProperty m_globalKey;	//!< Whether animating a vertex will cause EVERY vertex to
Toshihiro Shimizu 890ddd
	TBoolProperty m_keepDistance; //!< Whether animation editing can alter vertex distances
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TStringProperty m_minAngle, m_maxAngle; //!< Minimum and maximum angle values allowed
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPropertyGroup m_relayGroup; //!< Group for each vertex parameter relay
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParamRelayProperty m_distanceRelay; //!< Relay property for vertex distance
Toshihiro Shimizu 890ddd
	TDoubleParamRelayProperty m_angleRelay;	//!< Relay property for vertex angle
Toshihiro Shimizu 890ddd
	TDoubleParamRelayProperty m_soRelay;	   //!< Relay property for vertex so
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParamRelayProperty m_skelIdRelay; //!< Relay property for m_sd's skeleton id
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Mouse-related vars
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD m_pos;		  //!< Last known mouse position
Toshihiro Shimizu 890ddd
	TPointD m_pressedPos; //!< Last mouse press position
Toshihiro Shimizu 890ddd
	bool m_dragged;		  //!< Whether dragging occurred between a press/release
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<tpointd> m_pressedVxsPos; //!< Position of selected vertices at mouse press</tpointd>
Toshihiro Shimizu 890ddd
	SkDKey m_pressedSkDF;				  //!< Skeleton deformation keyframes at mouse press
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Selection/Highlighting-related vars
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int m_svHigh,					//!< Highlighted skeleton vertexes
Toshihiro Shimizu 890ddd
		m_seHigh;					//!< Highlighted skeleton edges
Toshihiro Shimizu 890ddd
	PlasticVertexSelection m_svSel; //!< Selected skeleton vertexes
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	MeshIndex m_mvHigh,	//!< Highlighted mesh vertexes
Toshihiro Shimizu 890ddd
		m_meHigh;		   //!< Highlighted mesh edges
Toshihiro Shimizu 890ddd
	MeshSelection m_mvSel, //!< Selected mesh vertexes
Toshihiro Shimizu 890ddd
		m_meSel;		   //!< Selected mesh edges
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Drawing-related vars
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	PlasticVisualSettings m_pvs; //!< Visual options for plastic painting
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Editing-related vars
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::auto_ptr<tcg::polymorphic> m_rigidityPainter; //!< Delegate class to deal with (undoable) rigidity painting</tcg::polymorphic>
Toshihiro Shimizu 890ddd
	bool m_showSkeletonOS;							   //!< Whether onion-skinned skeletons must be shown
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Deformation-related vars
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_recompileOnMouseRelease; //!< Whether skeleton recompilation should happen on mouse release
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	enum Modes { MESH_IDX = 0,
Toshihiro Shimizu 890ddd
				 RIGIDITY_IDX,
Toshihiro Shimizu 890ddd
				 BUILD_IDX,
Toshihiro Shimizu 890ddd
				 ANIMATE_IDX,
Toshihiro Shimizu 890ddd
				 MODES_COUNT };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	PlasticTool();
Toshihiro Shimizu 890ddd
	~PlasticTool();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolType getToolType() const;
Toshihiro Shimizu 890ddd
	int getCursorId() const { return ToolCursor::SplineEditorCursor; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ToolOptionsBox *createOptionsBox();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPropertyGroup *getProperties(int idx) { return &m_propGroup[idx]; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateTranslation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onSetViewer();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onActivate();
Toshihiro Shimizu 890ddd
	void onDeactivate();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onEnter();
Toshihiro Shimizu 890ddd
	void onLeave();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addContextMenuItems(QMenu *menu);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void reset();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool onPropertyChanged(string propertyName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	// Methods reimplemented in each interaction mode
Toshihiro Shimizu 890ddd
	void mouseMove(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDown(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDrag(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonUp(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	// Skeleton methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setSkeletonSelection(const PlasticVertexSelection &vSel);
Toshihiro Shimizu 890ddd
	void toggleSkeletonSelection(const PlasticVertexSelection &vSel);
Toshihiro Shimizu 890ddd
	void clearSkeletonSelections();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const PlasticVertexSelection &skeletonVertexSelection() const { return m_svSel; }
Toshihiro Shimizu 890ddd
	PlasticVertexSelection branchSelection(int vIdx) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void moveVertex_build(const std::vector<tpointd> &originalVxsPos, const TPointD &posShift);</tpointd>
Toshihiro Shimizu 890ddd
	void addVertex(const PlasticSkeletonVertex &vx);
Toshihiro Shimizu 890ddd
	void insertVertex(const PlasticSkeletonVertex &vx, int e);
Toshihiro Shimizu 890ddd
	void insertVertex(const PlasticSkeletonVertex &vx, int parent, const std::vector<int> &children);</int>
Toshihiro Shimizu 890ddd
	void removeVertex();
Toshihiro Shimizu 890ddd
	void setVertexName(QString &name);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int addSkeleton(const PlasticSkeletonP &skeleton);
Toshihiro Shimizu 890ddd
	void addSkeleton(int skelId, const PlasticSkeletonP &skeleton);
Toshihiro Shimizu 890ddd
	void removeSkeleton(int skelId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	PlasticSkeletonP skeleton() const;
Toshihiro Shimizu 890ddd
	void touchSkeleton();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	PlasticSkeletonDeformationP deformation() const { return m_sd; }
Toshihiro Shimizu 890ddd
	void touchDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void storeDeformation(); //!< Stores deformation of current column (copying its reference)
Toshihiro Shimizu 890ddd
	void storeSkeletonId();  //!< Stores current skeleton id associated to current deformation
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onChange(); //!< Updates the tool after a deformation parameter change.
Toshihiro Shimizu 890ddd
	//!< It can be used to refresh the tool in ANIMATION mode.
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	// Mesh methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const MeshSelection &meshVertexesSelection() const { return m_mvSel; }
Toshihiro Shimizu 890ddd
	const MeshSelection &meshEdgesSelection() const { return m_meSel; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setMeshVertexesSelection(const MeshSelection &vSel);
Toshihiro Shimizu 890ddd
	void toggleMeshVertexesSelection(const MeshSelection &vSel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setMeshEdgesSelection(const MeshSelection &eSel);
Toshihiro Shimizu 890ddd
	void toggleMeshEdgesSelection(const MeshSelection &eSel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void clearMeshSelections();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void storeMeshImage();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void moveVertex_mesh(const std::vector<tpointd> &originalVxsPos, const TPointD &posShift);</tpointd>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	// Actions with associated undo
Toshihiro Shimizu 890ddd
	int addSkeleton_undo(const PlasticSkeletonP &skeleton);
Toshihiro Shimizu 890ddd
	void addSkeleton_undo(int skelId, const PlasticSkeletonP &skeleton);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void removeSkeleton_undo(int skelId);
Toshihiro Shimizu 890ddd
	void removeSkeleton_withKeyframes_undo(int skelId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void editSkelId_undo(int skelId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void swapEdge_mesh_undo();
Toshihiro Shimizu 890ddd
	void collapseEdge_mesh_undo();
Toshihiro Shimizu 890ddd
	void splitEdge_mesh_undo();
Toshihiro Shimizu 890ddd
	void cutEdges_mesh_undo();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void deleteSelectedVertex_undo();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setKey_undo();
Toshihiro Shimizu 890ddd
	void setGlobalKey_undo();
Toshihiro Shimizu 890ddd
	void setRestKey_undo();
Toshihiro Shimizu 890ddd
	void setGlobalRestKey_undo();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void copySkeleton();
Toshihiro Shimizu 890ddd
	void pasteSkeleton_undo();
Toshihiro Shimizu 890ddd
	void copyDeformation();
Toshihiro Shimizu 890ddd
	void pasteDeformation_undo();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals: // privates
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void skelIdsListChanged();
Toshihiro Shimizu 890ddd
	void skelIdChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void mouseMove_mesh(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDown_mesh(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDrag_mesh(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonUp_mesh(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void addContextMenuActions_mesh(QMenu *menu);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseMove_build(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDown_build(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDrag_build(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonUp_build(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void addContextMenuActions_build(QMenu *menu);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseMove_rigidity(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDown_rigidity(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDrag_rigidity(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonUp_rigidity(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void addContextMenuActions_rigidity(QMenu *menu);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseMove_animate(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDown_animate(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonDrag_animate(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void leftButtonUp_animate(const TPointD &pos, const TMouseEvent &me);
Toshihiro Shimizu 890ddd
	void addContextMenuActions_animate(QMenu *menu);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw_mesh();
Toshihiro Shimizu 890ddd
	void draw_build();
Toshihiro Shimizu 890ddd
	void draw_rigidity();
Toshihiro Shimizu 890ddd
	void draw_animate();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	// Skeleton methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	PlasticSkeleton &deformedSkeleton();
Toshihiro Shimizu 890ddd
	void updateDeformedSkeleton(PlasticSkeleton &deformedSkeleton);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Keyframe methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void keyFunc_undo(void (PlasticTool::*keyFunc)());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setKey();
Toshihiro Shimizu 890ddd
	void setGlobalKey();
Toshihiro Shimizu 890ddd
	void setRestKey();
Toshihiro Shimizu 890ddd
	void setGlobalRestKey();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Rigidity methods
Toshihiro Shimizu 890ddd
	static std::auto_ptr<tcg::polymorphic> createRigidityPainter();</tcg::polymorphic>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Drawing methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void drawSkeleton(const PlasticSkeleton &skel, double pixelSize, UCHAR alpha = 255);
Toshihiro Shimizu 890ddd
	void drawOnionSkinSkeletons_build(double pixelSize);
Toshihiro Shimizu 890ddd
	void drawOnionSkinSkeletons_animate(double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void drawHighlights(const SkDP &sd, const PlasticSkeleton *skel, double pixelSize);
Toshihiro Shimizu 890ddd
	void drawSelections(const SkDP &sd, const PlasticSkeleton &skel, double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void drawAngleLimits(const SkDP &sd, int skeId, int v, double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Selection methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setMeshSelection(MeshSelection &target, const MeshSelection &newSel);
Toshihiro Shimizu 890ddd
	void toggleMeshSelection(MeshSelection &target, const MeshSelection &addedSel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onSelectionChanged();
Toshihiro Shimizu 890ddd
	void enableCommands();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Parameter Observation methods
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onChange(const TParamChange &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onFrameSwitched();
Toshihiro Shimizu 890ddd
	void onColumnSwitched();
Toshihiro Shimizu 890ddd
	void onXsheetChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onShowMeshToggled(bool on);
Toshihiro Shimizu 890ddd
	void onShowSOToggled(bool on);
Toshihiro Shimizu 890ddd
	void onShowRigidityToggled(bool on);
Toshihiro Shimizu 890ddd
	void onShowSkelOSToggled(bool on);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
//    PlasticToolOptionsBox  declaration
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class PlasticToolOptionsBox : public GenericToolOptionsBox, public TProperty::Listener
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	PlasticToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	class SkelIdsComboBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	TTool *m_tool;
Toshihiro Shimizu 890ddd
	GenericToolOptionsBox **m_subToolbars;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	SkelIdsComboBox *m_skelIdComboBox;
Toshihiro Shimizu 890ddd
	QPushButton *m_addSkelButton, *m_removeSkelButton;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	void showEvent(QShowEvent *se);
Toshihiro Shimizu 890ddd
	void hideEvent(QHideEvent *he);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onPropertyChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onSkelIdsListChanged();
Toshihiro Shimizu 890ddd
	void onSkelIdChanged();
Toshihiro Shimizu 890ddd
	void onSkelIdEdited();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onAddSkeleton();
Toshihiro Shimizu 890ddd
	void onRemoveSkeleton();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
//    PlasticTool  local functions
Toshihiro Shimizu 890ddd
//****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace PlasticToolLocals
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
extern PlasticTool l_plasticTool;		//!< Tool instance.
Toshihiro Shimizu 890ddd
extern bool l_suspendParamsObservation; //!< Used to join multiple param change notifications.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Generic functions
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPointD projection(const PlasticSkeleton &skeleton,
Toshihiro Shimizu 890ddd
				   int e, const TPointD &pos); //!< Projects specified position an a skeleton edge.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Global getters
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
double frame(); //!< Returns current global xsheet frame.
Toshihiro Shimizu 890ddd
int row();		//!< Returns current global xsheet row.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int column();				 //!< Returns current global xsheet column index.
Toshihiro Shimizu 890ddd
TXshColumn *xshColumn();	 //!< Returns current xsheet column object.
Toshihiro Shimizu 890ddd
TStageObject *stageObject(); //!< Returns current stage object.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const TXshCell &xshCell();		//!< Returns current xsheet cell.
Toshihiro Shimizu 890ddd
void setCell(int row, int col); //!< Moves current xsheet cell to the specified position.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int skeletonId(); //!< Returns current skeleton id.
Toshihiro Shimizu 890ddd
double sdFrame(); //!< Returns current stage object's parameters time
Toshihiro Shimizu 890ddd
				  //!  (ie the frame value to be used with function editor curves,
Toshihiro Shimizu 890ddd
				  //!  which takes cyclicity into consideration).
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Keyframe functions
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void setKeyframe(TDoubleParamP ¶m, double frame);				   //!< Sets a keyframe to the specified parameter curve.
Toshihiro Shimizu 890ddd
void setKeyframe(SkVD *vd, double frame);							   //!< Sets a keyframe to the specified vertex deformation.
Toshihiro Shimizu 890ddd
void setKeyframe(const PlasticSkeletonDeformationP &sd, double frame); //!< Sets a keyframe to an entire skeleton deformation.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void invalidateXsheet(); //!< Refreshes xsheet content.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Draw functions
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawSquare(const TPointD &pos, double radius);		//!< Draws the outline of a square
Toshihiro Shimizu 890ddd
void drawFullSquare(const TPointD &pos, double radius); //!< Draws a filled square
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Mesh functions
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
std::pair<double, plastictool::meshindex=""> closestVertex(const TMeshImage &mi, const TPointD &pos);</double,>
Toshihiro Shimizu 890ddd
std::pair<double, plastictool::meshindex=""> closestEdge(const TMeshImage &mi, const TPointD &pos);</double,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
} // namespace PlasticToolLocals
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // PLASTICTOOL_H