|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
#ifndef CONTROLPOINTEDITORTOOL_H
|
|
shun-iwasawa |
0842da |
#define CONTROLPOINTEDITORTOOL_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/selection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcurves.h"
|
|
shun-iwasawa |
0842da |
#include "tproperty.h"
|
|
shun-iwasawa |
0842da |
#include "controlpointselection.h"
|
|
shun-iwasawa |
0842da |
#include "toonz/strokegenerator.h"
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
// For Qt translation support
|
|
shun-iwasawa |
0842da |
#include <qcoreapplication></qcoreapplication>
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
class TUndo;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
shun-iwasawa |
0842da |
// ControlPointEditorTool
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
class ControlPointEditorTool final : public TTool {
|
|
shun-iwasawa |
0842da |
Q_DECLARE_TR_FUNCTIONS(ControlPointEditorTool)
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
bool m_draw;
|
|
shun-iwasawa |
0842da |
bool m_isMenuViewed;
|
|
shun-iwasawa |
0842da |
int m_lastPointSelected;
|
|
shun-iwasawa |
0842da |
bool m_isImageChanged;
|
|
shun-iwasawa |
0842da |
ControlPointSelection m_selection;
|
|
shun-iwasawa |
0842da |
ControlPointEditorStroke m_controlPointEditorStroke;
|
|
shun-iwasawa |
0842da |
std::pair<int, int=""> m_moveSegmentLimitation; // Indici dei punti di controllo</int,>
|
|
shun-iwasawa |
0842da |
// che limitano la curva da
|
|
shun-iwasawa |
0842da |
// muovere
|
|
shun-iwasawa |
0842da |
ControlPointEditorStroke m_moveControlPointEditorStroke; // Usate per muovere
|
|
shun-iwasawa |
0842da |
// la curva durante
|
|
shun-iwasawa |
0842da |
// il drag.
|
|
shun-iwasawa |
0842da |
TRectD m_selectingRect;
|
|
shun-iwasawa |
0842da |
TPointD m_pos;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
TPropertyGroup m_prop;
|
|
shun-iwasawa |
0842da |
TEnumProperty m_selectType;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
TBoolProperty
|
|
shun-iwasawa |
0842da |
m_autoSelectDrawing; // Consente di scegliere se swichare tra i livelli.
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
TBoolProperty m_snap;
|
|
shun-iwasawa |
0842da |
TEnumProperty m_snapSensitivity;
|
|
shun-iwasawa |
0842da |
double m_snapMinDistance;
|
|
shun-iwasawa |
0842da |
bool m_foundSnap;
|
|
shun-iwasawa |
0842da |
TPointD m_snapPoint;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
TPointD m_firstPos; // The first point inserted in m_track
|
|
shun-iwasawa |
0842da |
StrokeGenerator m_track; // Lazo selection generator.
|
|
shun-iwasawa |
0842da |
TStroke* m_stroke; // Stores the stroke generated by m_track.
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
enum Action {
|
|
shun-iwasawa |
0842da |
NONE,
|
|
shun-iwasawa |
0842da |
RECT_SELECTION,
|
|
shun-iwasawa |
0842da |
FREEHAND_SELECTION,
|
|
shun-iwasawa |
0842da |
CP_MOVEMENT,
|
|
shun-iwasawa |
0842da |
SEGMENT_MOVEMENT,
|
|
shun-iwasawa |
0842da |
IN_SPEED_MOVEMENT,
|
|
shun-iwasawa |
0842da |
OUT_SPEED_MOVEMENT
|
|
Shinya Kitaoka |
120a6e |
};
|
|
shun-iwasawa |
0842da |
Action m_action;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
enum CursorType { NORMAL, ADD, EDIT_SPEED, EDIT_SEGMENT, NO_ACTIVE };
|
|
shun-iwasawa |
0842da |
CursorType m_cursorType;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
TUndo* m_undo;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
0842da |
void selectRegion(TStroke* stroke);
|
|
shun-iwasawa |
0842da |
void startFreehand(const TPointD& pos);
|
|
shun-iwasawa |
0842da |
void freehandDrag(const TPointD& pos);
|
|
shun-iwasawa |
0842da |
void closeFreehand(const TPointD& pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
shun-iwasawa |
0842da |
ControlPointEditorTool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
ToolType getToolType() const override { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
void updateTranslation() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
TPropertyGroup* getProperties(int targetType) override { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
// da TSelectionOwner: chiamato quando la selezione corrente viene cambiata
|
|
shun-iwasawa |
0842da |
void onSelectionChanged() { invalidate(); }
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
// da TSelectionOwner: chiamato quando si vuole ripristinare una vecchia
|
|
shun-iwasawa |
0842da |
// selezione
|
|
shun-iwasawa |
0842da |
// attualmente non usato
|
|
shun-iwasawa |
0842da |
bool select(const TSelection*) { return false; }
|
|
shun-iwasawa |
0842da |
ControlPointEditorStroke getControlPointEditorStroke() {
|
|
shun-iwasawa |
0842da |
return m_controlPointEditorStroke;
|
|
shun-iwasawa |
0842da |
};
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
void initUndo();
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
void getNearestStrokeColumnIndexes(std::vector<int>& indexes, TPointD pos);</int>
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
void drawMovingSegment();
|
|
shun-iwasawa |
0842da |
void drawControlPoint();
|
|
shun-iwasawa |
0842da |
void draw() override;
|
|
shun-iwasawa |
0842da |
void mouseMove(const TPointD& pos, const TMouseEvent& e) override;
|
|
shun-iwasawa |
0842da |
void leftButtonDown(const TPointD& pos, const TMouseEvent& e) override;
|
|
shun-iwasawa |
0842da |
void rightButtonDown(const TPointD& pos, const TMouseEvent&) override;
|
|
shun-iwasawa |
0842da |
|
|
shun-iwasawa |
0842da |
void moveControlPoints(const TPointD& delta);
|
|
shun-iwasawa |
0842da |
void moveSpeed(const TPointD& delta, bool isIn);
|
|
shun-iwasawa |
0842da |
void moveSegment(const TPointD& delta, bool dragging, bool isShiftPressed);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
void leftButtonDrag(const TPointD& pos, const TMouseEvent& e) override;
|
|
shun-iwasawa |
0842da |
void leftButtonUp(const TPointD& pos, const TMouseEvent& e) override;
|
|
shun-iwasawa |
0842da |
void addContextMenuItems(QMenu* menu) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
void linkSpeedInOut(int index);
|
|
shun-iwasawa |
0842da |
void unlinkSpeedInOut(int pointIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
bool keyDown(QKeyEvent* event) override;
|
|
shun-iwasawa |
0842da |
void onEnter() override;
|
|
shun-iwasawa |
0842da |
void onLeave() override;
|
|
shun-iwasawa |
0842da |
bool onPropertyChanged(std::string propertyName) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
void onActivate() override;
|
|
shun-iwasawa |
0842da |
void onDeactivate() override;
|
|
shun-iwasawa |
0842da |
void onImageChanged() override;
|
|
shun-iwasawa |
0842da |
int getCursorId() const override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
// returns true if the pressed key is recognized and processed.
|
|
shun-iwasawa |
0842da |
bool isEventAcceptable(QEvent* e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
TPointD calculateSnap(TPointD pos);
|
|
shun-iwasawa |
0842da |
void drawSnap();
|
|
shun-iwasawa |
0842da |
TPointD getSnap(TPointD pos);
|
|
shun-iwasawa |
0842da |
void resetSnap();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
bool isBusy() { return m_undo != nullptr; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
0842da |
#endif // CONTROLPOINTEDITORTOOL_H
|