Newer
Older
/*
* Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
*/
#include "OE_display.h"
#include "OE_utils.h"
#include "OE_controller.h"
#include <iostream>
#include <GL/gl.h>
#include <cstdlib>
#include <math.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
//float OE_display::cx, OE_display::cy = 0.0;
vector_2d OE_display::viewPos;
//int OE_display::mouseX, OE_display::mouseY, OE_display::mouseXInit, OE_display::mouseYInit = -1;
bool OE_display::pan = false;
int OE_display::width, OE_display::height = 0;
OE_display::OE_display()
{
}
OE_display::OE_display(OE_document* document,OE_controller* controller)
}
OE_display::~OE_display()
{
}
/** \brief draw the document on screen
*
* \return true if all is ok
*
*/
bool OE_display::setDocument(OE_document * document)
{
this->document = document;
if(document)
{
3dsman
committed
std::list<OE_pointcurve*>::iterator curve = document->curves.begin();
while (curve != document->curves.end())
(*curve)->refresh(zoom/2);
curve++;
}
}
return true;
}
bool OE_display::setController(OE_controller* controller)
this->controller = controller;
return true;
}
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
bool OE_display::refresh()
{
if(document)
{
std::list<OE_pointcurve*>::iterator curve = document->curves.begin();
while (curve != document->curves.end())
{
(*curve)->refresh(zoom/2);
curve++;
}
std::list<OE_stitchs*>::iterator stitch = document->stitchs.begin();
while (stitch != document->stitchs.end())
{
(*stitch)->refresh(zoom/2);
stitch++;
}
changeDpi = false;
return true;
}
return false;
}
/** \brief draw the move gizmo
*
* \return true if all is ok
*
*/
bool OE_display::drawSelectionTools(bool select)
{
vector_2d min = selectionBounds.getMin();
vector_2d max = selectionBounds.getMax();
float crossSize = zoom*style.moveCrossSize;
float boxOffset = zoom*style.moveCrossSize;
min.x -= boxOffset;
min.y -= boxOffset;
max.x += boxOffset;
max.y += boxOffset;
if (selectionBounds.init)
{
if (select)
{
glTranslatef(min.x,min.y,0);
glPushName(0); //id of the move tool
glBegin(GL_QUADS);
style.selectionBoundColor.gl();
//glColor4d(1,0,0,1);
glVertex2f(crossSize*1.0f,0);
glVertex2f(0,crossSize*1.0f);
glVertex2f(-crossSize*1.0f,0);
glVertex2f(0,-crossSize*1.0f);
glEnd();
glPopName();
glPushName(1); //id of the scale tool
glBegin(GL_QUADS);
glVertex2f(-crossSize*0.5f,-crossSize*0.5f);
glVertex2f(-crossSize*0.5f,-crossSize*1.5f);
glVertex2f(-crossSize*1.5f,-crossSize*1.5f);
glVertex2f(-crossSize*1.5f,-crossSize*0.5f);
glEnd();
glPopName();
glTranslatef(-min.x,-min.y,0);
}else
{
//draw selection bound
glLineWidth(1.5);
glBegin(GL_LINE_LOOP);
style.selectionBoundColor.gl();
glVertex2f(min.x,min.y);
glVertex2f(min.x,max.y);
glVertex2f(max.x,max.y);
glVertex2f(max.x,min.y);
glEnd();
glTranslatef(min.x,min.y,0);
//draw move cross
glBegin(GL_TRIANGLES);
style.transformGizmoColor.gl();
glVertex2f(-crossSize*0.6f,-crossSize*0.1f);
glVertex2f(-crossSize*0.6f,crossSize*0.1f);
glVertex2f(crossSize*0.6f,crossSize*0.1f);
glVertex2f(crossSize*0.6f,crossSize*0.1f);
glVertex2f(-crossSize*0.6f,-crossSize*0.1f);
glVertex2f(crossSize*0.6f,-crossSize*0.1f);
glVertex2f(crossSize*0.6f,crossSize*0.3f);
glVertex2f(crossSize*1.0f,0);
glVertex2f(crossSize*0.6f,-crossSize*0.3f);
glVertex2f(-crossSize*0.6f,crossSize*0.3f);
glVertex2f(-crossSize*1.0f,0);
glVertex2f(-crossSize*0.6f,-crossSize*0.3f);
glVertex2f(-crossSize*0.1f,-crossSize*0.6f);
glVertex2f(crossSize*0.1f,-crossSize*0.6f);
glVertex2f(crossSize*0.1f,crossSize*0.6f);
Loading full blame...