#include "bbcreaMaracasVisuCutModule.h"
#include "bbcreaMaracasVisuPackage.h"
+#include "creaSystem.h"
+
namespace bbcreaMaracasVisu
{
}
void CutModule::CreateWidget(wxWindow* parent)
{
-
- _mainpanel = CutModelMainPanel::getInstance(parent);
+
+ std::string path = crea::System::GetDllAppPath("bbcreaMaracasVisu.dll");
+ _mainpanel = CutModelMainPanel::getInstance(parent, path);
+
bbSetOutputWidget( _mainpanel);
Process();
_tfun->RemoveAllPoints();
for(int i = 0; i < greylevel.size();i++){
_tfun->AddPoint(greylevel[i], value[i]);
- std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+ //std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
}
_ctfun->RemoveAllPoints();
for(int i = 0; i < greylevelcolors.size();i++){
_ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
- std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ //std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
}
--- /dev/null
+<ComboBoxData>
+ <ComboBoxItem>
+ <TransferenceFunction>
+ <Transferencepoint>
+ <greyValue>0</greyValue>
+ <intensity>0</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>0.5</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>1</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ </TransferenceFunction>
+ <Colors>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0</RGBgreyValue>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.25</RGBgreyValue>
+ <red>1</red>
+ <green>0</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.5</RGBgreyValue>
+ <red>0</red>
+ <green>0</green>
+ <blue>1</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.75</RGBgreyValue>
+ <red>0</red>
+ <green>1</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>1</RGBgreyValue>
+ <red>0</red>
+ <green>0</green>
+ <blue>0.2</blue>
+ </greyValueRGBpoint>
+ </Colors>
+ </ComboBoxItem>
+ <ComboBoxItem>
+ <TransferenceFunction>
+ <Transferencepoint>
+ <greyValue>0.0507602</greyValue>
+ <intensity>0</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>0.486513</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>0.932075</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ </TransferenceFunction>
+ <Colors>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0</RGBgreyValue>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.83693</RGBgreyValue>
+ <red>1</red>
+ <green>0</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ </Colors>
+ </ComboBoxItem>
+ <ComboBoxItem>
+ <TransferenceFunction>
+ <Transferencepoint>
+ <greyValue>0.0701324</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>0.491417</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ <Transferencepoint>
+ <greyValue>0.888426</greyValue>
+ <intensity>1</intensity>
+ </Transferencepoint>
+ </TransferenceFunction>
+ <Colors>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.00465915</RGBgreyValue>
+ <red>1</red>
+ <green>1</green>
+ <blue>1</blue>
+ </greyValueRGBpoint>
+ <greyValueRGBpoint>
+ <RGBgreyValue>0.997548</RGBgreyValue>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </greyValueRGBpoint>
+ </Colors>
+ </ComboBoxItem>
+</ComboBoxData>
--- /dev/null
+SUBDIRS(CutModule)
Program: wxMaracas
Module: $RCSfile: CutModelMainPanel.cxx,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:34 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:25 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
// EOF - wxMaracasMPR.cxx
#include "CutModelMainPanel.h"
-
+#include "HistogramDialog.h"
+#include "creaSystem.h"
#include <wx/colordlg.h>
#include <wx/bmpbuttn.h>
#include <Redo.xpm>
#include <OkAll.xpm>
+
+
CutModelMainPanel* CutModelMainPanel::instance=NULL;
-CutModelMainPanel::CutModelMainPanel( wxWindow* parent)
+CutModelMainPanel::CutModelMainPanel( wxWindow* parent, std::string path)
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
cutmanager=NULL;
- initialize();
+ initialize(path);
}
CutModelMainPanel::~CutModelMainPanel( ){
-
+ delete cutmanager;
}
-void CutModelMainPanel::initialize(){
- cutmanager = new CutModelManager();
+void CutModelMainPanel::initialize(std::string path){
+
+ cutmanager = new CutModelManager(path);
_panelid = 0;
_wxauimanager = new wxAuiManager(this);
_wxauimanager->Update();
}
-CutModelMainPanel* CutModelMainPanel::getInstance(wxWindow* parent){
+CutModelMainPanel* CutModelMainPanel::getInstance(wxWindow* parent, std::string path){
if(instance==NULL){
- instance = new CutModelMainPanel(parent);
+ if(parent == NULL){
+ parent = new wxFrame();
+ }
+ instance = new CutModelMainPanel(parent, path);
}
return instance;
}
-CutModelMainPanel* CutModelMainPanel::getInstance(){
+/*CutModelMainPanel* CutModelMainPanel::getInstance(){
return instance;
-}
+}*/
void CutModelMainPanel::setImageData(vtkImageData* img){
try{
return current;
}
void CutModelMainPanel::onUndo(){
+ try{
+ checkInvariant();
+ int result = cutmanager->Undo();
+ }catch(CutModelException e){
+ showErrorDialog(e.getCause());
+ }
+
}
void CutModelMainPanel::onRedo(){
+ try{
+ checkInvariant();
+ int result = cutmanager->Redo();
+
+ }catch(CutModelException e){
+ showErrorDialog(e.getCause());
+ }
+
}
void CutModelMainPanel::changeOpacity(int id,int opacity){
void CutModelMainPanel::ExecuteCut(int id, double* range, bool isinside){
try{
- checkInvariant();
+ checkInvariant();
+
cutmanager->ExecuteCut(id, range, isinside);
}catch(CutModelException e){
showErrorDialog(e.getCause());
}
void CutModelMainPanel::ShowStatistics(int id){
-
+
+ checkInvariant();
+ HistogramDialog *histo = new HistogramDialog(this, _T("Statistics"));
+
+ histo->initializeHistogram(cutmanager->GetResultImage());
+
+ histo->ShowModal();
+
+ delete histo;
+}
+
+void CutModelMainPanel::SaveCutModelData(std::string filename){
+ cutmanager->SaveCutModelData(filename);
+}
+
+void CutModelMainPanel::LoadCutModelData(std::string filename){
+ cutmanager->LoadCutModelData(filename);
}
/**
**
Program: wxMaracas
Module: $RCSfile: CutModelMainPanel.h,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:35 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:25 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
{
public:
- CutModelMainPanel( wxWindow* parent);
+
~CutModelMainPanel( );
- static CutModelMainPanel* getInstance(wxWindow* parent);
+ static CutModelMainPanel* getInstance(wxWindow* parent=NULL, std::string path ="");
- static CutModelMainPanel* getInstance();
+ //static CutModelMainPanel* getInstance();
void setImageData(vtkImageData* img);
void setRenderer(vtkRenderer* renderer);
- void initialize();
+ void initialize(std::string path);
void onAddCutModel();
void ShowPopUpMenu(int id);
void ShowStatistics(int id);
+
+
private:
+
+ CutModelMainPanel( wxWindow* parent, std::string path);
+
static CutModelMainPanel* instance;
CutModelManager* cutmanager;
void showErrorDialog(std::string str);
+ void SaveCutModelData(std::string filename);
+
+ void LoadCutModelData(std::string filename);
+
std::vector<CutModelView*> viewpanels;
wxAuiManager* _wxauimanager;
Program: wxMaracas
Module: $RCSfile: CutModelData.cxx,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:36 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
** Start of the manager class
**/
CutModelData::CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
+
+ initializeData(id, interactor, observer, img);
+
+}
+CutModelData::CutModelData(){
+
+}
+void CutModelData::initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
_id = id;
_currentshape=0;
createBoxWidget(interactor, observer);
createShapes();
ChangeShape(0);
checkInvariant();
-
-
}
CutModelData::~CutModelData(){
checkInvariant();
_boxWidgetVolume = vtkBoxWidget::New();
_boxWidgetVolume->SetInteractor( interactor );
- //_boxWidgetVolume->SetPlaceFactor(2);
+ //_boxWidgetVolume->SetPlaceFactor(1);
//_boxWidgetVolume->SetInput( img );
//_boxWidgetVolume->PlaceWidget();
+
_boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , observer );
_boxWidgetVolume->AddObserver( vtkCommand::StartInteractionEvent , observer );
_boxWidgetVolume->AddObserver( vtkCommand::RightButtonReleaseEvent , observer );
int *ext = img->GetExtent();
double *spc = img->GetSpacing();
+
matrix->SetElement(0,0,(ext[1]-ext[0])/4*spc[0]);
matrix->SetElement(1,1,(ext[3]-ext[2])/4*spc[1]);
- matrix->SetElement(2,2,(ext[5]-ext[4])/4*spc[2]);
- matrix->SetElement(0,3,(ext[1]-ext[0])/2*spc[0]);
- matrix->SetElement(1,3,(ext[3]-ext[2])/2*spc[1]);
- matrix->SetElement(2,3,(ext[5]-ext[4])/2*spc[2]);
+ matrix->SetElement(2,2,(ext[5]-ext[4])/4*spc[2]);
+
+ double orgx = (ext[1]-ext[0])/2*spc[0];
+ double orgy = (ext[3]-ext[2])/2*spc[1];
+ double orgz = (ext[5]-ext[4])/2*spc[2];
+ matrix->SetElement(0,3,orgx);
+ matrix->SetElement(1,3,orgy);
+ matrix->SetElement(2,3,orgz);
+
+
currentmatrix->SetMatrix(matrix);
_boxWidgetVolume->SetTransform(currentmatrix);
throw CutModelException("Shape type not found");
}
}
-void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)
+void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModelException)
{
wxBusyCursor wait;
CutModelFigure* actualCuttingModel = getCurentCuttingModel();
+ //_boxWidgetVolume->GetTransform(currentmatrix);
actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+ //actualCuttingModel->SetVtkTransform(currentmatrix);
actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());
bool inside;
}
-vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
+void CutModelData::ExecuteUnCut(bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModelException)
+{
- vtkMatrix4x4* matrix = currentmatrix->GetMatrix();
- vtkMatrix4x4* matrixmodel = modeltransform->GetMatrix();
+ wxBusyCursor wait;
- double *spc = copyimage->GetSpacing();
+ CutModelFigure* actualCuttingModel = getCurentCuttingModel();
+
+ actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+
+ actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());
- modeltransform->Identity();
+ bool inside;
+ bool volInt, volExt;
+ int xx,yy,zz;
+ unsigned short* pOrg;
+ int ext[6];
+ double spc[3];
+ long int contAfter = 0;
+ long int contBefor = 0;
+
+ double value;
+
- double* orient = currentmatrix->GetOrientationWXYZ();
- modeltransform->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);
+
+ copyimage->GetExtent(ext);
+
+ for (xx=ext[0];xx<ext[1]; xx++)
+ {
+ for (yy=ext[2];yy<ext[3]; yy++)
+ {
+ for (zz=ext[4];zz<ext[5];zz++)
+ {
+ inside=actualCuttingModel->IfPointInside(xx,yy,zz);
+ if ( ((inside==true)&&(isinside==true)) || ((!inside==true)&&(!isinside)) )
+ {
+ value = *((unsigned short*)image->GetScalarPointer (xx,yy,zz));
+ pOrg=(unsigned short*)copyimage->GetScalarPointer (xx,yy,zz);
+ //std::cout<<"CutModelData::ExecuteUnCut() "<<value<<" "<<*pOrg<<std::endl;
+ *pOrg=(unsigned short)value;
+ } // if inside
+ } // for zz
+ } // for yy
+ } // for xx
+
+}
- double* pos = currentmatrix->GetPosition();
- modeltransform->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);
+vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
- double* scal = currentmatrix->GetScale();
- modeltransform->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+ double *spc = copyimage->GetSpacing();
+ modeltransform->Identity();
- /*matrixmodel->Identity();
+ vtkMatrix4x4* matrix = currentmatrix->GetMatrix();
+ vtkMatrix4x4* matrixmodel = modeltransform->GetMatrix();
matrixmodel->SetElement(0,0,matrix->GetElement(0,0)/spc[0]);
matrixmodel->SetElement(1,0,matrix->GetElement(1,0)/spc[0]);
matrixmodel->SetElement(2,0,matrix->GetElement(2,0)/spc[0]);
matrixmodel->SetElement(2,2,matrix->GetElement(2,2)/spc[2]);
matrixmodel->SetElement(0,3,matrix->GetElement(0,3)/spc[0]);
matrixmodel->SetElement(1,3,matrix->GetElement(1,3)/spc[1]);
- matrixmodel->SetElement(2,3,matrix->GetElement(2,3)/spc[2]);*/
+ matrixmodel->SetElement(2,3,matrix->GetElement(2,3)/spc[2]);
+
+ /*
+
+ double* pos = currentmatrix->GetPosition();
+ modeltransform->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);
- //modeltransform->SetMatrix(matrixmodel);
+ double* scal = currentmatrix->GetScale();
+ modeltransform->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+ //double* orient = currentmatrix->GetOrientation();
+ //modeltransform->RotateZ(orient[2]);
+ //modeltransform->RotateY(orient[1]);
+ //modeltransform->RotateX(orient[0]);
+ double* orient = currentmatrix->GetOrientationWXYZ();
+ modeltransform->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);
+
+ */
+
modeltransform->Update();
return modeltransform;
+}
+void CutModelData::setTransform(vtkTransform* transform, vtkImageData* img)throw( CutModelException){
+
+
+ double *spc = img->GetSpacing();
+
+ currentmatrix->Identity();
+
+ /*double* orient = transform->GetOrientationWXYZ();
+ currentmatrix->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);
+
+ double* pos = transform->GetPosition();
+ currentmatrix->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);
+
+ double* scal = transform->GetScale();
+ currentmatrix->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+
+ currentmatrix->Update(); */
+
+ _boxWidgetVolume->SetTransform(transform);
+
+ /*vtkMatrix4x4* matrix = transform->GetMatrix();
+ vtkMatrix4x4* matrixcurrent = currentmatrix->GetMatrix();
+ matrixcurrent->SetElement(0,0,matrix->GetElement(0,0)/spc[0]);
+ matrixcurrent->SetElement(1,0,matrix->GetElement(1,0)/spc[0]);
+ matrixcurrent->SetElement(2,0,matrix->GetElement(2,0)/spc[0]);
+ matrixcurrent->SetElement(0,1,matrix->GetElement(0,1)/spc[1]);
+ matrixcurrent->SetElement(1,1,matrix->GetElement(1,1)/spc[1]);
+ matrixcurrent->SetElement(2,1,matrix->GetElement(2,1)/spc[1]);
+ matrixcurrent->SetElement(0,2,matrix->GetElement(0,2)/spc[2]);
+ matrixcurrent->SetElement(1,2,matrix->GetElement(1,2)/spc[2]);
+ matrixcurrent->SetElement(2,2,matrix->GetElement(2,2)/spc[2]);
+ matrixcurrent->SetElement(0,3,matrix->GetElement(0,3)/spc[0]);
+ matrixcurrent->SetElement(1,3,matrix->GetElement(1,3)/spc[1]);
+ matrixcurrent->SetElement(2,3,matrix->GetElement(2,3)/spc[2]); */
+
+
+ udapteActorDirection();
+ getModelTransform(img);
+
}
vtkTransform* CutModelData::getModelTransformInvers(){
inversModel->Identity ();
inversModel->Concatenate ( modeltransform );
inversModel->Inverse();
return inversModel;
+}
+
+vtkPolyData* CutModelData::getPolyData()throw( CutModelException){
+ return _Mapper->GetInput();
}
\ No newline at end of file
Program: wxMaracas
Module: $RCSfile: CutModelData.h,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:36 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
class CutModelData {
public:
+ CutModelData();
CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
~CutModelData();
+ void initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
+
int getId(){
return _id;
void ChangeShape(int selection)throw( CutModelException);
vtkActor* getActor()throw( CutModelException);
+
+ vtkPolyData* getPolyData()throw( CutModelException);
void changeColor(double r,double g,double b)throw( CutModelException);
void ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModelException);
+ void ExecuteUnCut( bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModelException);
+
void RefreshViewBox();
+
+ vtkTransform* getCurrentMatrix(){
+ return currentmatrix;
+ }
+
+ int getCurrentShape(){
+ return _currentshape;
+ }
+
+ void setCurrentShape(int currentshape){
+ _currentshape = currentshape;
+ }
+
+ void setTransform(vtkTransform* transform,vtkImageData* img)throw( CutModelException);
private:
void checkInvariant()throw( CutModelException);
void createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCommand* observer);
void createActor();
void setTransform(vtkImageData* img)throw( CutModelException);
- void createShapes();
+ void createShapes();
vtkBoxWidget* _boxWidgetVolume;
vtkPolyDataMapper* _Mapper;
vtkTransform* modeltransform;
vtkTransform* inversModel;
+
CutModelFigure* getCurentCuttingModel();
vtkTransform* getModelTransform(vtkImageData* copyimage);
Program: wxMaracas
Module: $RCSfile: CutModelManager.cxx,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:36 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
/**
** Start of the manager class
**/
-CutModelManager::CutModelManager(){
+CutModelManager::CutModelManager(std::string path){
+ _path = path;
_img = NULL;
_copyimg = NULL;
_interactor = NULL;
_render = NULL;
+ _currentaction=0;
}
CutModelManager::~CutModelManager(){
+ std::string files = _path;
+ files+="/infounrd_0_fig_0.info";
+ remove(files.c_str());
}
void CutModelManager::ExecuteCut(int id, double* range, bool isinside)throw( CutModelException){
checkInvariant();
+
CutModelData* current = getCutModelData(id);
current->ExecuteCut(range, isinside,_copyimg);
+
+ /*
+ Setting extra information for the undo
+ */
+ CutModelSaveBinInfo* undoaction = this->AddActionUndo(id, CUTMODEL_CUT);
+ undoaction->setRange(range);
+ undoaction->setIsInside(isinside);
+
}
vtkImageData* CutModelManager::GetResultImage(){
_render->AddActor(current->getActor());
current->RefreshViewBox();
_render->Render();
+}
+
+void CutModelManager::SaveCutModelData(std::string filename)throw( CutModelException){
+
+
+ throw CutModelException("not implemented");
+
+
+
+
+}
+
+
+
+void CutModelManager::LoadCutModelData(std::string filename)throw( CutModelException){
+
+ throw CutModelException("not implemented");
+
+}
+
+CutModelSaveBinInfo* CutModelManager::AddActionUndo(int idc, UNDOTYPE type)throw( CutModelException){
+
+ for(int i = _undoredo.size()-1; i > _currentaction;i--){
+ delete _undoredo[i];
+ _undoredo.pop_back();
+ }
+
+ CutModelSaveBinInfo* cutmodel = new CutModelSaveBinInfo(idc, _currentaction, type, _path);
+ if(type == CUTMODEL_CUT){
+ cutmodel->saveMatrix4x4(this->getCutModelData(idc)->getCurrentMatrix()->GetMatrix());
+ cutmodel->setCurrentShape(this->getCutModelData(idc)->getCurrentShape());
+ }
+
+ _undoredo.push_back(cutmodel);
+
+ _currentaction++;// = _undoredo.size();
+ //std::cout<<"current index "<<_currentaction;
+
+ return cutmodel;
+}
+
+int CutModelManager::Undo() throw( CutModelException){
+ //&& _currentaction < _undoredo.size()
+ if(_currentaction > 0){
+ int tempaction = _currentaction-1;
+ CutModelSaveBinInfo* currentundo = _undoredo[tempaction];
+ CutModelData* currentmodel;
+
+ if(currentundo->getActionType()==CUTMODEL_CUT){
+ //Undo the cut
+ vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+
+ currentmodel = getCutModelData(currentundo->getId());
+
+ currentmodel->setTransform(transform, _copyimg);
+
+ currentmodel->setCurrentShape(currentundo->getCurrentShape());
+
+ currentmodel->ExecuteUnCut(currentundo->getIsInside(), _img, _copyimg);
+
+ }
+ //Every thing ok
+ _currentaction--;
+ return 0;
+ }
+ return -1;
+}
+
+int CutModelManager::Redo() throw( CutModelException){
+
+ if(_currentaction >= 0 && _currentaction < _undoredo.size()){
+
+
+ CutModelSaveBinInfo* currentundo = _undoredo[_currentaction];
+ CutModelData* currentmodel;
+
+ if(currentundo->getActionType()==CUTMODEL_CUT){
+ //Redo the cut
+ vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+ currentmodel = getCutModelData(currentundo->getId());
+ currentmodel->setTransform(transform, _copyimg);
+ currentmodel->setCurrentShape(currentundo->getCurrentShape());
+ currentmodel->ExecuteCut(currentundo->getRange(), currentundo->getIsInside(), _copyimg);
+ }
+
+ _currentaction++;
+
+ return 0;
+ }
+ return -1;
}
\ No newline at end of file
Program: wxMaracas
Module: $RCSfile: CutModelManager.h,v $
Language: C++
- Date: $Date: 2009/09/01 14:01:36 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.3 $
Copyright: (c) 2002, 2003
License:
#define __CutModelManagerH__
#include <iostream>
+#include <stdio.h>
#include <vector>
#include "vtkImageData.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
+#include <vtkPolyDataWriter.h>
#include "CutModelException.h"
#include "CutModelData.h"
+#include "CutModelSaveBinInfo.h"
+
+
class CutModelManager {
public:
- CutModelManager();
+ CutModelManager(std::string path);
~CutModelManager();
void setImageData(vtkImageData* img);
vtkImageData* GetResultImage();
void RefreshActor(int id);
-private:
+
+ void SaveCutModelData(std::string filename)throw( CutModelException);
+
+ void LoadCutModelData(std::string filename)throw( CutModelException);
+
+ CutModelSaveBinInfo* AddActionUndo(int id, UNDOTYPE type)throw( CutModelException);
+
+ int Undo()throw( CutModelException);
+
+ int Redo()throw( CutModelException);
+private:
+
+ int _currentaction;
+
void checkInvariant() throw( CutModelException);
+ std::string _path;
vtkImageData* _img;
vtkImageData* _copyimg;
vtkRenderer* _render;
vtkRenderWindowInteractor* _interactor;
std::vector<CutModelData*> _vectordata;
+ std::vector<CutModelSaveBinInfo*> _undoredo;
CutModelData* getCutModelData(int id)throw( CutModelException);
};
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: CutModelSaveBinInfo.cxx,v $
+ Language: C++
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.1 $
+
+ 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 "CutModelSaveBinInfo.h"
+
+/**
+** Start of the manager class
+**/
+CutModelSaveBinInfo::CutModelSaveBinInfo(int id, int currentaction, UNDOTYPE actiontype, std::string path){
+
+ _id = id;
+
+ char c[100];
+ sprintf(c,"/infounrd_%d_fig_%d.info",currentaction,id);
+
+ _stdFilename = path;
+ _stdFilename+=c;
+ _stdFilename+=".poly";
+
+ _matrixFilename = path;
+ _matrixFilename+=c;
+ _actiontype = actiontype;
+
+
+}
+CutModelSaveBinInfo::~CutModelSaveBinInfo(){
+
+}
+void CutModelSaveBinInfo::savePolyData(vtkPolyData* polydata){
+ vtkPolyDataWriter * writer = vtkPolyDataWriter ::New();
+ writer->SetFileName(_stdFilename.c_str());
+ writer->SetInput(polydata);
+ writer->SetFileTypeToBinary();
+ writer->Write();
+ writer->Delete();
+}
+
+vtkTransform* CutModelSaveBinInfo::getPolyDataTransform()throw( CutModelException){
+ vtkPolyDataReader* reader = vtkPolyDataReader::New();
+ //std::cout<<"filename vtkTransform* CutModelSaveBinInfo::getPolyDataTransform()"<<this->getSTDFileName()<<std::endl;
+ reader->SetFileName(this->getSTDFileName().c_str());
+ vtkPolyData* poly = reader->GetOutput();
+
+ vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
+ mapper->SetInput(poly);
+ vtkActor* actor = vtkActor::New();
+ actor->SetMapper(mapper);
+ vtkMatrix4x4* actmatrix = actor->GetMatrix();
+
+ std::cout<<"tkTransform* CutModelSaveBinInfo::getPolyDataTransform() Actor "<<actor<<std::endl;
+ std::cout<<"tkTransform* CutModelSaveBinInfo::getPolyDataTransform() Actor Matrix "<<actmatrix<<std::endl;
+
+ mapper->Update();
+
+ vtkTransform* transform = vtkTransform::New();
+
+ transform->Identity();
+
+ transform->GetMatrix()->SetElement(0,0,actmatrix->GetElement(0,0));
+ transform->GetMatrix()->SetElement(1,0,actmatrix->GetElement(1,0));
+ transform->GetMatrix()->SetElement(2,0,actmatrix->GetElement(2,0));
+ transform->GetMatrix()->SetElement(0,1,actmatrix->GetElement(0,1));
+ transform->GetMatrix()->SetElement(1,1,actmatrix->GetElement(1,1));
+ transform->GetMatrix()->SetElement(2,1,actmatrix->GetElement(2,1));
+ transform->GetMatrix()->SetElement(0,2,actmatrix->GetElement(0,2));
+ transform->GetMatrix()->SetElement(1,2,actmatrix->GetElement(1,2));
+ transform->GetMatrix()->SetElement(2,2,actmatrix->GetElement(2,2));
+ transform->GetMatrix()->SetElement(0,3,actmatrix->GetElement(0,3));
+ transform->GetMatrix()->SetElement(1,3,actmatrix->GetElement(1,3));
+ transform->GetMatrix()->SetElement(2,3,actmatrix->GetElement(2,3));
+
+ actor->Delete();
+ mapper->Delete();
+ reader->Delete();
+ //poly->Delete();
+
+
+ return transform;
+
+}
+
+
+void CutModelSaveBinInfo::saveMatrix4x4(vtkMatrix4x4* matrix){
+ fstream binary_file(_matrixFilename.c_str(),ios::out|ios::binary);
+ binary_file.write(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
+ binary_file.close();
+}
+vtkTransform* CutModelSaveBinInfo::getTransformFromMatrixFile()throw( CutModelException){
+ vtkMatrix4x4* matrix = vtkMatrix4x4::New();
+ fstream binary_file(_matrixFilename.c_str(),ios::binary|ios::in);
+ binary_file.read(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
+ binary_file.close();
+
+ vtkTransform* transform = vtkTransform::New();
+ transform->SetMatrix(matrix);
+
+ return transform;
+}
\ No newline at end of file
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: CutModelSaveBinInfo.h,v $
+ Language: C++
+ Date: $Date: 2009/09/08 08:14:27 $
+ Version: $Revision: 1.1 $
+
+ 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 __CutModelSaveBinInfoH__
+#define __CutModelSaveBinInfoH__
+
+#include <iostream>
+#include <vector>
+#include "CutModelException.h"
+
+#include <vtkPolyData.h>
+#include <vtkPolyDataWriter.h>
+#include <vtkPolyDataReader.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkTransform.h>
+#include <vtkMatrix4x4.h>
+#include <vtkActor.h>
+
+enum UNDOTYPE
+{
+ CUTMODEL_ADD = 0,
+ CUTMODEL_REMOVE = 10,
+ CUTMODEL_CUT= 20,
+
+};
+
+class CutModelSaveBinInfo {
+
+public:
+
+ CutModelSaveBinInfo(int id, int currentaction,UNDOTYPE actiontype, std::string path);
+ ~CutModelSaveBinInfo();
+
+ int getId(){
+ return _id;
+ }
+
+ UNDOTYPE getActionType(){
+ return _actiontype;
+ }
+ std::string getSTDFileName()throw( CutModelException){
+ if(_stdFilename==""){
+ throw new CutModelException("Filename undoredo does not exists");
+ }
+ return _stdFilename;
+ }
+
+ /*void setSTDFileName(std::string filename){
+ _stdFilename = filename;
+ }*/
+
+ int getCurrentShape(){
+ return _currentshape;
+ }
+
+ void setCurrentShape(int currentshape){
+ _currentshape=currentshape;
+ }
+
+ void savePolyData(vtkPolyData* polydata);
+
+ vtkTransform* getPolyDataTransform()throw( CutModelException);
+
+ void saveMatrix4x4(vtkMatrix4x4* matrix);
+ vtkTransform* getTransformFromMatrixFile()throw( CutModelException);
+
+ void setRange(double* range){
+ _range = range;
+ }
+ void setIsInside(bool isinside){
+ _isinside = isinside;
+ }
+
+ double* getRange(){
+ return _range;
+ }
+ bool getIsInside(){
+ return _isinside;
+ }
+
+private:
+
+ int _id;
+ UNDOTYPE _actiontype;
+ int _currentshape;
+ double* _range;
+ bool _isinside;
+ std::string _stdFilename;
+ std::string _matrixFilename;
+};
+
+
+
+#endif
/*
Pointers
*/
- wxvtkmpr3Dview=NULL;
- wxvtkclipping3Dview=NULL;
+ //wxvtkmpr3Dview=NULL;
+ //wxvtkclipping3Dview=NULL;
/*
Histogram
NOTE I NEED THE UPDATE
*/
//if it was call from the clipping ctnrl panel
- if(wxvtkclipping3Dview!=NULL)
- {
- wxvtkclipping3Dview->Refresh();
+ //if(wxvtkclipping3Dview!=NULL)
+ //{
+ // wxvtkclipping3Dview->Refresh();
- }
- else if(wxvtkmpr3Dview!=NULL)
- {
- wxvtkmpr3Dview->Refresh();
+ //}
+ //else if(wxvtkmpr3Dview!=NULL)
+ //{
+ // wxvtkmpr3Dview->Refresh();
- }
+ //}
}
{
newvol=vol;
}
- void HistogramDialog::setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1)
- {
- wxvtkmpr3Dview=wxvtkmpr3Dview1;
- }
- void HistogramDialog::setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1)
- {
- wxvtkclipping3Dview=wxvtkclipping3Dview1;
- }
+ //void HistogramDialog::setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1)
+ //{
+ // wxvtkmpr3Dview=wxvtkmpr3Dview1;
+ //}
+ //void HistogramDialog::setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1)
+ //{
+ // wxvtkclipping3Dview=wxvtkclipping3Dview1;
+ //}
void HistogramDialog::setTransferenceFunctionHasPoints(bool hasPoints)
#include <vtkColorTransferFunction.h>
#include <vtkVolumeRayCastMapper.h>
#include <vtkVolume.h>
- #include "../wxMPRWidget.h"
+ //#include "../wxMPRWidget.h"
#include "HistogramDialogComboBoxItem.h"
#include <wx/checkbox.h>
void setTF(vtkPiecewiseFunction* tf);
void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
void setVolume(vtkVolume* vol);
- void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
- void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
+ //void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
+ //void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
//--------------------
// plotter Information
vtkVolume *newvol;
//things to refresh
- wxVtkMPR3DView *wxvtkmpr3Dview;
- wxVtkClipping3DView *wxvtkclipping3Dview;
+ //wxVtkMPR3DView *wxvtkmpr3Dview;
+ //wxVtkClipping3DView *wxvtkclipping3Dview;
wxSizer* getControls(bool extracontrols = false);
reader->SetFileName(namefile);
reader->Update();
_tissueStripper[3]->SetInput( reader->GetPolyDataOutput() );
+}
+
+void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
+
+ _volumeProperty->SetColor(colortable);
+
}
\ No newline at end of file
std::vector<double>* GetBlueColorsOfColorTransferenceFVector();
std::vector<double>* GetGreyValueColorsOfColorTransferenceFVector();
+ void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
//--------------------------------------
//Getters transference function
//and color of the transference function
// _saggitalColors->SetLookupTable(_bwLut);
_saggitalColors->SetLookupTable(_ctfun);
-
if(_saggital==NULL){
bool vtkMPR3DDataViewer::GetVisiblePosition(int idPosition)
{
return _visiblePosition[idPosition];
-}
\ No newline at end of file
+}
+
+void vtkMPR3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
+ _saggitalColors->SetLookupTable(colortable);
+ _coronalColors->SetLookupTable(colortable);
+ _axialColors->SetLookupTable(colortable);
+}
+
\ No newline at end of file
std::vector<double > *GetctFunVectorGreen();
std::vector<double > *GetctFunVectorBlue();
+ void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
private:
bool _visiblePosition[3];
Program: wxMaracas
Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
Language: C++
- Date: $Date: 2009/07/27 07:58:20 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2009/09/08 08:14:30 $
+ Version: $Revision: 1.16 $
Copyright: (c) 2002, 2003
License:
if(mvtkmpr2Dview_Z!=NULL){
mvtkmpr2Dview_Z->setColorTransferFunction(colortable);
}
+ if(mwxvtkmpr3Dview!=NULL){
+ mwxvtkmpr3Dview->setColorTransferFunction(colortable);
+ }
}
\ No newline at end of file
//setting variables if the user wants to do refresh
hDlg->setCTF(ctfun);
hDlg->setTF(tfun);
- hDlg->setClipping3DView(_wxvtkclipping3Dview);
+ //hDlg->setClipping3DView(_wxvtkclipping3Dview);
/*
hDlg->setVolume(newvol);
hDlg->setVolumeMapper(volumeMapper);
}
}
-
+void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable){
+ GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);
+}
//-------------------------------------------------------------------
void wxVtkMPR3DView::Refresh() // virtual
{
void RemoveActor(vtkActor* actor);
void ResetCamera(int *ext=NULL, double* origin=NULL,double* spc=NULL);
+ void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
private:
wxVtk3DBaseView *_wxvtk3Dbaseview;
vtkMPR3DDataViewer *_vtkmpr3Ddataviewer;
//setting variables if the user wants to do refresh
hDlg->setCTF(ctfun);
- hDlg->setMPR3Dview(_wxvtkmpr3Dview);
+ //hDlg->setMPR3Dview(_wxvtkmpr3Dview);
if(hDlg->ShowModal()== wxID_OK )
{