-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
canelibrarywidget.cpp
59 lines (47 loc) · 1.25 KB
/
canelibrarywidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "glassmime.h"
#include "cane.h"
#include "glasscolor.h"
#include "canerenderdata.h"
#include "canelibrarywidget.h"
#include "canecrosssectionrender.h"
CaneLibraryWidget :: CaneLibraryWidget(Cane *_cane, MainWindow *_window)
: AsyncRenderWidget(_window), cane(_cane)
{
setFixedSize(100, 100);
updatePixmaps();
connect(this->cane, SIGNAL(modified()), this, SLOT(updatePixmaps()));
}
void CaneLibraryWidget :: updatePixmaps()
{
// This is fast enough to do in real time
updateDragPixmap();
// queue up an async update:
Camera camera;
camera.eye = make_vector(0.0f, 11.0f, 5.0f);
camera.lookAt = make_vector(0.0f, 0.0f, 5.0f);
camera.up = make_vector(0.0f, 0.0f, 1.0f);
camera.isPerspective = false;
camera.size = make_vector(300U, 300U);
setScene(camera, new CaneRenderData(cane));
}
const QPixmap* CaneLibraryWidget :: dragPixmap()
{
return &(this->_dragPixmap);
}
bool CaneLibraryWidget :: isDraggable()
{
return true;
}
GlassMime::Type CaneLibraryWidget :: mimeType()
{
return GlassMime::PULLPLAN_LIBRARY_MIME;
}
void CaneLibraryWidget :: updateDragPixmap()
{
QPixmap _pixmap(100, 100);
_pixmap.fill(Qt::transparent);
QPainter painter(&_pixmap);
CaneCrossSectionRender::render(&painter, 100, cane);
painter.end();
_dragPixmap = _pixmap;
}