本文整理汇总了C++中Quad::setQuad方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::setQuad方法的具体用法?C++ Quad::setQuad怎么用?C++ Quad::setQuad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::setQuad方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMotion
void mouseMotion(int x, int y) {
Point *p = new Point(x, H2-y);
if ((figType == POINTER) && sel) {
Figure *f = figureSet[selected];
if (cpsel){ // the user is trying to move a control point (modify)
f->setPoint(cp - figureSet.size(), p);
}
else { // the user want to move the figure as a block (move)
// common points
int xoffset = x - ox;
int yoffset = oy - y; // openGl invert y coordinate
int *pt1 = f->getPoint(1)->getCoords();
int *pt2 = f->getPoint(2)->getCoords();
// move coordinates basing on offsets
Point *p1 = new Point(pt1[0] + xoffset, pt1[1] + yoffset);
f->setPoint(1, p1);
Point *p2 = new Point(pt2[0] + xoffset, pt2[1] + yoffset);
f->setPoint(2, p2);
if (Triangle *t = dynamic_cast<Triangle*>(f)) {
int *pt3 = t->getPoint(3)->getCoords();
Point *p3 = new Point(pt3[0] + xoffset, pt3[1] + yoffset);
t->setPoint(3, p3);
}
else if (Quad *q = dynamic_cast<Quad*>(f)) {
int *pt3 = q->getPoint(3)->getCoords();
int *pt4 = q->getPoint(4)->getCoords();
Point *p3 = new Point(pt3[0] + xoffset, pt3[1] + yoffset);
q->setPoint(3, p3);
Point *p4 = new Point(pt4[0] + xoffset, pt4[1] + yoffset);
q->setPoint(4, p4);
}
}
ox = x; // refresh coordinates
oy = y;
}
// show the figure while creating
switch(figType) {
case LINE: {
Line *l = (Line*) figureSet.back();
l->setPoint(2, p);
break;
}
case TRIANGLE: {
Triangle *t = (Triangle*) figureSet.back();
t->setTriangle(p);
break;
}
case QUAD: {
Quad *q = (Quad*) figureSet.back();
q->setQuad(p);
break;
}
}
glutPostRedisplay();
}