: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
{
// EED 2022-05-19
- // mmodelShowNPoints = new ModelShowNPoints();
- mActualCollection= 0;
- ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
+ // mmodelShowNPoints = new ModelShowNPoints();
+ idUndoRedo = 0;
+ maxUndoRedo = 0;
+ UndoRedoDir = "/tmp";
+
+ mActualCollection = 0;
+ ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
lstModelShowNPoints.push_back( modelShowNPoints );
lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
+ wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
+ wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
wxButton *btnSavePoints = NULL;
wxButton *btnLoadPoints = NULL;
Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
} // if mtype 0 3
-
Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
- Connect(cbTrackPoint->GetId() , wxEVT_CHECKBOX , (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
-
-
+ Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
+ Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
+ Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
wxFlexGridSizer *sizer4 = new wxFlexGridSizer(2);
-
- sizer1->Add(textCtrl);
- sizer1->Add(btnRenamePoint);
- sizer2->Add(btnAddPoint);
- sizer2->Add(btnInsertPoint);//CFT
- sizer3->Add(btnSetPositionPoint);
- sizer3->Add(cbTrackPoint);
- sizer4->Add(btnErasePoint);
- sizer4->Add(btnEraseLastPoint);
- sizer4->Add(btnDeleteAllPoints);
-
+ wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
+ sizer1->Add( textCtrl );
+ sizer1->Add( btnRenamePoint );
+ sizer2->Add( btnAddPoint );
+ sizer2->Add( btnInsertPoint );//CFT
+ sizer3->Add( btnSetPositionPoint );
+ sizer3->Add( cbTrackPoint );
+ sizer4->Add( btnErasePoint );
+ sizer4->Add( btnEraseLastPoint );
+ sizer4->Add( btnDeleteAllPoints );
+ sizer5->Add( btnUndo );
+ sizer5->Add( btnRedo );
// sizer0->Add(askPointLabel); // JPR
sizer0->Add(txtNrPoints);
sizer0->Add(sizer2);
sizer0->Add(sizer1);
sizer0->Add(sizer3);
sizer0->Add(sizer4);
-
+ sizer0->Add(sizer5);
if ( (mtype==0) || (mtype==3) )
{
wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
sizer = sizer1;
} // bbGetInputType 2
-
- panel->SetSizer(sizer);
- panel->SetAutoLayout(true);
- panel->Layout();
- bookSetPoints->AddPage(panel , _T("Points") );
+ panel->SetSizer(sizer);
+ panel->SetAutoLayout(true);
+ panel->Layout();
+ bookSetPoints->AddPage(panel , _T("Points") );
if ((mtype >= 0) && (mtype <= 3) )
{
//------------------------------------------------------------------------
void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
{
- printf("EED WidgetShowNPoints::OnAddPoint2 Start\n");
GetModelShowNPoints()->AddPoint(x,y,z, label );
// EED 2022-05-19
//AddVtkPoint();
//RefreshPoint(lstActorsSphere.size()-1);
GetViewShowNPoints()->AddPoint();
- printf("EED WidgetShowNPoints::OnAddPoint2 End\n");
}
//------------------------------------------------------------------------
void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
{
- printf("EED WidgetShowNPoints::InsertPoint2 Start\n");
// EED 2022-05-19
//if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
//{
AddPoint(x,y,z,label);
}
GetViewShowNPoints()->RefreshPoints();
- printf("EED WidgetShowNPoints::InsertPoint2 End\n");
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnInsertPoint_()
{
- printf("EED WidgetShowNPoints::InsertPoint_ Start\n");
// EED 2022-05-19
//if (this->renderer==NULL)
if (GetViewShowNPoints()->renderer==NULL)
{
return;
}
-
std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
if (point.size()==3)
{
} else {//mpoint.size
printf("creaMaracasVisu::ShowNPoints (not match point) \n");
}
- printf("EED WidgetShowNPoints::InsertPoint_ End\n");
}
-
-
//------------------------------------------------------------------------
void WidgetShowNPoints::OnAddPoint_()
{
- printf("EED WidgetShowNPoints::OnAddPoint_ Start\n");
// EED 2022-05-19
//if (this->renderer==NULL)
if (GetViewShowNPoints()->renderer==NULL)
{
return;
}
-
std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
if (point.size()==3)
{
AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
- SetOutputBox();
+ SetOutputBox();
// EED 2022-05-19
//renderer->GetRenderWindow()->Render();
GetViewShowNPoints()->Render();
} else {//mpoint.size
printf("creaMaracasVisu::ShowNPoints (not match point) \n");
}
- printf("EED WidgetShowNPoints::OnAddPoint_ End\n");
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
{
- printf("EED WidgetShowNPoints::OnAddPoint Start\n");
OnAddPoint_();
- printf("EED WidgetShowNPoints::OnAddPoint End\n");
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
{
OnInsertPoint_();
+ UndoRedo_SaveCollection();
}
void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
{
OnSetPoint_();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
GetViewShowNPoints()->RefreshPoint(idTrack);
GetViewShowNPoints()->Render();
+ UndoRedo_SaveCollection();
} // if id
} // if trackPointFlag
}
GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
GetViewShowNPoints()->Render();
SetOutputBox();
- }
+ UndoRedo_SaveCollection();
+ } // if id
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
{
OnErasePoint_();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
//renderer->GetRenderWindow()->Render();
int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
ErasePoint( id );
+ UndoRedo_SaveCollection();
GetViewShowNPoints()->Render();
SetOutputBox();
StopTrackPoint();
for (id=size-1;id>=0;id--)
{
ErasePoint(id);
- }
+ }// for id
SetOutputBox();
- // EED 2022-05-19
- //renderer->GetRenderWindow()->Render();
- GetViewShowNPoints()->Render();
}
void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
{
DeleteAllPoints();
+ GetViewShowNPoints()->Render();
+ UndoRedo_SaveCollection();
}
//NTU: Method for updating points opacity and Radio
view->renderer = lstViewShowNPoints[0]->renderer;
lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
- RefreshCollectionText();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
{
InsertCollection();
+ RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
}
{
mActualCollection++;
InsertCollection();
+ RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
}
void WidgetShowNPoints::OnDeleteCollection_()
{
DeleteCollection_();
+ GetViewShowNPoints()->Render();
RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
{
OnDeleteCollection_();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnResetCollections_()
{
- printf("EED WidgetShowNPoints::OnResetCollections_ \n");
int i,size=lstModelShowNPoints.size();
for (i=0;i<size;i++)
{
DeleteCollection_();
}
+ GetViewShowNPoints()->Render();
RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
{
OnResetCollections_();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
RefreshCollectionText();
RefreshColourCollection();
StopTrackPoint();
+ UndoRedo_SaveCollection();
}
//------------------------------------------------------------------------
} // if mtype 4
}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnSaveCollections_( std::string filename )
+{
+ FILE *ff;
+ ff = fopen( filename.c_str() , "w+" );
+ if (ff!=NULL)
+ {
+ int i,size = lstModelShowNPoints.size();
+ fprintf(ff,"NumberOfGroups %d \n",size);
+ for (i=0 ; i<size ; i++)
+ {
+ lstModelShowNPoints[i]->SavePoints_(ff);
+ } // for i
+ fclose(ff);
+ } else { // else ff
+ printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
+ } //ff
+
+}
+
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
{
if (FD->GetReturnCode()==wxID_OK)
{
std::string filename= (const char*) ( FD->GetPath().mb_str() );
-
- FILE *ff;
- ff = fopen( filename.c_str() , "w+" );
- if (ff!=NULL)
- {
- int i,size=lstModelShowNPoints.size();
- fprintf(ff,"NumberOfGroups %d \n",size);
-
- for (i=0;i<size;i++)
- {
- lstModelShowNPoints[i]->SavePoints_(ff);
- } // for i
-
- fclose(ff);
- } else { // else ff
- printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
- } //ff
-
-
+ OnSaveCollections_( filename );
} // dialog box
StopTrackPoint();
+}
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnLoadCollections_( std::string filename )
+{
+ bool okEraseFirstGroup=false;
+ if (lstModelShowNPoints.size()==1)
+ {
+ if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
+ }
+ FILE *ff = fopen( filename.c_str() , "r+" );
+ if (ff!=NULL)
+ {
+ int i;
+ int iGroup,sizeGroups;
+ int iPoint,numberPointsRead;
+ char chartmp[256];
+ fscanf(ff," %s %d",chartmp,&sizeGroups);
+ for (iGroup=0;iGroup<sizeGroups;iGroup++)
+ {
+ mActualCollection = lstModelShowNPoints.size();
+ InsertCollection();
+ int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
+ for (i=0;i<numberPointsRead;i++)
+ {
+ // EED 2022-05-19
+ //AddVtkPoint();
+ GetViewShowNPoints()->AddVtkPoint();
+ }// for
+ } // for i
+
+ fclose(ff);
+ } else { // else ff
+ printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
+ } //ff
+ if (okEraseFirstGroup==true)
+ {
+ mActualCollection=0;
+ DeleteCollection_();
+ mActualCollection = lstModelShowNPoints.size()-1;
+ }
+ GetViewShowNPoints()->Render();
+ RefreshCollectionText();
+ RefreshColourCollection();
+ StopTrackPoint();
}
//------------------------------------------------------------------------
wxFD_OPEN | wxFD_FILE_MUST_EXIST,
wxDefaultPosition);
#endif
- bool okEraseFirstGrout=false;
-
int result_FD = FD->ShowModal();
// This line is need it by windows //EED
FD->SetReturnCode( result_FD );
if (FD->GetReturnCode()==wxID_OK)
{
- if (lstModelShowNPoints.size()==1)
- {
- if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGrout=true; }
- }
std::string filename= (const char*) ( FD->GetPath().mb_str() );
- FILE *ff = fopen( filename.c_str() , "r+" );
- if (ff!=NULL)
- {
- int i;
- int iGroup,sizeGroups;
- int iPoint,numberPointsRead;
- char chartmp[256];
- fscanf(ff," %s %d",chartmp,&sizeGroups);
- for (iGroup=0;iGroup<sizeGroups;iGroup++)
- {
- mActualCollection = lstModelShowNPoints.size();
- InsertCollection();
-
- int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
- for (i=0;i<numberPointsRead;i++)
- {
- // EED 2022-05-19
- //AddVtkPoint();
- GetViewShowNPoints()->AddVtkPoint();
- }// for
- } // for i
-
- fclose(ff);
- } else { // else ff
- printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
- } //ff
- if (okEraseFirstGrout==true)
- {
- mActualCollection=0;
- DeleteCollection_();
- mActualCollection = lstModelShowNPoints.size()-1;
- }
- RefreshCollectionText();
- RefreshColourCollection();
+ OnLoadCollections_( filename );
+ UndoRedo_SaveCollection();
} // dialog box
- StopTrackPoint();
}
} // for iM
SetOutputBox();
}
+
+
+//------------------------------------------------------------------------
+std::string WidgetShowNPoints::GetUndoRedoFileName()
+{
+ char buff[20];
+ sprintf(buff,"%p_%d",this, idUndoRedo);
+ return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
+}
+
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
+{
+ OnResetCollections_();
+// if (idUndoRedo==maxUndoRedo+1)
+// {
+// idUndoRedo--;
+// } // if idUndoRedo+1
+ idUndoRedo--;
+ idUndoRedo--;
+ printf("EED WidgetShowNPoints::OnUndo %d %d\n", idUndoRedo, maxUndoRedo);
+ if (idUndoRedo<0)
+ {
+ idUndoRedo=-1;
+ } else {
+ OnLoadCollections_( GetUndoRedoFileName() );
+ }// if idUndoRedo
+ idUndoRedo++;
+
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
+{
+ printf("EED WidgetShowNPoints::OnRedo A %d %d\n", idUndoRedo, maxUndoRedo);
+ if (idUndoRedo>maxUndoRedo)
+ {
+ idUndoRedo=maxUndoRedo+1;
+ } else {
+ OnResetCollections_();
+ OnLoadCollections_( GetUndoRedoFileName() );
+ idUndoRedo++;
+ }// if idUndoRedo
+
+ printf("EED WidgetShowNPoints::OnRedo B %d %d\n", idUndoRedo, maxUndoRedo);
+
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::UndoRedo_SaveCollection()
+{
+ printf("EED \n EED WidgetShowNPoints::UndoRedo_SaveCollection %d %d\n", idUndoRedo, maxUndoRedo);
+ OnSaveCollections_( GetUndoRedoFileName() );
+ maxUndoRedo = idUndoRedo;
+ idUndoRedo++;
+ printf("EED WidgetShowNPoints::UndoRedo_SaveCollection %d %d\n", idUndoRedo, maxUndoRedo);
+}
+
+