Skip to content
OE_display.cpp 25.5 KiB
Newer Older
	{
		glLoadName(2); //id of the curves
		index = 0;
		glPushName(index); //init the curves index

		curve = selectedCurves.begin();
		while (curve != selectedCurves.end())
		{
			drawCurveControl((*curve), true);
			curve++;
			index++;
			glLoadName(index);
		}
		glPopName();
	}

	if(style.selectStitches)
	{
		glLoadName(1); //id of the stitches
		index = 0;
		glPushName(index); //init the stitches index

		int curpoint = document->curPoint;

		stitch = document->stitchs.begin();
		while (stitch != document->stitchs.end())
		{
			drawStitch((*stitch),curpoint);
			curpoint -= (*stitch)->getPoints().size();
			stitch++;
			index++;
			glLoadName(index);
		}
		glPopName();
	}

	if(style.selectCurves)
	{
		glLoadName(2); //id of the curves
		index = 0;
		glPushName(index); //init the curves index

		curve = document->curves.begin();
		while (curve != document->curves.end())
		{
			drawCurve((*curve));
			curve++;
			index++;
			glLoadName(index);
		}
		glPopName();
	}
}



/** \brief move and zoom to see the entire document
 */

void OE_display::showAll()
{
	if (document)
	
		float xMin,yMin,xMax,yMax;
		BoundingBox bound = document->getBound();
		viewPos.x = (bound.getMax().x + bound.getMin().x)/2;
		viewPos.y = (bound.getMax().y + bound.getMin().y)/2;
		zoom = maxf((bound.getMax().x - bound.getMin().x )/width/1.5,(bound.getMax().y - bound.getMin().y)/height/1.5);

		changeDpi = true;
void OE_display::showSelection()
{
	if (document&&controller)
	{

		float xMin,yMin,xMax,yMax;
		BoundingBox bound = controller->getSelectionBoundingBox();
		viewPos.x = (bound.getMax().x + bound.getMin().x)/2;
		viewPos.y = (bound.getMax().y + bound.getMin().y)/2;

		zoom = maxf((bound.getMax().x - bound.getMin().x )/width/1.5,(bound.getMax().y - bound.getMin().y)/height/1.5);
void OE_display::mouse_Pos(double x, double y)
{
    if (pan)
        viewPos = viewPos + (mouse-vector_2d(x,y))*zoom;

    mouse.x = x;
    mouse.y = y;
    absMouse = viewPos+(mouse-vector_2d(width,height)/2)*zoom*2;
}
void OE_display::mouse_Button(int button, int action, int mods)
{
	if (button == GLFW_MOUSE_BUTTON_MIDDLE)
    {
        if (action == GLFW_PRESS)
            pan = true;
        else
            pan = false;
    }
}
void OE_display::scroll(double xoffset, double yoffset)
{
    if(!pan){
        if (yoffset>0)
        zoom = zoom/1.1;
        else
void OE_display::resize(int width, int height)
{
	this->width = width;
	this->height = height;
}

void OE_display::key(int key, int scancode, int action, int mods){};

vector_2d OE_display::screenToDocument(vector_2d pos)
{
	return viewPos+(pos-vector_2d(width,height)/2)*zoom*2;
}