bool Board::move(const char* from,const char* to ) { unsigned int fromX = from[1] - '1'; unsigned int fromY = from[0] - 'a'; unsigned int toX = to[1] - '1'; unsigned int toY = to[0] - 'a'; Figure* figure = getFigure(Position(fromX, fromY)); if (figure == NULL) { return false; } if (figure->figureColor != moveTurn) { return false; } if (figure->move(Position(toX, toY))) { //change turn moveTurn = !moveTurn; return true; } else { return false; } }
void List::moveAllSelected(int x, int y) { Node *p = head; while (p != NULL) { Figure *f = p->getData(); if (f->getSelected()) f->move(x, y); p = p->getNext(); } }
void Vehicle::move(int x,int y) { FigureLink *p=content.GetNext(); Figure *cast; while(/*p->GetNext()!=NULL*/1) { cast=p->Get(); cast->move(x,y); p=p->GetNext(); if(p==0) return; } }
void on_mouse(int event, int x, int y, int flags, void* param) { switch(event) { case CV_EVENT_LBUTTONUP://evento del boton cuando se suelta window.followmousemove = 0; if(figure.task != '9') { figure.lp.x=x; figure.lp.y=y; } else { window.refresh(); figure.task = '?'; } if(figure.drawtype != '?' ) list.push_back(figure); drawList(window.image, list); break; case CV_EVENT_LBUTTONDOWN://evento del boton cuando se presiona xx = x; yy = y; window.followmousemove = 1; if(variable[3] != 9 && variable[3]<50) { figure = Figure(variable[0],variable[1],variable[2]); figure.fp.x=x; figure.fp.y=y; figure.drawtype=variable[3]; } else { figure = find(x,y,list); if(variable[4]==50 || variable[4]==75 || variable[4]==125 || variable[4]==150) { figure.setZoom((float)variable[4]/100); figure.task = '9'; } if(variable[0]!=-1 && variable[1]!=-1 && variable[2]!=-1) { figure.setColor(variable[0],variable[1],variable[2]); figure.task = '9'; } if(variable[3]==9) figure.task = '9'; } break; } if(CV_EVENT_MOUSEMOVE==event && window.followmousemove == 1)//evento del boton en movimiento { window.refresh(); if(figure.task == '9') { figure.move(x-xx,y-yy); xx=x; yy=y; } else { figure.lp.x = x; figure.lp.y = y; } figure.draw(window.image); drawList(window.image, list); } }
void Group::move(int movemode, int dx, int dy) { switch (movemode) { case 0:{ //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); pObj->move(movemode, dx, dy); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->move(movemode, dx, dy); } point.x += dx; point.y += dy; point_end.x += dx; point_end.y += dy; break; } case 1:{ //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); if (pObj->thisobject() == LINE || pObj->thisobject() == POLYLINE || pObj->thisobject() == FREECURVE) ; else pObj->move(movemode, dx, dy); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->move(movemode, dx, dy); } point.x += dx; point.y += dy; break; } case 3:{ //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); if (pObj->thisobject() == LINE || pObj->thisobject() == POLYLINE || pObj->thisobject() == FREECURVE) ; else pObj->move(movemode, dx, dy); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->move(movemode, dx, dy); } point.y += dy; point_end.x += dx; break; } case 5:{ //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); if (pObj->thisobject() == LINE || pObj->thisobject() == POLYLINE || pObj->thisobject() == FREECURVE) ; else pObj->move(movemode, dx, dy); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->move(movemode, dx, dy); } point_end.x += dx; point_end.y += dy; break; } case 7:{ //노드 데이터 변경 POSITION posNode = NodeData.GetHeadPosition(); while (posNode) { Figure* pObj = (Figure*)NodeData.GetNext(posNode); if (pObj->thisobject() == LINE || pObj->thisobject() == POLYLINE || pObj->thisobject() == FREECURVE) ; else pObj->move(movemode, dx, dy); } //차일드 데이터 변경(recursion이 일어남) POSITION posChild = Child.GetHeadPosition(); while (posChild) { Group* pGroup = (Group*)Child.GetNext(posChild); pGroup->move(movemode, dx, dy); } point.x += dx; point_end.y += dy; break; } } }