#include "OpenImageDialog.h"
#include "creaWx.h"
+#if defined(__GNUC__)
+// GCC compiler
+// dlopen, dlsym, etc.
+ #include <dlfcn.h>
+#endif
+
typedef vtkImageData* (*GETIMAGEDATADIALOG)();
namespace creaMaracasVisuKernel{
- OpenImageDialog::OpenImageDialog()
+ OpenImageDialog::OpenImageDialog(bool usegimmick)
{
- img = NULL;
- bool gimmicknotfound = true;
+ img = NULL;
+
+ bool gimmickfound = false;
- #ifdef WIN32
- HINSTANCE gimmickhandle;
- gimmickhandle = LoadLibrary(TEXT("creaImageIO2.dll"));
- std::cout<<"imagehandle "<<gimmickhandle<<std::endl;
- if(gimmickhandle!=NULL){
+ if(usegimmick){
+ #ifdef WIN32
+ HINSTANCE gimmickhandle;
+ gimmickhandle = LoadLibrary(TEXT("creaImageIO2.dll"));
+ std::cout<<"imagehandle "<<gimmickhandle<<std::endl;
+ if(gimmickhandle!=NULL){
- GETIMAGEDATADIALOG getImageDataDialog;
+ GETIMAGEDATADIALOG getImageDataDialog;
- getImageDataDialog = (GETIMAGEDATADIALOG)GetProcAddress(gimmickhandle, "getImageDataDialog");
+ getImageDataDialog = (GETIMAGEDATADIALOG)GetProcAddress(gimmickhandle, "getImageDataDialog");
- std::cout<<"imagedatadialog "<<getImageDataDialog<<std::endl;
+ std::cout<<"imagedatadialog "<<getImageDataDialog<<std::endl;
- if(getImageDataDialog!=NULL){
- img = getImageDataDialog();
- gimmicknotfound = false;
+ if(getImageDataDialog!=NULL){
+ img = getImageDataDialog();
+ gimmickfound = true;
+ }
+ if(!FreeLibrary(gimmickhandle)){
+ std::cout<<"Error while releasing the handle creaImageIO2.dll"<<std::endl;
+ }
+ }
+ #else
+ void * gimmickhandle;
+ GETIMAGEDATADIALOG getImageDataDialog;
+ char * erreur;
+ int closingerror;
+ gimmickhandle = dlopen ("libcreaImageIO2.so", RTLD_LAZY);
+ if (! gimmickhandle) {
+ erreur = dlerror ();
+ std::cout<<erreur<<"imagehandle "<<gimmickhandle<<std::endl;
+ }else{
+ getImageDataDialog = (GETIMAGEDATADIALOG) dlsym (gimmickhandle, "getImageDataDialog");
+ if(!getImageDataDialog){
+ erreur = dlerror ();
+ std::cout<<erreur<<"getImageDataDialog "<<getImageDataDialog<<std::endl;
+ }else{
+ img = (*getImageDataDialog)();
+ gimmickfound = true;
+
+ }
+ /*dlclose returns 0 on success, non-zero on error*/
+ closingerror = dlclose(gimmickhandle);
+ if(closingerror!=0){
+ std::cout<<closingerror<<"error closing handle "<<gimmickhandle<<std::endl;
+ }else{
+ std::cout<<"handle released..."<<std::endl;
+ }
}
- }
-
- #endif
-
- if(gimmicknotfound){
+ #endif
+ }
+
+ if(!gimmickfound || !usegimmick){
+ //int i, j, k, *extint;
+ //unsigned short* ptr1, *ptr2;
wxFileDialog* FD =
new wxFileDialog( 0, _T("Read Image"),wxEmptyString,wxEmptyString, _T("*.mhd"));
if (FD->ShowModal()==wxID_OK)
{
std::string path= crea::wx2std(FD->GetPath());
-
- vtkMetaImageReader *reader = vtkMetaImageReader::New();
+ vtkMetaImageReader* reader = vtkMetaImageReader::New();
reader->SetFileName(path.c_str());
- img = reader->GetOutput();
+ reader->Update();
+ img = vtkImageData::New();
+ img->DeepCopy(reader->GetOutput());
+ reader->Delete();
+ /*img->SetSpacing(reader->GetOutput()->GetSpacing());
+ extint = reader->GetOutput()->GetExtent();
+ img->SetExtent(extint);
+ img->SetScalarType(reader->GetOutput()->GetScalarType());
+ img->SetDimensions(reader->GetOutput()->GetDimensions());
+ img->AllocateScalars();
+ for (i=extint[0];i <= extint[1];i++){
+ for (j=extint[2];j<=extint[3];j++){
+ for (k=extint[4];k<=extint[5];k++){
+
+ ptr1=(unsigned short*) reader->GetOutput()->GetScalarPointer(i,j,k);
+ ptr2=(unsigned short*)img->GetScalarPointer(i,j,k);
+ *ptr2 = *ptr1;
+ }
+ }
+ }*/
}
+ //delete FD;
}
}
//-------------------------------------------------------------------
OpenImageDialog::~OpenImageDialog()
{
+ img = NULL;
}
- vtkImageData* OpenImageDialog::getImageData(){
+ vtkImageData* OpenImageDialog::getImageData(){
return img;
}
}
class creaMaracasVisu_EXPORT OpenImageDialog {
public:
- OpenImageDialog();
+ OpenImageDialog(bool usegimmick = true);
~OpenImageDialog();
vtkImageData* getImageData();
protected:
private:
- vtkImageData* img;
+ vtkImageData* img;
};
}
wxBitmapComboBox* HistogramDialogComboBox::getBitmapComboElements()
{
- std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");
+ std::string currentpath = "";
+#ifdef WIN32
+ currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");
+#endif
currentpath.append(FILENAME);
+
+ std::cout<<"current file name " <<currentpath<<std::endl;
std::vector<HistogramDialogComboBoxItem*> bitmapsitems;
OnLoadComboBoxData(bitmapsitems, currentpath);
#include <wx/bmpcbox.h>
#include "vtkImageData.h"
-
-#define FILENAME "/Data/colorsfunction.txt"
+#ifdef WIN32
+#define FILENAME "/data/colorsfunction.txt"
+#else
+#define FILENAME "~/.creaMaracasVisu/data/colorsfunction.txt"
+#endif
class HistogramDialogComboBox : public wxPanel
checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);
checkbox->SetValue(true);
- checkboxsizer->Add(checkbox,wxFIXED_MINSIZE);
+ checkboxsizer->Add(checkbox,1, wxGROW);
if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
checkboxsurface = new wxCheckBox(this,-1,wxString(_T("Surface Box")));
Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);
checkboxsurface->SetValue(true);
- checkboxsizer->Add(checkboxsurface,wxFIXED_MINSIZE);
+ checkboxsizer->Add(checkboxsurface,1, wxGROW);
}
- sizersurfprop->Add(checkboxsizer,wxFIXED_MINSIZE);
+ sizersurfprop->Add(checkboxsizer,1, wxGROW);
}
//this->addControl(checkbox);
wxBitmap bitmap(Color_xpm);
_colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);
- sizerbut->Add(_colorchoose,wxFIXED_MINSIZE);
+ sizerbut->Add(_colorchoose,1, wxGROW);
/*
wxBitmap bitmap1(Add_xpm);
Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onViewImage);
sizerbut->Add(_viewimage,wxFIXED_MINSIZE);
*/
- sizersurfprop->Add(sizerbut,wxFIXED_MINSIZE);
+ sizersurfprop->Add(sizerbut,1, wxGROW);
//sizercolor->Add(checkbox,wxFIXED_MINSIZE);
//sizercolor->Add(_colorchoose,wxFIXED_MINSIZE);
//this->addControl(sizercolor);
opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);
wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);
- sizeropacity->Add(label,wxFIXED_MINSIZE);
- sizeropacity->Add(opacity,wxFIXED_MINSIZE);
+ sizeropacity->Add(label,1, wxGROW);
+ sizeropacity->Add(opacity,1, wxGROW);
- sizersurfprop->Add(sizeropacity,wxFIXED_MINSIZE);
+ sizersurfprop->Add(sizeropacity,1, wxGROW);
this->addControl(sizersurfprop);
wxFlexGridSizer* sizer = new wxFlexGridSizer(1,1,1);
wxStaticText* label = new wxStaticText(this, -1, wxString(_T("IsoValue")));
- sizer->Add(label, wxFIXED_MINSIZE);
+ sizer->Add(label, 1, wxGROW);
//this->addControl(label);
isovalue = new wxSlider(this, -1,maxisovalue,0,maxisovalue,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS);
- sizer->Add(isovalue, wxFIXED_MINSIZE);
+ sizer->Add(isovalue, 1, wxGROW);
//this->addControl(isovalue);
this->addControl(sizer);
Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
Language: C++
- Date: $Date: 2010/02/04 10:54:49 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2010/03/25 08:50:32 $
+ Version: $Revision: 1.15 $
Copyright: (c) 2002, 2003
License:
delete mvtkmprbasedata;
}
- marImageData *marimagedata = new marImageData( imagedata );
+ /*marImageData *marimagedata = new marImageData( imagedata );
mvtkmprbasedata = new vtkMPRBaseData();
- mvtkmprbasedata->SetMarImageData(marimagedata);
+ mvtkmprbasedata->SetMarImageData(marimagedata);*/
if(_currentwxw != NULL){
_currentwxw->Show(false);
//std::cout<<"size "<<nTypeView->size()<<std::endl;
if (nTypeView->size()==1)
{
- wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0],mvtkmprbasedata);
+ wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0]);
wxwindow1->ConfigureVTK();
wxwindow = wxwindow1;
}else if (nTypeView->size()==2) {
wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
spliter->SetMinimumPaneSize(1);
- wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0],mvtkmprbasedata);
- wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1],mvtkmprbasedata);
+ wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0]);
+ wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1]);
wxwindow1->ConfigureVTK();
wxwindow2->ConfigureVTK();
spliter -> SplitVertically( wxwindow1 , wxwindow2 );
wxSplitterWindow *spliterA = new wxSplitterWindow( spliter , -1);
spliter->SetMinimumPaneSize(1);
spliterA->SetMinimumPaneSize(1);
- wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0],mvtkmprbasedata);
- wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
- wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2],mvtkmprbasedata);
+ wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0]);
+ wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1]);
+ wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2]);
wxwindow1->ConfigureVTK();
wxwindow2->ConfigureVTK();
wxwindow3->ConfigureVTK();
spliter->SetMinimumPaneSize(1);
spliterA->SetMinimumPaneSize(1);
spliterB->SetMinimumPaneSize(1);
- wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0],mvtkmprbasedata);
- wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
- wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2],mvtkmprbasedata);
- wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3],mvtkmprbasedata);
+ wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0]);
+ wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1]);
+ wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2]);
+ wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3]);
wxwindow1->ConfigureVTK();
wxwindow2->ConfigureVTK();
wxwindow3->ConfigureVTK();
//-----------------------------------------------------------------------------------
void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image )
- {
+ {
if (wxwindow1!=NULL) { wxwindow1->SetImage(image); }
if (wxwindow2!=NULL) { wxwindow2->SetImage(image); }
if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
{
if(index < _imagedataLST.size()){
- //vtkImageData* img = _imagedataLST[index];
+ /*vtkImageData* img = _imagedataLST[index];
+ if(img->GetReferenceCount()>1){
+ img->SetReferenceCount(img->GetReferenceCount()-1);
+ //img->Delete();
+ }*/
for(int i = index; i < _imagedataLST.size()-1; i++){
_imagedataLST[i] = _imagedataLST[i+1];
}