|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "edittoolgadgets.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tfxhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamuiconcept.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "historytypes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
1fbdc9 |
#include <qapplication></qapplication>
|
|
shun_iwasawa |
1fbdc9 |
#include <qdesktopwidget></qdesktopwidget>
|
|
shun_iwasawa |
1fbdc9 |
|
|
Toshihiro Shimizu |
890ddd |
using namespace EditToolGadgets;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
GLdouble FxGadget::m_selectedColor[3] = {0.2, 0.8, 0.1};
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
1fbdc9 |
namespace {
|
|
shun_iwasawa |
1fbdc9 |
int getDevPixRatio() {
|
|
shun_iwasawa |
1fbdc9 |
static int devPixRatio = QApplication::desktop()->devicePixelRatio();
|
|
shun_iwasawa |
1fbdc9 |
return devPixRatio;
|
|
shun_iwasawa |
1fbdc9 |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
TPointD hadamard(const TPointD &v1, const TPointD &v2) {
|
|
shun-iwasawa |
6817df |
return TPointD(v1.x * v2.x, v1.y * v2.y);
|
|
shun_iwasawa |
1fbdc9 |
}
|
|
shun_iwasawa |
1fbdc9 |
|
|
shun-iwasawa |
6817df |
} // namespace
|
|
shun-iwasawa |
6817df |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadgetUndo definition
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class FxGadgetUndo final : public TUndo {
|
|
Shinya Kitaoka |
120a6e |
struct ParamData {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_param;
|
|
Shinya Kitaoka |
120a6e |
double m_oldValue, m_newValue;
|
|
Shinya Kitaoka |
120a6e |
bool m_wasKeyframe;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
std::vector<paramdata> m_params;</paramdata>
|
|
Shinya Kitaoka |
120a6e |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
FxGadgetUndo(const std::vector<tdoubleparamp> ¶ms, int frame)</tdoubleparamp>
|
|
Shinya Kitaoka |
120a6e |
: m_frame(frame) {
|
|
Shinya Kitaoka |
120a6e |
m_params.resize(params.size());
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)params.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_param = params[i];
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_oldValue = params[i]->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_newValue = m_params[i].m_oldValue;
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_wasKeyframe = m_params[i].m_param->isKeyframe(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void onAdd() override {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_newValue = m_params[i].m_param->getValue(m_frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_params[i].m_wasKeyframe)
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_param->deleteKeyframe(m_frame);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_param->setValue(m_frame, m_params[i].m_oldValue);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
m_params[i].m_param->setValue(m_frame, m_params[i].m_newValue);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override {
|
|
Shinya Kitaoka |
120a6e |
return sizeof(*this) + m_params.size() * sizeof(ParamData);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
QString str = QObject::tr("Modify Fx Gadget ");
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
str += QString::fromStdString(m_params[i].m_param->getName());
|
|
Shinya Kitaoka |
120a6e |
if (i != (int)m_params.size() - 1) str += QString::fromStdString(", ");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
str += QString(" Frame : %1").arg(QString::number(m_frame + 1));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return str;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Fx; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GadgetDragTool definition
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class GadgetDragTool final : public DragTool {
|
|
Shinya Kitaoka |
120a6e |
FxGadgetController *m_controller;
|
|
Shinya Kitaoka |
120a6e |
FxGadget *m_gadget;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
GadgetDragTool(FxGadgetController *controller, FxGadget *gadget)
|
|
Shinya Kitaoka |
120a6e |
: m_controller(controller), m_gadget(gadget) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine getMatrix() const { return m_controller->getMatrix().inv(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override {
|
|
Shinya Kitaoka |
120a6e |
m_gadget->createUndo();
|
|
Shinya Kitaoka |
120a6e |
m_gadget->leftButtonDown(getMatrix() * pos, e);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
|
|
Shinya Kitaoka |
120a6e |
m_gadget->leftButtonDrag(getMatrix() * pos, e);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override {
|
|
Shinya Kitaoka |
120a6e |
m_gadget->leftButtonUp(getMatrix() * pos, e);
|
|
Shinya Kitaoka |
120a6e |
m_gadget->commitUndo();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadget implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6817df |
FxGadget::FxGadget(FxGadgetController *controller, int handleCount)
|
|
Shinya Kitaoka |
120a6e |
: m_id(-1)
|
|
shun-iwasawa |
6817df |
, m_selected(-1)
|
|
Shinya Kitaoka |
120a6e |
, m_controller(controller)
|
|
Shinya Kitaoka |
120a6e |
, m_pixelSize(1)
|
|
Shinya Kitaoka |
120a6e |
, m_undo(0)
|
|
shun-iwasawa |
6817df |
, m_scaleFactor(1)
|
|
shun-iwasawa |
6817df |
, m_handleCount(handleCount) {
|
|
Shinya Kitaoka |
120a6e |
controller->assignId(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxGadget::~FxGadget() {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_params.size(); i++)
|
|
Shinya Kitaoka |
120a6e |
m_params[i]->removeObserver(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::addParam(const TDoubleParamP ¶m) {
|
|
Shinya Kitaoka |
120a6e |
m_params.push_back(param);
|
|
Shinya Kitaoka |
120a6e |
param->addObserver(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double FxGadget::getValue(const TDoubleParamP ¶m) const {
|
|
Shinya Kitaoka |
120a6e |
return param->getValue(m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::setValue(const TDoubleParamP ¶m, double value) {
|
|
Shinya Kitaoka |
120a6e |
param->setValue(m_controller->getCurrentFrame(), value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD FxGadget::getValue(const TPointParamP ¶m) const {
|
|
Shinya Kitaoka |
120a6e |
return param->getValue(m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::setValue(const TPointParamP ¶m, const TPointD &pos) {
|
|
Shinya Kitaoka |
120a6e |
param->setValue(m_controller->getCurrentFrame(), pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
1fbdc9 |
void FxGadget::setPixelSize() {
|
|
shun_iwasawa |
1fbdc9 |
setPixelSize(sqrt(tglGetPixelSize2()) * getDevPixRatio());
|
|
shun_iwasawa |
1fbdc9 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::drawTooltip(const TPointD &tooltipPos,
|
|
Shinya Kitaoka |
120a6e |
std::string tooltipPosText) {
|
|
shun_iwasawa |
1fbdc9 |
double unit = sqrt(tglGetPixelSize2()) * getDevPixRatio();
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(tooltipPos.x, tooltipPos.y, 0.0);
|
|
Shinya Kitaoka |
120a6e |
double sc = unit * 1.6;
|
|
Shinya Kitaoka |
120a6e |
glScaled(sc, sc, 1);
|
|
Shinya Kitaoka |
120a6e |
tglDrawText(TPointD(8, -3), tooltipPosText);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::drawDot(const TPointD &pos) {
|
|
Shinya Kitaoka |
120a6e |
double r = getPixelSize() * 3;
|
|
Shinya Kitaoka |
120a6e |
tglDrawRect(pos.x - r, pos.y - r, pos.x + r, pos.y + r);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::onChange(const TParamChange &) {
|
|
Shinya Kitaoka |
120a6e |
m_controller->invalidateViewer();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::createUndo() {
|
|
Shinya Kitaoka |
120a6e |
assert(m_undo == 0);
|
|
Shinya Kitaoka |
120a6e |
m_undo = new FxGadgetUndo(m_params, m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadget::commitUndo() {
|
|
Shinya Kitaoka |
120a6e |
assert(m_undo);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(m_undo);
|
|
Shinya Kitaoka |
120a6e |
m_undo = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Specific Gadget Concepts definition
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class PointFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_xParam, m_yParam;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PointFxGadget(FxGadgetController *controller, const TPointParamP ¶m)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_xParam(param->getX()), m_yParam(param->getY()) {
|
|
Shinya Kitaoka |
120a6e |
addParam(m_xParam);
|
|
Shinya Kitaoka |
120a6e |
addParam(m_yParam);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
PointFxGadget(FxGadgetController *controller, const TDoubleParamP &xParam,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP &yParam)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_xParam(xParam), m_yParam(yParam) {
|
|
Shinya Kitaoka |
120a6e |
addParam(m_xParam);
|
|
Shinya Kitaoka |
120a6e |
addParam(m_yParam);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getPoint() const {
|
|
Shinya Kitaoka |
120a6e |
return TPointD(getValue(m_xParam), getValue(m_yParam));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PointFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
TPointD pos(getPoint());
|
|
Shinya Kitaoka |
120a6e |
double unit = getPixelSize();
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(pos.x, pos.y, 0);
|
|
Shinya Kitaoka |
120a6e |
double r = unit * 3;
|
|
Shinya Kitaoka |
120a6e |
double d = unit * 6;
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-d, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-r, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(d, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, -d);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, -r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, d);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, r);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
tglDrawRect(-r, -r, r, r);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(pos + TPointD(7, 3) * unit, getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PointFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PointFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
if (m_xParam) setValue(m_xParam, pos.x);
|
|
Shinya Kitaoka |
120a6e |
if (m_yParam) setValue(m_yParam, pos.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PointFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RadiusFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_radius;
|
|
Shinya Kitaoka |
120a6e |
TPointParamP m_center;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RadiusFxGadget(FxGadgetController *controller, const TDoubleParamP &radius,
|
|
Shinya Kitaoka |
120a6e |
const TPointParamP ¢er)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_radius(radius), m_center(center) {
|
|
Shinya Kitaoka |
120a6e |
addParam(radius);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getCenter() const;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD RadiusFxGadget::getCenter() const {
|
|
Shinya Kitaoka |
120a6e |
return m_center ? getValue(m_center) : TPointD();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RadiusFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_radius) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
double radius = getValue(m_radius);
|
|
Shinya Kitaoka |
120a6e |
TPointD center = getCenter();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xAAAA);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
tglDrawCircle(center, radius);
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
drawDot(center + TPointD(0.707, 0.707) * radius);
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(center + TPointD(0.707, 0.707) * radius, getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RadiusFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RadiusFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
setValue(m_radius, norm(pos - getCenter()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RadiusFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DistanceFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_distance, m_angle;
|
|
Shinya Kitaoka |
120a6e |
int m_grabPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DistanceFxGadget(FxGadgetController *controller,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP &distance, const TDoubleParamP &angle)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller)
|
|
Shinya Kitaoka |
120a6e |
, m_distance(distance)
|
|
Shinya Kitaoka |
120a6e |
, m_angle(angle)
|
|
Shinya Kitaoka |
120a6e |
, m_grabPos(1) {
|
|
Shinya Kitaoka |
120a6e |
addParam(distance);
|
|
Shinya Kitaoka |
120a6e |
if (angle) addParam(angle);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getDirection() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_angle) return TPointD(1.0, 0.0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double angle = getValue(m_angle);
|
|
Shinya Kitaoka |
120a6e |
return TPointD(cos(angle), sin(angle));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DistanceFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_distance) return;
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
double d = getValue(m_distance) * getScaleFactor();
|
|
Shinya Kitaoka |
120a6e |
TPointD dir(getDirection());
|
|
Shinya Kitaoka |
120a6e |
TPointD u = rotate90(dir) * (getPixelSize() * 10);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(-u, u);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD b, c;
|
|
Shinya Kitaoka |
120a6e |
b = dir * (d * 0.5);
|
|
Shinya Kitaoka |
120a6e |
c = b - dir * d;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(b - u, b + u);
|
|
Shinya Kitaoka |
120a6e |
tglDrawCircle(b, getPixelSize() * 5);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(c - u, c + u);
|
|
Shinya Kitaoka |
120a6e |
tglDrawCircle(c, getPixelSize() * 5);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xAAAA);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(b, c);
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(b + TPointD(5, 5) * getPixelSize(), getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DistanceFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
m_grabPos = (pos.x > 0.0) ? 1 : -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DistanceFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
double v = (pos * getDirection()) / getScaleFactor();
|
|
Shinya Kitaoka |
120a6e |
v = v * 2 * m_grabPos;
|
|
Shinya Kitaoka |
120a6e |
setValue(m_distance, v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DistanceFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class AngleFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_param;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
AngleFxGadget(FxGadgetController *controller, const TDoubleParamP ¶m,
|
|
Shinya Kitaoka |
120a6e |
const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
AngleFxGadget::AngleFxGadget(FxGadgetController *controller,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP ¶m, const TPointD &pos)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_param(param), m_pos(pos) {
|
|
Shinya Kitaoka |
120a6e |
addParam(param);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void AngleFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
shun_iwasawa |
1fbdc9 |
double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
|
|
Shinya Kitaoka |
120a6e |
double r = pixelSize * 40;
|
|
Shinya Kitaoka |
120a6e |
double a = pixelSize * 10, b = pixelSize * 5;
|
|
Shinya Kitaoka |
120a6e |
tglDrawCircle(m_pos, r);
|
|
Shinya Kitaoka |
120a6e |
double phi = getValue(m_param);
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(m_pos.x, m_pos.y, 0);
|
|
Shinya Kitaoka |
120a6e |
glRotated(phi, 0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r - a, b);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r - a, -b);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(m_pos + TPointD(0.707, 0.707) * r, getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void AngleFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void AngleFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
TPointD d = pos - m_pos;
|
|
Shinya Kitaoka |
120a6e |
double phi = atan2(d.y, d.x);
|
|
Shinya Kitaoka |
120a6e |
setValue(m_param, phi * M_180_PI);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void AngleFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DiamondFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_param;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DiamondFxGadget(FxGadgetController *controller, const TDoubleParamP ¶m)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_param(param) {
|
|
Shinya Kitaoka |
120a6e |
addParam(param);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DiamondFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
double size = getValue(m_param);
|
|
Shinya Kitaoka |
120a6e |
double r = 3 * getPixelSize();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xAAAA);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-size + r, r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-r, size - r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, size - r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(size - r, r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(size - r, -r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(r, -size + r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-r, -size + r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-size + r, -r);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
drawDot(-size, 0);
|
|
Shinya Kitaoka |
120a6e |
drawDot(size, 0);
|
|
Shinya Kitaoka |
120a6e |
drawDot(0, -size);
|
|
Shinya Kitaoka |
120a6e |
drawDot(0, size);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double d = getPixelSize() * 3;
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(TPointD(d, size - d), getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DiamondFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
shun-iwasawa |
6817df |
double sz = fabs(pos.x) + fabs(pos.y);
|
|
Shinya Kitaoka |
120a6e |
if (sz < 0.1) sz = 0.1;
|
|
Shinya Kitaoka |
120a6e |
setValue(m_param, sz);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SizeFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_lx, m_ly;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SizeFxGadget(FxGadgetController *controller, const TDoubleParamP &lx,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP &ly)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller), m_lx(lx), m_ly(ly) {
|
|
Shinya Kitaoka |
120a6e |
addParam(lx);
|
|
Shinya Kitaoka |
120a6e |
if (ly) addParam(ly);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SizeFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
double lx = getValue(m_lx), ly = m_ly ? getValue(m_ly) : lx;
|
|
Shinya Kitaoka |
120a6e |
double r = getPixelSize() * 3;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xCCCC);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(lx, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, ly);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(lx, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(lx, ly - r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, ly);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(lx - r, ly);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
drawDot(lx, ly);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double d = getPixelSize() * 3;
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(TPointD(lx, ly), getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SizeFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
if (m_ly)
|
|
Shinya Kitaoka |
120a6e |
setValue(m_lx, std::max(pos.x, 0.1)), setValue(m_ly, std::max(pos.y, 0.1));
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setValue(m_lx, std::max({pos.x, pos.y, 0.1}));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RectFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_width, m_height;
|
|
Shinya Kitaoka |
120a6e |
TPointParamP m_center;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_picked;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
enum { None, Corner, HorizontalSide, VerticalSide };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RectFxGadget(FxGadgetController *controller, const TDoubleParamP &width,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP &height, const TPointParamP ¢er)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller)
|
|
Shinya Kitaoka |
120a6e |
, m_width(width)
|
|
Shinya Kitaoka |
120a6e |
, m_height(height)
|
|
Shinya Kitaoka |
120a6e |
, m_center(center)
|
|
Shinya Kitaoka |
120a6e |
, m_picked(None) {
|
|
Shinya Kitaoka |
120a6e |
addParam(width);
|
|
Shinya Kitaoka |
120a6e |
addParam(height);
|
|
Shinya Kitaoka |
120a6e |
if (center) addParam(center->getX()), addParam(center->getY());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getCenter() const {
|
|
Shinya Kitaoka |
120a6e |
return m_center ? getValue(m_center) : TPointD();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RectFxGadget::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
TPointD center = getCenter();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(center.x, center.y, 0);
|
|
Shinya Kitaoka |
120a6e |
double w_2 = 0.5 * getValue(m_width);
|
|
Shinya Kitaoka |
120a6e |
double h_2 = 0.5 * getValue(m_height);
|
|
Shinya Kitaoka |
120a6e |
double r = getPixelSize() * 3;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xCCCC);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-w_2 + r, -h_2);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(w_2 - r, -h_2);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-w_2 + r, h_2);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(w_2 - r, h_2);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-w_2, -h_2 + r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(-w_2, h_2 - r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(w_2, -h_2 + r);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(w_2, h_2 - r);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
drawDot(w_2, h_2);
|
|
Shinya Kitaoka |
120a6e |
drawDot(-w_2, h_2);
|
|
Shinya Kitaoka |
120a6e |
drawDot(w_2, -h_2);
|
|
Shinya Kitaoka |
120a6e |
drawDot(-w_2, -h_2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RectFxGadget::leftButtonDown(const TPointD &ppos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = ppos - getCenter();
|
|
Shinya Kitaoka |
120a6e |
m_picked = None;
|
|
Shinya Kitaoka |
120a6e |
double w_2 = 0.5 * getValue(m_width);
|
|
Shinya Kitaoka |
120a6e |
double h_2 = 0.5 * getValue(m_height);
|
|
Shinya Kitaoka |
120a6e |
double x = fabs(pos.x);
|
|
Shinya Kitaoka |
120a6e |
double y = fabs(pos.y);
|
|
Shinya Kitaoka |
120a6e |
double r = getPixelSize() * 15;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fabs(w_2 - x) < r && fabs(y - h_2) < r)
|
|
Shinya Kitaoka |
120a6e |
m_picked = Corner;
|
|
Shinya Kitaoka |
120a6e |
else if (fabs(w_2 - x) < r && y < h_2)
|
|
Shinya Kitaoka |
120a6e |
m_picked = VerticalSide;
|
|
Shinya Kitaoka |
120a6e |
else if (fabs(h_2 - y) < r && x < w_2)
|
|
Shinya Kitaoka |
120a6e |
m_picked = HorizontalSide;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RectFxGadget::leftButtonDrag(const TPointD &ppos, const TMouseEvent &) {
|
|
Shinya Kitaoka |
120a6e |
TPointD pos = ppos - getCenter();
|
|
Shinya Kitaoka |
120a6e |
double w = fabs(pos.x), h = fabs(pos.y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_picked == Corner || m_picked == VerticalSide)
|
|
Shinya Kitaoka |
120a6e |
setValue(m_width, 2.0 * w);
|
|
Shinya Kitaoka |
120a6e |
if (m_picked == Corner || m_picked == HorizontalSide)
|
|
Shinya Kitaoka |
120a6e |
setValue(m_height, 2.0 * h);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class PolarFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_phiParam, m_lengthParam;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PolarFxGadget(FxGadgetController *controller, const TPointD &pos,
|
|
Shinya Kitaoka |
120a6e |
const TDoubleParamP &phiParam, const TDoubleParamP &lengthParam)
|
|
Shinya Kitaoka |
120a6e |
: FxGadget(controller)
|
|
Shinya Kitaoka |
120a6e |
, m_pos(pos)
|
|
Shinya Kitaoka |
120a6e |
, m_phiParam(phiParam)
|
|
Shinya Kitaoka |
120a6e |
, m_lengthParam(lengthParam) {
|
|
Shinya Kitaoka |
120a6e |
addParam(phiParam);
|
|
Shinya Kitaoka |
120a6e |
addParam(lengthParam);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
double pixelSize = getPixelSize();
|
|
Shinya Kitaoka |
120a6e |
double r = getValue(m_lengthParam);
|
|
Shinya Kitaoka |
120a6e |
double a = pixelSize * 10, b = pixelSize * 5, c = pixelSize * 4;
|
|
Shinya Kitaoka |
120a6e |
// tglDrawCircle(m_pos, r);
|
|
Shinya Kitaoka |
120a6e |
double phi = getValue(m_phiParam);
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(m_pos.x, m_pos.y, 0);
|
|
Shinya Kitaoka |
120a6e |
glRotated(phi, 0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
double rr = r - c;
|
|
Shinya Kitaoka |
120a6e |
if (rr > 0) {
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xAAAA);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_STRIP);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(0, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(rr, 0);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINES);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(rr, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(rr - a, b);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(rr, 0);
|
|
Shinya Kitaoka |
120a6e |
glVertex2d(rr - a, -b);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glTranslated(r, 0, 0);
|
|
Shinya Kitaoka |
120a6e |
glRotated(-phi, 0, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
drawDot(0, 0);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
glPopName();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (isSelected()) {
|
|
Shinya Kitaoka |
120a6e |
double phiRad = phi * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
TPointD toolTipPos = m_pos + r * TPointD(cos(phiRad), sin(phiRad));
|
|
Shinya Kitaoka |
120a6e |
drawTooltip(toolTipPos, getLabel());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override {
|
|
Shinya Kitaoka |
120a6e |
TPointD d = pos - m_pos;
|
|
Shinya Kitaoka |
120a6e |
double phi = atan2(d.y, d.x);
|
|
Shinya Kitaoka |
120a6e |
double length = norm(d);
|
|
Shinya Kitaoka |
120a6e |
setValue(m_phiParam, phi * M_180_PI);
|
|
Shinya Kitaoka |
120a6e |
setValue(m_lengthParam, length);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class VectorFxGadget final : public FxGadget {
|
|
Shinya Kitaoka |
120a6e |
TPointParamP m_pa, m_pb;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
VectorFxGadget(FxGadgetController *controller, const TPointParamP &pa,
|
|
Shinya Kitaoka |
120a6e |
const TPointParamP &pb)
|
|
shun-iwasawa |
6817df |
: FxGadget(controller), m_pa(pa), m_pb(pb) {
|
|
Shinya Kitaoka |
120a6e |
addParam(pa->getX());
|
|
Shinya Kitaoka |
120a6e |
addParam(pa->getY());
|
|
Shinya Kitaoka |
120a6e |
addParam(pb->getX());
|
|
Shinya Kitaoka |
120a6e |
addParam(pb->getY());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override {
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
Shinya Kitaoka |
120a6e |
if (isSelected())
|
|
Shinya Kitaoka |
120a6e |
glColor3dv(m_selectedColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3d(0, 0, 1);
|
|
shun-iwasawa |
6817df |
// glPushName(getId());
|
|
Shinya Kitaoka |
120a6e |
double pixelSize = getPixelSize();
|
|
Shinya Kitaoka |
120a6e |
TPointD pa = getValue(m_pa);
|
|
Shinya Kitaoka |
120a6e |
TPointD pb = getValue(m_pb);
|
|
Shinya Kitaoka |
120a6e |
TPointD dab = pb - pa;
|
|
Shinya Kitaoka |
120a6e |
double ab2 = norm2(dab);
|
|
Shinya Kitaoka |
120a6e |
if (ab2 > 0.0001) {
|
|
Shinya Kitaoka |
120a6e |
double ab = sqrt(ab2);
|
|
Shinya Kitaoka |
120a6e |
TPointD u = dab * (1.0 / ab);
|
|
Shinya Kitaoka |
120a6e |
TPointD v = rotate90(u);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double a = pixelSize * 10, b = pixelSize * 5;
|
|
Shinya Kitaoka |
120a6e |
double c = pixelSize * 4;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD pbb = pb - u * c;
|
|
Shinya Kitaoka |
120a6e |
if (ab - c > 0) {
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xAAAA);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(pa, pbb);
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(pbb, pbb - u * a + v * b);
|
|
Shinya Kitaoka |
120a6e |
tglDrawSegment(pbb, pbb - u * a - v * b);
|
|
shun-iwasawa |
6817df |
// drawDot(pa);
|
|
shun-iwasawa |
6817df |
// drawDot(pb);
|
|
shun-iwasawa |
6817df |
} // else
|
|
shun-iwasawa |
6817df |
// drawDot(pa);
|
|
shun-iwasawa |
6817df |
// glPopName();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override {}
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class QuadFxGadget final : public FxGadget {
|
|
shun-iwasawa |
6817df |
TPointParamP m_TL, m_TR, m_BR, m_BL;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
enum HANDLE {
|
|
shun-iwasawa |
6817df |
Body = 0,
|
|
shun-iwasawa |
6817df |
TopLeft,
|
|
shun-iwasawa |
6817df |
TopRight,
|
|
shun-iwasawa |
6817df |
BottomRight,
|
|
shun-iwasawa |
6817df |
BottomLeft,
|
|
shun-iwasawa |
6817df |
TopEdge,
|
|
shun-iwasawa |
6817df |
RightEdge,
|
|
shun-iwasawa |
6817df |
BottomEdge,
|
|
shun-iwasawa |
6817df |
LeftEdge,
|
|
shun-iwasawa |
6817df |
None
|
|
shun-iwasawa |
6817df |
} m_handle = None;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
TPointD m_pivot;
|
|
shun-iwasawa |
6817df |
TPointD m_dragStartPos;
|
|
shun-iwasawa |
6817df |
TPointD m_startTL, m_startTR, m_startBR, m_startBL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
shun-iwasawa |
6817df |
QuadFxGadget(FxGadgetController *controller, const TPointParamP &topLeft,
|
|
shun-iwasawa |
6817df |
const TPointParamP &topRight, const TPointParamP &bottomRight,
|
|
shun-iwasawa |
6817df |
const TPointParamP &bottomLeft)
|
|
shun-iwasawa |
6817df |
: FxGadget(controller, 9)
|
|
shun-iwasawa |
6817df |
, m_TL(topLeft)
|
|
shun-iwasawa |
6817df |
, m_TR(topRight)
|
|
shun-iwasawa |
6817df |
, m_BR(bottomRight)
|
|
shun-iwasawa |
6817df |
, m_BL(bottomLeft) {
|
|
shun-iwasawa |
6817df |
addParam(topLeft->getX());
|
|
shun-iwasawa |
6817df |
addParam(topLeft->getY());
|
|
shun-iwasawa |
6817df |
addParam(topRight->getX());
|
|
shun-iwasawa |
6817df |
addParam(topRight->getY());
|
|
shun-iwasawa |
6817df |
addParam(bottomRight->getX());
|
|
shun-iwasawa |
6817df |
addParam(bottomRight->getY());
|
|
shun-iwasawa |
6817df |
addParam(bottomLeft->getX());
|
|
shun-iwasawa |
6817df |
addParam(bottomLeft->getY());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void draw(bool picking) override {
|
|
shun-iwasawa |
6817df |
int idBase = getId();
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto setColorById = [&](int id) {
|
|
shun-iwasawa |
6817df |
if (isSelected(id))
|
|
shun-iwasawa |
6817df |
glColor3dv(m_selectedColor);
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
glColor3d(0, 0, 1);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto id2Str = [](const HANDLE handleId) -> std::string {
|
|
shun-iwasawa |
6817df |
switch (handleId) {
|
|
shun-iwasawa |
6817df |
case TopLeft:
|
|
shun-iwasawa |
6817df |
return "Top Left";
|
|
shun-iwasawa |
6817df |
case TopRight:
|
|
shun-iwasawa |
6817df |
return "Top Right";
|
|
shun-iwasawa |
6817df |
case BottomRight:
|
|
shun-iwasawa |
6817df |
return "Bottom Right";
|
|
shun-iwasawa |
6817df |
case BottomLeft:
|
|
shun-iwasawa |
6817df |
return "Bottom Left";
|
|
shun-iwasawa |
6817df |
default:
|
|
shun-iwasawa |
6817df |
return "";
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto drawPoint = [&](const TPointD &pos, int id) {
|
|
shun-iwasawa |
6817df |
setColorById(id);
|
|
shun-iwasawa |
6817df |
glPushName(idBase + id);
|
|
shun-iwasawa |
6817df |
double unit = getPixelSize();
|
|
shun-iwasawa |
6817df |
glPushMatrix();
|
|
shun-iwasawa |
6817df |
glTranslated(pos.x, pos.y, 0);
|
|
shun-iwasawa |
6817df |
double r = unit * 3;
|
|
shun-iwasawa |
6817df |
tglDrawRect(-r, -r, r, r);
|
|
shun-iwasawa |
6817df |
glPopMatrix();
|
|
shun-iwasawa |
6817df |
glPopName();
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
if (isSelected(id) && id >= TopLeft && id <= BottomLeft) {
|
|
shun-iwasawa |
6817df |
drawTooltip(pos + TPointD(7, 3) * unit,
|
|
shun-iwasawa |
6817df |
id2Str((HANDLE)id) + getLabel());
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
Shinya Kitaoka |
120a6e |
setPixelSize();
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// lines for moving all vertices
|
|
shun-iwasawa |
6817df |
glPushName(idBase + Body);
|
|
shun-iwasawa |
6817df |
setColorById(Body);
|
|
shun-iwasawa |
6817df |
double pixelSize = getPixelSize();
|
|
shun-iwasawa |
6817df |
TPointD topLeft = getValue(m_TL);
|
|
shun-iwasawa |
6817df |
TPointD topRight = getValue(m_TR);
|
|
shun-iwasawa |
6817df |
TPointD bottomRight = getValue(m_BR);
|
|
shun-iwasawa |
6817df |
TPointD bottomLeft = getValue(m_BL);
|
|
Shinya Kitaoka |
120a6e |
glLineStipple(1, 0xCCCC);
|
|
Shinya Kitaoka |
120a6e |
glEnable(GL_LINE_STIPPLE);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_STRIP);
|
|
shun-iwasawa |
6817df |
tglVertex(topLeft);
|
|
shun-iwasawa |
6817df |
tglVertex(topRight);
|
|
shun-iwasawa |
6817df |
tglVertex(bottomRight);
|
|
shun-iwasawa |
6817df |
tglVertex(bottomLeft);
|
|
shun-iwasawa |
6817df |
tglVertex(topLeft);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glDisable(GL_LINE_STIPPLE);
|
|
shun-iwasawa |
6817df |
glPopName();
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// corners
|
|
shun-iwasawa |
6817df |
drawPoint(topLeft, TopLeft);
|
|
shun-iwasawa |
6817df |
drawPoint(topRight, TopRight);
|
|
shun-iwasawa |
6817df |
drawPoint(bottomRight, BottomRight);
|
|
shun-iwasawa |
6817df |
drawPoint(bottomLeft, BottomLeft);
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
// center of the edges
|
|
shun-iwasawa |
6817df |
drawPoint((topLeft + topRight) * 0.5, TopEdge);
|
|
shun-iwasawa |
6817df |
drawPoint((topRight + bottomRight) * 0.5, RightEdge);
|
|
shun-iwasawa |
6817df |
drawPoint((bottomRight + bottomLeft) * 0.5, BottomEdge);
|
|
shun-iwasawa |
6817df |
drawPoint((bottomLeft + topLeft) * 0.5, LeftEdge);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
6817df |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
shun-iwasawa |
6817df |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
shun-iwasawa |
6817df |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6817df |
//---------------------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
void QuadFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &) {
|
|
shun-iwasawa |
6817df |
m_handle = (HANDLE)m_selected;
|
|
shun-iwasawa |
6817df |
m_dragStartPos = pos;
|
|
shun-iwasawa |
6817df |
m_startTL = getValue(m_TL);
|
|
shun-iwasawa |
6817df |
m_startTR = getValue(m_TR);
|
|
shun-iwasawa |
6817df |
m_startBR = getValue(m_BR);
|
|
shun-iwasawa |
6817df |
m_startBL = getValue(m_BL);
|
|
shun-iwasawa |
6817df |
m_pivot = (m_startTL + m_startTR + m_startBR + m_startBL) * 0.25;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//---------------------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
void QuadFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
|
|
shun-iwasawa |
6817df |
TPointD offset = pos - m_dragStartPos;
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto scaleShape = [&](const TPointD &start, const TPointD &pivot) {
|
|
shun-iwasawa |
6817df |
TPointD startVec = start - pivot;
|
|
shun-iwasawa |
6817df |
TPointD endVec = start + offset - pivot;
|
|
shun-iwasawa |
6817df |
TPointD scaleFac((startVec.x == 0.0) ? 1.0 : endVec.x / startVec.x,
|
|
shun-iwasawa |
6817df |
(startVec.y == 0.0) ? 1.0 : endVec.y / startVec.y);
|
|
shun-iwasawa |
6817df |
if (e.isShiftPressed()) {
|
|
shun-iwasawa |
6817df |
if (std::abs(scaleFac.x) > std::abs(scaleFac.y))
|
|
shun-iwasawa |
6817df |
scaleFac.y = scaleFac.x;
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
scaleFac.x = scaleFac.y;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
if (m_startTL != pivot)
|
|
shun-iwasawa |
6817df |
setValue(m_TL, pivot + hadamard((m_startTL - pivot), scaleFac));
|
|
shun-iwasawa |
6817df |
if (m_startTR != pivot)
|
|
shun-iwasawa |
6817df |
setValue(m_TR, pivot + hadamard((m_startTR - pivot), scaleFac));
|
|
shun-iwasawa |
6817df |
if (m_startBR != pivot)
|
|
shun-iwasawa |
6817df |
setValue(m_BR, pivot + hadamard((m_startBR - pivot), scaleFac));
|
|
shun-iwasawa |
6817df |
if (m_startBL != pivot)
|
|
shun-iwasawa |
6817df |
setValue(m_BL, pivot + hadamard((m_startBL - pivot), scaleFac));
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto doCorner = [&](const TPointParamP point, const TPointD &start,
|
|
shun-iwasawa |
6817df |
const TPointD &opposite) {
|
|
shun-iwasawa |
6817df |
if (e.isCtrlPressed())
|
|
shun-iwasawa |
6817df |
setValue(point, start + offset);
|
|
shun-iwasawa |
6817df |
else if (e.isAltPressed())
|
|
shun-iwasawa |
6817df |
scaleShape(start, m_pivot);
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
scaleShape(start, opposite);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto doEdge = [&](const TPointParamP p1, const TPointParamP p2) {
|
|
shun-iwasawa |
6817df |
if (e.isShiftPressed()) {
|
|
shun-iwasawa |
6817df |
if (std::abs(offset.x) > std::abs(offset.y))
|
|
shun-iwasawa |
6817df |
offset.y = 0;
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
offset.x = 0;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
if (m_TL == p1 || m_TL == p2)
|
|
shun-iwasawa |
6817df |
setValue(m_TL, m_startTL + offset);
|
|
shun-iwasawa |
6817df |
else if (e.isAltPressed())
|
|
shun-iwasawa |
6817df |
setValue(m_TL, m_startTL - offset);
|
|
shun-iwasawa |
6817df |
if (m_TR == p1 || m_TR == p2)
|
|
shun-iwasawa |
6817df |
setValue(m_TR, m_startTR + offset);
|
|
shun-iwasawa |
6817df |
else if (e.isAltPressed())
|
|
shun-iwasawa |
6817df |
setValue(m_TR, m_startTR - offset);
|
|
shun-iwasawa |
6817df |
if (m_BR == p1 || m_BR == p2)
|
|
shun-iwasawa |
6817df |
setValue(m_BR, m_startBR + offset);
|
|
shun-iwasawa |
6817df |
else if (e.isAltPressed())
|
|
shun-iwasawa |
6817df |
setValue(m_BR, m_startBR - offset);
|
|
shun-iwasawa |
6817df |
if (m_BL == p1 || m_BL == p2)
|
|
shun-iwasawa |
6817df |
setValue(m_BL, m_startBL + offset);
|
|
shun-iwasawa |
6817df |
else if (e.isAltPressed())
|
|
shun-iwasawa |
6817df |
setValue(m_BL, m_startBL - offset);
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
auto pointRotate = [&](const TPointD pos, const double angle) {
|
|
shun-iwasawa |
6817df |
TPointD p = pos - m_pivot;
|
|
shun-iwasawa |
6817df |
return m_pivot + TPointD(p.x * std::cos(angle) - p.y * std::sin(angle),
|
|
shun-iwasawa |
6817df |
p.x * std::sin(angle) + p.y * std::cos(angle));
|
|
shun-iwasawa |
6817df |
};
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
switch (m_handle) {
|
|
shun-iwasawa |
6817df |
case Body:
|
|
shun-iwasawa |
6817df |
if (e.isCtrlPressed()) { // rotate
|
|
shun-iwasawa |
6817df |
TPointD startVec = m_dragStartPos - m_pivot;
|
|
shun-iwasawa |
6817df |
TPointD currentVec = pos - m_pivot;
|
|
shun-iwasawa |
6817df |
if (currentVec == TPointD()) return;
|
|
shun-iwasawa |
6817df |
double angle = std::atan2(currentVec.y, currentVec.x) -
|
|
shun-iwasawa |
6817df |
std::atan2(startVec.y, startVec.x);
|
|
shun-iwasawa |
6817df |
if (e.isShiftPressed()) {
|
|
shun-iwasawa |
6817df |
angle = std::round(angle / (M_PI / 2.0)) * (M_PI / 2.0);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
setValue(m_TL, pointRotate(m_startTL, angle));
|
|
shun-iwasawa |
6817df |
setValue(m_TR, pointRotate(m_startTR, angle));
|
|
shun-iwasawa |
6817df |
setValue(m_BR, pointRotate(m_startBR, angle));
|
|
shun-iwasawa |
6817df |
setValue(m_BL, pointRotate(m_startBL, angle));
|
|
shun-iwasawa |
6817df |
} else { // translate
|
|
shun-iwasawa |
6817df |
// move all shapes
|
|
shun-iwasawa |
6817df |
if (e.isShiftPressed()) {
|
|
shun-iwasawa |
6817df |
if (std::abs(offset.x) > std::abs(offset.y))
|
|
shun-iwasawa |
6817df |
offset.y = 0;
|
|
shun-iwasawa |
6817df |
else
|
|
shun-iwasawa |
6817df |
offset.x = 0;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
setValue(m_TL, m_startTL + offset);
|
|
shun-iwasawa |
6817df |
setValue(m_TR, m_startTR + offset);
|
|
shun-iwasawa |
6817df |
setValue(m_BR, m_startBR + offset);
|
|
shun-iwasawa |
6817df |
setValue(m_BL, m_startBL + offset);
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case TopLeft:
|
|
shun-iwasawa |
6817df |
doCorner(m_TL, m_startTL, m_startBR);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case TopRight:
|
|
shun-iwasawa |
6817df |
doCorner(m_TR, m_startTR, m_startBL);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case BottomRight:
|
|
shun-iwasawa |
6817df |
doCorner(m_BR, m_startBR, m_startTL);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case BottomLeft:
|
|
shun-iwasawa |
6817df |
doCorner(m_BL, m_startBL, m_startTR);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case TopEdge:
|
|
shun-iwasawa |
6817df |
doEdge(m_TL, m_TR);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case RightEdge:
|
|
shun-iwasawa |
6817df |
doEdge(m_TR, m_BR);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case BottomEdge:
|
|
shun-iwasawa |
6817df |
doEdge(m_BR, m_BL);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
case LeftEdge:
|
|
shun-iwasawa |
6817df |
doEdge(m_BL, m_TL);
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
default:
|
|
shun-iwasawa |
6817df |
break;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
//---------------------------------------------------------------------------
|
|
shun-iwasawa |
6817df |
|
|
shun-iwasawa |
6817df |
void QuadFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &) {
|
|
shun-iwasawa |
6817df |
m_handle = None;
|
|
shun-iwasawa |
6817df |
}
|
|
shun-iwasawa |
6817df |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadgetController implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController::FxGadgetController(TTool *tool)
|
|
Shinya Kitaoka |
120a6e |
: m_tool(tool)
|
|
Shinya Kitaoka |
120a6e |
, m_fxHandle(tool->getApplication()->getCurrentFx())
|
|
Shinya Kitaoka |
120a6e |
, m_idBase(0)
|
|
Shinya Kitaoka |
120a6e |
, m_nextId(0)
|
|
Shinya Kitaoka |
120a6e |
, m_selectedGadget(0)
|
|
Shinya Kitaoka |
120a6e |
, m_editingNonZeraryFx(false) {
|
|
Shinya Kitaoka |
120a6e |
m_idBase = m_nextId = 5000;
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched()));
|
|
Shinya Kitaoka |
120a6e |
connect(tool->getApplication()->getCurrentXsheet(), SIGNAL(xsheetChanged()),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(onFxSwitched()));
|
|
Shinya Kitaoka |
120a6e |
onFxSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxGadgetController::~FxGadgetController() { clearGadgets(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::clearGadgets() {
|
|
Shinya Kitaoka |
120a6e |
std::vector<fxgadget *="">::iterator it;</fxgadget>
|
|
Shinya Kitaoka |
120a6e |
for (it = m_gadgets.begin(); it != m_gadgets.end(); ++it) delete (*it);
|
|
Shinya Kitaoka |
120a6e |
m_gadgets.clear();
|
|
Shinya Kitaoka |
120a6e |
m_idTable.clear();
|
|
Shinya Kitaoka |
120a6e |
m_selectedGadget = 0;
|
|
Shinya Kitaoka |
120a6e |
m_nextId = m_idBase;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::assignId(FxGadget *gadget) {
|
|
Shinya Kitaoka |
120a6e |
gadget->setId(m_nextId);
|
|
shun-iwasawa |
6817df |
for (int g = 0; g < gadget->getHandleCount(); g++) {
|
|
shun-iwasawa |
6817df |
m_idTable[m_nextId] = gadget;
|
|
shun-iwasawa |
6817df |
++m_nextId;
|
|
shun-iwasawa |
6817df |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::addGadget(FxGadget *gadget) {
|
|
Shinya Kitaoka |
120a6e |
m_gadgets.push_back(gadget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::draw(bool picking) {
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
tglMultMatrix(getMatrix());
|
|
Shinya Kitaoka |
120a6e |
std::vector<fxgadget *="">::iterator it;</fxgadget>
|
|
Shinya Kitaoka |
120a6e |
for (it = m_gadgets.begin(); it != m_gadgets.end(); ++it)
|
|
Shinya Kitaoka |
120a6e |
(*it)->draw(picking);
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::selectById(unsigned int id) {
|
|
Shinya Kitaoka |
120a6e |
std::map<gluint, *="" fxgadget="">::iterator it;</gluint,>
|
|
Shinya Kitaoka |
120a6e |
it = m_idTable.find(id);
|
|
Shinya Kitaoka |
120a6e |
FxGadget *selectedGadget = it != m_idTable.end() ? it->second : 0;
|
|
Shinya Kitaoka |
120a6e |
if (selectedGadget != m_selectedGadget) {
|
|
shun-iwasawa |
6817df |
if (m_selectedGadget) m_selectedGadget->select(-1);
|
|
Shinya Kitaoka |
120a6e |
m_selectedGadget = selectedGadget;
|
|
shun-iwasawa |
6817df |
if (m_selectedGadget)
|
|
shun-iwasawa |
6817df |
m_selectedGadget->select(id - m_selectedGadget->getId());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxGadget *FxGadgetController::allocateGadget(const TParamUIConcept &uiConcept) {
|
|
Shinya Kitaoka |
120a6e |
FxGadget *gadget = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
switch (uiConcept.m_type) {
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::RADIUS: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointParamP center((uiConcept.m_params.size() >= 2)
|
|
Shinya Kitaoka |
120a6e |
? (TPointParamP)uiConcept.m_params[1]
|
|
Shinya Kitaoka |
120a6e |
: TPointParamP());
|
|
Shinya Kitaoka |
120a6e |
gadget = new RadiusFxGadget(this, uiConcept.m_params[0], center);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::WIDTH: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP angle((uiConcept.m_params.size() >= 2)
|
|
Shinya Kitaoka |
120a6e |
? (TDoubleParamP)uiConcept.m_params[1]
|
|
Shinya Kitaoka |
120a6e |
: TDoubleParamP());
|
|
Shinya Kitaoka |
120a6e |
gadget = new DistanceFxGadget(this, uiConcept.m_params[0], angle);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::ANGLE: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 1);
|
|
Shinya Kitaoka |
120a6e |
gadget = new AngleFxGadget(this, uiConcept.m_params[0], TPointD());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::POINT: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 1);
|
|
Shinya Kitaoka |
120a6e |
gadget = new PointFxGadget(this, uiConcept.m_params[0]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::POINT_2: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 2);
|
|
Shinya Kitaoka |
120a6e |
gadget =
|
|
Shinya Kitaoka |
120a6e |
new PointFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::VECTOR: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 2);
|
|
Shinya Kitaoka |
120a6e |
gadget =
|
|
Shinya Kitaoka |
120a6e |
new VectorFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::POLAR: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 2);
|
|
Shinya Kitaoka |
120a6e |
gadget = new PolarFxGadget(this, TPointD(), uiConcept.m_params[0],
|
|
Shinya Kitaoka |
120a6e |
uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::SIZE: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP y((uiConcept.m_params.size() >= 2)
|
|
Shinya Kitaoka |
120a6e |
? (TDoubleParamP)uiConcept.m_params[1]
|
|
Shinya Kitaoka |
120a6e |
: TDoubleParamP());
|
|
Shinya Kitaoka |
120a6e |
gadget = new SizeFxGadget(this, uiConcept.m_params[0], y);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::QUAD: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 4);
|
|
Shinya Kitaoka |
120a6e |
gadget =
|
|
Shinya Kitaoka |
120a6e |
new QuadFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1],
|
|
Shinya Kitaoka |
120a6e |
uiConcept.m_params[2], uiConcept.m_params[3]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::RECT: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() >= 2 && uiConcept.m_params.size() <= 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointParamP center((uiConcept.m_params.size() >= 3)
|
|
Shinya Kitaoka |
120a6e |
? (TPointParamP)uiConcept.m_params[2]
|
|
Shinya Kitaoka |
120a6e |
: TPointParamP());
|
|
Shinya Kitaoka |
120a6e |
gadget = new RectFxGadget(this, uiConcept.m_params[0],
|
|
Shinya Kitaoka |
120a6e |
uiConcept.m_params[1], center);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
case TParamUIConcept::DIAMOND: {
|
|
Shinya Kitaoka |
120a6e |
assert(uiConcept.m_params.size() == 1);
|
|
Shinya Kitaoka |
120a6e |
gadget = new DiamondFxGadget(this, uiConcept.m_params[0]);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (gadget) gadget->setLabel(uiConcept.m_label);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return gadget;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::onFxSwitched() {
|
|
Shinya Kitaoka |
120a6e |
clearGadgets();
|
|
Shinya Kitaoka |
120a6e |
bool enabled = false;
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = m_fxHandle ? m_fxHandle->getFx() : 0;
|
|
Shinya Kitaoka |
120a6e |
if (fx) {
|
|
Shinya Kitaoka |
120a6e |
int referenceColumnIndex = fx->getReferenceColumnIndex();
|
|
Shinya Kitaoka |
120a6e |
if (referenceColumnIndex == -1) {
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *oh = m_tool->getApplication()->getCurrentObject();
|
|
Shinya Kitaoka |
120a6e |
if (!oh->getObjectId().isCamera()) {
|
|
John Dancel |
c323ac |
TXsheet *xsh = m_tool->getXsheet();
|
|
John Dancel |
c323ac |
oh->setObjectId(TStageObjectId::CameraId(xsh->getCameraColumnIndex()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
enabled = true;
|
|
Shinya Kitaoka |
120a6e |
} else if (referenceColumnIndex == m_tool->getColumnIndex())
|
|
Shinya Kitaoka |
120a6e |
enabled = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (fx && enabled) {
|
|
Shinya Kitaoka |
120a6e |
m_editingNonZeraryFx = true;
|
|
Shinya Kitaoka |
120a6e |
TZeraryColumnFx *zfx = 0;
|
|
Shinya Kitaoka |
120a6e |
if ((zfx = dynamic_cast<tzerarycolumnfx *="">(fx)) ||</tzerarycolumnfx>
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tlevelcolumnfx *="">(fx))</tlevelcolumnfx>
|
|
Shinya Kitaoka |
120a6e |
// WARNING! quick patch for huge bug: I added the || with TLevelColumnFx;
|
|
Shinya Kitaoka |
120a6e |
// before, the levels were considered as nonZeraryFx and the edit tool
|
|
Shinya Kitaoka |
120a6e |
// gadget was not displayed! Vinz
|
|
Shinya Kitaoka |
120a6e |
{
|
|
shun-iwasawa |
6817df |
if (zfx) fx = zfx->getZeraryFx();
|
|
Shinya Kitaoka |
120a6e |
m_editingNonZeraryFx = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Parse the UI Concepts returned by the fx
|
|
Shinya Kitaoka |
120a6e |
TParamUIConcept *uiConcepts = 0;
|
|
Shinya Kitaoka |
120a6e |
int i, count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fx->getParamUIs(uiConcepts, count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < count; ++i) {
|
|
Shinya Kitaoka |
120a6e |
FxGadget *gadget = allocateGadget(uiConcepts[i]);
|
|
Shinya Kitaoka |
120a6e |
if (gadget) addGadget(gadget);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
delete[] uiConcepts;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
m_editingNonZeraryFx = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_tool->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
EditToolGadgets::DragTool *FxGadgetController::createDragTool(int gadgetId) {
|
|
Shinya Kitaoka |
120a6e |
selectById(gadgetId);
|
|
Shinya Kitaoka |
120a6e |
if (m_selectedGadget)
|
|
Shinya Kitaoka |
120a6e |
return new GadgetDragTool(this, m_selectedGadget);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine FxGadgetController::getMatrix() {
|
|
Shinya Kitaoka |
120a6e |
return m_tool->getMatrix().inv() * m_tool->getCurrentColumnMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int FxGadgetController::getCurrentFrame() const { return m_tool->getFrame(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FxGadgetController::invalidateViewer() { m_tool->invalidate(); }
|