-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPointBrush.cpp
86 lines (66 loc) · 1.7 KB
/
PointBrush.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// PointBrush.cpp
//
// The implementation of Point Brush. It is a kind of ImpBrush. All your brush implementations
// will look like the file with the different GL primitive calls.
//
#include "impressionistDoc.h"
#include "impressionistUI.h"
#include "pointbrush.h"
#include <iostream>
using namespace std;
extern float frand();
PointBrush::PointBrush( ImpressionistDoc* pDoc, char* name ) :
ImpBrush(pDoc,name)
{
}
void PointBrush::BrushBegin( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if(!dlg->getEnableAutoDraw())
saveState();
int size = pDoc->getSize();
glPointSize((float)size);
BrushMove( source, target );
}
void PointBrush::BrushMove( const Point source, const Point target )
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg=pDoc->m_pUI;
if ( pDoc == NULL ) {
printf( "PointBrush::BrushMove document is NULL\n" );
return;
}
int x = target.x;
int y = target.y;
int startCol = dlg->m_paintView->getStartCol();
int startRow = dlg->m_paintView->getStartRow() + dlg->m_mainWindow->h() - dlg->m_paintView->getDrawHeight() - 25;
//int startRow = 0;
int endCol = dlg->m_paintView->getEndCol();
int endRow = startRow + dlg->m_paintView->getDrawHeight();
if (x < startCol) {
x = startCol;
}
if (x > endCol) {
x = endCol;
}
if (y < startRow) {
y = startRow;
}
if (y > endRow) {
y = endRow;
}
glBegin( GL_POINTS );
SetColor( source );
glVertex2d( x,y );
//cout << " (" << x << "," << y << ") " << endl;
glEnd();
}
void PointBrush::BrushEnd( const Point source, const Point target )
{
// do nothing so far
}
char* PointBrush::BrushName(void) {
return ImpBrush::BrushName();
}