#include <QmitkTransferFunctionCanvas.h>


Public Member Functions | |
| QmitkTransferFunctionCanvas (QWidget *parent=0, Qt::WindowFlags f=0) | |
| mitk::SimpleHistogram * | GetHistogram () |
| void | SetHistogram (mitk::SimpleHistogram *histogram) |
| vtkFloatingPointType | GetMin () |
| void | SetMin (vtkFloatingPointType min) |
| vtkFloatingPointType | GetMax () |
| void | SetMax (vtkFloatingPointType max) |
| vtkFloatingPointType | GetLower () |
| void | SetLower (vtkFloatingPointType lower) |
| vtkFloatingPointType | GetUpper () |
| void | SetUpper (vtkFloatingPointType upper) |
| void | mousePressEvent (QMouseEvent *mouseEvent) |
| virtual void | paintEvent (QPaintEvent *e) |
| virtual void | DoubleClickOnHandle (int handle)=0 |
| void | mouseMoveEvent (QMouseEvent *mouseEvent) |
| void | mouseReleaseEvent (QMouseEvent *mouseEvent) |
| void | mouseDoubleClickEvent (QMouseEvent *mouseEvent) |
| void | PaintHistogram (QPainter &p) |
| virtual int | GetNearHandle (int x, int y, unsigned int maxSquaredDistance=32)=0 |
| virtual void | AddFunctionPoint (vtkFloatingPointType x, vtkFloatingPointType val)=0 |
| virtual void | RemoveFunctionPoint (vtkFloatingPointType x)=0 |
| virtual void | MoveFunctionPoint (int index, std::pair< vtkFloatingPointType, vtkFloatingPointType > pos)=0 |
| virtual vtkFloatingPointType | GetFunctionX (int index)=0 |
| virtual float | GetFunctionY (int index)=0 |
| virtual int | GetFunctionSize ()=0 |
| std::pair< int, int > | FunctionToCanvas (std::pair< vtkFloatingPointType, vtkFloatingPointType >) |
| std::pair < vtkFloatingPointType, vtkFloatingPointType > | CanvasToFunction (std::pair< int, int >) |
| void | keyPressEvent (QKeyEvent *e) |
| void | SetImmediateUpdate (bool state) |
| void | SetX (float x) |
| void | SetY (float y) |
| void | SetQLineEdits (QLineEdit *xEdit, QLineEdit *yEdit) |
Static Public Member Functions | |
| static std::pair < vtkFloatingPointType, vtkFloatingPointType > | ValidateCoord (std::pair< vtkFloatingPointType, vtkFloatingPointType > x) |
Public Attributes | |
| int | m_GrabbedHandle |
| vtkFloatingPointType | m_Lower |
| vtkFloatingPointType | m_Upper |
| vtkFloatingPointType | m_Min |
| vtkFloatingPointType | m_Max |
| mitk::SimpleHistogram * | m_Histogram |
Protected Attributes | |
| bool | m_ImmediateUpdate |
| float | m_Range |
| bool | m_LineEditAvailable |
| QLineEdit * | m_XEdit |
| QLineEdit * | m_YEdit |
Definition at line 204 of file QmitkTransferFunctionCanvas.h.
| QmitkTransferFunctionCanvas::QmitkTransferFunctionCanvas | ( | QWidget * | parent = 0, |
| Qt::WindowFlags | f = 0 |
||
| ) |
Definition at line 141 of file QmitkTransferFunctionCanvas.cpp.
References m_LineEditAvailable.
: QWidget(parent, f), m_GrabbedHandle(-1), m_Lower(0.0f), m_Upper(1.0f), m_Min( 0.0f), m_Max(1.0f) { setEnabled(false); setFocusPolicy(Qt::ClickFocus); m_LineEditAvailable = false; }
| virtual void QmitkTransferFunctionCanvas::AddFunctionPoint | ( | vtkFloatingPointType | x, |
| vtkFloatingPointType | val | ||
| ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by mousePressEvent().
| std::pair< vtkFloatingPointType, vtkFloatingPointType > QmitkTransferFunctionCanvas::CanvasToFunction | ( | std::pair< int, int > | canvasPoint ) |
Definition at line 164 of file QmitkTransferFunctionCanvas.cpp.
References m_Lower, and m_Upper.
Referenced by mouseMoveEvent(), and mousePressEvent().
{
//std::cout<<"C2F.first: "<<(canvasPoint.first * (m_Upper - m_Lower) / width() + m_Lower)<<" C2F.second: "<<(1.0 - (vtkFloatingPointType)canvasPoint.second / height())<<std::endl;
return std::make_pair((canvasPoint.first - contentsRect().x()) * (m_Upper - m_Lower) / contentsRect().width()
+ m_Lower, 1.0 - (vtkFloatingPointType) (canvasPoint.second - contentsRect().y()) / contentsRect().height());
}
| virtual void QmitkTransferFunctionCanvas::DoubleClickOnHandle | ( | int | handle ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by mouseDoubleClickEvent().
| std::pair< int, int > QmitkTransferFunctionCanvas::FunctionToCanvas | ( | std::pair< vtkFloatingPointType, vtkFloatingPointType > | functionPoint ) |
Definition at line 156 of file QmitkTransferFunctionCanvas.cpp.
References m_Lower, and m_Upper.
Referenced by QmitkPiecewiseFunctionCanvas::GetNearHandle(), QmitkColorTransferFunctionCanvas::GetNearHandle(), QmitkPiecewiseFunctionCanvas::paintEvent(), and QmitkColorTransferFunctionCanvas::paintEvent().
{
//std::cout<<"F2C.first: "<<(int)((functionPoint.first - m_Lower) / (m_Upper - m_Lower) * width())<<" F2C.second: "<<(int)(height() * (1 - functionPoint.second))<<std::endl;
return std::make_pair((int) ((functionPoint.first - m_Lower) / (m_Upper
- m_Lower) * contentsRect().width()) + contentsRect().x(), (int) (contentsRect().height() * (1 - functionPoint.second)) + contentsRect().y());
}
| virtual int QmitkTransferFunctionCanvas::GetFunctionSize | ( | ) | [pure virtual] |
| virtual vtkFloatingPointType QmitkTransferFunctionCanvas::GetFunctionX | ( | int | index ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by keyPressEvent(), and mousePressEvent().
| virtual float QmitkTransferFunctionCanvas::GetFunctionY | ( | int | index ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by keyPressEvent().
| mitk::SimpleHistogram* QmitkTransferFunctionCanvas::GetHistogram | ( | ) | [inline] |
Definition at line 213 of file QmitkTransferFunctionCanvas.h.
{
return m_Histogram;
}
| vtkFloatingPointType QmitkTransferFunctionCanvas::GetLower | ( | ) | [inline] |
Definition at line 245 of file QmitkTransferFunctionCanvas.h.
{
return m_Lower;
}
| vtkFloatingPointType QmitkTransferFunctionCanvas::GetMax | ( | ) | [inline] |
Definition at line 234 of file QmitkTransferFunctionCanvas.h.
{
return m_Max;
}
| vtkFloatingPointType QmitkTransferFunctionCanvas::GetMin | ( | ) | [inline] |
Definition at line 223 of file QmitkTransferFunctionCanvas.h.
{
return m_Min;
}
| int QmitkTransferFunctionCanvas::GetNearHandle | ( | int | x, |
| int | y, | ||
| unsigned int | maxSquaredDistance = 32 |
||
| ) | [pure virtual] |
returns index of a near handle or -1 if none is near
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Definition at line 183 of file QmitkTransferFunctionCanvas.cpp.
Referenced by mouseDoubleClickEvent(), and mousePressEvent().
{
return -1;
}
| vtkFloatingPointType QmitkTransferFunctionCanvas::GetUpper | ( | ) | [inline] |
Definition at line 255 of file QmitkTransferFunctionCanvas.h.
{
return m_Upper;
}
| void QmitkTransferFunctionCanvas::keyPressEvent | ( | QKeyEvent * | e ) |
Definition at line 324 of file QmitkTransferFunctionCanvas.cpp.
References GetFunctionSize(), GetFunctionX(), GetFunctionY(), mitk::RenderingManager::GetInstance(), mitk::Key_Delete, mitk::Key_Down, mitk::Key_Left, mitk::Key_Right, mitk::Key_Up, m_GrabbedHandle, MoveFunctionPoint(), RemoveFunctionPoint(), and ValidateCoord().
{
if( m_GrabbedHandle == -1)
return;
switch(e->key())
{
case Qt::Key_Delete:
if(this->GetFunctionSize() > 1)
{
this->RemoveFunctionPoint(GetFunctionX(m_GrabbedHandle));
m_GrabbedHandle = -1;
}
break;
case Qt::Key_Left:
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle)-1 , GetFunctionY(m_GrabbedHandle))));
break;
case Qt::Key_Right:
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle)+1 , GetFunctionY(m_GrabbedHandle))));
break;
case Qt::Key_Up:
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle) , GetFunctionY(m_GrabbedHandle)+0.001)));
break;
case Qt::Key_Down:
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle) , GetFunctionY(m_GrabbedHandle)-0.001)));
break;
}
update();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
| void QmitkTransferFunctionCanvas::mouseDoubleClickEvent | ( | QMouseEvent * | mouseEvent ) |
Definition at line 172 of file QmitkTransferFunctionCanvas.cpp.
References DoubleClickOnHandle(), and GetNearHandle().
{
int nearHandle = GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y());
if (nearHandle != -1)
{
this->DoubleClickOnHandle(nearHandle);
}
}
| void QmitkTransferFunctionCanvas::mouseMoveEvent | ( | QMouseEvent * | mouseEvent ) |
Definition at line 223 of file QmitkTransferFunctionCanvas.cpp.
References CanvasToFunction(), GetFunctionSize(), mitk::RenderingManager::GetInstance(), m_GrabbedHandle, m_Max, m_Min, and MoveFunctionPoint().
{
if (m_GrabbedHandle != -1)
{
std::pair<vtkFloatingPointType,vtkFloatingPointType>
newPos = this->CanvasToFunction(std::make_pair(mouseEvent->x(),
mouseEvent->y()));
// X Clamping
{
// Check with predecessor
if( m_GrabbedHandle > 0 )
if (newPos.first <= this->GetFunctionX(m_GrabbedHandle - 1))
newPos.first = this->GetFunctionX(m_GrabbedHandle);
// Check with sucessor
if( m_GrabbedHandle < this->GetFunctionSize()-1 )
if (newPos.first >= this->GetFunctionX(m_GrabbedHandle + 1))
newPos.first = this->GetFunctionX(m_GrabbedHandle);
// Clamping to histogramm
if (newPos.first < m_Min) newPos.first = m_Min;
else if (newPos.first > m_Max) newPos.first = m_Max;
}
// Y Clamping
{
if (newPos.second < 0.0) newPos.second = 0.0;
else if (newPos.second > 1.0) newPos.second = 1.0;
}
// Move selected point
this->MoveFunctionPoint(m_GrabbedHandle, newPos);
/*
// Search again selected point ??????? should not be required, seems like a legacy workaround/bugfix
// and no longer required
m_GrabbedHandle = -1;
for (int i = 0; i < this->GetFunctionSize(); i++)
{
if (this->GetFunctionX(i) == newPos.first)
{
m_GrabbedHandle = i;
break;
}
}
*/
update();
//if (m_ImmediateUpdate)
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
| void QmitkTransferFunctionCanvas::mousePressEvent | ( | QMouseEvent * | mouseEvent ) |
Definition at line 190 of file QmitkTransferFunctionCanvas.cpp.
References AddFunctionPoint(), CanvasToFunction(), GetFunctionSize(), GetFunctionX(), mitk::RenderingManager::GetInstance(), GetNearHandle(), m_GrabbedHandle, m_LineEditAvailable, m_XEdit, m_YEdit, and RemoveFunctionPoint().
{
if (m_LineEditAvailable)
{
m_XEdit->clear();
if(m_YEdit)
m_YEdit->clear();
}
m_GrabbedHandle = GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y());
if ( (mouseEvent->button() & Qt::LeftButton) && m_GrabbedHandle == -1)
{
this->AddFunctionPoint(
this->CanvasToFunction(std::make_pair(mouseEvent->pos().x(),
mouseEvent->pos().y())).first,
this->CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y())).second);
m_GrabbedHandle = GetNearHandle(mouseEvent->pos().x(),
mouseEvent->pos().y());
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
else if ((mouseEvent->button() & Qt::RightButton) && m_GrabbedHandle != -1 && this->GetFunctionSize() > 1)
{
this->RemoveFunctionPoint(this->GetFunctionX(m_GrabbedHandle));
m_GrabbedHandle = -1;
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
update();
// m_TransferFunction->UpdateVtkFunctions();
}
| void QmitkTransferFunctionCanvas::mouseReleaseEvent | ( | QMouseEvent * | mouseEvent ) |
Definition at line 279 of file QmitkTransferFunctionCanvas.cpp.
References mitk::RenderingManager::GetInstance().
{
// m_GrabbedHandle = -1;
update();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
| virtual void QmitkTransferFunctionCanvas::MoveFunctionPoint | ( | int | index, |
| std::pair< vtkFloatingPointType, vtkFloatingPointType > | pos | ||
| ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by keyPressEvent(), and mouseMoveEvent().
| void QmitkTransferFunctionCanvas::paintEvent | ( | QPaintEvent * | e ) | [virtual] |
Reimplemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Definition at line 151 of file QmitkTransferFunctionCanvas.cpp.
{
QWidget::paintEvent(ev);
}
| void QmitkTransferFunctionCanvas::PaintHistogram | ( | QPainter & | p ) |
Definition at line 286 of file QmitkTransferFunctionCanvas.cpp.
References mitk::SimpleHistogram::GetRelativeBin(), m_Histogram, m_Lower, and m_Upper.
Referenced by QmitkPiecewiseFunctionCanvas::paintEvent().
{
if(m_Histogram)
{
p.save();
p.setPen(Qt::gray);
int displayWidth = contentsRect().width();
int displayHeight = contentsRect().height();
int windowLeft = m_Lower;
int windowRight = m_Upper;
double step = (windowRight-windowLeft)/double(displayWidth);
double pos = windowLeft;
for (int x = 0; x < displayWidth; x++)
{
float left = pos;
float right = pos + step;
float height = m_Histogram->GetRelativeBin( left , right );
if (height >= 0)
p.drawLine(x, displayHeight*(1-height), x, displayHeight);
pos += step;
}
p.restore();
}
}
| virtual void QmitkTransferFunctionCanvas::RemoveFunctionPoint | ( | vtkFloatingPointType | x ) | [pure virtual] |
Implemented in QmitkColorTransferFunctionCanvas, and QmitkPiecewiseFunctionCanvas.
Referenced by keyPressEvent(), and mousePressEvent().
| void QmitkTransferFunctionCanvas::SetHistogram | ( | mitk::SimpleHistogram * | histogram ) | [inline] |
Definition at line 218 of file QmitkTransferFunctionCanvas.h.
Referenced by QmitkTransferFunctionWidget::SetDataNode().
{
m_Histogram = histogram;
}
| void QmitkTransferFunctionCanvas::SetImmediateUpdate | ( | bool | state ) |
Definition at line 361 of file QmitkTransferFunctionCanvas.cpp.
References m_ImmediateUpdate.
{
m_ImmediateUpdate = state;
}
| void QmitkTransferFunctionCanvas::SetLower | ( | vtkFloatingPointType | lower ) | [inline] |
Definition at line 250 of file QmitkTransferFunctionCanvas.h.
{
this->m_Lower = lower;
}
| void QmitkTransferFunctionCanvas::SetMax | ( | vtkFloatingPointType | max ) | [inline] |
Definition at line 239 of file QmitkTransferFunctionCanvas.h.
References QuadProgPP::max().
Referenced by QmitkColorTransferFunctionCanvas::SetColorTransferFunction(), QmitkPiecewiseFunctionCanvas::SetPiecewiseFunction(), and QmitkTransferFunctionWidget::UpdateRanges().
| void QmitkTransferFunctionCanvas::SetMin | ( | vtkFloatingPointType | min ) | [inline] |
Definition at line 228 of file QmitkTransferFunctionCanvas.h.
References min.
Referenced by QmitkColorTransferFunctionCanvas::SetColorTransferFunction(), QmitkPiecewiseFunctionCanvas::SetPiecewiseFunction(), and QmitkTransferFunctionWidget::UpdateRanges().
| void QmitkTransferFunctionCanvas::SetQLineEdits | ( | QLineEdit * | xEdit, |
| QLineEdit * | yEdit | ||
| ) | [inline] |
Definition at line 326 of file QmitkTransferFunctionCanvas.h.
Referenced by QmitkTransferFunctionWidget::QmitkTransferFunctionWidget().
{
m_XEdit = xEdit;
m_YEdit = yEdit;
m_LineEditAvailable = true;
}
| void QmitkTransferFunctionCanvas::SetUpper | ( | vtkFloatingPointType | upper ) | [inline] |
Definition at line 260 of file QmitkTransferFunctionCanvas.h.
{
this->m_Upper = upper;
}
| void QmitkTransferFunctionCanvas::SetX | ( | float | x ) | [inline] |
Definition at line 306 of file QmitkTransferFunctionCanvas.h.
References mitk::RenderingManager::GetInstance().
Referenced by QmitkTransferFunctionWidget::SetXValueColor(), QmitkTransferFunctionWidget::SetXValueGradient(), and QmitkTransferFunctionWidget::SetXValueScalar().
{
if (m_GrabbedHandle != -1)
{
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(x,GetFunctionY(m_GrabbedHandle))));
update();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
| void QmitkTransferFunctionCanvas::SetY | ( | float | y ) | [inline] |
Definition at line 316 of file QmitkTransferFunctionCanvas.h.
References mitk::RenderingManager::GetInstance().
Referenced by QmitkTransferFunctionWidget::SetYValueGradient(), and QmitkTransferFunctionWidget::SetYValueScalar().
{
if (m_GrabbedHandle != -1)
{
this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(GetFunctionX(m_GrabbedHandle),y)));
update();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
| static std::pair<vtkFloatingPointType,vtkFloatingPointType> QmitkTransferFunctionCanvas::ValidateCoord | ( | std::pair< vtkFloatingPointType, vtkFloatingPointType > | x ) | [inline, static] |
Definition at line 283 of file QmitkTransferFunctionCanvas.h.
Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), QmitkPiecewiseFunctionCanvas::paintEvent(), and QmitkColorTransferFunctionCanvas::paintEvent().
Definition at line 291 of file QmitkTransferFunctionCanvas.h.
Referenced by PaintHistogram().
bool QmitkTransferFunctionCanvas::m_ImmediateUpdate [protected] |
Definition at line 334 of file QmitkTransferFunctionCanvas.h.
Referenced by SetImmediateUpdate().
bool QmitkTransferFunctionCanvas::m_LineEditAvailable [protected] |
Definition at line 337 of file QmitkTransferFunctionCanvas.h.
Referenced by mousePressEvent(), QmitkPiecewiseFunctionCanvas::paintEvent(), QmitkColorTransferFunctionCanvas::paintEvent(), and QmitkTransferFunctionCanvas().
| vtkFloatingPointType QmitkTransferFunctionCanvas::m_Lower |
Definition at line 285 of file QmitkTransferFunctionCanvas.h.
Referenced by CanvasToFunction(), FunctionToCanvas(), and PaintHistogram().
| vtkFloatingPointType QmitkTransferFunctionCanvas::m_Max |
Definition at line 285 of file QmitkTransferFunctionCanvas.h.
Referenced by mouseMoveEvent(), QmitkPiecewiseFunctionCanvas::paintEvent(), and QmitkColorTransferFunctionCanvas::paintEvent().
| vtkFloatingPointType QmitkTransferFunctionCanvas::m_Min |
Definition at line 285 of file QmitkTransferFunctionCanvas.h.
Referenced by mouseMoveEvent(), QmitkPiecewiseFunctionCanvas::paintEvent(), and QmitkColorTransferFunctionCanvas::paintEvent().
float QmitkTransferFunctionCanvas::m_Range [protected] |
Definition at line 335 of file QmitkTransferFunctionCanvas.h.
| vtkFloatingPointType QmitkTransferFunctionCanvas::m_Upper |
Definition at line 285 of file QmitkTransferFunctionCanvas.h.
Referenced by CanvasToFunction(), FunctionToCanvas(), and PaintHistogram().
QLineEdit* QmitkTransferFunctionCanvas::m_XEdit [protected] |
Definition at line 338 of file QmitkTransferFunctionCanvas.h.
Referenced by mousePressEvent(), QmitkPiecewiseFunctionCanvas::paintEvent(), and QmitkColorTransferFunctionCanvas::paintEvent().
QLineEdit* QmitkTransferFunctionCanvas::m_YEdit [protected] |
Definition at line 339 of file QmitkTransferFunctionCanvas.h.
Referenced by mousePressEvent(), and QmitkPiecewiseFunctionCanvas::paintEvent().
1.7.2