Newer
Older
glVertex2f(zero.x-zeroSize,zero.y);
glEnd();
glBegin(GL_LINES);
style->zeroColor.gl();
glVertex2f(zero.x-zeroSize,zero.y);
glVertex2f(zero.x+zeroSize,zero.y);
glVertex2f(zero.x,zero.y-zeroSize);
glVertex2f(zero.x,zero.y+zeroSize);
glEnd();
}
refreshAll();
document->lock();
/*if (changeDpi)
refreshAll();*/
selectionBounds.init = false;
if(style->drawCurves)
{
std::list<OE_pointcurve*>::iterator curve = document->curves.begin();
while (curve != document->curves.end())
{
drawCurve((*curve));
curve++;
}
curve = document->selectedCurves.begin();
while (curve != document->selectedCurves.end())
{
drawCurveControl( (*curve));
selectionBounds += (*curve)->getBound();
curve++;
}
}
if(style->drawStitches)
{
std::list<OE_stitchs*>::iterator stitch = document->stitchs.begin();
int curpoint = document->curPoint;
while (stitch != document->stitchs.end())
{
drawStitch((*stitch), curpoint);
curpoint -= (*stitch)->getPoints().size();
stitch++;
}
stitch = document->selectedStitchs.begin();
while (stitch != document->selectedStitchs.end())
{
drawStitchControl((*stitch));
selectionBounds += (*stitch)->getBound();
stitch++;
}
}
if(style->drawCommands)
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
drawCommands();
document->unlock();
drawSelectionTools();
return true;
}
bool OE_display::select(std::list<OE_pointcurve*> selectedCurves, std::list<OE_stitchs*> selectedStitches)
{
std::list<OE_pointcurve*>::iterator curve;
std::list<OE_stitchs*>::iterator stitch;
int index;
glLoadName(0); //id of the tools
/* glPushName(0); //id of the zero tool
//draw 0
vector_2d zero = document->getZeroPoint();
glPointSize(6);
glBegin(GL_POINT);
glVertex2f(zero.x,zero.y);
glEnd();
glPopName();
*/
glPushName(1); //id of the move tool
drawSelectionTools(true);
glPopName();
//if (changeDpi)
refreshAll();
if(style->selectStitches)
{
glLoadName(1); //id of the stitches
index = 0;
glPushName(index); //init the stitches index
stitch = selectedStitches.begin();
while (stitch != selectedStitches.end())
{
drawStitchControl((*stitch), true);
stitch++;
index++;
glLoadName(index);
}
glPopName();
}
if(style->selectCurves)
{
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)
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::zoomSelection()
3dsman
committed
{
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);
changeDpi = true;
3dsman
committed
}
}
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
zoom = zoom*1.1;
changeDpi = true;
}
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){};