|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/selectioncommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/selection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/hook.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjecttree.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/keycodes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qmessagebox></qmessagebox>
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h></math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// For Qt translation support
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace ToolUtils;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TrackerTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TrackerRegionSelection
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
// Ancora da definire.
|
|
Toshihiro Shimizu |
890ddd |
// under construction
|
|
Toshihiro Shimizu |
890ddd |
class TrackerRegionSelection : public TSelection
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
std::set<std::pair<int, int="">> m_objtp; // objtp: 1=ObjectId 2=Tracker Region Index</std::pair<int,>
|
|
Toshihiro Shimizu |
890ddd |
TrackerTool *m_tool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TrackerRegionSelection() : m_tool(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setTool(TrackerTool *tool) { m_tool = tool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TSelection *clone() const { return new TrackerRegionSelection(*this); }
|
|
Toshihiro Shimizu |
890ddd |
void setLevel(const TXshLevelP &level) { m_level = level; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void select(int objectId, int trackerRegionIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_objtp.insert(std::make_pair(objectId, trackerRegionIndex));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void deselect(int objectId, int trackerRegionIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_objtp.erase(std::make_pair(objectId, trackerRegionIndex));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isSelected(int objectId, int trackerRegionIndex) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_objtp.count(std::make_pair(objectId, trackerRegionIndex)) > 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void invertSelection(int objectId, int trackerRegionIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected(objectId, trackerRegionIndex))
|
|
Toshihiro Shimizu |
890ddd |
deselect(objectId, trackerRegionIndex);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
select(objectId, trackerRegionIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isEmpty() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_objtp.empty();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void selectNone() { m_objtp.clear(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
HookSet *getHookSet() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
//TXshLevel *xl = m_level.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
return xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDataP getData() { return TDataP(); }
|
|
Toshihiro Shimizu |
890ddd |
TDataP cutData() { return TDataP(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDataP clearData()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
//HookData *data = new HookData();
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = TTool::getApplication()->getCurrentFrame()->getFid();
|
|
Toshihiro Shimizu |
890ddd |
if(!hookSet) return TDataP();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for(int i=0;i<hookset->getHookCount();i++)</hookset->
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(i);
|
|
Toshihiro Shimizu |
890ddd |
if(!hook || hook->isEmpty()) continue;
|
|
Toshihiro Shimizu |
890ddd |
if(isSelected(i,1) && isSelected(i,2))
|
|
Toshihiro Shimizu |
890ddd |
hookSet->clearHook(hook);
|
|
Toshihiro Shimizu |
890ddd |
else if(isSelected(i,2))
|
|
Toshihiro Shimizu |
890ddd |
hook->setBPos(fid, hook->getAPos(fid));
|
|
Toshihiro Shimizu |
890ddd |
else if(isSelected(i,1))
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, hook->getBPos(fid));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
return TDataP(); */
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDataP pasteData(const TDataP &data) { return TDataP(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void resetData(const TDataP &data, bool insert) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool select(const TSelection *s)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (const TrackerRegionSelection *hs = dynamic_cast<const *="" trackerregionselection="">(s)) {</const>
|
|
Toshihiro Shimizu |
890ddd |
m_level = hs->m_level;
|
|
Toshihiro Shimizu |
890ddd |
m_objtp = hs->m_objtp;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void enableCommands();
|
|
Toshihiro Shimizu |
890ddd |
void convertToRegion();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TrackerTool class declaration
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TrackerTool : public TTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_DECLARE_TR_FUNCTIONS(TrackerTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TrackerRegionSelection m_selection;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_firstPos, m_lastPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_hookSelectedIndex;
|
|
Toshihiro Shimizu |
890ddd |
int m_lastHookSelectedIndex;
|
|
Toshihiro Shimizu |
890ddd |
bool m_deselectArmed;
|
|
Toshihiro Shimizu |
890ddd |
bool m_newObjectAdded; // serve al buttonUp per sapere se l'ultima tracker region
|
|
Toshihiro Shimizu |
890ddd |
// aggiunta รจ un oggetto nuovo oppure no
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup m_prop;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_toolSizeWidth;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_toolSizeHeight;
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_toolPosX;
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_toolPosY;
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_shapeBBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_buttonDown;
|
|
Toshihiro Shimizu |
890ddd |
bool m_dragged;
|
|
Toshihiro Shimizu |
890ddd |
bool m_picked;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_pos; // posizione del mouse
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_oldPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_what;
|
|
Toshihiro Shimizu |
890ddd |
enum { Outside,
|
|
Toshihiro Shimizu |
890ddd |
Inside,
|
|
Toshihiro Shimizu |
890ddd |
P00,
|
|
Toshihiro Shimizu |
890ddd |
P01,
|
|
Toshihiro Shimizu |
890ddd |
P10,
|
|
Toshihiro Shimizu |
890ddd |
P11,
|
|
Toshihiro Shimizu |
890ddd |
P1M,
|
|
Toshihiro Shimizu |
890ddd |
PM1,
|
|
Toshihiro Shimizu |
890ddd |
P0M,
|
|
Toshihiro Shimizu |
890ddd |
PM0,
|
|
Toshihiro Shimizu |
890ddd |
ADD_OBJECT,
|
|
Toshihiro Shimizu |
890ddd |
NormalHook };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TrackerTool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolType getToolType() const { return TTool::LevelReadTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateTranslation();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *getTrackerObjectsSet() const;
|
|
Toshihiro Shimizu |
890ddd |
HookSet *getHookSet() const;
|
|
Toshihiro Shimizu |
890ddd |
void draw();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void deleteSelectedTrackerRegion();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &);
|
|
Toshihiro Shimizu |
890ddd |
void mouseMove(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool keyDown(int key, TUINT32 flags, const TPoint &pos);
|
|
Toshihiro Shimizu |
890ddd |
// bool moveCursor(const TPointD &pos){}
|
|
Toshihiro Shimizu |
890ddd |
void onEnter();
|
|
Toshihiro Shimizu |
890ddd |
void onLeave();
|
|
Toshihiro Shimizu |
890ddd |
void onActivate();
|
|
Toshihiro Shimizu |
890ddd |
void onDeactivate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onImageChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void reset();
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties(int targetType) { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onSelectionChanged() { invalidate(); }
|
|
Shinya Kitaoka |
3bfa54 |
bool onPropertyChanged(std::string propertyName);
|
|
Toshihiro Shimizu |
890ddd |
bool select(const TSelection *) { return false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool pick(int &hookIndex, const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getCursorId() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} trackerTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TrackerTool implementation
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TrackerTool::TrackerTool()
|
|
Toshihiro Shimizu |
890ddd |
: TTool("T_Tracker"), m_hookSelectedIndex(-1), m_lastHookSelectedIndex(-1), m_deselectArmed(false), m_toolSizeWidth("Width:", 0, 1000, 10) //W_ToolOptions
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight("Height:", 0, 1000, 10) //W_ToolOptions
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX("X:", -9000, 9000, 10) //W_ToolOptions
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY("Y:", -9000, 9000, 10) //W_ToolOptions
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_shapeBBox(), m_buttonDown(false), m_dragged(false), m_oldPos(TPointD(0, 0)), m_newObjectAdded(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bind(TTool::CommonLevels);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_toolSizeWidth);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_toolSizeHeight);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_toolPosX);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_toolPosY);
|
|
Toshihiro Shimizu |
890ddd |
m_selection.setTool(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::updateTranslation()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeWidth.setQStringName(tr("Width:"));
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight.setQStringName(tr("Height:"));
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX.setQStringName(tr("X:"));
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY.setQStringName(tr("Y:"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *TrackerTool::getTrackerObjectsSet() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
return hookSet->getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
HookSet *TrackerTool::getHookSet() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
return xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::draw()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (hookSet->getHookCount() <= m_hookSelectedIndex)
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
int selectedObjectId;
|
|
Toshihiro Shimizu |
890ddd |
if (m_hookSelectedIndex >= 0 && hookSet->getHook(m_hookSelectedIndex))
|
|
Toshihiro Shimizu |
890ddd |
selectedObjectId = hookSet->getHook(m_hookSelectedIndex)->getTrackerObjectId();
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
selectedObjectId = -1;
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<trectd> balloons; // this is used to avoid balloons overlapping</trectd>
|
|
Toshihiro Shimizu |
890ddd |
// draw hooks
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < hookSet->getHookCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
assert(hook);
|
|
Toshihiro Shimizu |
890ddd |
// Se l'Hook ha una TrackerRegion allora la disegno
|
|
Toshihiro Shimizu |
890ddd |
if (hook->getTrackerObjectId() >= 0) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect;
|
|
Toshihiro Shimizu |
890ddd |
rect = hook->getTrackerRegion(fid);
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 textColor(127, 127, 127);
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 trackerObjectColor(0, 0, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (hook->getTrackerObjectId() == selectedObjectId) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_hookSelectedIndex == i) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 frameColor(127, 127, 127);
|
|
Toshihiro Shimizu |
890ddd |
drawSquare(0.5 * (rect.getP01() + rect.getP11()), pixelSize * 4, frameColor); // scalaY
|
|
Toshihiro Shimizu |
890ddd |
drawSquare(0.5 * (rect.getP11() + rect.getP10()), pixelSize * 4, frameColor); // scalaX
|
|
Toshihiro Shimizu |
890ddd |
drawSquare(rect.getP00(), pixelSize * 4, frameColor); // scala
|
|
Toshihiro Shimizu |
890ddd |
drawSquare(rect.getP10(), pixelSize * 4, frameColor); // ridimensiona
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectColor = TPixel32(183, 227, 0);
|
|
Toshihiro Shimizu |
890ddd |
textColor = TPixel32(155, 213, 219);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
textColor = TPixel32(183, 227, 0);
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectColor = TPixel32(155, 213, 219);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectColor = TPixel32(0, 0, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglColor(trackerObjectColor);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawRect(rect);
|
|
Toshihiro Shimizu |
890ddd |
tglColor(textColor);
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glTranslated(hook->getPos(fid).x, hook->getPos(fid).y, 0);
|
|
Toshihiro Shimizu |
890ddd |
glScaled(pixelSize, pixelSize, 1);
|
|
Toshihiro Shimizu |
890ddd |
int objectId = hook->getTrackerObjectId();
|
|
Toshihiro Shimizu |
890ddd |
char *objectChar = (char *)malloc(2);
|
|
Toshihiro Shimizu |
890ddd |
objectChar[0] = (char)(objectId + 65);
|
|
Toshihiro Shimizu |
890ddd |
objectChar[1] = '\0';
|
|
Shinya Kitaoka |
3bfa54 |
std::string text(objectChar);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawText(TPointD(-15, 10), text);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD p0 = hook->getAPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
TPointD p1 = hook->getBPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
bool linked = p0 == p1;
|
|
Toshihiro Shimizu |
890ddd |
drawHook(p0, linked ? ToolUtils::NormalHook : ToolUtils::PassHookA, m_hookSelectedIndex == i);
|
|
Shinya Kitaoka |
3bfa54 |
std::string hookName = toString(i + 1);
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 balloonColor(200, 220, 205, 200);
|
|
Toshihiro Shimizu |
890ddd |
TPoint balloonOffset(20, 20);
|
|
Toshihiro Shimizu |
890ddd |
drawBalloon(p0, hookName, balloonColor, balloonOffset, false, &balloons);
|
|
Toshihiro Shimizu |
890ddd |
if (!linked) {
|
|
Toshihiro Shimizu |
890ddd |
drawHook(p1, PassHookB, m_selection.isSelected(i, 2));
|
|
Toshihiro Shimizu |
890ddd |
drawBalloon(p1, hookName, balloonColor, balloonOffset, false, &balloons);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TrackerTool::pick(int &hookIndex, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double minDistance = -1;
|
|
Toshihiro Shimizu |
890ddd |
m_what = Outside;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)hookSet->getHookCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
int trackerObjectId = hook->getTrackerObjectId();
|
|
Toshihiro Shimizu |
890ddd |
if (trackerObjectId < 0) // se non รจ una trackeRregion
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD hookPos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
TRectD overArea = TRectD(hookPos.x - 20 * pixelSize, hookPos.y - 20 * pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
hookPos.x + 20 * pixelSize, hookPos.y + 20 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
if (overArea.contains(pos)) {
|
|
Toshihiro Shimizu |
890ddd |
hookIndex = i; //setto l'indice dell'hook
|
|
Toshihiro Shimizu |
890ddd |
m_what = NormalHook;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
if(!trackerObjectsSet) return false;
|
|
Toshihiro Shimizu |
890ddd |
TrackerObject *trackerObject = trackerObjectsSet->getObjectFromIndex(i);
|
|
Toshihiro Shimizu |
890ddd |
int j=0;
|
|
Toshihiro Shimizu |
890ddd |
for(j=0;j<(int)trackerObject->getHooksCount();j++)
|
|
Toshihiro Shimizu |
890ddd |
{*/
|
|
Toshihiro Shimizu |
890ddd |
TPointD centerPos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
double width = hook->getTrackerRegionWidth();
|
|
Toshihiro Shimizu |
890ddd |
double height = hook->getTrackerRegionHeight();
|
|
Toshihiro Shimizu |
890ddd |
double distance = tdistance2(centerPos, pos);
|
|
Toshihiro Shimizu |
890ddd |
TPointD localPos = pos - centerPos;
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect = hook->getTrackerRegion(fid);
|
|
Toshihiro Shimizu |
890ddd |
TRectD overArea = TRectD(rect.getP00().x - 4 * pixelSize, rect.getP00().y - 4 * pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
rect.getP11().x + 4 * pixelSize, rect.getP11().y + 4 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
// se pos รจ all'interno del'area sensibile del rettangolo
|
|
Toshihiro Shimizu |
890ddd |
if (overArea.contains(pos)) {
|
|
Toshihiro Shimizu |
890ddd |
if (distance < minDistance || minDistance == -1) {
|
|
Toshihiro Shimizu |
890ddd |
minDistance = distance;
|
|
Toshihiro Shimizu |
890ddd |
hookIndex = i;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_what = Inside;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// scale Y Area
|
|
Toshihiro Shimizu |
890ddd |
double x = 0.5 * (rect.getP01().x + rect.getP11().x); //ascissa punto medio
|
|
Toshihiro Shimizu |
890ddd |
TPointD my = TPointD(x, rect.getP11().y);
|
|
Toshihiro Shimizu |
890ddd |
TRectD scaleYArea = TRectD(my.x - 4 * pixelSize, my.y - 4 * pixelSize, my.x + 4 * pixelSize, my.y + 4 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
if (scaleYArea.contains(pos))
|
|
Toshihiro Shimizu |
890ddd |
m_what = PM1;
|
|
Toshihiro Shimizu |
890ddd |
// scale X Area
|
|
Toshihiro Shimizu |
890ddd |
double y = 0.5 * (rect.getP11().y + rect.getP10().y); //ordinata punto medio
|
|
Toshihiro Shimizu |
890ddd |
TPointD mx = TPointD(rect.getP10().x, y);
|
|
Toshihiro Shimizu |
890ddd |
TRectD scaleXArea = TRectD(mx.x - 4 * pixelSize, mx.y - 4 * pixelSize, mx.x + 4 * pixelSize, mx.y + 4 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
if (scaleXArea.contains(pos))
|
|
Toshihiro Shimizu |
890ddd |
m_what = P1M;
|
|
Toshihiro Shimizu |
890ddd |
// resize area (scale X and Y)
|
|
Toshihiro Shimizu |
890ddd |
TRectD resizeArea = TRectD(rect.getP10().x - 4 * pixelSize, rect.getP10().y - 4 * pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
rect.getP10().x + 4 * pixelSize, rect.getP10().y + 4 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
if (resizeArea.contains(pos))
|
|
Toshihiro Shimizu |
890ddd |
m_what = P10;
|
|
Toshihiro Shimizu |
890ddd |
// scale area
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD scaleArea = TRectD(rect.getP00().x - 4 * pixelSize, rect.getP00().y - 4 * pixelSize,
|
|
Toshihiro Shimizu |
890ddd |
rect.getP00().x + 4 * pixelSize, rect.getP00().y + 4 * pixelSize);
|
|
Toshihiro Shimizu |
890ddd |
if (scaleArea.contains(pos))
|
|
Toshihiro Shimizu |
890ddd |
m_what = P00;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return (minDistance != -1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_buttonDown = true;
|
|
Toshihiro Shimizu |
890ddd |
m_picked = true;
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_selection.setLevel(xl);
|
|
Toshihiro Shimizu |
890ddd |
m_firstPos = m_lastPos = pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_deselectArmed = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_oldPos = pos;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
if (!trackerObjectsSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (pick(m_hookSelectedIndex, pos)) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_what == NormalHook) {
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_selection.selectNone();
|
|
Toshihiro Shimizu |
890ddd |
m_selection.select(m_hookSelectedIndex, m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeWidth.setValue(hook->getTrackerRegionWidth());
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight.setValue(hook->getTrackerRegionHeight());
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX.setValue(hook->getPos(fid).x);
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY.setValue(hook->getPos(fid).y);
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeWidth.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_selection.selectNone();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (xl->getSimpleLevel() && !xl->getSimpleLevel()->isReadOnly()) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
m_what = P10;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Se non รจ selezionato alcun oggetto allora aggiungo un nuovo oggetto e a questo
|
|
Toshihiro Shimizu |
890ddd |
// aggiungo una trackerRegion
|
|
Toshihiro Shimizu |
890ddd |
int trackerObjectId;
|
|
Toshihiro Shimizu |
890ddd |
if (m_hookSelectedIndex == -1 || hookSet->getHook(m_hookSelectedIndex) == 0) {
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectId = trackerObjectsSet->addObject();
|
|
Toshihiro Shimizu |
890ddd |
m_newObjectAdded = true;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectId = hookSet->getHook(m_hookSelectedIndex)->getTrackerObjectId();
|
|
Toshihiro Shimizu |
890ddd |
// se l'oggetto selezionato รจ un semplice Hook (senza region)
|
|
Toshihiro Shimizu |
890ddd |
// allora creo un nuovo hook con region
|
|
Toshihiro Shimizu |
890ddd |
if (trackerObjectId == -1) {
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectId = trackerObjectsSet->addObject();
|
|
Toshihiro Shimizu |
890ddd |
m_newObjectAdded = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// aggiungo un Hook all'oggetto selezionato
|
|
Toshihiro Shimizu |
890ddd |
Hook *newHook = hookSet->addHook();
|
|
Toshihiro Shimizu |
890ddd |
if (newHook) {
|
|
Toshihiro Shimizu |
890ddd |
newHook->setTrackerObjectId(trackerObjectId);
|
|
Toshihiro Shimizu |
890ddd |
newHook->setAPos(fid, pos);
|
|
Toshihiro Shimizu |
890ddd |
newHook->setTrackerRegionHeight(pixelSize * 10);
|
|
Toshihiro Shimizu |
890ddd |
newHook->setTrackerRegionWidth(pixelSize * 10);
|
|
Toshihiro Shimizu |
890ddd |
// setto l'indice della trackerRegion corrente
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = newHook->getId(); // hookSet->getHookCount()-1;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (hookSet->getHookCount() >= 20)
|
|
Toshihiro Shimizu |
890ddd |
QMessageBox::warning(0, "TrackerTool Error", "Hooks number must be at most 20");
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_selection.makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::leftButtonDrag(const TPointD &pp, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_buttonDown)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_hookSelectedIndex < 0 && m_what != NormalHook)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
assert(hookSet->getHook(m_hookSelectedIndex) != 0);
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
if (!trackerObjectsSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_dragged == false) {
|
|
Toshihiro Shimizu |
890ddd |
m_dragged = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (xl->getSimpleLevel() && xl->getSimpleLevel()->isReadOnly() && m_what != Inside && m_what != NormalHook)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_dragged == true) {
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = new Hook();
|
|
Toshihiro Shimizu |
890ddd |
hook = getHookSet()->getHook(m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TPointD deltaPos = pp - m_oldPos;
|
|
Toshihiro Shimizu |
890ddd |
m_oldPos = pp;
|
|
Toshihiro Shimizu |
890ddd |
double newWidth = hook->getTrackerRegionWidth();
|
|
Toshihiro Shimizu |
890ddd |
double newHeight = hook->getTrackerRegionHeight();
|
|
Toshihiro Shimizu |
890ddd |
TAffine aff;
|
|
Toshihiro Shimizu |
890ddd |
const double epsilon = 1e-2;
|
|
Toshihiro Shimizu |
890ddd |
TPointD posCenter = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
double a = norm2(pp - posCenter);
|
|
Toshihiro Shimizu |
890ddd |
double b = norm2(pp - deltaPos - posCenter);
|
|
Toshihiro Shimizu |
890ddd |
switch (m_what) {
|
|
Toshihiro Shimizu |
890ddd |
case Inside: //Traslazione
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, hook->getPos(fid) + deltaPos);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
case NormalHook: //Traslazione Hook
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, hook->getPos(fid) + deltaPos);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
case P00: // Scalatura
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (a <= epsilon || b <= epsilon)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
aff = TScale(posCenter, sqrt(a / b));
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect = hook->getTrackerRegion(fid);
|
|
Toshihiro Shimizu |
890ddd |
TPointD av(hook->getTrackerRegion(fid).getP00());
|
|
Toshihiro Shimizu |
890ddd |
TPointD av2(hook->getTrackerRegion(fid).getP11());
|
|
Toshihiro Shimizu |
890ddd |
av = aff * av;
|
|
Toshihiro Shimizu |
890ddd |
av2 = aff * av2;
|
|
Toshihiro Shimizu |
890ddd |
rect = TRectD(av, av2);
|
|
Toshihiro Shimizu |
890ddd |
newWidth = rect.getLx();
|
|
Toshihiro Shimizu |
890ddd |
newHeight = rect.getLy();
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
case P10: // Scalatura X e Y
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
TPointD diffPos = pp - pos;
|
|
Toshihiro Shimizu |
890ddd |
int signumx = 1;
|
|
Toshihiro Shimizu |
890ddd |
int signumy = 1;
|
|
Toshihiro Shimizu |
890ddd |
if (diffPos.x < 0)
|
|
Toshihiro Shimizu |
890ddd |
signumx = -1;
|
|
Toshihiro Shimizu |
890ddd |
if (diffPos.y < 0)
|
|
Toshihiro Shimizu |
890ddd |
signumy = -1;
|
|
Toshihiro Shimizu |
890ddd |
newWidth = fabs(hook->getTrackerRegionWidth() + 2 * signumx * deltaPos.x);
|
|
Toshihiro Shimizu |
890ddd |
newHeight = fabs(hook->getTrackerRegionHeight() + 2 * signumy * deltaPos.y);
|
|
Toshihiro Shimizu |
890ddd |
//double newWidth = fabs(2*diffPos.x-fabs(2*signumx*deltaPos.x));
|
|
Toshihiro Shimizu |
890ddd |
//double newHeight = fabs(2*diffPos.y-fabs(2*signumy*deltaPos.y));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
case P1M: // Ridimensiono X
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect = hook->getTrackerRegion(fid);
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.enlarge(deltaPos.x, 0);
|
|
Toshihiro Shimizu |
890ddd |
newWidth = rect.getLx();
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
case PM1: // Ridimensiono Y
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect = hook->getTrackerRegion(fid);
|
|
Toshihiro Shimizu |
890ddd |
rect = rect.enlarge(0, deltaPos.y);
|
|
Toshihiro Shimizu |
890ddd |
newHeight = rect.getLy();
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
default:
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (newWidth > m_toolSizeWidth.getRange().second ||
|
|
Toshihiro Shimizu |
890ddd |
newHeight > m_toolSizeHeight.getRange().second)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionWidth(newWidth);
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionHeight(newHeight);
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeWidth.setValue(hook->getTrackerRegionWidth());
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight.setValue(hook->getTrackerRegionHeight());
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX.setValue(hook->getPos(fid).x);
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY.setValue(hook->getPos(fid).y);
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosX.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolPosY.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeWidth.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
m_toolSizeHeight.notifyListeners();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//TTool::Application *app = TTool::getApplication());
|
|
Toshihiro Shimizu |
890ddd |
//app->getCurrentScene()->getScene()->getXsheet()->getPegbarTree()->invalidateAll();
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// note: apparently sometimes (when the user triple-clicks) we receive this event twice
|
|
Toshihiro Shimizu |
890ddd |
if (!m_buttonDown)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
// se clicco su una TrackerRegion giร selezionato lo deseleziono (per permettere
|
|
Toshihiro Shimizu |
890ddd |
// poi l'aggiunta di un nuovo TrackerObject
|
|
Toshihiro Shimizu |
890ddd |
if (m_dragged == false &&
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex == m_lastHookSelectedIndex) {
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_newObjectAdded) {
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
m_newObjectAdded = false;
|
|
Toshihiro Shimizu |
890ddd |
// emit signal in order to update schematic
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_lastHookSelectedIndex = m_hookSelectedIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_dragged = false;
|
|
Toshihiro Shimizu |
890ddd |
m_buttonDown = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl || !xl->getSimpleLevel())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
xl->getSimpleLevel()->getProperties()->setDirtyFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//m_selection.selectNone();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::deleteSelectedTrackerRegion()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = app->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl || !xl->getSimpleLevel() || !hookSet || xl->getSimpleLevel()->isReadOnly())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//HookUndo *undo = new HookUndo(xl->getSimpleLevel());
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
hookSet->clearHook(hook);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentScene()->getScene()->getXsheet()->getStageObjectTree()->invalidateAll();
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// emit signal in order to update schematic
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
int a = m_selectedObjectId;
|
|
Toshihiro Shimizu |
890ddd |
int b = m_selectedTrackerRegionIndex;
|
|
Toshihiro Shimizu |
890ddd |
if(m_selectedObjectId<0 ||m_selectedTrackerRegionIndex<0) return;
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
if(!trackerObjectsSet) return;
|
|
Toshihiro Shimizu |
890ddd |
TrackerObject *trackerObject= trackerObjectsSet->getObject(m_selectedObjectId);
|
|
Toshihiro Shimizu |
890ddd |
if(trackerObject==NULL) return;
|
|
Toshihiro Shimizu |
890ddd |
if(trackerObject->getHooksCount()==0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectsSet->removeObject(m_selectedObjectId);
|
|
Toshihiro Shimizu |
890ddd |
m_selectedObjectId = -1;
|
|
Toshihiro Shimizu |
890ddd |
m_selectedTrackerRegionIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
trackerObject->removeHook(m_selectedTrackerRegionIndex);
|
|
Toshihiro Shimizu |
890ddd |
m_selectedTrackerRegionIndex = trackerObject->getHooksCount()-1;
|
|
Toshihiro Shimizu |
890ddd |
invalidate(); */
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::mouseMove(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_picked = true;
|
|
Toshihiro Shimizu |
890ddd |
if (m_dragged == false) {
|
|
Toshihiro Shimizu |
890ddd |
int hookSelectedIndex;
|
|
Toshihiro Shimizu |
890ddd |
pick(hookSelectedIndex, pos);
|
|
Toshihiro Shimizu |
890ddd |
if (hookSelectedIndex < 0) {
|
|
Toshihiro Shimizu |
890ddd |
m_pos = pos;
|
|
Toshihiro Shimizu |
890ddd |
m_picked = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
bool TrackerTool::onPropertyChanged(std::string propertyName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet || m_hookSelectedIndex < 0)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == "Width:") {
|
|
Toshihiro Shimizu |
890ddd |
double width = m_toolSizeWidth.getValue();
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionWidth(width);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == "Height:") {
|
|
Toshihiro Shimizu |
890ddd |
double height = m_toolSizeHeight.getValue();
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionHeight(height);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == "X:") {
|
|
Toshihiro Shimizu |
890ddd |
double x = m_toolPosX.getValue();
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
pos.x = x;
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == "Y:") {
|
|
Toshihiro Shimizu |
890ddd |
double y = m_toolPosY.getValue();
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
pos.y = y;
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::reset()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int TrackerTool::getCursorId() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
switch (m_what) {
|
|
Toshihiro Shimizu |
890ddd |
case Outside:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::TrackerCursor;
|
|
Toshihiro Shimizu |
890ddd |
case Inside:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::MoveCursor;
|
|
Toshihiro Shimizu |
890ddd |
case NormalHook:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::MoveCursor;
|
|
Toshihiro Shimizu |
890ddd |
case P00:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::ScaleCursor;
|
|
Toshihiro Shimizu |
890ddd |
case P01:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::MoveCursor;
|
|
Toshihiro Shimizu |
890ddd |
case P10:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::ScaleCursor;
|
|
Toshihiro Shimizu |
890ddd |
case P1M:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::ScaleHCursor;
|
|
Toshihiro Shimizu |
890ddd |
case PM1:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::ScaleVCursor;
|
|
Toshihiro Shimizu |
890ddd |
case ADD_OBJECT:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::SplineEditorCursorAdd;
|
|
Toshihiro Shimizu |
890ddd |
default:
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::TrackerCursor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::TrackerCursor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool TrackerTool::keyDown(int key, TUINT32 flags, const TPoint &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(m_hookSelectedIndex);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
TPointD hookPos = hook->getPos(fid);
|
|
Toshihiro Shimizu |
890ddd |
TPointD delta(0, 0);
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (key == TwConsts::TK_UpArrow)
|
|
Toshihiro Shimizu |
890ddd |
delta.y = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (key == TwConsts::TK_DownArrow)
|
|
Toshihiro Shimizu |
890ddd |
delta.y = -1;
|
|
Toshihiro Shimizu |
890ddd |
else if (key == TwConsts::TK_LeftArrow)
|
|
Toshihiro Shimizu |
890ddd |
delta.x = -1;
|
|
Toshihiro Shimizu |
890ddd |
else if (key == TwConsts::TK_RightArrow)
|
|
Toshihiro Shimizu |
890ddd |
delta.x = 1;
|
|
Toshihiro Shimizu |
890ddd |
else if (key == TwConsts::TK_PageUp) //converto in Hook
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerObjectId(-1);
|
|
Toshihiro Shimizu |
890ddd |
else if (key == TwConsts::TK_PageDown) // converto in trackerRegion
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!trackerObjectsSet)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int trackerObjectId = hook->getTrackerObjectId();
|
|
Toshihiro Shimizu |
890ddd |
if (trackerObjectId != -1)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectId = trackerObjectsSet->addObject();
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerObjectId(trackerObjectId);
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionHeight(pixelSize * 20);
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerRegionWidth(pixelSize * 20);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
hookPos += delta;
|
|
Toshihiro Shimizu |
890ddd |
hook->setAPos(fid, hookPos);
|
|
Toshihiro Shimizu |
890ddd |
//TTool::getApplication()->getCurrentTool()->getTool()->notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
// TNotifier::instance()->notify(TLevelChange());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
// bool moveCursor(const TPointD &pos){}
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::onEnter()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet || hookSet->getHookCount() <= m_hookSelectedIndex)
|
|
Toshihiro Shimizu |
890ddd |
m_hookSelectedIndex = -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::onLeave()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TrackerObjectsSet *trackerObjectsSet = getTrackerObjectsSet();
|
|
Toshihiro Shimizu |
890ddd |
if (trackerObjectsSet)
|
|
Toshihiro Shimizu |
890ddd |
trackerObjectsSet->clearAll();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::onActivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerTool::onDeactivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//m_selection.selectNone();
|
|
Toshihiro Shimizu |
890ddd |
//TSelection::setCurrent(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool *getTrackerToolTool() { return &trackerTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerRegionSelection::enableCommands()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
enableCommand(m_tool, MI_Clear, &TrackerTool::deleteSelectedTrackerRegion);
|
|
Toshihiro Shimizu |
890ddd |
//enableCommand(m_tool, MI_ConvertToRegion, &TrackerRegionSelection::convertToRegion);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TrackerRegionSelection::convertToRegion()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
if (!xl)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
HookSet *hookSet = xl->getHookSet();
|
|
Toshihiro Shimizu |
890ddd |
if (!hookSet)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < hookSet->getHookCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
if (isSelected(i, i)) {
|
|
Toshihiro Shimizu |
890ddd |
int trackerObjectId = hookSet->getTrackerObjectsSet()->addObject();
|
|
Toshihiro Shimizu |
890ddd |
Hook *hook = hookSet->getHook(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!hook || hook->isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
hook->setTrackerObjectId(trackerObjectId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|