void CurveEditor::NotifyPointMove(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id != MyGUI::MouseButton::Left) return; if (!CheckPosition(_left, _top)) return; auto pos = MyGUI::IntPoint(_left, _top) - _sender->getCroppedParent()->getAbsolutePosition(); auto value = GetValue(pos.left, pos.top); pos.left -= 7; pos.top -= 7; _sender->setPosition(pos); DiString str; str.Format("%.3g", value.x); mEditTimeEditBox->setCaption(str.c_str()); str.Format("%.3g", value.y); mEditValueEditBox->setCaption(str.c_str()); std::sort(mButtons.begin(), mButtons.end(), [](MyGUI::Button* a, MyGUI::Button* b) { return a->getPosition().left < b->getPosition().left; }); RefreshCurve(); }
/** * @brief VToolCutSpline constructor. * @param doc dom document container. * @param data container with variables. * @param id object id in container. * @param formula string with formula length first spline. * @param splineId id spline in data container. * @param typeCreation way we create this tool. * @param parent parent object. */ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, const Source &typeCreation, QGraphicsItem *parent) :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, parent) { RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); if (typeCreation == Source::FromGui) { AddToFile(); } else { RefreshDataInFile(); } }
void CurveEditor::NotifyPointPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id != MyGUI::MouseButton::Right) return; auto it = std::find(mButtons.begin(), mButtons.end(), _sender); if (it != mButtons.end()) { mCanvasWidget->_destroyChildWidget(*it); mButtons.erase(it); RefreshCurve(); } }
void CurveEditor::AddButton(int _left, int _top) { auto btn = mCanvasWidget->createWidget<MyGUI::Button>("RoundButtonSkin", MyGUI::IntCoord(_left - 7, _top - 7, 15, 15), MyGUI::Align::Left | MyGUI::Align::Top); btn->eventMouseDrag += newDelegate(this, &CurveEditor::NotifyPointMove); btn->eventMouseButtonPressed += newDelegate(this, &CurveEditor::NotifyPointPressed); mButtons.push_back(btn); std::sort(mButtons.begin(), mButtons.end(), [](MyGUI::Button* a, MyGUI::Button* b) { return a->getPosition().left < b->getPosition().left; }); RefreshCurve(); }
void CurveEditor::NotifySplineChecked(MyGUI::Widget* _sender) { mSplineButton->setStateSelected(!mSplineButton->getStateSelected()); RefreshCurve(); }