+//------------------------------------------------------------------------
+void WidgetShowNPoints::MovePoint_(double step)
+{
+ step=step*2;
+
+ StopAutoAddPoints();
+ StopTrackPoint();
+
+ int id=GetModelShowNPoints()->GetIdCurrentPoint();
+ if (aux_mesh!=NULL)
+ {
+ if((GetLstModelShowNPointsSize()>=2) //Check condition
+ && (GetModelShowNPoints()->GetLstPointsSize()>0)
+ && (aux_mesh != NULL)
+ && (aux_mesh_spc.size() == 3))
+ {
+ double x,y,z;
+ double p[3];
+ double normal[3];; // point to modify and normal
+ std::vector<double> pN(3); // new point
+ vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New();
+ pointLocator->SetDataSet( aux_mesh );
+ pointLocator->BuildLocator();
+
+ // int idControlPoint = wsp->GetModelShowNPoints()->GetNearestPoint();
+ int idControlPoint = GetModelShowNPoints()->GetIdCurrentPoint();
+
+ if(idControlPoint >= 0)
+ {
+ GetModelShowNPoints()->GetIdPoint(idControlPoint, &x, &y, &z);
+ p[0] = x * aux_mesh_spc[0];
+ p[1] = y * aux_mesh_spc[1];
+ p[2] = z * aux_mesh_spc[2];
+ int idMeshPoint = pointLocator->FindClosestPoint(p);
+ aux_mesh->GetPointData()->GetNormals()->GetTuple(idMeshPoint, normal);
+ int direction = step;
+// pN[0] = p[0] / spc[0] + direction*normal[0];
+// pN[1] = p[1] / spc[1] + direction*normal[1];
+// pN[2] = p[2] / spc[2] + direction*normal[2];
+ pN[0] = x + direction*normal[0];
+ pN[1] = y + direction*normal[1];
+ pN[2] = z + direction*normal[2];
+
+ GetModelShowNPoints()->SetPointById(idControlPoint, pN);
+ // GetViewShowNPoints()->RefreshPoint(idControlPoint);
+// RefreshCollectionText();
+// RefreshColourCollection();
+// SetOutputBox();
+ UndoRedo_SaveCollection();
+ } // if idControlPoint
+ } // if wsp->GetLstModelShowNPointsSiz->size()>=2
+
+ } else {
+ printf("EED WidgetShowNPoints::MovePoint_ BB \n" );
+ if (id>=0) {
+ int i,j,sizeG,sizeP;
+ double max=100000;
+ double minX=max,minY=max,minZ=max;
+ double maxX=-max,maxY=-max,maxZ=-max;
+ sizeG = lstModelShowNPoints.size();
+ for (i=0; i<sizeG; i++)
+ {
+ std::vector<double> lstX = lstModelShowNPoints[i]->GetLstPointsX();
+ std::vector<double> lstY = lstModelShowNPoints[i]->GetLstPointsY();
+ std::vector<double> lstZ = lstModelShowNPoints[i]->GetLstPointsZ();
+ sizeP=lstX.size();
+ for (j=0; j<sizeP; j++)
+ {
+ if ( lstX[j]<minX ) { minX=lstX[j]; }
+ if ( lstY[j]<minY ) { minY=lstY[j]; }
+ if ( lstZ[j]<minZ ) { minZ=lstZ[j]; }
+ if ( lstX[j]>maxX ) { maxX=lstX[j]; }
+ if ( lstY[j]>maxY ) { maxY=lstY[j]; }
+ if ( lstZ[j]>maxZ ) { maxZ=lstZ[j]; }
+ } // for j
+ } // for i
+ double pc[3];
+ pc[0]=(minX+maxX) /2 ; pc[1]=(minY+maxY) /2 ; pc[2]=(minZ+maxZ) /2 ;
+ double p[3];
+ p[0]=GetModelShowNPoints()->GetLstPointsX()[id];
+ p[1]=GetModelShowNPoints()->GetLstPointsY()[id];
+ p[2]=GetModelShowNPoints()->GetLstPointsZ()[id];
+ double v[3];
+ v[0] = p[0]-pc[0];
+ v[1] = p[1]-pc[1];
+ v[2] = p[2]-pc[2];
+ double mag=sqrt ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
+
+ std::vector<double> point;
+ if (mag!=0)
+ {
+ v[0] = v[0]/mag;
+ v[1] = v[1]/mag;
+ v[2] = v[2]/mag;
+ } else {
+ v[0] = 0;
+ v[1] = 0;
+ v[2] = 0;
+ }// if mag
+ point.push_back( p[0] + step*v[0] );
+ point.push_back( p[1] + step*v[1] );
+ point.push_back( p[2] + step*v[2] );
+ GetModelShowNPoints()->SetPointById(id,point);
+ UndoRedo_SaveCollection();
+
+ } // if id
+
+ } // if aux_mesh
+
+ RefreshCollectionText();
+ RefreshColourCollection();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnMovePointUp(wxCommandEvent& event)
+{
+ MovePoint_(-1);
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnMovePointDown(wxCommandEvent& event)
+{
+ MovePoint_(+1);
+}
+