Program: wxMaracas
Module: $RCSfile: CutModelMainPanel.cxx,v $
Language: C++
-Date: $Date: 2010/03/05 17:54:39 $
-Version: $Revision: 1.7 $
+Date: $Date: 2010/03/31 12:41:56 $
+Version: $Revision: 1.8 $
Copyright: (c) 2002, 2003
License:
{
try{
checkInvariant();
- int result = cutmanager->Undo();
+ int result = cutmanager->Undo(); // result unused// JPR
}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){
showErrorDialog(e.getCause());
}
}
+
void CutModelMainPanel::ShowPopUpMenu(int id){
showErrorDialog("test");
}
+
void CutModelMainPanel::changeColor(int id,double r,double g,double b){
try{
}catch(CutModelException e){
showErrorDialog(e.getCause());
}
-
}
+
void CutModelMainPanel::ChangeShape(int id,int selection){
try{
checkInvariant();
for(i = 0; i < (int)viewpanels.size(); i++){
viewpanels[i]->ExecuteCut();
}
-
}
+
vtkImageData* CutModelMainPanel::GetResultImage(){
try{
checkInvariant();
Connect(btnExecutePolygonCut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onExecuteCutPolygon));
sizer->Add(btnExecutePolygonCut, 0, wxALIGN_LEFT);
-
_notebook->AddPage(panel, _T("Polygon Cutter"), false);
-
}
-
void PolygonCutterEventHandlerCutModel::onCheckChanged(wxCommandEvent& event){
CutModelMainPanel::getInstance()->onCheckChanged();
}
CutModelMainPanel::getInstance()->onExecuteCutPolygon();
}
-
-
/**
**
**/
_evthand = new ToolBarEventHandlerCutModel();
this->SetEventHandler(_evthand);
-
}
ToolBarCutModel::~ToolBarCutModel(void){
CutModelMainPanel::getInstance()->ExecuteAll();
}
-
BEGIN_EVENT_TABLE(ToolBarEventHandlerCutModel, wxEvtHandler)
EVT_MENU(10, ToolBarEventHandlerCutModel::onAdd)
EVT_MENU(20, ToolBarEventHandlerCutModel::onUndo)
EVT_MENU(30, ToolBarEventHandlerCutModel::onRedo)
EVT_MENU(40, ToolBarEventHandlerCutModel::onExecuteAll)
END_EVENT_TABLE()
-
Program: wxMaracas
Module: $RCSfile: CutModelData.cxx,v $
Language: C++
- Date: $Date: 2009/11/25 16:35:37 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2010/03/31 12:41:58 $
+ Version: $Revision: 1.6 $
Copyright: (c) 2002, 2003
License:
CutModelData::CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
initializeData(id, interactor, observer, img);
-
}
+
CutModelData::CutModelData(){
}
ChangeShape(0);
checkInvariant();
}
+
CutModelData::~CutModelData(){
checkInvariant();
_boxWidgetVolume->RemoveAllObservers();
inversModel->Delete();
_id = -1;
}
+
void CutModelData::RefreshViewBox(){
}
void CutModelData::createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCommand* observer){
-
_boxWidgetVolume = vtkBoxWidget::New();
_boxWidgetVolume->SetInteractor( interactor );
//_boxWidgetVolume->SetPlaceFactor(1);
//_boxWidgetVolume->GetHandleProperty()->SetOpacity(0.5);
//_boxWidgetVolume->GetOutlineProperty()->SetOpacity(0.5);
}
+
void CutModelData::setTransform(vtkImageData* img)throw( CutModelException){
currentmatrix = vtkTransform::New();
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(1,3,orgy);
matrix->SetElement(2,3,orgz);
-
currentmatrix->SetMatrix(matrix);
- _boxWidgetVolume->SetTransform(currentmatrix);
-
+ _boxWidgetVolume->SetTransform(currentmatrix);
}
+
void CutModelData::createActor(){
_Mapper = vtkPolyDataMapper::New();
_Actor = vtkActor::New();
_Actor->SetMapper(_Mapper);
_Actor->GetProperty()->SetColor(1, 0, 0);
- _Actor->GetProperty()->SetOpacity(0.5);
-
+ _Actor->GetProperty()->SetOpacity(0.5);
}
+
void CutModelData::udapteActorDirection()throw( CutModelException){
checkInvariant();
_boxWidgetVolume->GetTransform(currentmatrix);
_Actor->SetUserMatrix(currentmatrix->GetMatrix());//SetUserTransform(currentmatrix );
}
+
void CutModelData::createShapes(){
_cubefigure = new CutModelFigureCube();
_cylinderfigure = new CutModelFigureCylinder();
_spherefigure = new CutModelFigureSphere();
}
+
void CutModelData::changeOpacity(int opacity)throw( CutModelException){
checkInvariant();
_Actor->GetProperty()->SetOpacity((double)opacity/100.0);
}else{
throw CutModelException("Shape type not found");
}
-
_currentshape=selection;
}
}
if(_spherefigure==NULL){
throw CutModelException("Sphere not created");
- }
-
+ }
}
vtkActor* CutModelData::getActor()throw( CutModelException){
checkInvariant();
_Actor->GetProperty()->SetColor( r,g,b );
}
+
CutModelFigure* CutModelData::getCurentCuttingModel(){
checkInvariant();
throw CutModelException("Shape type not found");
}
}
+
void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModelException)
{
-
wxBusyCursor wait;
CutModelFigure* actualCuttingModel = getCurentCuttingModel();
actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());
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;
+ //bool volInt, volExt; // unused
+ int xx,yy,zz;
+ unsigned short* pOrg;
+ int ext[6];
+ //double spc[3]; // unused
+ //long int contAfter = 0; // unused
+ //long int contBefor = 0; // unused
double minvalue = range[0];
double value = range[1];
double maxvalue = range[2];
-
-
+
copyimage->GetExtent(ext);
for (xx=ext[0];xx<ext[1]; xx++)
} // for zz
} // for yy
} // for xx
-
}
void CutModelData::ExecuteUnCut(bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModelException)
{
-
wxBusyCursor wait;
CutModelFigure* actualCuttingModel = getCurentCuttingModel();
-
+
actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
-
+
actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());
bool inside;
- bool volInt, volExt;
- int xx,yy,zz;
+ // bool volInt, volExt; // unused // JPRx
+ int xx,yy,zz;
unsigned short* pOrg;
- int ext[6];
- double spc[3];
- long int contAfter = 0;
- long int contBefor = 0;
-
+ int ext[6];
+ //double spc[3]; // unused // JPRx
+ //long int contAfter = 0; // unused // JPRx
+ //long int contBefor = 0; // unused // JPRx
+
double value;
-
-
copyimage->GetExtent(ext);
-
+
for (xx=ext[0];xx<ext[1]; xx++)
{
for (yy=ext[2];yy<ext[3]; yy++)
} // for zz
} // for yy
} // for xx
-
}
vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
double *spc = copyimage->GetSpacing();
modeltransform->Identity();
- vtkMatrix4x4* matrix = currentmatrix->GetMatrix();
+ 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,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->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();
+void CutModelData::setTransform(vtkTransform* transform, vtkImageData* img)throw( CutModelException){
+
+ double *spc = img->GetSpacing(); // spc unused // JPR
currentmatrix->Identity();
currentmatrix->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
currentmatrix->Update(); */
-
+
_boxWidgetVolume->SetTransform(transform);
/*vtkMatrix4x4* matrix = transform->GetMatrix();
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 );