Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void mousePressEvent(QMouseEvent *e)
- {
- QColor colours[10] = { QColor(255,0,0), QColor(0,255,0), QColor(0,0,255),
- QColor(0,0,0), QColor(255,255,255),
- QColor(0,128,64) };
- static int i;
- switch (e->button())
- {
- case Qt::LeftButton:
- clusters.push_back(new Cluster(e->x() %width(), e->y() %height(), colours[i]));
- Cluster* cc;
- for each(KPoint* p in kpoints)
- {
- double minim=1000;
- for each (Cluster* c in clusters)
- {
- double dist = abs(sqrt(((p->x - c->x)*(p->x - c->x)) + ((p->y - c->y)*(p->y - c->y))));
- if (dist < minim)
- {
- minim = dist;
- cc = c;
- }
- }
- p->parentCluster = cc;
- }
- update(); //redesenarea ferestrei (se apeleaza paintEvent())
- break;
- case Qt::RightButton:
- update();
- break;
- }
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement