}
+//------------------------------------------------------------------------
+void ModelShowNPoints::SavePoints_(FILE* ff)
+{
+ std::string tmpLabel;
+ int i , size = (int) (lstPointsX.size());
+ fprintf(ff,"NumberOfPoints %d \n",size);
+ fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
+ int x, y, z;
+ double value;
+ for (i=0; i<size; i++)
+ {
+ x = lstPointsX[i];
+ y = lstPointsY[i];
+ z = lstPointsZ[i];
+ value = mimage->GetScalarComponentAsDouble(x,y,z,0);
+ if (lstLabels[i]!="")
+ {
+ tmpLabel=lstLabels[i];
+ } else{
+ tmpLabel="<_VOID_>";
+ }
+ fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
+ } // for
+}
+
//------------------------------------------------------------------------
void ModelShowNPoints::SavePoints(std::string filename)
{
- std::string tmpLabel;
- FILE *ff;
- ff = fopen( filename.c_str() , "w+" );
- if (ff!=NULL)
- {
- int i , size = (int) (lstPointsX.size());
- fprintf(ff,"NumberOfPoints %d \n",size);
- fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
- int x, y, z;
- double value;
- for (i=0; i<size; i++)
- {
- x=lstPointsX[i];
- y=lstPointsY[i];
- z=lstPointsZ[i];
- value= mimage->GetScalarComponentAsDouble(x,y,z,0);
- if (lstLabels[i]!="")
- {
- tmpLabel=lstLabels[i];
- } else{
- tmpLabel="<_VOID_>";
- }
- fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
- } // for
+ FILE* ff = fopen( filename.c_str() , "w+" );
+ if (ff!=NULL)
+ {
+ SavePoints_(ff);
fclose(ff);
} else { // else ff
- printf("ModelShowNPoints::SavePoints ...Error... creating file");
+ printf("ModelShowNPoints::SavePoints ...Error... creating file\n");
} //ff
}
+//------------------------------------------------------------------------
+int ModelShowNPoints::ReadPoints_(FILE* ff)
+{
+ int i,size;
+ char chartmp[256];
+ fscanf(ff," %s %d",chartmp,&size);
+ fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
+
+ float value;
+ int x,y,z;
+ for (i=0; i<size; i++)
+ {
+ fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
+ if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
+ AddPoint(x,y,z, chartmp );
+ }
+ return size;
+}
+
//------------------------------------------------------------------------
int ModelShowNPoints::ReadPoints(std::string filename)
{
- int i,size;
- char chartmp[256];
- FILE *ff;
- ff = fopen( filename.c_str() , "r+" );
+ int size=0;
+ FILE *ff = fopen( filename.c_str() , "r+" );
if (ff!=NULL)
{
- fscanf(ff," %s %d",chartmp,&size);
- fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
-
- float value;
- int x,y,z;
- for (i=0; i<size; i++)
- {
- fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
- if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
- AddPoint(x,y,z, chartmp );
- }
+ size = ReadPoints_(ff);
fclose(ff);
} else { // else ff
printf("ModelShowNPoints::LoadPoints ...Error... reading file");
wxPanel* panel = NULL;
wxPanel* panel2 = NULL;
-
-
-
bookSetPoints = new wxNotebook(panelParent,
-1,
wxDefaultPosition,
txtNrCollections = new wxStaticText(panel2,-1, _T("1 / 1 "));
wxButton *btnBackCollection = new wxButton( panel2, -1, _T("<"));
wxButton *btnNextCollection = new wxButton( panel2, -1, _T(">"));
- wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("Insert Before"));
- wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("Insert After"));
- wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("Delete"));
-
- Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore);
- Connect(btnInsertCollectionAfter->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter);
- Connect(btnDeleteCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection);
- Connect(btnBackCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection);
- Connect(btnNextCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection);
+ wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("Insert Group Before"));
+ wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("Insert Group After"));
+ wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("Delete Group "));
+ wxButton *btnSaveCollection = new wxButton( panel2, -1, _T("Save Groups"));
+ wxButton *btnLoadCollection = new wxButton( panel2, -1, _T("Load Groups"));
+
+ //NTU: Sliders for opacity and radio change
+ wxStaticText* txOpacity = new wxStaticText(panel2, -1, wxString(_T(" Points Opacity ")));
+ sdrOpacity = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ wxStaticText* txRadio = new wxStaticText(panel2, -1, wxString(_T(" Points Radius ")));
+ sdrRadio = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ //NTU: Slider events
+ Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+ Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+
+ Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore );
+ Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter );
+ Connect(btnDeleteCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection );
+ Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection );
+ Connect(btnSaveCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections );
+ Connect(btnLoadCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections );
wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
sizer1->Add( btnInsertCollectionBefore );
sizer1->Add( btnInsertCollectionAfter );
sizer1->Add( btnDeleteCollection );
+
+ sizer1->Add( txOpacity );
+ sizer1->Add( sdrOpacity );
+ sizer1->Add( txRadio );
+ sizer1->Add( sdrRadio );
+
+ sizer1->Add( btnSaveCollection );
+ sizer1->Add( btnLoadCollection );
MNPsizer = sizer1;
panel2->SetSizer( MNPsizer );
panel2->SetAutoLayout(true);
panel2->Layout();
- bookGroupManager->AddPage(panel2 , _T("Collection") );
+ bookGroupManager->AddPage(panel2 , _T("Groupts") );
} // if mtype 4
if ( (mtype==0) || (mtype==3) || (mtype==4) )
wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
wxButton *btnSavePoints = NULL;
wxButton *btnLoadPoints = NULL;
- if ( (mtype==0) || (mtype==4) )
+ if ( mtype==0 )
{
btnSavePoints = new wxButton( panel, -1, _T("Save points"));
btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
+ Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
+ Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
} // if mtype
txtNrPoints = new wxStaticText(panel,-1, _T(" "));
- //NTU: Sliders for opacity and radio change
- wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
- sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
- wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
- sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ wxStaticText* txOpacity;
+ wxStaticText* txRadio;
+ if ( (mtype==0) || (mtype==3) )
+ {
+ //NTU: Sliders for opacity and radio change
+ txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
+ sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
+ sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+ //NTU: Slider events
+ 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(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);
- if ((mtype==0) || (mtype==4) )
- {
- Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
- Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
- }
- //NTU: Slider events
- Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
- Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+
wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
sizer1->Add(askPointLabel); // JPR
sizer1->Add(btnEraseLastPoint);
sizer1->Add(btnDeleteAllPoints);
sizer1->Add(txtNrPoints);
- sizer1->Add(txOpacity);
- sizer1->Add(sdrOpacity,1,wxGROW );
- sizer1->Add(txRadio);
- sizer1->Add(sdrRadio,1,wxGROW );
- if ((mtype==0) || (mtype==4) )
+
+ if ( (mtype==0) || (mtype==3) )
+ {
+ sizer1->Add(txOpacity);
+ sizer1->Add(sdrOpacity,1,wxGROW );
+ sizer1->Add(txRadio);
+ sizer1->Add(sdrRadio,1,wxGROW );
+ } // if mtype 0 3
+ if ( mtype==0 )
{
sizer1->Add(btnSavePoints);
sizer1->Add(btnLoadPoints);
- }
+ } // if mtype 0
sizer = sizer1;
}
panel->SetSizer(sizer);
panel->SetAutoLayout(true);
panel->Layout();
- bookSetPoints->AddPage(panel , _T("Set Points") );
+ bookSetPoints->AddPage(panel , _T("Points") );
if ((mtype >= 0) && (mtype <= 3) )
{
lstViewShowNPoints[i]->mopacity = opacity;
lstModelShowNPoints[i]->SetRadio( radio ) ;
} // for i
- GetViewShowNPoints()->RefreshPoints();
+// GetViewShowNPoints()->RefreshPoints();
+ RefreshColourCollection();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
{
InsertCollection();
+ RefreshColourCollection();
}
//------------------------------------------------------------------------
{
mActualCollection++;
InsertCollection();
+ RefreshColourCollection();
}
//------------------------------------------------------------------------
{
mActualCollection--;
} // if
- }
+ } else {
+ DeleteAllPoints(); // Actual Collection
+ } // if
+
RefreshCollectionText();
+ RefreshColourCollection();
}
//------------------------------------------------------------------------
mActualCollection=0;
} //if <=0
RefreshCollectionText();
+ RefreshColourCollection();
}
//------------------------------------------------------------------------
mActualCollection = lstModelShowNPoints.size()-1;
} //if <=0
RefreshCollectionText();
+ RefreshColourCollection();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::RefreshColourCollection()
+{
+ std::vector<double> colourAll;
+ colourAll.push_back(1);
+ colourAll.push_back(0);
+ colourAll.push_back(0);
+ std::vector<double> colourActual;
+ colourActual.push_back(1);
+ colourActual.push_back(1);
+ colourActual.push_back(0);
+ SetColour( colourAll ); // For all collections
+
+ int i,size=lstViewShowNPoints.size();
+ for (i=0;i<size;i++)
+ {
+ lstViewShowNPoints[i] -> mcolour = colourAll; // All collection
+ lstViewShowNPoints[i]->RefreshEachPoint();
+ } // for i
+ lstViewShowNPoints[mActualCollection] -> mcolour = colourActual; // Actual collection
+ lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
+ lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
}
//------------------------------------------------------------------------
txtNrCollections->SetLabel( strTmp );
SetOutputBox();
}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
+{
+ //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+ #if wxMAJOR_VERSION <= 2
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Save groups of points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxSAVE | wxOVERWRITE_PROMPT,
+ wxDefaultPosition);
+ #else
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Save groups of points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+ wxDefaultPosition);
+ #endif
+
+ int result_FD = FD->ShowModal();
+ // This line is need it by windows //EED
+ FD->SetReturnCode( result_FD );
+ 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
+
+
+ } // dialog box
+
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
+{
+ //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+ #if wxMAJOR_VERSION <= 2
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Load groups of points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxOPEN | wxFILE_MUST_EXIST,
+ wxDefaultPosition);
+ #else
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Load groups of points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxFD_OPEN | wxFD_FILE_MUST_EXIST,
+ wxDefaultPosition);
+ #endif
+ int i;
+ //EED
+ int result_FD = FD->ShowModal();
+ // This line is need it by windows //EED
+ FD->SetReturnCode( result_FD );
+ if (FD->GetReturnCode()==wxID_OK)
+ {
+
+ FILE *ff = fopen( filename.c_str() , "r+" );
+ if (ff!=NULL)
+ {
+ int iGroup,sizeGroups;
+ int iPoint,numberPointsRead
+ char chartmp[256];
+ fscanf(ff," %s %d",chartmp,&sizeGroups);
+
+ /// InsertCollection();
+
+ for (iGroup=0;i<sizeGroups;i++)
+ {
+ int numberPointsRead= lstModelShowNPoints?????????[i]->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
+
+ RefreshCollectionText();
+ RefreshColourCollection();
+
+ } // dialog box
+
+///
+
+}