void ProfileScene::moveVertex() { // we have have at least one vertex on the profile plan, if we click on it, we can move it if (isProfileSelected){ Vertex* currentVertex = currentProfile->getProfileVertex(); // find which vertex we have selected while(currentVertex != 0) { QGraphicsEllipseItem* ellipse = currentVertex->getEllipse(); if (ellipse->isUnderMouse()) { // cannot move the first vertex if (currentVertex->getNeighbor1() == 0) { return; } isVertexMoving = true; currentlyMovingVertex = currentVertex; // tell the meshManager to generate new point/triangle meshManager->setLongUpdateOnMesh(true); return; } currentVertex = currentVertex->getNeighbor2(); } } }
void FloorScene::removeVertex() { //remove point if clicked on a point FloorVertex* floorplan = mesh->getFloorPlan(); unsigned int floorPlanSize = mesh->getFloorPlanSize(); if (floorPlanSize <= 3) { return; } Vertex* currentVertex = floorplan; //find if a vertex is under the mouse for (unsigned int i(0); i < floorPlanSize; ++i) { QGraphicsEllipseItem* ellipse = currentVertex->getEllipse(); if (ellipse->isUnderMouse()) { // first set the floorplan pointer in mesh to be the neighbor of the // currently deleted vertex. Because it can be the one pointed in // the mesh class used to iterate over the floorplan mesh->setFloorPlan((FloorVertex*)currentVertex->getNeighbor2()); // we find one vertex to remove under the mouse, we remove it QGraphicsLineItem* newEdge = currentVertex->removeVertex(); QGraphicsLineItem* oldEdge1 = currentVertex->getEdge1(); QGraphicsLineItem* oldEdge2 = currentVertex->getEdge2(); this->removeItem(ellipse); this->removeItem(oldEdge1); this->removeItem(oldEdge2); //update normals of the two neighbor FloorVertex* neighbor1 = (FloorVertex*)currentVertex->getNeighbor1(); FloorVertex* neighbor2 = (FloorVertex*)currentVertex->getNeighbor2(); neighbor1->computeNormal(); neighbor2->computeNormal(); this->addItem(newEdge); delete oldEdge1; delete oldEdge2; delete ellipse; delete currentVertex; mesh->decrementFloorPlanSize(); // tell the mesh to generate new point/triangle mesh->setUpdateOnMesh(); break; } currentVertex = currentVertex->getNeighbor2(); } }
void FloorScene::moveVertex() { unsigned int floorPlanSize = mesh->getFloorPlanSize(); // find which vertex we have selected Vertex* currentVertex = mesh->getFloorPlan(); for (unsigned int i(0); i < floorPlanSize; ++i) { QGraphicsEllipseItem* ellipse = currentVertex->getEllipse(); if (ellipse->isUnderMouse()) { isVertexMoving = true; currentlyMovingVertex = (FloorVertex*)currentVertex; newProfileSelected(((FloorVertex*)currentVertex)->getProfile()); // tell the mesh to generate new point/triangle mesh->setLongUpdateOnMesh(true); break; } currentVertex = currentVertex->getNeighbor2(); } }
void ProfileScene::removeVertex() { //remove point if clicked on a point Vertex* currentVertex = currentProfile->getProfileVertex(); bool foundVertex(false); QGraphicsEllipseItem* ellipse; while(currentVertex != 0) { ellipse = currentVertex->getEllipse(); if (ellipse->isUnderMouse()) { foundVertex = true; break; } currentVertex = currentVertex->getNeighbor2(); } // cannot remove if we do not find the vertex or if it is the first one if (foundVertex && currentVertex->getNeighbor1() != 0) { Edge* newEdge = currentVertex->removeVertex(); this->removeItem(ellipse); Edge* oldEdge1 = currentVertex->getEdge1(); Edge* oldEdge2 = currentVertex->getEdge2(); if (currentVertex->getNeighbor1() != 0) { this->removeItem(oldEdge1->getLineItem()); delete oldEdge1->getLineItem(); delete oldEdge1; } if (currentVertex->getNeighbor2() != 0) { this->removeItem(oldEdge2->getLineItem()); delete oldEdge2->getLineItem(); delete oldEdge2; } if (newEdge != 0) { this->addItem(newEdge->computeLineItem()); } delete ellipse; delete currentVertex; // tell the meshManager to generate new point/triangle meshManager->setUpdateOnMesh(); } }