Esempio n. 1
0
TStroke *PinchTool::getClosestStroke(const TPointD &pos, double &w) const
{
	TVectorImageP vi = TImageP(getImage(false));
	if (!vi)
		return 0;
	double dist = 0;
	UINT index;
	if (vi->getNearestStroke(pos, w, index, dist, true))
		return vi->getStroke(index);
	else
		return 0;
}
Esempio n. 2
0
void PinchTool::leftButtonDown(const TPointD &pos,
							   const TMouseEvent &event)
{
	m_curr = m_down = pos;

	if (!m_active &&
		!m_selector.isSelected()) {
		m_active = false;

		assert(m_undo == 0);

		StrokeDeformation *
			deformation = m_deformation;

		TVectorImageP
			vi = TImageP(getImage(true));

		if (!vi)
			return;

		m_active = true;

		ContextStatus
			*status = &m_status;

		// reset status
		status->init();

		double
			w,
			dist2;

		// find nearest stroke
		if (vi->getNearestStroke(m_down,
								 w,
								 m_n,
								 dist2, true)) {

			TStroke
				*stroke = vi->getStroke(m_n);
			assert(stroke && "Not valid stroke found!!!");
			if (!stroke)
				return;

			updateStrokeStatus(stroke,
							   w);

			// set parameters from sliders
			updateInterfaceStatus(event);

			deformation->activate(status);

			// stroke can be changed (replaced by another) during deformation activate
			if (TTool::getApplication()->getCurrentObject()->isSpline())
				m_undo = new ToolUtils::UndoPath(getXsheet()->getStageObject(getObjectId())->getSpline());
			else {
				TXshSimpleLevel *sl = TTool::getApplication()->getCurrentLevel()->getSimpleLevel();
				assert(sl);
				TFrameId id = getCurrentFid();
				m_undo = new UndoModifyStrokeAndPaint(sl, id, m_n);
			}
		}
	}

	m_selector.mouseDown(m_curr);
	m_prev = m_curr;

	invalidate();
}