bbSetInputIn2(NULL);
bbSetInputIn3(NULL);
bbSetInputIn4(NULL);
- bbSetOutputWidget(NULL);
+ bbSetInputRenderer(NULL);
+ bbSetOutputWidget(NULL);
}
//-----------------------------------------------------------------
void ImageActor::Process()
{
- if ((bbGetInputIn()!=NULL) && (bbGetInputRenderer()!=NULL))
- {
+ //JCP 04/04/09
+ vtkRenderer *render = bbGetInputRenderer();
+ vtkImageData *img = bbGetInputIn();
+ vtkLinearTransform* transform = bbGetInputTransform();
+
+ if(img != NULL && transform != NULL){
imageactor = vtkImageActor::New();
vtkImageShiftScale *imageshiftscale = vtkImageShiftScale::New();
- imageshiftscale->SetInput( bbGetInputIn() );
+ imageshiftscale->SetInput( img );
imageshiftscale->SetOutputScalarTypeToUnsignedChar();
imageactor->SetInput( imageshiftscale->GetOutput() );
- imageactor->SetUserTransform( bbGetInputTransform() );
+ imageactor->SetUserTransform( transform );
+
+ if(render != NULL ){
+ render->AddActor( imageactor );
+ }
+
+
+ bbSetOutputOut(imageactor);
+
}
- // Interface Update
- if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
- {
- firsttime=false;
- bbGetInputRenderer()->AddActor( imageactor );
- }
+
}
void ImageActor::bbUserSetDefaultValues()
{
BBTK_DECLARE_INPUT(In,vtkImageData*);
BBTK_DECLARE_INPUT(Transform,vtkLinearTransform*);
BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
-// BBTK_DECLARE_OUTPUT(Out,double);
+ BBTK_DECLARE_OUTPUT(Out,vtkProp3D*);
BBTK_PROCESS(Process);
void Process();
bool firsttime;
BBTK_INPUT(ImageActor,In,"Image input",vtkImageData*,"");
BBTK_INPUT(ImageActor,Transform,"Transform",vtkLinearTransform*,"");
BBTK_INPUT(ImageActor,Renderer,"Renderer",vtkRenderer*,"");
-//BBTK_OUTPUT(ImageActor,Out,"First output",double,"");
+BBTK_OUTPUT(ImageActor,Out,"Output actor",vtkProp3D*,"");
BBTK_END_DESCRIBE_BLACK_BOX(ImageActor);
}
// EO namespace bbcreaMaracasVisu
this->renderer = NULL;
wxPanel *panel = this;
wxSizer *sizer = NULL;
-
+
// Widget interface
textCtrl = new wxTextCtrl(panel, -1);
wxButton *btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
txtNrPoints = new wxStaticText(panel,-1, _T(" "));
- wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+ wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
// sizer1->Add(new wxStaticText(panel,-1,_T(" ")));
Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
sizer = sizer1;
panel -> SetSizer(sizer);
panel -> SetAutoLayout(true);
- panel -> Layout();
-
+ panel -> Layout();
+
}
{
return lstLabels;
}
-
-
+
+
//------------------------------------------------------------------------
}
return ss;
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
{
lstPointsZ.push_back( z );
std::string strLabel = CleanSpaces( label );
-
+
lstLabels.push_back( strLabel );
-
+
// Sphere
vtkSphereSource *vtksphere = vtkSphereSource::New();
vtksphere->SetThetaResolution (20);
vtksphere->SetPhiResolution (20);
- vtksphere->SetRadius( mradio );
+ vtksphere->SetRadius( mradio );
vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
sphereMapper->SetInput( vtksphere->GetOutput() );
vtkActor *sphereActor = vtkActor::New();
sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
sphereActor->GetProperty()->SetOpacity( mopacity );
-
+
lstActorsSphere.push_back(sphereActor);
renderer->AddActor( sphereActor );
-
+
// Actor
vtkTextActor3D *textActor = vtkTextActor3D::New();
textActor->SetPosition( mradio+spc[0]*x , spc[1]*y , spc[2]*z );
textActor->SetInput( strLabel.c_str() );
renderer->AddActor( textActor );
lstActorsText.push_back(textActor);
-
- SetOutputBox();
-
+
+ SetOutputBox();
+
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
{
- if (this->renderer!=NULL){
+ if (this->renderer!=NULL){
if (mpoint.size()==3){
- AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+ AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
} else {//mpoint.size
printf("creaMaracasVisu::ShowNPoints (not match point) \n");
}
} // renderer
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::SetOutputBox()
{
renderer->GetRenderWindow()->Render();
wxString strTmp;
- strTmp.Printf("Nbr of points: %d", (int)(lstPointsX.size()) );
+ strTmp.Printf(_T("Nbr of points: %d"), (int)(lstPointsX.size()) );
txtNrPoints->SetLabel( strTmp );
-
+
//--BBTK
mbbShowNPoints->bbSetOutputlstPointsX( lstPointsX );
mbbShowNPoints->bbSetOutputlstPointsY( lstPointsY );
mbbShowNPoints->bbSetOutputlstPointsZ( lstPointsZ );
mbbShowNPoints->bbSetOutputlstLabels( lstLabels );
- mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
- mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
- mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
- mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
{
-
- wxFileDialog* FD = new wxFileDialog( 0,
+
+ wxFileDialog* FD = new wxFileDialog( 0,
_T("Save points .."),
_T(""),
_T(""),
wxSAVE | wxOVERWRITE_PROMPT,
wxDefaultPosition);
//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;
printf("WidgetShowNPoints::OnSavePoints ...Error... creating file");
} //ff
} // dialog box
-
- }
+
+ }
//------------------------------------------------------------------------
void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
{
- wxFileDialog* FD = new wxFileDialog( 0,
+ wxFileDialog* FD = new wxFileDialog( 0,
_T("Load points .."),
_T(""),
_T(""),
wxOPEN | wxFILE_MUST_EXIST,
wxDefaultPosition);
//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;
for (i=0; i<size; i++)
{
fscanf(ff," %d %d %d %f %s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
- AddPoint(x,y,z, chartmp );
+ AddPoint(x,y,z, chartmp );
}
fclose(ff);
} else { // else ff
printf("WidgetShowNPoints::OnLoadPoints ...Error... reading file");
} //ff
} // dialog box
-
-
- }
-
+
+
+ }
+
int WidgetShowNPoints::GetNearestPoint()
{
int id=-1;
int i, size=(int)(lstActorsSphere.size());
double spc[3];
mimage->GetSpacing(spc);
-
+
for ( i=0 ; i<size; i++ )
{
double rx = spc[0]*(mpoint[0] - lstPointsX [i]);
if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
{
id=i;
- } // if
+ } // if
} // for
-
+
return id;
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
{
std::string strLabel = CleanSpaces( (const char*) ( textCtrl->GetValue().mb_str() ) );
lstLabels[id] = CleanSpaces( (const char*) (textCtrl->GetValue().mb_str()) ) ;
lstActorsText[id]->SetInput( lstLabels[id].c_str() );
- SetOutputBox();
+ SetOutputBox();
}
- }
-
+ }
+
//------------------------------------------------------------------------
void WidgetShowNPoints::ErasePoint(int id)
{
- if (this->renderer!=NULL){
+ if (this->renderer!=NULL){
if (id>=0){
renderer->RemoveActor( lstActorsSphere[id] );
renderer->RemoveActor( lstActorsText[id] );
lstActorsText[id]->Delete();
lstActorsSphere.erase( lstActorsSphere.begin()+id );
lstActorsText.erase( lstActorsText.begin()+id );
-
+
lstPointsX.erase( lstPointsX.begin()+id );
lstPointsY.erase( lstPointsY.begin()+id );
lstPointsZ.erase( lstPointsZ.begin()+id );
lstLabels.erase( lstLabels.begin()+id );
- SetOutputBox();
+ SetOutputBox();
} // if id
} // if renderer
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
{
ErasePoint( GetNearestPoint() );
}
-
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
{
ErasePoint(lstActorsSphere.size()-1);
}
-
-
+
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
{
{
ErasePoint(id);
}
-
+
}
void ShowNPoints::Process()
{
if (mwxwidget!=NULL){
- mwxwidget->SetRenderer( bbGetInputRenderer() );
- mwxwidget->SetPoint( bbGetInputIn() );
- mwxwidget->SetImage( bbGetInputImage() );
- mwxwidget->SetColour( bbGetInputColour() );
- mwxwidget->SetOpacity( bbGetInputOpacity() );
- mwxwidget->SetRadio( bbGetInputRadio() );
+ mwxwidget->SetRenderer( bbGetInputRenderer() );
+ mwxwidget->SetPoint( bbGetInputIn() );
+ mwxwidget->SetImage( bbGetInputImage() );
+ mwxwidget->SetColour( bbGetInputColour() );
+ mwxwidget->SetOpacity( bbGetInputOpacity() );
+ mwxwidget->SetRadio( bbGetInputRadio() );
bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
printf("Missing Image (ShowNPoints) \n");
}
- bbSetOutputWidget( mwxwidget );
+ bbSetOutputWidget( mwxwidget );
}
void ShowNPoints::bbUserSetDefaultValues()
bbSetInputRadio(0.5);
bbSetInputOpacity(1);
-
+
std::vector<double> colour;
colour.push_back(1.0);
colour.push_back(0.0);
bbSetInputImage(NULL);
bbSetInputRenderer(NULL);
}
-
- //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
void ShowNPoints::bbUserInitializeProcessing()
{
}
-
- //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
void ShowNPoints::bbUserFinalizeProcessing()
{
}
-
- //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
}
// EO namespace bbcreaMaracasVisu
_cntSplineX->RemoveAllPoints();
_cntSplineY->RemoveAllPoints();
_cntSplineZ->RemoveAllPoints();
-
+
_cntSplineX->Delete();
_cntSplineY->Delete();
_cntSplineZ->Delete();
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMView.cxx,v $
Language: C++
- Date: $Date: 2009/05/29 13:39:56 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2009/06/10 17:42:29 $
+ Version: $Revision: 1.10 $
Copyright: (c) 2002, 2003
License:
wxMaracasIRMView* wxMaracasIRMView::instance=NULL;
-wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
-
- irmmanager = new wxMaracasIRMViewManager();
+wxMaracasIRMView::wxMaracasIRMView( wxWindow* parent,std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
- wxauimanager = new wxAuiManager(this);
+ irmmanager = new wxMaracasIRMViewManager();
+
+ wxauimanager = new wxAuiManager(this);
_path = path;
std::string iconsdir = path;
iconsdir+="/data/Icons";
wxToolBar* toolbar = new ToolBar(this,iconsdir);
- wxAuiPaneInfo paneinfo;
- wxauimanager->AddPane(toolbar,paneinfo.ToolbarPane().Top());
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(toolbar,paneinfo.ToolbarPane().Top());
wxauimanager->Update();
createFileChooser();
void wxMaracasIRMView::createFileChooser(){
-
+
}
wxMaracasIRMView* wxMaracasIRMView::getInstance(wxWindow* parent,std::string path){
irmmanager->changeOpacity(_propid,value);
}
-void wxMaracasIRMView::changeIsoValue(int propid, double value){
+void wxMaracasIRMView::changeIsoValue(int propid, double value){
irmmanager->changeIsoValue(propid, value);
}
if(fildial->ShowModal()==wxID_OK){
wxString filename = fildial->GetFilename();
- wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
-
+ wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
+
- if(filename.EndsWith(mhd)){
+ if(filename.EndsWith(mhd)){
loadPropMHD(pathfile,filename);
}else if(filename.EndsWith(stl)){
loadProp3D(pathfile,filename);
delete fildial;
}
-void wxMaracasIRMView::loadPropMHD(wxString filename, wxString dataname){
-
+void wxMaracasIRMView::loadPropMHD(wxString filename, wxString dataname){
+
std::string s = std::string(filename.mb_str());
vtkImageData* img = irmmanager->getImageData(s);
if(img!=NULL){
s = std::string(dataname.mb_str());
addPropMHD(img, s);
}
-
-
+
+
}
void wxMaracasIRMView::addPropMHD(vtkImageData* imgdata, std::string dataname){
try{
- int id = irmmanager->addPropMHD(imgdata,dataname);
+ int id = irmmanager->addPropMHD(imgdata,dataname);
if(id!=-1){
-
+
wxMaracasIRMViewPanel* controlpan = new wxMaracasIRMViewProp3DMHD(this, id);
int maxiso = irmmanager->getMaxIsoValue(id);
((wxMaracasIRMViewProp3DMHD*)controlpan)->createControls(maxiso);
}
}
-void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){
+void wxMaracasIRMView::loadProp3D(wxString filename, wxString dataname){
std::string s = std::string(filename.mb_str());
vtkProp3D* prop3D = irmmanager->getProp3D(s);
if(prop3D != NULL){
}else{
//TODO msj to the user indicating error in file
}
-
-
-
+
+
+
}
void wxMaracasIRMView::addProp3D(vtkProp3D* prop3D, std::string dataname){
}catch(char* str){
std::cout << "Exception : " << str << '\n';
wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
- diag->ShowModal();
+ diag->ShowModal();
}
-
+
}
void wxMaracasIRMView::addIRMViewPanel(wxMaracasIRMViewPanel* irmview, std::string dataname){
wxString s(dataname.c_str(),wxConvUTF8 );
- wxAuiPaneInfo paneinfo;
+ wxAuiPaneInfo paneinfo;
wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
wxauimanager->Update();
-
-
+
+
}
void wxMaracasIRMView::deleteActor(int propid){
try{
irmmanager->deleteActor(propid);
}catch(char* e){
-
+
}
}
ToolBar::ToolBar(wxWindow * parent,std::string iconsdir)
: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
-{
+{
std::string iconfil = iconsdir;
/*iconfil+= "/Open.png";
wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
- this->AddTool(2, wxString(_T("test")),*bitmap2); */
+ this->AddTool(2, wxString(_T("test")),*bitmap2); */
/*iconfil = iconsdir;
iconfil+= "/Open.png";
wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
this->AddTool(30, wxString(_T("test")),*bitmap30);*/
-
+
this->Realize();
-
-
+
+ this->SetEventHandler(&evthand);
+
}
ToolBar::~ToolBar(void){
}
-void ToolBar::onLoadImageFile(wxCommandEvent& event){
+
+ToolBar::ToolBarEventHandler::ToolBarEventHandler()
+: wxEvtHandler(){
+}
+ToolBar::ToolBarEventHandler::~ToolBarEventHandler(){
+}
+
+void ToolBar::ToolBarEventHandler::onLoadImageFile(wxCommandEvent& event){
wxMaracasIRMView::getInstance()->onLoadImageFile();
}
-BEGIN_EVENT_TABLE(ToolBar, wxToolBar)
- EVT_MENU(0, ToolBar::onLoadImageFile)
-
+BEGIN_EVENT_TABLE(ToolBar::ToolBarEventHandler, wxEvtHandler)
+ EVT_MENU(0, ToolBar::ToolBarEventHandler::onLoadImageFile)
END_EVENT_TABLE()
Program: wxMaracas
Module: $RCSfile: wxMaracasIRMView.h,v $
Language: C++
- Date: $Date: 2009/05/14 13:54:35 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2009/06/10 17:42:28 $
+ Version: $Revision: 1.5 $
Copyright: (c) 2002, 2003
License:
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
class creaMaracasVisu_EXPORT wxMaracasIRMView : public wxPanel
-{
+{
public:
wxMaracasIRMView( wxWindow* parent, std::string path);
~wxMaracasIRMView( );
-
+
static wxMaracasIRMView* getInstance(wxWindow* parent,std::string path="");
static wxMaracasIRMView* getInstance();
class ToolBar : public wxToolBar{
-public:
-
+ public:class ToolBarEventHandler : public wxEvtHandler{
+
+ public:
+ ToolBarEventHandler();
+ ~ToolBarEventHandler();
+
+ void onLoadImageFile(wxCommandEvent& event);
+
+ private:
+
+ DECLARE_EVENT_TABLE()
+ };
+
ToolBar(wxWindow * parent,std::string iconsdir);
~ToolBar(void);
-
-
- void onLoadImageFile(wxCommandEvent& event);
-
+
+
private:
-
+ ToolBarEventHandler evthand;
-
-DECLARE_EVENT_TABLE()
};
#endif