7 #include "fwDataTools/helper/MedicalImageAdaptor.hpp" 9 #include "fwDataTools/fieldHelper/Image.hpp" 10 #include "fwDataTools/fieldHelper/MedicalImageHelpers.hpp" 11 #include "fwDataTools/helper/Composite.hpp" 12 #include "fwDataTools/helper/Image.hpp" 14 #include <fwCom/Slot.hpp> 15 #include <fwCom/Slot.hxx> 16 #include <fwCom/Slots.hpp> 17 #include <fwCom/Slots.hxx> 19 #include <fwData/Image.hpp> 20 #include <fwData/TransferFunction.hpp> 28 static const ::fwCom::Slots::SlotKeyType s_UPDATE_TF_POINTS_SLOT =
"updateTFPoints";
29 static const ::fwCom::Slots::SlotKeyType s_UPDATE_TF_WINDOWING_SLOT =
"updateTFWindowing";
48 ::fwData::Image::sptr image = this->
getImage();
50 const ::fwData::Image::SpacingType& imSpacing = image->getSpacing();
51 std::copy(imSpacing.begin(), imSpacing.end(), spacing);
58 ::fwData::Image::sptr image = this->
getImage();
60 std::copy(image->getOrigin().begin(), image->getOrigin().end(), origin);
67 ::fwData::Image::sptr image = this->
getImage();
69 const ::fwData::Image::SizeType& imSize = image->getSize();
70 std::copy(imSize.begin(), imSize.end(), size);
77 ::fwData::Image::sptr image = this->
getImage();
80 const ::fwData::Image::SizeType& imSize = image->getSize();
81 std::copy(imSize.begin(), imSize.end(), size);
84 size[0] *= spacing[0];
85 size[1] *= spacing[1];
86 size[2] *= spacing[2];
93 ::fwData::Image::sptr image = this->
getImage();
99 ::fwData::Integer::sptr sliceIndex[3];
102 static_cast<double>(sliceIndex[0]->value()),
103 static_cast<double>(sliceIndex[1]->value()),
104 static_cast<double>(sliceIndex[2]->value())
107 center[0] = origin[0] + (imageSize[0]-1.)/ 2.;
108 center[1] = origin[1] + (imageSize[1]-1.)/ 2.;
109 center[2] = origin[2] + (imageSize[2]-1.)/ 2.;
127 OSLM_ASSERT(
"orientation value must be 0,1 or 2 (value = " << orientation <<
")",
128 orientation == 0 || orientation == 1 || orientation == 2);
129 this->
setOrientation(static_cast< ::fwDataTools::helper::MedicalImageAdaptor::Orientation >(orientation));
134 static const int indexZ[12] = { 0, 2, 4, 1, 2, 4, 1, 3, 4, 0, 3, 4 };
135 static const int indexY[12] = { 0, 2, 4, 1, 2, 4, 1, 2, 5, 0, 2, 5 };
136 static const int indexX[12] = { 0, 2, 4, 0, 2, 5, 0, 3, 5, 0, 3, 4 };
137 static const int* indexSet[3] = { indexX, indexY, indexZ };
142 ::fwData::Image::sptr image = this->
getImage();
144 for (
unsigned char i = 0; i < 3; ++i )
147 extent[2*i+1] = image->getSize()[i]*image->getSpacing()[i];
153 for (
int p = 0; p < 4; ++p)
155 for (
int i = 0; i < 3; ++i)
157 points[p][i] = extent[ *(extentIndex++) ];
170 for (
int i = 0; i < 3; ++i )
172 world[i] =
static_cast<int>( (index[i]*spacing[i]) + 0.5*spacing[i] + origin[i] );
184 for (
int i = 0; i < 3; ++i )
188 static_cast<int>( ( (world[i]-origin[i])/spacing[i] ) +
189 ( ( (world[i]-origin[i])/spacing[i] ) >= 0 ? 0.5 : -0.5 ) );
202 for (
int i = 0; i < 3; i++)
204 int max = imageSize[i]-1;
210 else if (idval > max)
230 bool isModified =
false;
232 ::fwData::Integer::sptr sliceIndex[3];
254 ::fwData::Integer::New(0));
256 ::fwData::Integer::New(0));
258 ::fwData::Integer::New(0));
265 ::fwData::Composite::sptr tfPool =
267 ::fwData::Composite::New());
272 ::fwData::TransferFunction::sptr tfGreyLevel = ::fwData::TransferFunction::createDefaultTF();
273 if (image->getWindowWidth() != 0 )
275 tfGreyLevel->setWindow( image->getWindowWidth() );
276 tfGreyLevel->setLevel( image->getWindowCenter() );
282 ::fwData::TransferFunction::TFValuePairType wlMinMax(min, max);
283 tfGreyLevel->setWLMinMax(wlMinMax);
291 if (m_transferFunction.expired())
293 ::fwData::TransferFunction::sptr tfGreyLevel =
295 m_transferFunction = tfGreyLevel;
297 else if (m_transferFunction.lock()->getTFValues().empty())
299 ::fwData::TransferFunction::sptr tfGreyLevel =
301 m_transferFunction.lock()->deepCopy(tfGreyLevel);
325 SLM_ASSERT(
"Transfer funtion is not defined, you must call setTransferFunction() or createTransferFunction() first." 326 , !m_transferFunction.expired());
327 return m_transferFunction.lock();
334 SLM_ASSERT(
"Image weak pointer empty !", !m_weakImage.expired());
335 return m_weakImage.lock();
342 m_transferFunction = tf;
379 SLM_ASSERT(
"This methods (updateTFPoints) must be reimplemented in subclass to manage TF modifications",
false);
386 SLM_ASSERT(
"This methods (updateTFWindowing) must be reimplemented in subclass to manage TF modifications",
FWCOM_API void disconnect()
Disconnect all registered connections and clear m_connections.
static FWDATA_API const std::string s_DEFAULT_TF_NAME
Default transfer function name.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWCOM_API void addConnection(::fwCom::Connection connection)
Add a connection.
This class proposes a mapping between a SlotKeyType and a SlotBase.
Class managing Signal-Slot connections.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
This class defines a transfer function.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_WINDOWING_MODIFIED_SIG
Type of signal when points are modified.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINTS_MODIFIED_SIG
Type of signal when points are modified.