std::vector<vtkProp3D*> tempvect;
int i;
-
-
if(irmview != NULL){
vtkRenderer* renderer = bbGetInputRenderer();
irmview->setRenderer(renderer);
#include "bbcreaMaracasVisuVolumeRendering.h"
#include "bbcreaMaracasVisuPackage.h"
+
+#include "wxMaracasMultipleVolumeRendererView.h"
+
namespace bbcreaMaracasVisu
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,VolumeRendering)
-BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRendering,bbtk::AtomicBlackBox);
+BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRendering,bbtk::WxBlackBox);
void VolumeRendering::Process()
{
// (the one provided in the attribute 'name' of the tag 'input')
// * TYPE is the C++ type of the input/output
// (the one provided in the attribute 'type' of the tag 'input')
-
-
- vtkImageData* _img = bbGetInputIn();
-
- if(_img!=NULL){
- double range[2];
- _img->GetScalarRange(range);
- double max = range[1];
- _tfun->AddPoint(max * 0/2 , 0.0);
- _tfun->AddPoint(max * 1/2 , 1.0);
- _tfun->AddPoint(max * 2/2 , 1.0);
- _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
- _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
- _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
- _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
- _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
+ wxMaracasMultipleVolumeRendererView* volview = (wxMaracasMultipleVolumeRendererView*)bbGetOutputWidget();
+ vtkImageData* _img1 = bbGetInputIn1();
+ vtkImageData* _img2 = bbGetInputIn2();
+ vtkImageData* _img3 = bbGetInputIn3();
+ vtkImageData* _img4 = bbGetInputIn4();
+ vtkRenderer* renderer = bbGetInputRenderer();
- _volumeMapper->SetInput( _img );
-
- _volumeMapper->Update();
- _newvol->Update();
+ if(volview!=NULL){
+ if(renderer!=NULL&&_currentrenderer != renderer){
+ volview->setRenderer(renderer);
+ _currentrenderer = renderer;
+ }
+ if(_currentrenderer!=NULL){
+ if(_img1 !=NULL){
+ volview->addVolume(_img1, "INPUT 1");
+ }
+ if(_img2 !=NULL){
+ volview->addVolume(_img2, "INPUT 2");
+ }
+ if(_img3 !=NULL){
+ volview->addVolume(_img3, "INPUT 3");
+ }
+ if(_img4 !=NULL){
+ volview->addVolume(_img4, "INPUT 4");
+ }
+ }
+ }
+}
+void VolumeRendering::CreateWidget(wxWindow* parent)
+{
- bbSetOutputOut(_newvol);
- }
-
+ wxMaracasMultipleVolumeRendererView* volview = wxMaracasMultipleVolumeRendererView::getInstance(parent);
+ bbSetOutputWidget(volview);
-
}
void VolumeRendering::bbUserSetDefaultValues()
{
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
- bbSetInputIn(0);
- bbSetOutputOut(0);
+ bbSetInputIn1(0);
+ bbSetInputIn2(0);
+ bbSetInputIn3(0);
+ bbSetInputIn4(0);
+ bbSetInputRenderer(0);
}
void VolumeRendering::bbUserInitializeProcessing()
-{
- _tfun = vtkPiecewiseFunction::New();
- _ctfun = vtkColorTransferFunction::New();
-
- _volumePlanes = vtkPlanes::New();
- _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
- _volumeMapper = vtkVolumeRayCastMapper::New();
- _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
- _volumeMapper->SetClippingPlanes( _volumePlanes );
- _volumeMapper->AutoAdjustSampleDistancesOn();
- _volumeProperty = vtkVolumeProperty::New();
- _volumeProperty->SetInterpolationTypeToLinear();
- _volumeProperty->ShadeOn();
- _volumeProperty->DisableGradientOpacityOn();
- _volumeProperty->SetColor(_ctfun);
- _volumeProperty->SetScalarOpacity( _tfun );
- _newvol = vtkVolume::New();
- _newvol->SetMapper(_volumeMapper );
- _newvol->SetProperty(_volumeProperty );
-
+{
+ _currentrenderer = NULL;
}
void VolumeRendering::bbUserFinalizeProcessing()
{
#ifndef __bbcreaMaracasVisuVolumeRendering_h_INCLUDED__
#define __bbcreaMaracasVisuVolumeRendering_h_INCLUDED__
#include "bbcreaMaracasVisu_EXPORT.h"
-#include "bbtkAtomicBlackBox.h"
+#include "bbtkWxBlackBox.h"
#include "iostream"
-#include <vtkVolumeRayCastCompositeFunction.h>
-#include <vtkPlanes.h>
-#include <vtkVolumeRayCastMapper.h>
-#include <vtkVolumeProperty.h>
-#include <vtkVolume.h>
-#include <vtkPiecewiseFunction.h>
-#include <vtkColorTransferFunction.h>
+
#include <vtkImageData.h>
-#include <vtkProp3D.h>
+#include <vtkRenderer.h>
namespace bbcreaMaracasVisu
class bbcreaMaracasVisu_EXPORT VolumeRendering
:
- public bbtk::AtomicBlackBox
+ public bbtk::WxBlackBox
{
- BBTK_BLACK_BOX_INTERFACE(VolumeRendering,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,vtkImageData*);
- BBTK_DECLARE_OUTPUT(Out,vtkProp3D*);
+ BBTK_BLACK_BOX_INTERFACE(VolumeRendering,bbtk::WxBlackBox);
+
+
+
+ BBTK_DECLARE_INPUT(In1,vtkImageData*);
+ BBTK_DECLARE_INPUT(In2,vtkImageData*);
+ BBTK_DECLARE_INPUT(In3,vtkImageData*);
+ BBTK_DECLARE_INPUT(In4,vtkImageData*);
+ BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
+
+
+ /*BBTK_DECLARE_INPUT(GreyLevel, std::vector<double> );
+ BBTK_DECLARE_INPUT(Value, std::vector<double> );
+ BBTK_DECLARE_INPUT(GreyLevelColors, std::vector<double>);
+ BBTK_DECLARE_INPUT(Red, std::vector<double>);
+ BBTK_DECLARE_INPUT(Green, std::vector<double>);
+ BBTK_DECLARE_INPUT(Blue, std::vector<double>);*/
+ //BBTK_DECLARE_OUTPUT(Out,vtkProp3D*);
BBTK_PROCESS(Process);
void Process();
+ BBTK_CREATE_WIDGET(CreateWidget);
+ void CreateWidget(wxWindow*);
private:
- vtkVolumeRayCastCompositeFunction *_compositeFunction;
- vtkPlanes *_volumePlanes;
- vtkVolumeRayCastMapper *_volumeMapper;
- vtkVolumeProperty *_volumeProperty;
- vtkVolume *_newvol;
- vtkPiecewiseFunction* _tfun;
- vtkColorTransferFunction* _ctfun;
+ vtkRenderer* _currentrenderer;
+
};
-BBTK_BEGIN_DESCRIBE_BLACK_BOX(VolumeRendering,bbtk::AtomicBlackBox);
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(VolumeRendering,bbtk::WxBlackBox);
BBTK_NAME("VolumeRendering");
BBTK_AUTHOR("car-prie@uniandes.edu.co");
BBTK_DESCRIPTION("Volume Rendering of a given image");
BBTK_CATEGORY("__CATEGORY__");
-BBTK_INPUT(VolumeRendering,In,"Image to create the volume rendering",vtkImageData*,"");
-BBTK_OUTPUT(VolumeRendering,Out,"Prop3D resulting from the volume rendering",vtkProp3D*,"");
+
+BBTK_INPUT(VolumeRendering,In1,"Image to create the volume rendering",vtkImageData*,"");
+BBTK_INPUT(VolumeRendering,In2,"Image to create the volume rendering",vtkImageData*,"");
+BBTK_INPUT(VolumeRendering,In3,"Image to create the volume rendering",vtkImageData*,"");
+BBTK_INPUT(VolumeRendering,In4,"Image to create the volume rendering",vtkImageData*,"");
+BBTK_INPUT(VolumeRendering,Renderer,"Image to create the volume rendering",vtkRenderer*,"");
+
+
+//BBTK_OUTPUT(VolumeRendering,Out,"Prop3D resulting from the volume rendering",vtkProp3D*,"");
+
+/*BBTK_INPUT(VolumeRendering,GreyLevel,"Greylevel related to the transparency",std::vector<double>,"");
+ BBTK_INPUT(VolumeRendering,Value,"Value of the transparency in the transfer function",std::vector<double>,"");
+ BBTK_INPUT(VolumeRendering,GreyLevelColors,"Grey level of the color in the transfer function",std::vector<double>,"");
+ BBTK_INPUT(VolumeRendering,Red,"Red value according to the GreyLevelColors",std::vector<double>,"");
+ BBTK_INPUT(VolumeRendering,Green,"Green value according to the GreyLevelColors",std::vector<double>,"");
+ BBTK_INPUT(VolumeRendering,Blue,"Blue value according to the GreyLevelColors",std::vector<double>,"");*/
BBTK_END_DESCRIBE_BLACK_BOX(VolumeRendering);
}
// EO namespace bbcreaMaracasVisu
//-----------------------------------------------------
void TransferFunctionView::Process()
{
- if(bbGetInputIn()!=NULL){
- mwxwidget->initializeHistogram(bbGetInputIn());
- mwxwidget->Refresh();
- }
-
+
+ std::vector<double> greylevel;
+ std::vector<double> value;
+
+ std::vector<double> greylevelcolors;
+ std::vector<double> red;
+ std::vector<double> green;
+ std::vector<double> blue;
+
+ if(bbGetInputIn()!=NULL){
+
+ if(_currentimg != bbGetInputIn()){
+ _currentimg = bbGetInputIn();
+ mwxwidget->initializeHistogram(_currentimg);
+ mwxwidget->Refresh();
+ }
+
+ mwxwidget->GetValuesPointsFunction(greylevel, value);
+ mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue);
+
+
+ _tfun->RemoveAllPoints();
+ for(int i = 0; i < greylevel.size();i++){
+ _tfun->AddPoint(greylevel[i], value[i]);
+// std::cout<<"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<<"transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ }
+
+
+ bbSetOutputOpacityFunction(_tfun);
+ bbSetOutputColorFunction(_ctfun);
+ /*bbSetOutputGreyLevel(greylevel);
+ bbSetOutputValue(value);
+ bbSetOutputGreyLevelColors(greylevelcolors);
+ bbSetOutputRed(red);
+ bbSetOutputGreen(green);
+ bbSetOutputBlue(blue);*/
+
+
+
+
+ }
+
+
}
//-----------------------------------------------------
void TransferFunctionView::bbUserSetDefaultValues()
{
mwxwidget = NULL;
+ _currentimg = NULL;
+
+ _tfun = NULL;
+ _ctfun = NULL;
}
//-----------------------------------------------------------------
void TransferFunctionView::bbUserInitializeProcessing()
{
+ _tfun = vtkPiecewiseFunction::New();
+ _ctfun = vtkColorTransferFunction::New();
bbSetInputIn(NULL);
}
#include "vtkImageData.h"
#include "HistogramWidget.h"
+#include "vtkPiecewiseFunction.h"
+#include "vtkColorTransferFunction.h"
+
namespace bbcreaMaracasVisu
{
{
BBTK_BLACK_BOX_INTERFACE(TransferFunctionView,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In, vtkImageData*);
+ BBTK_DECLARE_OUTPUT(OpacityFunction, vtkPiecewiseFunction*);
+ BBTK_DECLARE_OUTPUT(ColorFunction, vtkColorTransferFunction*);
+ /*BBTK_DECLARE_OUTPUT(GreyLevel, std::vector<double> );
+ BBTK_DECLARE_OUTPUT(Value, std::vector<double> );
+ BBTK_DECLARE_OUTPUT(GreyLevelColors, std::vector<double>);
+ BBTK_DECLARE_OUTPUT(Red, std::vector<double>);
+ BBTK_DECLARE_OUTPUT(Green, std::vector<double>);
+ BBTK_DECLARE_OUTPUT(Blue, std::vector<double>);*/
+
BBTK_PROCESS(Process);
void Process();
BBTK_CREATE_WIDGET(CreateWidget);
private:
HistogramWidget *mwxwidget;
+ vtkImageData* _currentimg;
+ vtkPiecewiseFunction* _tfun;
+ vtkColorTransferFunction* _ctfun;
};
BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransferFunctionView,bbtk::WxBlackBox);
BBTK_DESCRIPTION("Transfer Function Window");
//BBTK_CATEGORY("__CategoryBlackBox__");
BBTK_INPUT(TransferFunctionView,In,"Input image",vtkImageData*,"");
+ BBTK_OUTPUT(TransferFunctionView,OpacityFunction,"Transfer function for the opacity", vtkPiecewiseFunction*,"");
+ BBTK_OUTPUT(TransferFunctionView,ColorFunction,"Transfer function for the color", vtkColorTransferFunction*,"");
+ /*BBTK_OUTPUT(TransferFunctionView,GreyLevel,"Greylevel related to the transparency",std::vector<double>,"");
+ BBTK_OUTPUT(TransferFunctionView,Value,"Value of the transparency in the transfer function",std::vector<double>,"");
+ BBTK_OUTPUT(TransferFunctionView,GreyLevelColors,"Grey level of the color in the transfer function",std::vector<double>,"");
+ BBTK_OUTPUT(TransferFunctionView,Red,"Red value according to the GreyLevelColors",std::vector<double>,"");
+ BBTK_OUTPUT(TransferFunctionView,Green,"Green value according to the GreyLevelColors",std::vector<double>,"");
+ BBTK_OUTPUT(TransferFunctionView,Blue,"Blue value according to the GreyLevelColors",std::vector<double>,"");*/
BBTK_END_DESCRIBE_BLACK_BOX(TransferFunctionView);
}
// EO namespace bbcreaMaracasVisu
this->type=type;
}
+/**
+** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+**/
+ void HistogramWidget::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value){
+ plotter->GetValuesPointsFunction(greylevel,value,histogramSize);
+ }
+/**
+** Returns two vectors, the grey level of the point and its value, the red, green
+** and blue value is between [0,1]
+**/
+ void HistogramWidget::GetValuesColorPointsFunction(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue)
+ {
+ plotter->GetValuesColorPointsFunction(greylevel,red,green,blue);
+ }
int getHistogramSize();
void setType(int type);
+ /**
+ ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+ **/
+ void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value);
+
+ /**
+ ** Returns two vectors, the grey level of the point and its value, the red, green
+ ** and blue value is between [0,1]
+ **/
+ void GetValuesColorPointsFunction(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue);
private:
SetFont( ff );
}
-void mpScaleY::Plot(wxDC & dc, mpWindow & w)
+void mpScaleY::Plot(wxDC & dc, mpWindow & w, int orgy)
{
dc.SetPen( m_pen);
dc.SetFont( m_font);
const int orgx = -(int)(w.GetPosX() * w.GetScaleX());
const int extend = w.GetScrY()/2;
- dc.DrawLine( orgx, -extend, orgx, extend);
+ double sizedc = dc.GetSize().GetHeight()-orgy;
+
+ dc.DrawLine( orgx, GetYTranslated(sizedc, -extend), orgx, GetYTranslated(sizedc, extend));
const double dig = floor( log( 128.0 / w.GetScaleY() ) / mpLN10 );
const double step = exp( mpLN10 * dig);
for (;n < end; n += step)
{
const int p = (int)((w.GetPosY() - n) * w.GetScaleY());
- dc.DrawLine( orgx, p, orgx+4, p);
+ dc.DrawLine( orgx, GetYTranslated(sizedc, p), orgx+4, GetYTranslated(sizedc,p));
s.Printf(fmt, n);
dc.GetTextExtent(s, &tx, &ty);
if ((tmp-p+ty/2) > 32)
{
- dc.DrawText( s, orgx+4, p-ty/2);
+ dc.DrawText( s, orgx+4, GetYTranslated(sizedc,p-ty/2));
tmp=p-ty/2;
}
}
dc.GetTextExtent(m_name, &tx, &ty);
- dc.DrawText( m_name, orgx-tx-4, -extend + ty + 4);
+ dc.DrawText( m_name, orgx-tx-4, GetYTranslated(sizedc,-extend + ty + 4));
}
//-----------------------------------------------------------------------------
//dc.SetDeviceOrigin(70,40);
//dc.SetAxisOrientation(false,true);
- temp_dc.SetAxisOrientation(true,false);
+ //temp_dc.SetAxisOrientation(true,false);
//EED 14mai2009
//dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,-70,-m_scrY+40);
*/
void SetPen(wxPen& pen) { m_pen = pen; }
+ /**
+ ** Get the translation of the Y coordinate acoording to the new orientation of the axis du to the problem
+ ** identified in MACOS with the funtion 'SetAxisOrientation'
+ **/
+ int GetYTranslated(double sizey, double y){
+ return -y+sizey;
+ }
+
protected:
wxFont m_font; //!< Layer's font
wxPen m_pen; //!< Layer's pen
/** Layer plot handler.
This implementation will plot the ruler adjusted to the visible area.
*/
- virtual void Plot(wxDC & dc, mpWindow & w);
+ virtual void Plot(wxDC & dc, mpWindow & w, int orgy);
/** Check whether this layer has a bounding box.
This implementation returns \a FALSE thus making the ruler invisible
/** Refresh display */
void UpdateAll();
+ /**
+ ** Get the translation of the Y coordinate
+ **/
+ int GetYTranslated(wxSize size, double y){
+ return size.GetHeight()-y;
+ }
+
protected:
void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
void pColorBar :: onAddColorPoint ( wxCommandEvent& anEvent )
{
bool addedPoint = false;
- double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );;
+ double real_x = getOrientation() ? convertToRealValue( clickedX ) : convertToRealValue( clickedY );
wxColour selectedColor = getSelectedColour();
if (okSelectedColor)
{
int minDiference=10000000;
wxNode* node=logicFunction->GetPointAt(0);
wxNode* before=NULL;
+
while(node)
{
pFunctionPoint* before1=(pFunctionPoint*)node->GetData();
//realPoints.DeleteC
np = logicFunction->getSizePoints();
- nps = 100;
+ nps = 200;
delta=( double ) ( np ) / ( double ) ( nps );
for( i = 0; i < nps; i++ )
{
*/
maxLevelOfGrey=(int)range[1];
minLevelOfGrey=(int)range[0];
+ //std::cout<<"maxLevelOfGrey "<<maxLevelOfGrey<<" minLevelOfGrey "<<minLevelOfGrey<<std::endl;
/*
Image Size
*/
//j=p*k;
j=getIndex(*dataImagePointer);
+ //std::cout<<j<<std::endl;
dataHistogramPointer[j]++;
dataImagePointer++;
}
*/
int pHistogram::getIndex(int gValue)
{
- double p=((float)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey);
+
+ double p=((double)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey);
double k=p*(size-1);
+ //std::cout<<"gValue "<<gValue<<" k "<<k<<std::endl;
return (int)k;
}
/*
*/
+/**
+** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+**/
+void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize)
+{
+ if(actualFunction != NULL){
+ double* xval = actualFunction->getX_RealValues();
+ double* yval = actualFunction->getY_RealValues();
+
+ actualFunction->getScaleY();
+ for(int i = 0; i < actualFunction->getSizePoints();i++){
+ greylevel.push_back(xval[i]);
+ value.push_back(yval[i]/histogramsize);
+ }
+ }
+}
+
+/**
+** Returns two vectors, the grey level of the point and its value, the red, green
+** and blue value is between [0,1]
+**/
+void pPlotter::GetValuesColorPointsFunction(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue)
+{
+
+ if(color_bar != NULL){
+
+ std::vector<pColorPoint*> colors;
+ color_bar->getAddedColorsPointsList(colors);
+
+ for(int i = 0; i < colors.size();i++){
+ pColorPoint* pcolor = colors[i];
+
+ greylevel.push_back(pcolor->getRealX());
+ wxColour colour = pcolor->getColor();
+
+ double _red = (double)(colour.Red())/255.0;
+ double _green = (double)(colour.Green())/255.0;
+ double _blue = (double)(colour.Blue())/255.0;
+
+ red.push_back(_red);
+ green.push_back(_green);
+ blue.push_back(_blue);
+ }
+ }
+}
+
+
bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
bool delPoint,bool load,bool save);
+
+ /**
+ ** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
+ **/
+ void GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize);
+
+ /**
+ ** Returns two vectors, the grey level of the point and its value, the red, green
+ ** and blue value is between [0,1]
+ **/
+ void GetValuesColorPointsFunction(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue);
+
//----------------------------------------------------------------------------------------
// Attributes declration
//----------------------------------------------------------------------------------------
Draw the line from (x1,y1) to (x2,y2) only passing by the
positive points in the line
*/
-void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2)
+void pPlotterLayer::draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int orgy)
{
//intercepts
float x0=-y1/m+x1;
float y0=-m*x1+y1;
+ double sizedc = dc.GetSize().GetHeight()-orgy;
//analyzing the curve
if(x1<=0 && x2>=0)
{
if(y2>=0 && y1>=0)
- dc.DrawLine(0,y0, x2,y2);
+ dc.DrawLine(0,GetYTranslated(sizedc,y0), x2,GetYTranslated(sizedc,y2));
else if(y2<=0 && y1>=0)
{
if(y0>=0 && x0>=0)
- dc.DrawLine(0,y0,x0,0 );
+ dc.DrawLine(0,GetYTranslated(sizedc,y0),x0,GetYTranslated(sizedc,0) );
}
else if(y2>=0 && y1<=0)
{
if(y0>=0)
- dc.DrawLine(0,y0,x2,y2 );
+ dc.DrawLine(0,GetYTranslated(sizedc,y0),x2,GetYTranslated(sizedc,y2) );
}
}
if(x1>=0 && x2>=0)
{
if(y1>=0 && y2>=0 )
- dc.DrawLine(x1,y1, x2,y2);
+ dc.DrawLine(x1,GetYTranslated(sizedc,y1), x2,GetYTranslated(sizedc,y2));
else if(y1>=0 && y2<=0)
- dc.DrawLine(x1,y1,x0,0 );
+ dc.DrawLine(x1,GetYTranslated(sizedc,y1),x0,GetYTranslated(sizedc,0) );
else if(y1<=0 && y2>=0)
- dc.DrawLine(x0,0,x2,y2);
+ dc.DrawLine(x0,GetYTranslated(sizedc,0),x2,GetYTranslated(sizedc,y2));
}
* Draw the function with th spline points
*
*/
-void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w)
+void pPlotterLayer::drawSplineCurve(wxDC & dc,mpWindow & w, int orgy)
{
std::vector<double> vx=getXSpline();
std::vector<double> vy=getYSpline();
if(type!=2)
- draw(dc,w,cxi,cyi,cxj,cyj);
+ draw(dc,w,cxi,cyi,cxj,cyj,orgy);
else if(type==2)
{
if(!initializePolygon(ppoints,cxi,cyi,cxj,cyj) && ((cxi<=0 && cxj>=0)||(cxi>=0 && cxj>=0)))
dc.SetBrush(wxBrush( wxColour(239,238,242) ,wxSOLID ));
dc.SetPen(wxPen( wxColour(0,0,0) ,1,wxSOLID ));
//dc.DrawPolygon(vx.size()+2,ppoints,0,0);
+ for(int i = 0; i <= j + 1; i++){
+ int sizedc = dc.GetSize().GetHeight()-orgy;
+ ppoints[i].y = GetYTranslated(sizedc, ppoints[i].y);
+ }
dc.DrawPolygon(j+2,ppoints,0,0);
}
/**
* Draw the lines between the points of the function
*/
-void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w)
+void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy)
{
dc.GetSize(&scrwX, &scrwY);
//Lines between the points
+
+ int sizedc = dc.GetSize().GetHeight()-orgy;
GetPoints(points);
ppoints=(wxPoint*)malloc(sizeof(int)*2*(points.GetCount()+2));
//initialize points
point.x=-5000;
- point.y=-5000;
+ point.y=GetYTranslated(sizedc,-5000);
ppoints[0]=point;
ppoints[1]=point;
int cyj=pyj* scaleY+ offsetpy ;
//dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy );
if(type!=2)
- draw(dc,w,pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy );
+ draw(dc,w,pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy,orgy );
//dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy );
else if(type==2)
{
if(!initializePolygon(ppoints,cxi,cyi,cxj,cyj) && ((cxi<=0 && cxj>=0)||(cxi>=0 && cxj>=0)))
{
point.x=cxj;
- point.y=cyj;
+ point.y=GetYTranslated(sizedc,cyj);
ppoints[j]=point;
j++;
{
//point.x=vx.at(size-1)* scaleX + offsetpx;
point.x=ppoints[j-1].x;
- point.y=0;
+ point.y=GetYTranslated(sizedc,0);
//ppoints[vx.size()]=point;
ppoints[j]=point;
/*
//settings for fill
//point.x=vx.at(0)*scaleX + offsetpx;
point.x=ppoints[0].x;
- point.y=0;
+ point.y=GetYTranslated(sizedc,0);
//ppoints[vx.size()+1]=point;
ppoints[j+1]=point;
/**
* Draw the points of the function
*/
-void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w)
+void pPlotterLayer::drawPoints(wxDC & dc,mpWindow & w, int orgy)
{
Rewind();
double x, y;
int minX,maxX,minY,maxY;
+ double sizedc = dc.GetSize().GetHeight()-orgy;
/*
This is the offset of every point scale to the window
dc.SetBrush(wxBrush( wxColour(255,0,0),wxSOLID ));
//dc.SetPen(wxPen(wxColour(0,0,0),1,wxSOLID) );
points[0].x=((x-minX-offsetX)*scaleX + offsetpx-MOVE);
- points[0].y=((y-minY-offsetY)*scaleY+ offsetpy-MOVE);
+ points[0].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy-MOVE));
points[1].x=((x-minX-offsetX)*scaleX+ offsetpx+MOVE);
- points[1].y=((y-minY-offsetY)*scaleY+ offsetpy-MOVE);
+ points[1].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy-MOVE));
points[2].x=((x-minX-offsetX)*scaleX+ offsetpx+MOVE);
- points[2].y=((y-minY-offsetY)*scaleY+ offsetpy+MOVE);
+ points[2].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy+MOVE));
points[3].x=((x-minX-offsetX)*scaleX+ offsetpx-MOVE);
- points[3].y=((y-minY-offsetY)*scaleY+ offsetpy+MOVE);
+ points[3].y=GetYTranslated(sizedc,((y-minY-offsetY)*scaleY+ offsetpy+MOVE));
if((x-minX-offsetX)*scaleX >=0 && (y-minY-offsetY/*w.getMinScrY()*/)*scaleY>=0)
dc.DrawPolygon(4,points,0,0);
}
* Draw the line between the last point of the function
* and the position of the mouse
*/
-void pPlotterLayer::drawLineToMousePoint(wxDC & dc,mpWindow & w)
+void pPlotterLayer::drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy)
{
int x,y,sizeP,maxX,maxY,minX,minY;
bool direction;
*/
dc.GetSize(&scrwX, &scrwY);
+
getIfActual(actual);
//getMax(maxX, maxY);
/***********/
// dc.SetAxisOrientation(true,true);
int orgy = 40;
- dc.SetDeviceOrigin( orgx ,orgy);
- dc.SetAxisOrientation(true,false);
+ //dc.SetDeviceOrigin( orgx ,orgy);
+ dc.SetDeviceOrigin( orgx ,0);
+ int sizedc = dc.GetSize().GetHeight()-orgy;
+ //dc.SetAxisOrientation(true,false);
//if the user dont want to see the points of the function and if he stops drawing
//we have to draw the function
if(!show && !drawing && type==1)
- drawFunction(dc,w);
+ drawFunction(dc,w,orgy);
else if(!show && !drawing && type==2)
- drawSplineCurve(dc,w);
+ drawSplineCurve(dc,w,orgy);
//we just draw the point that the user just clicked
else if(drawing && type==1)
{
- drawFunction(dc,w);
- drawLineToMousePoint(dc,w);
- drawPoints(dc,w);
+ drawFunction(dc,w,orgy);
+ drawLineToMousePoint(dc,w,orgy);
+ drawPoints(dc,w,orgy);
}
else if(drawing && type==1)
{
- drawSplineCurve(dc,w);
- drawLineToMousePoint(dc,w);
- drawPoints(dc,w);
+ drawSplineCurve(dc,w,orgy);
+ drawLineToMousePoint(dc,w,orgy);
+ drawPoints(dc,w,orgy);
}
else if(show && type==1)
{
- drawFunction(dc,w);
- drawPoints(dc,w);
+ drawFunction(dc,w,orgy);
+ drawPoints(dc,w,orgy);
}
else if(show && type==2)
{
- drawSplineCurve(dc,w);
- drawPoints(dc,w);
+ drawSplineCurve(dc,w,orgy);
+ drawPoints(dc,w,orgy);
}
// Drawing the guides according to real values entered according to the integrated interaction (IS NOT WORKING!!!)
int realX_guide = w.getRealGuideX();
if( realX_guide!=-1 )
{
- dc.DrawLine( (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, 0, (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx, scrwY);
+ dc.DrawLine( (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx,
+ GetYTranslated(sizedc,0),
+ (realX_guide/*-w.getMinScrX()*/-offsetX)*scaleX + offsetpx,
+ GetYTranslated(sizedc,scrwY));
}
int realY_guide = w.getRealGuideY();
if( realY_guide!=-1 )
{
- dc.DrawLine( 0,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx, scrwX, (realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx);
+ dc.DrawLine( 0,
+ GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx),
+ scrwX,
+ GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx));
}
}
Draw the line from (x1,y1) to (x2,y2) only passing by the
positive points in the line
*/
-void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2);
+void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int orgy);
/**
* Draw the function with th spline points
*
*/
- void drawSplineCurve(wxDC & dc,mpWindow & w);
+ void drawSplineCurve(wxDC & dc,mpWindow & w, int orgy);
/**
* Draw the line between the last point of the function
* and the position of the mouse
*/
- void drawLineToMousePoint(wxDC & dc,mpWindow & w);
+ void drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy);
/**
* Draw le lines between the points of the function
*/
- void drawFunction(wxDC & dc,mpWindow & w);
+ void drawFunction(wxDC & dc,mpWindow & w, int orgy);
/**
* Draw the points of the function
*/
- void drawPoints(wxDC & dc,mpWindow & w);
+ void drawPoints(wxDC & dc,mpWindow & w, int orgy );
/**
Get the value of the traslation
dc.SetPen( m_pen);
dc.SetFont( m_font);
+
+
//data
float min=(float)w.getMinScrX();
// dc.SetAxisOrientation(true,true); //EED MacOx ???
const int orgy = 40;
- dc.SetDeviceOrigin(70,orgy);
- dc.SetAxisOrientation(true,false);
-
+ //dc.SetDeviceOrigin(70,orgy);
+ dc.SetDeviceOrigin(70,0);
+ //dc.SetAxisOrientation(true,false);
+ double sizedc = dc.GetSize().GetY()-orgy;
+
//const int extend = w.GetScrX()-100; //JPRx
//draw the axe
- dc.DrawLine(0,0,(max-min)*scaleX,0);
+ dc.DrawLine(0,GetYTranslated(sizedc, 0),(max-min)*scaleX,GetYTranslated(sizedc, 0));
//maximum value in x
int d=max-min;
//drawing the first line
- dc.DrawLine(0,0,0,-10);
+ dc.DrawLine(0,GetYTranslated(sizedc, 0),0,GetYTranslated(sizedc, -10));
s.Printf(_T("%d"),(int)(min));
- dc.DrawText(s,(wxCoord)0,(wxCoord)-20);
+ dc.DrawText(s,(wxCoord)0,GetYTranslated(sizedc, (wxCoord)-20));
for(float i=0;i<=(max);i+=step)
{
{
dc.DrawLine(p,0,p,-10);
s.Printf(_T("%d"),(int)(i));
- dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
+ dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20));
}
}
//drawing the last line
int p=(max-min-offsetX)*scaleX+offsetpx;
- dc.DrawLine(p,0,p,-10);
+ dc.DrawLine(p,GetYTranslated(sizedc, 0),p,GetYTranslated(sizedc, -10));
s.Printf(_T("%d"),(int)(max));
- dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
+ dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20));
}
// dc.SetAxisOrientation(true,true); //EED MacOx ???
const int orgy = 40;
- dc.SetDeviceOrigin(70,orgy);
- dc.SetAxisOrientation(true,false);
+ //dc.SetDeviceOrigin(70,orgy);
+ dc.SetDeviceOrigin(70,0);
+ double sizedc = dc.GetSize().GetY()-orgy;
+ //dc.SetAxisOrientation(true,false);
// const int extend = w.GetScrY()-50; //EED
//draw the axe
- dc.DrawLine( 0,0, 0, (max-min)*scaleY);
+ dc.DrawLine( 0,GetYTranslated(sizedc, 0), 0, GetYTranslated(sizedc, (max-min)*scaleY));
//maximum value in Y
int d=max-min;
//drawing the axe with the numbers
wxString s;
//drawing the first line
- dc.DrawLine(0,0,-10,0);
+ dc.DrawLine(0,GetYTranslated(sizedc, 0),-10,GetYTranslated(sizedc, 0));
s.Printf(_T("%d"),(int)(min));
- dc.DrawText(s,(wxCoord)-20,(wxCoord)0);
+ dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)0));
for(float i=0;i<=(max);i+=step)
int p=(i-min-offsetY)*scaleY+offsetpy;
if(p>=0)
{
- dc.DrawLine(0,p,-10,p);
+ dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p));
s.Printf(_T("%d"),(int)(i));
- dc.DrawText(s,(wxCoord)-20,(wxCoord)p);
+ dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p));
}
}
//drawing the last line
int p=(max-min-offsetY)*scaleY+offsetpy;
- dc.DrawLine(0,p,-10,p);
+ dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p));
s.Printf(_T("%d"),(int)(max));
- dc.DrawText(s,(wxCoord)-20,(wxCoord)p);
+ dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p));
}
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererManager.cxx,v $
+ Language: C++
+ Date: $Date: 2009/07/08 14:22:14 $
+ 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 "wxMaracasMultipleVolumeRendererManager.h"
+
+#include <vtkMetaImageReader.h>
+/**
+** Start of the manager class
+**/
+wxMaracasMultipleVolumeRendererManager::wxMaracasMultipleVolumeRendererManager(){
+ _renderer = NULL;
+ _idCount=0;
+}
+wxMaracasMultipleVolumeRendererManager::~wxMaracasMultipleVolumeRendererManager(){
+}
+
+/**
+** Sets the renderer to manage the prop3D from the view
+**/
+void wxMaracasMultipleVolumeRendererManager::setRenderer(vtkRenderer* renderer){
+ _renderer = renderer;
+}
+/**
+** Adds a prop3D to the manager and returns the identifier
+**/
+int wxMaracasMultipleVolumeRendererManager::addVolume(vtkImageData* vol, std::string dataname) throw(char*){
+ checkInvariant();
+ if(vol != NULL){
+ wxMaracasMultipleVolumeRendererManagerData* data = new wxMaracasMultipleVolumeRendererManagerData(vol, dataname);
+ prop3Dvect.push_back(data);
+ _renderer->AddActor(data->getProp3D());
+ data->setId(_idCount);
+ _idCount++;
+ return data->getId();
+ }else{
+ throw "Check mhd imagefile file or input";
+ }
+ return -1;
+}
+/**
+** adds or removes an actor depending of the bool value
+**/
+
+void wxMaracasMultipleVolumeRendererManager::addRemoveActor(int propid, bool addremove) throw(char*){
+ checkInvariant();
+
+ wxMaracasMultipleVolumeRendererManagerData* data = this->getViewData(propid);
+ if(data->getProp3D()!=NULL){
+ if(addremove){
+ _renderer->AddViewProp(data->getProp3D());
+ }else{
+ _renderer->RemoveViewProp(data->getProp3D());
+ }
+ _renderer->Render();
+ }
+
+}
+/**
+** Changes the opacity in a prop3D
+**/
+void wxMaracasMultipleVolumeRendererManager::setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*){
+ checkInvariant();
+
+ this->getViewData(propid)->setVolumeOpacity(greylevel, value);
+
+ _renderer->Render();
+
+}
+
+/**
+** Set Volume Color
+**/
+void wxMaracasMultipleVolumeRendererManager::setVolumeColor(int volid, std::vector<double> greylevel,
+ std::vector<double> red,
+ std::vector<double> green,
+ std::vector<double> blue)
+{
+ checkInvariant();
+
+ this->getViewData(volid)->setVolumeColor(greylevel, red, green, blue);
+
+ _renderer->Render();
+}
+
+vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(std::string filename){
+ if(filename.compare("")!= 0){
+
+
+ vtkMetaImageReader* reader = vtkMetaImageReader::New();
+ reader->SetFileName(filename.c_str());
+ reader->Update();
+ vtkImageData* img = reader->GetOutput();
+ //reader->Delete();
+ return img;
+ }
+ return NULL;
+}
+
+void wxMaracasMultipleVolumeRendererManager::checkInvariant() throw(char*){
+ if(this->_renderer==NULL){
+ throw "Renderer not set";
+ }
+}
+
+wxMaracasMultipleVolumeRendererManagerData* wxMaracasMultipleVolumeRendererManager::getViewData(int id) throw(char*){
+ int i;
+ for(i = 0; i < (int)(prop3Dvect.size());i++){
+ if(prop3Dvect[i]->getId() == id){
+ return prop3Dvect[i];
+ }
+ }
+ throw "id not found in the data";
+
+ return NULL;
+}
+
+void wxMaracasMultipleVolumeRendererManager::deleteActor(int propid) throw (char *){
+ checkInvariant();
+
+ this->addRemoveActor(propid, false);
+
+ int i,n;
+ bool exit = false;
+ for(i = 0; i < (int)(prop3Dvect.size())&&!exit;i++){
+ if(prop3Dvect[i]->getId() == propid){
+ n=i;
+ exit = true;
+ }
+ }
+ if(exit){
+ wxMaracasMultipleVolumeRendererManagerData* data = prop3Dvect[n];
+ int j;
+ for(j = i; j < (int)(prop3Dvect.size())-1;j++){
+ prop3Dvect[j] = prop3Dvect[j+1];
+ }
+ delete data;
+ prop3Dvect.pop_back();
+ }else{
+ throw "id not found in the data";
+ }
+
+}
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererManager.h,v $
+ Language: C++
+ Date: $Date: 2009/07/08 14:22:14 $
+ 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 __wxMaracasMultipleVolumeRendererManagerH__
+#define __wxMaracasMultipleVolumeRendererManagerH__
+
+#include <iostream>
+#include <vector>
+
+#include "wxMaracasMultipleVolumeRendererManagerData.h"
+
+
+class wxMaracasMultipleVolumeRendererManager {
+
+public:
+ wxMaracasMultipleVolumeRendererManager();
+ ~wxMaracasMultipleVolumeRendererManager();
+
+ /**
+ ** Sets the renderer to manage the prop3D from the view
+ **/
+ void setRenderer(vtkRenderer* renderer);
+ /**
+ ** Adds a volume
+ **/
+ int addVolume(vtkImageData* img, std::string dataname) throw (char*);
+
+ /**
+ ** loads a prop3D from a nSTL file
+ **/
+ vtkProp3D* getVolume(std::string filename);
+
+ /**
+ ** loads a MHD file to convert it into an actor
+ **/
+ vtkImageData* getImageData(std::string filename);
+
+ /**
+ ** adds or removes an actor depending of the bool value
+ **/
+ void addRemoveActor(int propid, bool addremove) throw(char*);
+ /**
+ ** Check if the variables are setted correctly
+ **/
+ void checkInvariant()throw(char*);
+
+ /**
+ ** Set Volume Opacity
+ **/
+ void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value);
+ /**
+ ** Set Volume Color
+ **/
+ void setVolumeColor(int volid, std::vector<double> greylevel,
+ std::vector<double> red,
+ std::vector<double> green,
+ std::vector<double> blue);
+
+ /**
+ ** Given an id search the data in the vector
+ **/
+ wxMaracasMultipleVolumeRendererManagerData* getViewData(int id)throw(char*);
+ /**
+ **
+ **/
+ void deleteActor(int volumeid)throw (char *);
+
+private:
+ std::vector<wxMaracasMultipleVolumeRendererManagerData*> prop3Dvect;
+
+ vtkRenderer* _renderer;
+
+ int _idCount;
+
+
+
+
+};
+
+#endif
--- /dev/null
+
+#include "wxMaracasMultipleVolumeRendererManagerData.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+wxMaracasMultipleVolumeRendererManagerData::wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname){
+
+ _vol = vol;
+ _dataname = dataname;
+
+ _tfun = vtkPiecewiseFunction::New();
+ _ctfun = vtkColorTransferFunction::New();
+
+ _volumePlanes = vtkPlanes::New();
+ _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+ _volumeMapper = vtkVolumeRayCastMapper::New();
+ _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+ _volumeMapper->SetClippingPlanes( _volumePlanes );
+ _volumeMapper->AutoAdjustSampleDistancesOn();
+ _volumeProperty = vtkVolumeProperty::New();
+ _volumeProperty->SetInterpolationTypeToLinear();
+ _volumeProperty->ShadeOn();
+ _volumeProperty->DisableGradientOpacityOn();
+ _volumeProperty->SetColor(_ctfun);
+ _volumeProperty->SetScalarOpacity(_tfun );
+
+ _newvol = vtkVolume::New();
+ _newvol->SetMapper(_volumeMapper );
+ _newvol->SetProperty(_volumeProperty );
+ _volumeMapper->SetInput( _vol );
+ _volumeMapper->Update();
+ _newvol->Update();
+}
+
+
+wxMaracasMultipleVolumeRendererManagerData::~wxMaracasMultipleVolumeRendererManagerData(){
+
+ _tfun->Delete();
+ _ctfun->Delete();
+ _volumePlanes->Delete();
+ _compositeFunction->Delete();
+ _volumeMapper->Delete();
+ _volumeProperty->Delete();
+ _newvol->Delete();
+
+}
+/**
+** Set Volume Color
+**/
+void wxMaracasMultipleVolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue)
+{
+
+ _ctfun->RemoveAllPoints();
+ for(int i = 0; i < greylevelcolors.size();i++){
+ _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
+ // std::cout<<"transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ }
+ _newvol->Update();
+}
+
+/**
+** Volume Opacity
+**/
+void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
+
+ _tfun->RemoveAllPoints();
+ for(int i = 0; i < greylevel.size();i++){
+ _tfun->AddPoint(greylevel[i], value[i]);
+// std::cout<<"transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+ }
+ _newvol->Update();
+}
+
+/**
+** Check if the variables are setted correctly
+**/
+void wxMaracasMultipleVolumeRendererManagerData::checkInvariant(){
+
+}
+/**
+** get the prop3D
+**/
+vtkProp3D* wxMaracasMultipleVolumeRendererManagerData::getProp3D(){
+ return this->_newvol;
+}
+/**
+** return the id from the daat
+**/
+int wxMaracasMultipleVolumeRendererManagerData::getId(){
+ return _id;
+}
+/**
+** set data id
+**/
+void wxMaracasMultipleVolumeRendererManagerData::setId(int propid){
+ _id = propid;
+}
+
+/**
+** Get the filanme
+**/
+std::string wxMaracasMultipleVolumeRendererManagerData::getDataname(){
+ return _dataname;
+}
+/**
+** Set the filanme
+**/
+void wxMaracasMultipleVolumeRendererManagerData::setDataname(std::string dataname){
+ _dataname = dataname;
+}
+
--- /dev/null
+#ifndef wxMaracasMultipleVolumeRendererManagerData_H_
+#define wxMaracasMultipleVolumeRendererManagerData_H_
+
+#include <vtkVolumeRayCastCompositeFunction.h>
+#include <vtkPlanes.h>
+#include <vtkVolumeRayCastMapper.h>
+#include <vtkVolumeProperty.h>
+#include <vtkVolume.h>
+#include <vtkPiecewiseFunction.h>
+#include <vtkColorTransferFunction.h>
+#include <vtkImageData.h>
+#include <vtkProp3D.h>
+#include <vtkRenderer.h>
+
+#include <vector>
+
+
+class wxMaracasMultipleVolumeRendererManagerData {
+
+public:
+ wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
+ ~wxMaracasMultipleVolumeRendererManagerData();
+
+ /**
+ ** Check if the variables are setted correctly
+ **/
+ void checkInvariant();
+ /**
+ ** get the prop3D
+ **/
+ vtkProp3D* getProp3D();
+ /**
+ ** return the id from the daat
+ **/
+ int getId();
+ /**
+ ** set data id
+ **/
+ void setId(int propid);
+ /**
+ ** Get the filanme
+ **/
+ std::string getDataname();
+ /**
+ ** Set the filanme
+ **/
+ void setDataname(std::string dataname);
+
+
+ /**
+ ** Set Volume Color
+ **/
+ void setVolumeColor(std::vector<double>& greylevel,
+ std::vector<double>& red,
+ std::vector<double>& green,
+ std::vector<double>& blue);
+
+ /**
+ ** Volume Opacity
+ **/
+ void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
+
+protected:
+ /**
+ * Prop 3D (data actor)
+ */
+ vtkImageData* _vol;
+ /**
+ * Dataname given by the user (ex. filename)
+ **/
+ std::string _dataname;
+
+
+private:
+
+ /*
+ * id of the data
+ */
+ int _id;
+
+ vtkVolumeRayCastCompositeFunction *_compositeFunction;
+ vtkPlanes *_volumePlanes;
+ vtkVolumeRayCastMapper *_volumeMapper;
+ vtkVolumeProperty *_volumeProperty;
+ vtkVolume *_newvol;
+ vtkPiecewiseFunction* _tfun;
+ vtkColorTransferFunction* _ctfun;
+
+
+};
+
+#endif /*wxMaracasMultipleVolumeRendererManagerData_H_*/
--- /dev/null
+#include "wxMaracasMultipleVolumeRendererPanel.h"
+
+#include <wx/colordlg.h>
+#include "wxMaracasMultipleVolumeRendererView.h"
+#include "Color.xpm"
+/**
+** Implementation of viewProp3D
+**/
+
+wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
+{
+ _propid = propid;
+
+ createControls(img);
+}
+
+wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
+ //wxMaracasIRMView::getInstance()->addRemoveActor(_propid, false);
+ wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
+}
+
+void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
+
+ wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(1,1,1);
+
+ wxString choices[2];
+ choices[0] = wxString(_T("On"));
+ choices[1] = wxString(_T("Off"));
+ checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
+ Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);
+ checkbox->SetValue(true);
+
+ sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
+
+ //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)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
+ sizerirmprop->Add(_colorchoose,wxFIXED_MINSIZE);
+
+
+ this->SetSizer(sizerirmprop, true);
+ this->SetAutoLayout( true );
+
+
+
+ _frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));
+
+ wxButton* button1 = new wxButton(_frame,20,_T("OK"));
+ Connect(button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onOK);
+ wxButton* button2 = new wxButton(_frame,30,_T("Cancel") );
+ Connect(button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCancel);
+ wxButton* button3 = new wxButton(_frame,40,_T("Update"));
+ Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate);
+
+
+ mwxwidget = new HistogramWidget(_frame, -1);
+
+ mwxwidget->initializeHistogram(img);
+ mwxwidget->Refresh();
+
+ wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
+ boxSizer0->Add(mwxwidget, 4, wxGROW);
+
+ wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button1, wxCENTER);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button2, wxCENTER);
+ boxSizer->AddSpacer(40);
+ boxSizer->Add(button3, wxCENTER);
+
+ wxBoxSizer* boxsizer2 = new wxBoxSizer(wxVERTICAL);
+ boxsizer2->Add(boxSizer0,1,wxEXPAND);
+ boxsizer2->Add(boxSizer,0,wxCENTER);
+
+ _frame->SetAutoLayout(true);
+
+
+ _frame->SetSizer(boxsizer2);
+
+ _frame->Refresh();
+ _frame->Update();
+
+}
+void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
+ updateVolume();
+ _frame->Show(false);
+}
+void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
+ _frame->Show(false);
+}
+void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
+ updateVolume();
+}
+void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
+ std::vector<double> greylevelcolors;
+ std::vector<double> red;
+ std::vector<double> green;
+ std::vector<double> blue;
+
+ std::vector<double> greylevel;
+ std::vector<double> values;
+
+ mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue);
+ mwxwidget->GetValuesPointsFunction(greylevel, values);
+
+
+ wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue);
+ wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
+
+}
+void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
+ _frame->Show(true);
+}
+void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){
+ wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
+}
+
+int wxMaracasMultipleVolumeRendererPanel::getPropId(){
+ return _propid;
+}
\ No newline at end of file
--- /dev/null
+#ifndef wxMaracasMultipleVolumeRendererPanel_H_
+#define wxMaracasMultipleVolumeRendererPanel_H_
+
+#include <wx/wx.h>
+#include "HistogramWidget.h"
+
+class wxMaracasMultipleVolumeRendererPanel : public wxPanel{
+
+public:
+ wxMaracasMultipleVolumeRendererPanel(wxWindow* parent, int propid, vtkImageData* img);
+ ~wxMaracasMultipleVolumeRendererPanel();
+ void createControls(vtkImageData* img);
+ void onCheckBoxChange(wxCommandEvent& event);
+ void onColorChange(wxCommandEvent& event);
+ void onOK(wxCommandEvent& event);
+ void onCancel(wxCommandEvent& event);
+ void onUpdate(wxCommandEvent& event);
+
+ void updateVolume();
+ int getPropId();
+
+private:
+ wxCheckBox* checkbox;
+ wxBitmapButton* _colorchoose;
+
+ int _propid;
+
+ HistogramWidget* mwxwidget;
+ wxFrame* _frame;
+
+};
+
+#endif /*wxMaracasMultipleVolumeRendererPanel_H_*/
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $
+ Language: C++
+ Date: $Date: 2009/07/08 14:22:14 $
+ 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.
+
+=========================================================================*/
+
+
+
+// EOF - wxMaracasMPR.cxx
+
+#include "wxMaracasMultipleVolumeRendererView.h"
+
+
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <OpenImage.xpm>
+#include <Color.xpm>
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::instance=NULL;
+
+wxMaracasMultipleVolumeRendererView::wxMaracasMultipleVolumeRendererView( wxWindow* parent,std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
+ wxauimanager = new wxAuiManager(this);
+
+ _path = path;
+
+ volmanager = new wxMaracasMultipleVolumeRendererManager();
+ std::string iconsdir = path;
+ iconsdir+="/data/Icons";
+ this->_toolb = new ToolBarMultipleVolumeRenderer(this,iconsdir);
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
+
+ wxauimanager->Update();
+
+}
+wxMaracasMultipleVolumeRendererView::~wxMaracasMultipleVolumeRendererView( ){
+
+ delete _toolb;
+
+}
+
+std::string wxMaracasMultipleVolumeRendererView::getPath(){
+ return _path;
+}
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(wxWindow* parent,std::string path){
+ if(instance==NULL){
+ instance = new wxMaracasMultipleVolumeRendererView(parent,path);
+ }
+ return instance;
+}
+
+wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(){
+ return instance;
+}
+
+void wxMaracasMultipleVolumeRendererView::setRenderer(vtkRenderer* renderer){
+ volmanager->setRenderer(renderer);
+}
+
+void wxMaracasMultipleVolumeRendererView::addRemoveActor(int id, bool addremove){
+ volmanager->addRemoveActor(id, addremove);
+}
+
+void wxMaracasMultipleVolumeRendererView::onLoadImageFile(){
+
+ wxString mhd(_T("mhd"));
+
+ wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")),
+ wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) );
+
+ if(fildial->ShowModal()==wxID_OK){
+ wxString filename = fildial->GetFilename();
+ wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
+ if(filename.EndsWith(mhd)){
+ loadVolume(pathfile,filename);
+ }
+ }
+ delete fildial;
+
+}
+
+void wxMaracasMultipleVolumeRendererView::addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname){
+
+ wxString s(dataname.c_str(),wxConvUTF8 );
+ wxAuiPaneInfo paneinfo;
+ wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
+ wxauimanager->Update();
+
+
+}
+
+void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::string dataname){
+
+ try{
+ int id = volmanager->addVolume(img,dataname);
+ if(id!=-1){
+ wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img);
+ addVolumeViewPanel(controlpan, dataname);
+ }
+ }catch(char* str){
+ std::cout << "Exception : " << str << '\n';
+ wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
+ diag->ShowModal();
+ }
+}
+
+void wxMaracasMultipleVolumeRendererView::loadVolume(wxString filename, wxString dataname){
+
+ std::string s = std::string(filename.mb_str());
+ vtkImageData* img = volmanager->getImageData(s);
+ if(img!=NULL){
+ s = std::string(dataname.mb_str());
+ addVolume(img, s);
+ }
+
+}
+
+void wxMaracasMultipleVolumeRendererView::deleteVolume(int volid){
+ volmanager->deleteActor(volid);
+}
+
+void wxMaracasMultipleVolumeRendererView::SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue){
+ volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
+}
+void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values){
+ volmanager->setVolumeOpacity(volid, greylevel, values);
+}
+
+/**
+**
+**/
+
+ToolBarMultipleVolumeRenderer::ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir)
+: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
+{
+
+
+ std::string iconfil = iconsdir;
+
+ //iconfil+= "/OpenImage.png";
+ //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
+ wxBitmap bitmap0(OpenImage_xpm);
+ this->AddTool(1, wxString(_T("test")),bitmap0);
+
+ /*iconfil+= "/Open.png";
+ wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
+ 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();
+
+ _evthand = new ToolBarEventHandlerMultipleVolumeRenderer();
+ this->SetEventHandler(_evthand);
+
+}
+
+ToolBarMultipleVolumeRenderer::~ToolBarMultipleVolumeRenderer(void){
+}
+
+ToolBarEventHandlerMultipleVolumeRenderer::ToolBarEventHandlerMultipleVolumeRenderer()
+: wxEvtHandler(){
+}
+ToolBarEventHandlerMultipleVolumeRenderer::~ToolBarEventHandlerMultipleVolumeRenderer(){
+}
+
+void ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile(wxCommandEvent& event){
+ wxMaracasMultipleVolumeRendererView::getInstance()->onLoadImageFile();
+}
+
+
+
+BEGIN_EVENT_TABLE(ToolBarEventHandlerMultipleVolumeRenderer, wxEvtHandler)
+ EVT_MENU(1, ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile)
+END_EVENT_TABLE()
+
+
--- /dev/null
+/*=========================================================================
+
+ Program: wxMaracas
+ Module: $RCSfile: wxMaracasMultipleVolumeRendererView.h,v $
+ Language: C++
+ Date: $Date: 2009/07/08 14:22:14 $
+ 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 __wxMaracasMultipleVolumeRendererViewPanelH__
+#define __wxMaracasMultipleVolumeRendererViewPanelH__
+
+#include <vector>
+#include <wx/wx.h>
+#include "wx/aui/aui.h"
+#include <iostream>
+#include "marTypes.h"
+#include "vtkProp3D.h"
+
+#include "wxMaracasMultipleVolumeRendererManager.h"
+#include "wxMaracasMultipleVolumeRendererPanel.h"
+
+
+
+class creaMaracasVisu_EXPORT wxMaracasMultipleVolumeRendererView : public wxPanel
+{
+
+public:
+ wxMaracasMultipleVolumeRendererView( wxWindow* parent, std::string path);
+ ~wxMaracasMultipleVolumeRendererView( );
+
+ static wxMaracasMultipleVolumeRendererView* getInstance(wxWindow* parent,std::string path="");
+
+ static wxMaracasMultipleVolumeRendererView* getInstance();
+
+ void setRenderer(vtkRenderer* renderer);
+
+ void addVolume(vtkImageData* img, std::string dataname="");
+
+ void loadVolume(wxString filename, wxString dataname);
+
+ void onLoadImageFile();
+
+ void addVolumeRendererPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname="");
+
+ std::string getPath();
+
+ void deleteVolume(int volid);
+
+ void addRemoveActor(int id, bool remove);
+
+ void SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue);
+ void SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values);
+
+ void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname);
+
+private:
+ static wxMaracasMultipleVolumeRendererView* instance;
+
+ wxMaracasMultipleVolumeRendererManager* volmanager;
+
+ wxAuiManager* wxauimanager;
+
+ std::string _path;
+
+ wxToolBar* _toolb;
+
+};
+
+class ToolBarEventHandlerMultipleVolumeRenderer : public wxEvtHandler{
+
+ public:
+ ToolBarEventHandlerMultipleVolumeRenderer();
+ ~ToolBarEventHandlerMultipleVolumeRenderer();
+
+ void onLoadImageFile(wxCommandEvent& event);
+
+ private:
+
+ DECLARE_EVENT_TABLE()
+ };
+
+class ToolBarMultipleVolumeRenderer : public wxToolBar{
+
+
+public:
+ ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir);
+ ~ToolBarMultipleVolumeRenderer(void);
+
+
+private:
+
+ ToolBarEventHandlerMultipleVolumeRenderer* _evthand;
+
+};
+
+#endif
+