|
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 "toonz/stage.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 |
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadgetUndo definition
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class FxGadgetUndo : public TUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
struct ParamData {
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_param;
|
|
Toshihiro Shimizu |
890ddd |
double m_oldValue, m_newValue;
|
|
Toshihiro Shimizu |
890ddd |
bool m_wasKeyframe;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
std::vector<paramdata> m_params;</paramdata>
|
|
Toshihiro Shimizu |
890ddd |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetUndo(const std::vector<tdoubleparamp> ¶ms, int frame)</tdoubleparamp>
|
|
Toshihiro Shimizu |
890ddd |
: m_frame(frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_params.resize(params.size());
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)params.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_param = params[i];
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_oldValue = params[i]->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_newValue = m_params[i].m_oldValue;
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_wasKeyframe = m_params[i].m_param->isKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onAdd()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_newValue = m_params[i].m_param->getValue(m_frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void undo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_params[i].m_wasKeyframe)
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_param->deleteKeyframe(m_frame);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_param->setValue(m_frame, m_params[i].m_oldValue);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_params[i].m_param->setValue(m_frame, m_params[i].m_newValue);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const { return sizeof(*this) + m_params.size() * sizeof(ParamData); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getHistoryString()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString str = QObject::tr("Modify Fx Gadget ");
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_params.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
str += QString::fromStdString(m_params[i].m_param->getName());
|
|
Toshihiro Shimizu |
890ddd |
if (i != (int)m_params.size() - 1)
|
|
Toshihiro Shimizu |
890ddd |
str += QString::fromStdString(", ");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
str += QString(" Frame : %1").arg(QString::number(m_frame + 1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return str;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::Fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GadgetDragTool definition
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class GadgetDragTool : public DragTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *m_controller;
|
|
Toshihiro Shimizu |
890ddd |
FxGadget *m_gadget;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
GadgetDragTool(FxGadgetController *controller, FxGadget *gadget)
|
|
Toshihiro Shimizu |
890ddd |
: m_controller(controller), m_gadget(gadget) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TAffine getMatrix() const { return m_controller->getMatrix().inv(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_gadget->createUndo();
|
|
Toshihiro Shimizu |
890ddd |
m_gadget->leftButtonDown(getMatrix() * pos, e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_gadget->leftButtonDrag(getMatrix() * pos, e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_gadget->leftButtonUp(getMatrix() * pos, e);
|
|
Toshihiro Shimizu |
890ddd |
m_gadget->commitUndo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadget implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadget::FxGadget(FxGadgetController *controller)
|
|
Toshihiro Shimizu |
890ddd |
: m_id(-1), m_selected(false), m_controller(controller), m_pixelSize(1), m_undo(0), m_scaleFactor(1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
controller->assignId(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadget::~FxGadget()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_params.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_params[i]->removeObserver(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::addParam(const TDoubleParamP ¶m)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_params.push_back(param);
|
|
Toshihiro Shimizu |
890ddd |
param->addObserver(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double FxGadget::getValue(const TDoubleParamP ¶m) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return param->getValue(m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::setValue(const TDoubleParamP ¶m, double value)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
param->setValue(m_controller->getCurrentFrame(), value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD FxGadget::getValue(const TPointParamP ¶m) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return param->getValue(m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::setValue(const TPointParamP ¶m, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
param->setValue(m_controller->getCurrentFrame(), pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::setPixelSize()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize(sqrt(tglGetPixelSize2()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::drawTooltip(const TPointD &tooltipPos, std::string tooltipPosText)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double unit = sqrt(tglGetPixelSize2());
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(tooltipPos.x, tooltipPos.y, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
double sc = unit * 1.6;
|
|
Toshihiro Shimizu |
890ddd |
glScaled(sc, sc, 1);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawText(TPointD(8, -3), tooltipPosText);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::drawDot(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double r = getPixelSize() * 3;
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::onChange(const TParamChange &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_controller->invalidateViewer();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::createUndo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_undo == 0);
|
|
Toshihiro Shimizu |
890ddd |
m_undo = new FxGadgetUndo(m_params, m_controller->getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadget::commitUndo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_undo);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(m_undo);
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
class PointFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_pos;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_xParam, m_yParam;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PointFxGadget(FxGadgetController *controller, const TPointParamP ¶m)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_xParam(param->getX()), m_yParam(param->getY())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_xParam);
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_yParam);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PointFxGadget(FxGadgetController *controller, const TDoubleParamP &xParam, const TDoubleParamP &yParam)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_xParam(xParam), m_yParam(yParam)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_xParam);
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_yParam);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD getPoint() const { return TPointD(getValue(m_xParam), getValue(m_yParam)); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PointFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos(getPoint());
|
|
Toshihiro Shimizu |
890ddd |
double unit = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(pos.x, pos.y, 0);
|
|
Toshihiro Shimizu |
890ddd |
double r = unit * 3;
|
|
Toshihiro Shimizu |
890ddd |
double d = unit * 6;
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-d, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-r, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(d, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, -d);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, -r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, d);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, r);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
tglDrawRect(-r, -r, r, r);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(pos + TPointD(7, 3) * unit, getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PointFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PointFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_xParam)
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_xParam, pos.x);
|
|
Toshihiro Shimizu |
890ddd |
if (m_yParam)
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_yParam, pos.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PointFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RadiusFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_radius;
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP m_center;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RadiusFxGadget(
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &radius,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP ¢er)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_radius(radius), m_center(center)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(radius);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD getCenter() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD RadiusFxGadget::getCenter() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_center ? getValue(m_center) : TPointD();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadiusFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_radius)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double radius = getValue(m_radius);
|
|
Toshihiro Shimizu |
890ddd |
TPointD center = getCenter();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xAAAA);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(center, radius);
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(center + TPointD(0.707, 0.707) * radius);
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(center + TPointD(0.707, 0.707) * radius, getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadiusFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadiusFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_radius, norm(pos - getCenter()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadiusFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DistanceFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_distance, m_angle;
|
|
Toshihiro Shimizu |
890ddd |
int m_grabPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
DistanceFxGadget(
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &distance,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &angle)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_distance(distance), m_angle(angle), m_grabPos(1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(distance);
|
|
Toshihiro Shimizu |
890ddd |
if (angle)
|
|
Toshihiro Shimizu |
890ddd |
addParam(angle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD getDirection() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_angle)
|
|
Toshihiro Shimizu |
890ddd |
return TPointD(1.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double angle = getValue(m_angle);
|
|
Toshihiro Shimizu |
890ddd |
return TPointD(cos(angle), sin(angle));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DistanceFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_distance)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
double d = getValue(m_distance) * getScaleFactor();
|
|
Toshihiro Shimizu |
890ddd |
TPointD dir(getDirection());
|
|
Toshihiro Shimizu |
890ddd |
TPointD u = rotate90(dir) * (getPixelSize() * 10);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(-u, u);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD b, c;
|
|
Toshihiro Shimizu |
890ddd |
b = dir * (d * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
c = b - dir * d;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(b - u, b + u);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(b, getPixelSize() * 5);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(c - u, c + u);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(c, getPixelSize() * 5);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xAAAA);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(b, c);
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(b + TPointD(5, 5) * getPixelSize(), getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DistanceFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_grabPos = (pos.x > 0.0) ? 1 : -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DistanceFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double v = (pos * getDirection()) / getScaleFactor();
|
|
Toshihiro Shimizu |
890ddd |
v = v * 2 * m_grabPos;
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_distance, v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DistanceFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class AngleFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_param;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
AngleFxGadget(FxGadgetController *controller, const TDoubleParamP ¶m, const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
AngleFxGadget::AngleFxGadget(FxGadgetController *controller, const TDoubleParamP ¶m, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_param(param), m_pos(pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(param);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AngleFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = sqrt(tglGetPixelSize2());
|
|
Toshihiro Shimizu |
890ddd |
double r = pixelSize * 40;
|
|
Toshihiro Shimizu |
890ddd |
double a = pixelSize * 10, b = pixelSize * 5;
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(m_pos, r);
|
|
Toshihiro Shimizu |
890ddd |
double phi = getValue(m_param);
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(m_pos.x, m_pos.y, 0);
|
|
Toshihiro Shimizu |
890ddd |
glRotated(phi, 0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r - a, b);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r - a, -b);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(m_pos + TPointD(0.707, 0.707) * r, getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AngleFxGadget::leftButtonDown(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AngleFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD d = pos - m_pos;
|
|
Toshihiro Shimizu |
890ddd |
double phi = atan2(d.y, d.x);
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_param, TConsts::invOf_pi_180 * phi);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AngleFxGadget::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DiamondFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_param;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
DiamondFxGadget(FxGadgetController *controller, const TDoubleParamP ¶m)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_param(param)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(param);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DiamondFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double size = getValue(m_param);
|
|
Toshihiro Shimizu |
890ddd |
double r = 3 * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xAAAA);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-size + r, r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-r, size - r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, size - r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(size - r, r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(size - r, -r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(r, -size + r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-r, -size + r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-size + r, -r);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(-size, 0);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(size, 0);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(0, -size);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(0, size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double d = getPixelSize() * 3;
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(TPointD(d, size - d), getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DiamondFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double sz = fabs(pos.x) + fabs(pos.y);
|
|
Toshihiro Shimizu |
890ddd |
if (sz < 0.1)
|
|
Toshihiro Shimizu |
890ddd |
sz = 0.1;
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_param, sz);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SizeFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_lx, m_ly;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SizeFxGadget(FxGadgetController *controller, const TDoubleParamP &lx, const TDoubleParamP &ly)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_lx(lx), m_ly(ly)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(lx);
|
|
Toshihiro Shimizu |
890ddd |
if (ly)
|
|
Toshihiro Shimizu |
890ddd |
addParam(ly);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SizeFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double lx = getValue(m_lx), ly = m_ly ? getValue(m_ly) : lx;
|
|
Toshihiro Shimizu |
890ddd |
double r = getPixelSize() * 3;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xCCCC);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(lx, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, ly);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(lx, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(lx, ly - r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, ly);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(lx - r, ly);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(lx, ly);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double d = getPixelSize() * 3;
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(TPointD(lx, ly), getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SizeFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_ly)
|
|
Shinya Kitaoka |
12c444 |
setValue(m_lx, std::max(pos.x, 0.1)), setValue(m_ly, std::max(pos.y, 0.1));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Shinya Kitaoka |
12c444 |
setValue(m_lx, std::max({pos.x, pos.y, 0.1}));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RectFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_width, m_height;
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP m_center;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_picked;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
enum { None,
|
|
Toshihiro Shimizu |
890ddd |
Corner,
|
|
Toshihiro Shimizu |
890ddd |
HorizontalSide,
|
|
Toshihiro Shimizu |
890ddd |
VerticalSide };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RectFxGadget(FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &width,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &height,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP ¢er)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_width(width), m_height(height), m_center(center), m_picked(None)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(width);
|
|
Toshihiro Shimizu |
890ddd |
addParam(height);
|
|
Toshihiro Shimizu |
890ddd |
if (center)
|
|
Toshihiro Shimizu |
890ddd |
addParam(center->getX()), addParam(center->getY());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD getCenter() const { return m_center ? getValue(m_center) : TPointD(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RectFxGadget::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
TPointD center = getCenter();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(center.x, center.y, 0);
|
|
Toshihiro Shimizu |
890ddd |
double w_2 = 0.5 * getValue(m_width);
|
|
Toshihiro Shimizu |
890ddd |
double h_2 = 0.5 * getValue(m_height);
|
|
Toshihiro Shimizu |
890ddd |
double r = getPixelSize() * 3;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xCCCC);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-w_2 + r, -h_2);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(w_2 - r, -h_2);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-w_2 + r, h_2);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(w_2 - r, h_2);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-w_2, -h_2 + r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(-w_2, h_2 - r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(w_2, -h_2 + r);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(w_2, h_2 - r);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(w_2, h_2);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(-w_2, h_2);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(w_2, -h_2);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(-w_2, -h_2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RectFxGadget::leftButtonDown(const TPointD &ppos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = ppos - getCenter();
|
|
Toshihiro Shimizu |
890ddd |
m_picked = None;
|
|
Toshihiro Shimizu |
890ddd |
double w_2 = 0.5 * getValue(m_width);
|
|
Toshihiro Shimizu |
890ddd |
double h_2 = 0.5 * getValue(m_height);
|
|
Toshihiro Shimizu |
890ddd |
double x = fabs(pos.x);
|
|
Toshihiro Shimizu |
890ddd |
double y = fabs(pos.y);
|
|
Toshihiro Shimizu |
890ddd |
double r = getPixelSize() * 15;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (fabs(w_2 - x) < r && fabs(y - h_2) < r)
|
|
Toshihiro Shimizu |
890ddd |
m_picked = Corner;
|
|
Toshihiro Shimizu |
890ddd |
else if (fabs(w_2 - x) < r && y < h_2)
|
|
Toshihiro Shimizu |
890ddd |
m_picked = VerticalSide;
|
|
Toshihiro Shimizu |
890ddd |
else if (fabs(h_2 - y) < r && x < w_2)
|
|
Toshihiro Shimizu |
890ddd |
m_picked = HorizontalSide;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RectFxGadget::leftButtonDrag(const TPointD &ppos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = ppos - getCenter();
|
|
Toshihiro Shimizu |
890ddd |
double w = fabs(pos.x), h = fabs(pos.y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_picked == Corner || m_picked == VerticalSide)
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_width, 2.0 * w);
|
|
Toshihiro Shimizu |
890ddd |
if (m_picked == Corner || m_picked == HorizontalSide)
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_height, 2.0 * h);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PolarFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_pos;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_phiParam, m_lengthParam;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PolarFxGadget(
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &pos,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &phiParam,
|
|
Toshihiro Shimizu |
890ddd |
const TDoubleParamP &lengthParam)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_pos(pos), m_phiParam(phiParam), m_lengthParam(lengthParam)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(phiParam);
|
|
Toshihiro Shimizu |
890ddd |
addParam(lengthParam);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
double r = getValue(m_lengthParam);
|
|
Toshihiro Shimizu |
890ddd |
double a = pixelSize * 10, b = pixelSize * 5, c = pixelSize * 4;
|
|
Toshihiro Shimizu |
890ddd |
// tglDrawCircle(m_pos, r);
|
|
Toshihiro Shimizu |
890ddd |
double phi = getValue(m_phiParam);
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(m_pos.x, m_pos.y, 0);
|
|
Toshihiro Shimizu |
890ddd |
glRotated(phi, 0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
double rr = r - c;
|
|
Toshihiro Shimizu |
890ddd |
if (rr > 0) {
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xAAAA);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(rr, 0);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINES);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(rr, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(rr - a, b);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(rr, 0);
|
|
Toshihiro Shimizu |
890ddd |
glVertex2d(rr - a, -b);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(r, 0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glRotated(-phi, 0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected()) {
|
|
Toshihiro Shimizu |
890ddd |
double phiRad = TConsts::pi_180 * phi;
|
|
Toshihiro Shimizu |
890ddd |
TPointD toolTipPos = m_pos + r * TPointD(cos(phiRad), sin(phiRad));
|
|
Toshihiro Shimizu |
890ddd |
drawTooltip(toolTipPos, getLabel());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD d = pos - m_pos;
|
|
Toshihiro Shimizu |
890ddd |
double phi = atan2(d.y, d.x);
|
|
Toshihiro Shimizu |
890ddd |
double length = norm(d);
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_phiParam, TConsts::invOf_pi_180 * phi);
|
|
Toshihiro Shimizu |
890ddd |
setValue(m_lengthParam, length);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class VectorFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP m_pa, m_pb;
|
|
Toshihiro Shimizu |
890ddd |
int m_selected;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
VectorFxGadget(
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pa,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pb)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_pa(pa), m_pb(pb), m_selected(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(pa->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pa->getY());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pb->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pb->getY());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
TPointD pa = getValue(m_pa);
|
|
Toshihiro Shimizu |
890ddd |
TPointD pb = getValue(m_pb);
|
|
Toshihiro Shimizu |
890ddd |
TPointD dab = pb - pa;
|
|
Toshihiro Shimizu |
890ddd |
double ab2 = norm2(dab);
|
|
Toshihiro Shimizu |
890ddd |
if (ab2 > 0.0001) {
|
|
Toshihiro Shimizu |
890ddd |
double ab = sqrt(ab2);
|
|
Toshihiro Shimizu |
890ddd |
TPointD u = dab * (1.0 / ab);
|
|
Toshihiro Shimizu |
890ddd |
TPointD v = rotate90(u);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double a = pixelSize * 10, b = pixelSize * 5;
|
|
Toshihiro Shimizu |
890ddd |
double c = pixelSize * 4;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD pbb = pb - u * c;
|
|
Toshihiro Shimizu |
890ddd |
if (ab - c > 0) {
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xAAAA);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(pa, pbb);
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(pbb, pbb - u * a + v * b);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(pbb, pbb - u * a - v * b);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(pa);
|
|
Toshihiro Shimizu |
890ddd |
drawDot(pb);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
drawDot(pa);
|
|
Toshihiro Shimizu |
890ddd |
glPopName();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class QuadFxGadget : public FxGadget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP m_pa, m_pb, m_pc, m_pd;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
QuadFxGadget(
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController *controller,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pa,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pb,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pc,
|
|
Toshihiro Shimizu |
890ddd |
const TPointParamP &pd)
|
|
Toshihiro Shimizu |
890ddd |
: FxGadget(controller), m_pa(pa), m_pb(pb), m_pc(pc), m_pd(pd)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(pa->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pa->getY());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pb->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pb->getY());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pc->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pc->getY());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pd->getX());
|
|
Toshihiro Shimizu |
890ddd |
addParam(pd->getY());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected())
|
|
Toshihiro Shimizu |
890ddd |
glColor3dv(m_selectedColor);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0, 0, 1);
|
|
Toshihiro Shimizu |
890ddd |
//glPushName(getId());
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
TPointD pa = getValue(m_pa);
|
|
Toshihiro Shimizu |
890ddd |
TPointD pb = getValue(m_pb);
|
|
Toshihiro Shimizu |
890ddd |
TPointD pc = getValue(m_pc);
|
|
Toshihiro Shimizu |
890ddd |
TPointD pd = getValue(m_pd);
|
|
Toshihiro Shimizu |
890ddd |
glLineStipple(1, 0xCCCC);
|
|
Toshihiro Shimizu |
890ddd |
glEnable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(pa);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(pb);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(pc);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(pd);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(pa);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
glDisable(GL_LINE_STIPPLE);
|
|
Toshihiro Shimizu |
890ddd |
//glPopName();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// FxGadgetController implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController::FxGadgetController(TTool *tool)
|
|
Toshihiro Shimizu |
890ddd |
: m_tool(tool), m_fxHandle(tool->getApplication()->getCurrentFx()), m_idBase(0), m_nextId(0), m_selectedGadget(0), m_editingNonZeraryFx(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_idBase = m_nextId = 5000;
|
|
Toshihiro Shimizu |
890ddd |
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(onFxSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
connect(
|
|
Toshihiro Shimizu |
890ddd |
tool->getApplication()->getCurrentXsheet(), SIGNAL(xsheetChanged()),
|
|
Toshihiro Shimizu |
890ddd |
this, SLOT(onFxSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
onFxSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadgetController::~FxGadgetController()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clearGadgets();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::clearGadgets()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<fxgadget *="">::iterator it;</fxgadget>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_gadgets.begin(); it != m_gadgets.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
delete (*it);
|
|
Toshihiro Shimizu |
890ddd |
m_gadgets.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_idTable.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_selectedGadget = 0;
|
|
Toshihiro Shimizu |
890ddd |
m_nextId = m_idBase;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::assignId(FxGadget *gadget)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
gadget->setId(m_nextId);
|
|
Toshihiro Shimizu |
890ddd |
m_idTable[m_nextId] = gadget;
|
|
Toshihiro Shimizu |
890ddd |
++m_nextId;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::addGadget(FxGadget *gadget)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_gadgets.push_back(gadget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::draw(bool picking)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
tglMultMatrix(getMatrix());
|
|
Toshihiro Shimizu |
890ddd |
std::vector<fxgadget *="">::iterator it;</fxgadget>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_gadgets.begin(); it != m_gadgets.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->draw(picking);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::selectById(unsigned int id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::map<gluint, *="" fxgadget="">::iterator it;</gluint,>
|
|
Toshihiro Shimizu |
890ddd |
it = m_idTable.find(id);
|
|
Toshihiro Shimizu |
890ddd |
FxGadget *selectedGadget = it != m_idTable.end() ? it->second : 0;
|
|
Toshihiro Shimizu |
890ddd |
if (selectedGadget != m_selectedGadget) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectedGadget)
|
|
Toshihiro Shimizu |
890ddd |
m_selectedGadget->select(false);
|
|
Toshihiro Shimizu |
890ddd |
m_selectedGadget = selectedGadget;
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectedGadget)
|
|
Toshihiro Shimizu |
890ddd |
m_selectedGadget->select(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FxGadget *FxGadgetController::allocateGadget(const TParamUIConcept &uiConcept)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FxGadget *gadget = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
switch (uiConcept.m_type) {
|
|
Toshihiro Shimizu |
890ddd |
case TParamUIConcept::RADIUS: {
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP center((uiConcept.m_params.size() >= 2) ? (TPointParamP)uiConcept.m_params[1] : TPointParamP());
|
|
Toshihiro Shimizu |
890ddd |
gadget = new RadiusFxGadget(this, uiConcept.m_params[0], center);
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::WIDTH:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP angle((uiConcept.m_params.size() >= 2) ? (TDoubleParamP)uiConcept.m_params[1] : TDoubleParamP());
|
|
Toshihiro Shimizu |
890ddd |
gadget = new DistanceFxGadget(this, uiConcept.m_params[0], angle);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::ANGLE:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 1);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new AngleFxGadget(this, uiConcept.m_params[0], TPointD());
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::POINT:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 1);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new PointFxGadget(this, uiConcept.m_params[0]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::POINT_2:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 2);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new PointFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::VECTOR:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 2);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new VectorFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::POLAR:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 2);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new PolarFxGadget(this, TPointD(), uiConcept.m_params[0], uiConcept.m_params[1]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::SIZE:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP y((uiConcept.m_params.size() >= 2) ? (TDoubleParamP)uiConcept.m_params[1] : TDoubleParamP());
|
|
Toshihiro Shimizu |
890ddd |
gadget = new SizeFxGadget(this, uiConcept.m_params[0], y);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::QUAD:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 4);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new QuadFxGadget(this,
|
|
Toshihiro Shimizu |
890ddd |
uiConcept.m_params[0], uiConcept.m_params[1], uiConcept.m_params[2], uiConcept.m_params[3]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::RECT:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() >= 2 && uiConcept.m_params.size() <= 3);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointParamP center((uiConcept.m_params.size() >= 3) ? (TPointParamP)uiConcept.m_params[2] : TPointParamP());
|
|
Toshihiro Shimizu |
890ddd |
gadget = new RectFxGadget(this, uiConcept.m_params[0], uiConcept.m_params[1], center);
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
case TParamUIConcept::DIAMOND:
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(uiConcept.m_params.size() == 1);
|
|
Toshihiro Shimizu |
890ddd |
gadget = new DiamondFxGadget(this, uiConcept.m_params[0]);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
d4642c |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (gadget)
|
|
Toshihiro Shimizu |
890ddd |
gadget->setLabel(uiConcept.m_label);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return gadget;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::onFxSwitched()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clearGadgets();
|
|
Toshihiro Shimizu |
890ddd |
bool enabled = false;
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = m_fxHandle ? m_fxHandle->getFx() : 0;
|
|
Toshihiro Shimizu |
890ddd |
if (fx) {
|
|
Toshihiro Shimizu |
890ddd |
int referenceColumnIndex = fx->getReferenceColumnIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (referenceColumnIndex == -1) {
|
|
Toshihiro Shimizu |
890ddd |
TObjectHandle *oh = m_tool->getApplication()->getCurrentObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!oh->getObjectId().isCamera()) {
|
|
Toshihiro Shimizu |
890ddd |
oh->setObjectId(TStageObjectId::CameraId(0));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
enabled = true;
|
|
Toshihiro Shimizu |
890ddd |
} else if (referenceColumnIndex == m_tool->getColumnIndex())
|
|
Toshihiro Shimizu |
890ddd |
enabled = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (fx && enabled) {
|
|
Toshihiro Shimizu |
890ddd |
m_editingNonZeraryFx = true;
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zfx = 0;
|
|
Toshihiro Shimizu |
890ddd |
if ((zfx = dynamic_cast<tzerarycolumnfx *="">(fx)) || dynamic_cast<tlevelcolumnfx *="">(fx))</tlevelcolumnfx></tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
//WARNING! quick patch for huge bug: I added the || with TLevelColumnFx; before, the levels were considered as nonZeraryFx and the edit tool gadget was not displayed! Vinz
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (zfx)
|
|
Toshihiro Shimizu |
890ddd |
fx = zfx->getZeraryFx();
|
|
Toshihiro Shimizu |
890ddd |
m_editingNonZeraryFx = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Parse the UI Concepts returned by the fx
|
|
Toshihiro Shimizu |
890ddd |
TParamUIConcept *uiConcepts = 0;
|
|
Toshihiro Shimizu |
890ddd |
int i, count;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fx->getParamUIs(uiConcepts, count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < count; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
FxGadget *gadget = allocateGadget(uiConcepts[i]);
|
|
Toshihiro Shimizu |
890ddd |
if (gadget)
|
|
Toshihiro Shimizu |
890ddd |
addGadget(gadget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
delete[] uiConcepts;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
m_editingNonZeraryFx = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_tool->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
EditToolGadgets::DragTool *FxGadgetController::createDragTool(int gadgetId)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
selectById(gadgetId);
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectedGadget)
|
|
Toshihiro Shimizu |
890ddd |
return new GadgetDragTool(this, m_selectedGadget);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TAffine FxGadgetController::getMatrix()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_tool->getMatrix().inv() * m_tool->getCurrentColumnMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int FxGadgetController::getCurrentFrame() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_tool->getFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxGadgetController::invalidateViewer()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_tool->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|