From 4db65eb4d687cf3695582df7098db27b0d24ab97 Mon Sep 17 00:00:00 2001 From: donadio Date: Wed, 3 Jun 2009 13:47:06 +0000 Subject: [PATCH] *** empty log message *** --- .../wxWindows/Contour/ContourExtractData.cxx | 56 +++++- .../widgets/wxMaracasSuperposition.cxx | 167 ++++++++++++++++++ .../widgets/wxMaracasSuperposition.h | 79 +++++++++ .../widgets/wxMaracasSuperpositionPanel.cxx | 123 +++++++++++++ .../widgets/wxMaracasSuperpositionPanel.h | 87 +++++++++ 5 files changed, 504 insertions(+), 8 deletions(-) create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.h create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.h diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index e64fa03..8f98a10 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -197,22 +197,62 @@ double ContourExtractData::GetDataValue(int x, int y, int z) void *p; p = imagedata->GetScalarPointer(x,y,z); - if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR) - { unsigned char *pp = (unsigned char*)p; + if (imagedata->GetScalarType()==VTK_CHAR) + { + char *pp = (char*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_FLOAT) - { float *pp = (float*)p; + else if (imagedata->GetScalarType()==VTK_SIGNED_CHAR) + { + signed char *pp = (signed char*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_SHORT) - { short *pp = (short*)p; + else if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR) + { + unsigned char *pp = (unsigned char*)p; result = (double)(*pp); } - if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT) - { unsigned short *pp = (unsigned short*)p; + else if (imagedata->GetScalarType()==VTK_SHORT) + { + short *pp = (short*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT) + { + unsigned short *pp = (unsigned short*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_INT) + { + int *pp = (int*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_INT) + { + unsigned int *pp = (unsigned int*)p; result = (double)(*pp); } + else if (imagedata->GetScalarType()==VTK_LONG) + { + long *pp = (long*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG) + { + unsigned long *pp = (unsigned long*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_FLOAT) + { + float *pp = (float*)p; + result = (double)(*pp); + } + else if (imagedata->GetScalarType()==VTK_DOUBLE) + { + double *pp = (double*)p; + result = (double)(*pp); + } + return result; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.cxx new file mode 100644 index 0000000..2581b39 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.cxx @@ -0,0 +1,167 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasSuperposition.cxx,v $ + Language: C++ + Date: $Date: 2009/06/03 13:47:07 $ + Version: $Revision: 1.3 $ + + Copyright: (c) 2002, 2003 + License: + + 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. + +=========================================================================*/ + +#include "wxMaracasSuperposition.h" +#include "creaWx.h" +#include "vtkMetaImageReader.h" +#include "wx/artprov.h" + + + +wxMaracasSuperposition* wxMaracasSuperposition::instance=NULL; + +wxMaracasSuperposition::wxMaracasSuperposition( wxWindow* parent, std::vector imgs): wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize) +{ + m_mgr.SetManagedWindow(this); + + _superposition1 = NULL; + _superposition2 = NULL; + _superposition3 = NULL; + + _images = imgs; + + // set up default notebook style + m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER; + m_notebook_theme = 0; + _notebook = this->createNotebook(); + + createPanels(); + configurePanels(); +} + +wxMaracasSuperposition::~wxMaracasSuperposition() +{ + _notebook->Destroy(); + m_mgr.UnInit(); +} + +wxMaracasSuperposition* wxMaracasSuperposition :: getInstance ( wxWindow* parent, std::vector imgs) +{ + if(instance == NULL) + { + instance = new wxMaracasSuperposition(parent, imgs); + } + return instance; +} + +wxMaracasSuperposition* wxMaracasSuperposition :: getInstance() +{ + return instance; +} + +//------------------------------------------------------------------------------------------------------------ +// Creational and initialization methods using WxAui +//------------------------------------------------------------------------------------------------------------ + +wxAuiNotebook * wxMaracasSuperposition :: createNotebook() +{ + wxSize client_size = GetClientSize(); + wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style); + wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); + + return noteBook; +} + +void wxMaracasSuperposition :: configurePanels() +{ + if( _superposition1!=NULL ) + { + _notebook->AddPage( _superposition1, wxT(" Superoposition 1 ") ); + m_mgr.Update(); + } + + if( _superposition2!=NULL ) + { + _notebook->AddPage( _superposition2, wxT(" Superoposition 2 ") ); + m_mgr.Update(); + } + + if( _superposition3!=NULL ) + { + _notebook->AddPage( _superposition3, wxT(" Superoposition 3 ") ); + m_mgr.Update(); + } + + + m_mgr.AddPane(_notebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); + m_mgr.Update(); + + SetMinSize(wxSize(300,300)); + m_mgr.Update(); +} + +void wxMaracasSuperposition :: createPanels() +{ + if( _superposition1==NULL ) + { + createSuperpositionPanel(1); + } + + else if( _superposition1!=NULL ) + { + + } + + if( _superposition2==NULL ) + { + createSuperpositionPanel(2); + } + + else if( _superposition2!=NULL ) + { + + } + + if( _superposition3==NULL ) + { + createSuperpositionPanel(3); + } + + else if( _superposition3!=NULL ) + { + + } +} + +void wxMaracasSuperposition :: createSuperpositionPanel(int type) +{ + if (type=1) + { + _superposition1 = new wxMaracasSuperpositionPanel ( _images, _notebook ); + } + if (type=2) + { + _superposition2 = new wxMaracasSuperpositionPanel ( _images, _notebook ); + } + if (type=3) + { + _superposition3 = new wxMaracasSuperpositionPanel ( _images, _notebook ); + } +} + +void wxMaracasSuperposition :: changeImages(std::vector imgs) +{ + _images = imgs; + + createPanels(); + configurePanels(); +} + +std::vector wxMaracasSuperposition :: getImages( ) +{ + return _images; +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.h new file mode 100644 index 0000000..e595b7e --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperposition.h @@ -0,0 +1,79 @@ +/*========================================================================= + + Program: wxMaracas + Module: $RCSfile: wxMaracasSuperposition.h,v $ + Language: C++ + Date: $Date: 2009/06/03 13:47:07 $ + Version: $Revision: 1.3 $ + + Copyright: (c) 2002, 2003 + License: + + 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. + +=========================================================================*/ + +#ifndef __wxMaracasSuperpositionH__ +#define __wxMaracasSuperpositionH__ + +#include +#include +#include "wx/aui/aui.h" +#include "wxMaracasSuperpositionPanel.h" +#include "vtkMetaImageReader.h" +#include "vtkImageData.h" + + + + +class creaMaracasVisu_EXPORT wxMaracasSuperposition : public wxPanel +{ + +public: + + wxMaracasSuperposition(wxWindow* parent, std::vector imgs); + + ~wxMaracasSuperposition(); + + static wxMaracasSuperposition* getInstance(wxWindow* parent, std::vector imgs); + + static wxMaracasSuperposition* getInstance(); + + wxAuiNotebook * createNotebook(); + + void createPanels(); + + void createSuperpositionPanel(int type); + + void configurePanels(); + + void changeImages(std::vector imgs); + + std::vector getImages( ); + + +private: + + static wxMaracasSuperposition * instance; + + wxAuiManager m_mgr; + + wxAuiNotebook * _notebook; + + std::vector _images; + + wxMaracasSuperpositionPanel * _superposition1; + + wxMaracasSuperpositionPanel * _superposition2; + + wxMaracasSuperpositionPanel * _superposition3; + + long m_notebook_style; + + long m_notebook_theme; +}; + +#endif + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.cxx new file mode 100644 index 0000000..803eaa5 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.cxx @@ -0,0 +1,123 @@ + +//---------------------------------------------------------------------------------------------------------------- +// Class definition include +//---------------------------------------------------------------------------------------------------------------- +#include "wxMaracasSuperpositionPanel.h" + +//---------------------------------------------------------------------------------------------------------------- +// Other includes +//---------------------------------------------------------------------------------------------------------------- + + //------------------------------------------------------------------------------------------------------------ + // Constructors & Destructors + //------------------------------------------------------------------------------------------------------------ + + wxMaracasSuperpositionPanel :: wxMaracasSuperpositionPanel ( std::vector imgs, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd ) + :wxPanel(parent, -1, pos, size, style) + { + _images = imgs; + int gapH = 20; + int gapV = 10; + createSuperpositionPanel(); + + outSizer = new wxFlexGridSizer(1, 1, gapH, gapV); + outSizer -> AddGrowableCol(0); + outSizer -> AddGrowableRow(0); + outSizer->Add( theViewPanel, 1, wxGROW); + + this->SetSizer( outSizer ); + this->SetAutoLayout( true ); + this->Layout(); + } + + + wxMaracasSuperpositionPanel :: ~wxMaracasSuperpositionPanel() + { + + } + + //------------------------------------------------------------------------------------------------------------ + // Creational and initialization methods + //------------------------------------------------------------------------------------------------------------ + + void wxMaracasSuperpositionPanel :: createSuperpositionPanel() + { + + std::vector * numViews = new std::vector (); + numViews->push_back(0); + theViewPanel = new wxMaracas_N_ViewersWidget( this, _images[0], numViews ); + SetVisibleAxis(false); + + theViewPanel->SetBackgroundColour(wxColour(0,0,0)); + + theViewPanel->SetSize(800, 900); + theViewPanel->GetWindow(1)->SetSize(800, 900); + } + + //------------------------------------------------------------------------------------------------------------ + + wxVtkBaseView* wxMaracasSuperpositionPanel :: GetWxVtkBaseView() + { + return theViewPanel->GetwxVtkBaseView(1); + } + + + wxVtkMPR2DView * wxMaracasSuperpositionPanel::GetwxVtkMPR2DView() + { + return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1)); + } + + vtkImageData * wxMaracasSuperpositionPanel::GetshowingVID() + { + return _images[0]; + } + + int wxMaracasSuperpositionPanel::GetImageDataSizeZ() + { + int ext[6]; + GetshowingVID()->GetExtent(ext); + int sizeZ = ext[5]-ext[4]+1; + + return sizeZ; + } + + void wxMaracasSuperpositionPanel :: RefreshInterface() + { + GetWxVtkBaseView()->Refresh(); + } + + void wxMaracasSuperpositionPanel :: ChangeImage(vtkImageData* img) + { + theViewPanel->SetImage(img); + } + + //------------------------------------------------------------------------------------------------------------ + // Other functional methods + //------------------------------------------------------------------------------------------------------------ + + void wxMaracasSuperpositionPanel::SetVisibleAxis(bool ok) + { + GetwxVtkMPR2DView()->SetVisibleAxis(ok); + } + + //------------------------------------------------------------------------------------------------------------ + int wxMaracasSuperpositionPanel::GetX() + { + return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetX(); + } + //------------------------------------------------------------------------------------------------------------ + int wxMaracasSuperpositionPanel::GetY() + { + return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetY(); + } + //------------------------------------------------------------------------------------------------------------ + int wxMaracasSuperpositionPanel::GetZ() + { + return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ(); + } + + //------------------------------------------------------------------------------------------------------------ + void wxMaracasSuperpositionPanel::Refresh() + { + GetwxVtkMPR2DView()->GetRenWin()->Render(); + } \ No newline at end of file diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.h new file mode 100644 index 0000000..58ee022 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSuperpositionPanel.h @@ -0,0 +1,87 @@ +#ifndef __wxMaracasSuperpositionPanelH__ +#define __wxMaracasSuperpositionPanelH__ + +// ----------------------------------------------------------------------------------------------------------- +// WX headers inclusion. +// For compilers that support precompilation, includes . +// ----------------------------------------------------------------------------------------------------------- + +#include +#ifdef __BORLANDC__ +#pragma hdrstop +#endif +#ifndef WX_PRECOMP +#include +#endif + +#include + +//------------------------------------------------------------------------------------------------------------ +// Includes +//------------------------------------------------------------------------------------------------------------ + +#include "wxMaracas_N_ViewersWidget.h" +#include "vtkImageData.h" +#include "wxVtkBaseView.h" + +//------------------------------------------------------------------------------------------------------------ +// Class definition +//------------------------------------------------------------------------------------------------------------ + +class creaMaracasVisu_EXPORT wxMaracasSuperpositionPanel : public wxPanel +{ + +public: + + wxMaracasSuperpositionPanel( std::vector imgs, wxWindow *parent, const wxPoint& pos=wxDefaultPosition, + const wxSize& size = wxDefaultSize,long style= wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER, int vertStart=1, int vertEnd=1, + int horzStart=1, int horzEnd=1 ); + + + ~wxMaracasSuperpositionPanel(); + +//------------------------------------------------------------------------------------------------------------ +// Creational and initialization methods +//------------------------------------------------------------------------------------------------------------ + + void createSuperpositionPanel(); + +//------------------------------------------------------------------------------------------------------------ +// Other functional methods +//------------------------------------------------------------------------------------------------------------ + + void getSpacing( double * spacing ); + + wxVtkBaseView* GetWxVtkBaseView(); + wxVtkMPR2DView * GetwxVtkMPR2DView(); + vtkImageData * GetshowingVID(); + int GetImageDataSizeZ(); + void RefreshInterface(); + void ChangeImage(vtkImageData* img); + + void SetVisibleAxis(bool ok); + int GetX(); + int GetY(); + int GetZ(); + void Refresh(); + + +private: + + std::vector _images; + + /* + * Represents the panel for viewing + */ + wxMaracas_N_ViewersWidget * theViewPanel; + + /* + * Represents the outer sizer of the IRMViewPanel + */ + wxFlexGridSizer* outSizer; + + double last_spacing[3]; + +}; + +#endif /*__wxMaracasSuperpositionPanelH__*/ -- 2.45.1