#include "input_geometry_curves.hpp" QtInputGeometryCurves::QtInputGeometryCurves(){ margin=10; radius=8; min_d=0.01; initPoints(); hbot.setPoints(point,np); hbot.compute(); hsoil.setPoints(&point[np],np); hsoil.compute(); } void QtInputGeometryCurves::initPoints(){ for(size_t i=0;ix(); int my=event->y(); selected=findPoint(mx,my); } void QtInputGeometryCurves::mouseMoveEvent(QMouseEvent* event){ if(selected<2*np){ int w=width()-2*margin; int h=height(); float mx=event->x(); float my=event->y(); float x=(mx-margin)/w; float y=my/h; moveSelected(x,y); update(); } } void QtInputGeometryCurves::mouseReleaseEvent(QMouseEvent* event){ selected=2*np; } size_t QtInputGeometryCurves::findPoint(int x,int y){ int w=width()-2*margin; int h=height(); for(size_t i=0;i<2*np;++i){ Point& P=point[i]; int px=get_x(P.x,w); int py=get_y(P.y,h); int dx=x-px; int dy=y-py; int d=dx*dx+dy*dy; if(d<=radius*radius) return i; } return 2*np; } void QtInputGeometryCurves::moveSelected(float x,float y){ double xp=point[selected].x; double yp=point[selected].y; if(selected!=0 and selected!=np-1){ float xmin=point[selected-1].x+min_d; float xmax=point[selected+1].x-min_d; if(xmin<=x and x<=xmax){ point[selected].x=x; } } if(0<=y and y<=1){ point[selected].y=y; } if(selected1-min_d or ysoil1-min_d or ybot