HistogramDialogComboBox::HistogramDialogComboBox(wxWindow* parent)
: wxPanel(parent)
{
- _img = NULL;
+ _img = NULL;
_bitmapcombo = NULL;
_slidercolor = NULL;
- _sliderwindowlevel = NULL;
+ _sliderwindowlevel = NULL;
colorBar_Bitmap = NULL;
_bitmapsizer = NULL;
this->SetSizer(getBitmapCombo());
- _img = NULL;
+ _img = NULL;
_currentitem = -1;
_maxgreyvalue = 0;
-printf("EED HistogramDialogComboBox\n");
+printf("EED HistogramDialogComboBox\n");
+#ifdef LINUX
+ std::string currentpath = crea::System::GetExecutablePath();
+
+
+ currentpath.append("../share/creaMaracasVisu/data/");
+printf("EED JCP OOOOJJJOOO cambiar esto HistogramDialogComboBox::HistogramDialog writting in this directory\n");
+ currentpath = "/home/davila/dataHistogram";
+
+
+ crea::System::createDirectory(currentpath.c_str());
+#endif
}
HistogramDialogComboBox::~HistogramDialogComboBox()
-{
+{
}
void HistogramDialogComboBox::SetColors(std::vector<double> greyvect, std::vector<double> redvect, std::vector<double> greenvect, std::vector<double> bluevect)
_greyvect = greyvect;
_redvect = redvect;
_greenvect = greenvect;
- _bluevect = bluevect;
+ _bluevect = bluevect;
}
wxSizer* HistogramDialogComboBox::getBitmapCombo()
_bitmapcombo = getBitmapComboElements();
wxBitmap bitmap1(Edit_xpm);
- wxBitmapButton* edit = new wxBitmapButton(this, -1, bitmap1,wxDefaultPosition,wxSize(30,30));
- Connect(edit->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialogComboBox::OnEditBitmapCombo);
-
+ wxBitmapButton* edit = new wxBitmapButton(this, -1, bitmap1,wxDefaultPosition,wxSize(30,30));
+ Connect(edit->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialogComboBox::OnEditBitmapCombo);
+
comboeditsizer->Add(_bitmapcombo,wxSizerFlags().Center().FixedMinSize());
comboeditsizer->Add(edit,wxSizerFlags().Center());
-
_bitmapsizer->Add(comboeditsizer,wxSizerFlags().FixedMinSize().Center());
_bitmapsizer->AddSpacer(5);
_bitmapsizer->Add(getSlidersWlCo(),wxSizerFlags().Expand().Center());
return _bitmapsizer;
}
-wxSizer* HistogramDialogComboBox::getSlidersWlCo(){
+wxSizer* HistogramDialogComboBox::getSlidersWlCo()
+{
wxBoxSizer* sizersliders = new wxBoxSizer(wxVERTICAL);
_slidercolor = new wxSlider(this, -1,1,0,1,wxDefaultPosition,wxDefaultSize,wxSL_LABELS);
sizersliders->Add(_slidercolor,wxSizerFlags().Expand().Center());
sizersliders->Add(_sliderwindowlevel,wxSizerFlags().Expand().Center());
- Connect(_slidercolor->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnColorLevelChanged);
+ Connect(_slidercolor->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnColorLevelChanged);
Connect(_sliderwindowlevel->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnWindowLevelChanged);
return sizersliders;
double HistogramDialogComboBox::GetWindowLevel()
{
- if(_sliderwindowlevel != NULL)
- {
- return _sliderwindowlevel->GetValue();
- }
+ double val(0.0);
+ if(_sliderwindowlevel != NULL)
+ val= _sliderwindowlevel->GetValue();
+ return val; // JPR
}
double HistogramDialogComboBox::GetColorLevel()
{
- if(_slidercolor != NULL)
- {
- return _slidercolor->GetValue();
- }
+ double val(0.0);
+ if(_slidercolor != NULL)
+ val = _slidercolor->GetValue();
+ return val; // JPR
}
void HistogramDialogComboBox::OnColorLevelChanged(wxCommandEvent& event)
{
- _slidercolor->GetValue();
- wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
- ProcessEvent(newevent);
+ _slidercolor->GetValue();
+ wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+ ProcessEvent(newevent);
}
void HistogramDialogComboBox::OnWindowLevelChanged(wxCommandEvent& event)
{
- _sliderwindowlevel->GetValue();
- wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
- ProcessEvent(newevent);
+ _sliderwindowlevel->GetValue();
+ wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+ ProcessEvent(newevent);
}
void HistogramDialogComboBox::setImageData(vtkImageData* img)
{
- _maxgreyvalue = img->GetScalarRange()[1];
- _img = img;
- setSlidersValue();
+ _maxgreyvalue = img->GetScalarRange()[1];
+ _img = img;
+ setSlidersValue();
}
void HistogramDialogComboBox::setSlidersValue()
}
void HistogramDialogComboBox::OnEditBitmapCombo(wxCommandEvent& event)
-{
+{
if(_img!=NULL)
{
bool createaddandremovecontrols = true;
HistogramDialog* dialog = new HistogramDialog(this,_T("Color Configuration"),createaddandremovecontrols);
- dialog->initializeHistogram(_img);
+ dialog->initializeHistogram(_img);
dialog->setInfoPanExtraControls(_bitmapsitems);
if(dialog->ShowModal()==wxID_OK)
{
-
dialog->UpdateCurrentComboElement();
_bitmapsitems = dialog->getComboBoxItems();
-
- std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");
+ //std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu"); // JPR
+ std::string dllLastName;
+ std::string currentpath;
+ #ifdef WIN32
+ dllLastName = "bbcreaMaracasVisu";
+ currentpath = crea::System::GetDllAppPath(dllLastName);
+ #endif
+ #ifdef LINUX
+ currentpath = crea::System::GetExecutablePath();
+ currentpath.append("../share/creaMaracasVisu/data/");
+ #endif
currentpath.append(FILENAME);
std::vector<double> redvect,greenvect,bluevect;
}
_bitmapsitems.clear();
_bitmapcombo = getBitmapComboElements();
- if(_bitmapsizer->Replace(tempbitmapcombo,_bitmapcombo)){
-
+ if(_bitmapsizer->Replace(tempbitmapcombo,_bitmapcombo)){
+
tempbitmapcombo->Destroy();
}
this->Layout();
- }
+ }
dialog->Destroy();
}
}
void HistogramDialogComboBox::saveCurrentConfiguration(std::vector<HistogramDialogComboBoxItem*>& itembitmaps,std::string filename)
{
- std::ofstream file;
- file.open( (const char*) (filename.c_str()) );
+ std::ofstream file;
+ file.open( (const char*) (filename.c_str()) );
double gv=-1,red=-1,gr=-1,bl=-1;
int in=-1;
if(j==0){
file << " <TransferenceFunction>"<< std::endl;
}
- file << " <Transferencepoint>" << std::endl;
- file << " <greyValue>" << vecttransfer[j] << "</greyValue>" <<std::endl;
+ file << " <Transferencepoint>" << std::endl;
+ file << " <greyValue>" << vecttransfer[j] << "</greyValue>" <<std::endl;
file << " <intensity>" << value[j] << "</intensity> "<<std::endl;
file << " </Transferencepoint>" << std::endl;
if(j==vecttransfer.size()-1){
std::vector<double> green = item->getGreenVector();
std::vector<double> blue = item->getBlueVector();
for(int j = 0; j < greyv.size();j++)
- {
+ {
if(j==0){
file << " <Colors>" << std::endl;
}
file << " <red>" << red[j] << "</red>" <<std::endl;
file << " <green>" << green[j] << "</green>" <<std::endl;
file << " <blue>" << blue[j] << "</blue>" <<std::endl;
- file << " </greyValueRGBpoint>" << std::endl;
+ file << " </greyValueRGBpoint>" << std::endl;
if(j==greyv.size()-1){
file << " </Colors>" << std::endl;
}
}
- file << " </ComboBoxItem>"<< std::endl;
+ file << " </ComboBoxItem>"<< std::endl;
}
- file << "</ComboBoxData>" << std::endl;
+ file << "</ComboBoxData>" << std::endl;
}
file.close();
}
wxBitmapComboBox* HistogramDialogComboBox::getBitmapComboElements()
{
- std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");
+ std::string currentpath = "";
+#ifdef WIN32
+ currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");
+#endif
+#ifdef LINUX
+ currentpath = crea::System::GetExecutablePath();
+ currentpath.append("../share/CreaMaracasVisu/data/");
+
+printf("EED JCP OOOOJJJOOO cambiar esto HistogramDialogComboBox::HistogramDialog writting in this file ******************\n");
+ currentpath = "/home/davila/dataHistogram";
+
+#endif
currentpath.append(FILENAME);
+ std::cout<<"current file name " <<currentpath<<std::endl;
+
std::vector<HistogramDialogComboBoxItem*> bitmapsitems;
- OnLoadComboBoxData(bitmapsitems, currentpath);
+ OnLoadComboBoxData(bitmapsitems, currentpath);
_bitmapsitems = bitmapsitems;
wxString* choices;
choices = new wxString[bitmapsitems.size()];
wxBitmapComboBox* bitmapcombo = new wxBitmapComboBox(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, bitmapsitems.size(),choices);
bitmapcombo->SetSize(65,30);
- Connect(bitmapcombo->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&HistogramDialogComboBox::OnBitmapComboItemSelected);
+ Connect(bitmapcombo->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&HistogramDialogComboBox::OnBitmapComboItemSelected);
for(int i = 0; i < bitmapsitems.size(); i++)
{
}
void HistogramDialogComboBox::OnBitmapComboItemSelected(wxCommandEvent& event)
-{
+{
if(_bitmapcombo!=NULL)
{
_currentitem = event.GetInt();
_value = currentconfig->getValueVector();
wxCommandEvent newevent(wxEVT_COMMAND_COMBOBOX_SELECTED,this->GetId());
ProcessEvent(newevent);
- }
+ }
}
}
void HistogramDialogComboBox::OnLoadComboBoxData(std::vector<HistogramDialogComboBoxItem*>& itembitmaps, std::string filename)
-{
+{
std::vector<double> redvect, greenvect, bluevect;
std::vector<double> greyvect, greyvecttransfunct, value;
- redvect.clear();
- greenvect.clear();
+ redvect.clear();
+ greenvect.clear();
bluevect.clear();
- greyvect.clear();
- greyvecttransfunct.clear();
+ greyvect.clear();
+ greyvecttransfunct.clear();
value.clear();
- std::ifstream file;
- file.open( (const char*) (filename.c_str()) );
+ std::ifstream file;
+ file.open( (const char*) (filename.c_str()) );
double gv=-1,gvtransfer=-1,intensity=-1,red=-1,gr=-1,bl=-1;
int in=-1;
//std::cout<<filename<<std::endl;
itembitmaps.clear();
if(file.is_open())
- {
+ {
bool add = false;
HistogramDialogComboBoxItem* item=NULL;
while(!file.eof())
std::getline(file,line);
//std::cout<<line<<std::endl;
if( (int)(line.find("<ComboBoxItem>")!=-1))
- {
- item = new HistogramDialogComboBoxItem();
- }else if((int)(line.find("<greyValue>"))!=-1){
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- gvtransfer=atof(x.c_str());
- greyvecttransfunct.push_back(gvtransfer);
- }else if((int)(line.find("<intensity>"))!=-1){
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- intensity=atof(x.c_str());
- value.push_back(intensity);
- }
- else if( (int)(line.find("<RGBgreyValue>"))!=-1)
- {
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- gv=atof(x.c_str());
- greyvect.push_back(gv);
- }
- else if( (int)(line.find("<red>"))!=-1)
- {
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- red=atof(x.c_str());
- redvect.push_back(red);
- }
- else if( (int)(line.find("<green>"))!=-1)
- {
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- gr=atof(x.c_str());
- greenvect.push_back(gr);
- }
- else if( (int)(line.find("<blue>"))!=-1 )
- {
- int pos1=line.find(">");
- int pos2=line.find("<",pos1+1);
- std::string x=line.substr(pos1+1,pos2-pos1-1);
- bl=atof(x.c_str());
- bluevect.push_back(bl);
-
- }else if( (int)(line.find("</ComboBoxItem>"))!=-1 ){
-
- item->SetColors(greyvect,redvect,greenvect,bluevect);
- item->SetTransferFunction(greyvecttransfunct,value);
- /*for(int i = 0; i < greyvecttransfunct.size();i++){
+ {
+ item = new HistogramDialogComboBoxItem();
+ }else if((int)(line.find("<greyValue>"))!=-1) {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ gvtransfer=atof(x.c_str());
+ greyvecttransfunct.push_back(gvtransfer);
+ }else if((int)(line.find("<intensity>"))!=-1) {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ intensity=atof(x.c_str());
+ value.push_back(intensity);
+ }
+ else if( (int)(line.find("<RGBgreyValue>"))!=-1)
+ {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ gv=atof(x.c_str());
+ greyvect.push_back(gv);
+ }
+ else if( (int)(line.find("<red>"))!=-1)
+ {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ red=atof(x.c_str());
+ redvect.push_back(red);
+ }
+ else if( (int)(line.find("<green>"))!=-1)
+ {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ gr=atof(x.c_str());
+ greenvect.push_back(gr);
+ }
+ else if( (int)(line.find("<blue>"))!=-1 )
+ {
+ int pos1=line.find(">");
+ int pos2=line.find("<",pos1+1);
+ std::string x=line.substr(pos1+1,pos2-pos1-1);
+ bl=atof(x.c_str());
+ bluevect.push_back(bl);
+
+ }else if( (int)(line.find("</ComboBoxItem>"))!=-1 ) {
+
+ item->SetColors(greyvect,redvect,greenvect,bluevect);
+ item->SetTransferFunction(greyvecttransfunct,value);
+ /*for(int i = 0; i < greyvecttransfunct.size();i++){
std::cout<<"HistogramDialogComboBox::OnLoadComboBoxData("<<greyvecttransfunct[i]<<std::endl;
std::cout<<value[i]<<std::endl;
- }
- for(int i = 0; i < greyvect.size();i++){
+ }
+ for(int i = 0; i < greyvect.size();i++){
std::cout<<"HistogramDialogComboBox::OnLoadComboBoxData("<<greyvect[i]<<std::endl;
std::cout<<redvect[i]<<std::endl;
std::cout<<greenvect[i]<<std::endl;
std::cout<<bluevect[i]<<std::endl;
- }*/
-
- itembitmaps.push_back(item);
-
- greyvecttransfunct.clear();
- value.clear();
- greyvect.clear();
- redvect.clear();
- greenvect.clear();
- bluevect.clear();
- }
- line.clear();
+ }*/
+
+ itembitmaps.push_back(item);
+
+ greyvecttransfunct.clear();
+ value.clear();
+ greyvect.clear();
+ redvect.clear();
+ greenvect.clear();
+ bluevect.clear();
}
- file.close();
- //std::cout<<itembitmaps.size()<<std::endl;
- }
+ line.clear();
+ }
+ file.close();
+ //std::cout<<itembitmaps.size()<<std::endl;
+ }
}
/**
** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
**/
void HistogramDialogComboBox::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value)
-{
- for(int i = 0; i < _greyvecttransfer.size();i++){
+{
+ for(int i = 0; i < _greyvecttransfer.size();i++) {
greylevel.push_back(_greyvecttransfer[i]*_maxgreyvalue);
- value.push_back(_value[i]);
+ value.push_back(_value[i]);
}
}
std::vector<double>& red,
std::vector<double>& green,
std::vector<double>& blue)
-{
- for(int i = 0; i < _greyvect.size();i++){
+{
+ for(int i = 0; i < _greyvect.size();i++) {
greylevel.push_back(_greyvect[i]*_maxgreyvalue);
red.push_back(_redvect[i]);
green.push_back(_greenvect[i]);
- blue.push_back(_bluevect[i]);
+ blue.push_back(_bluevect[i]);
}
}