13 #ifndef QmitkTransferFunctionCanvas_h
14 #define QmitkTransferFunctionCanvas_h
103 void SetLower(
double lower) { this->m_Lower = lower; }
115 void SetUpper(
double upper) { this->m_Upper = upper; }
151 virtual int GetNearHandle(
int x,
int y,
unsigned int maxSquaredDistance = 100) = 0;
234 double max = m_Histogram->
GetMax();
235 double min = m_Histogram->
GetMin();
253 if (m_GrabbedHandle != -1)
255 this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(x, GetFunctionY(m_GrabbedHandle))));
267 if (m_GrabbedHandle != -1)
269 this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(GetFunctionX(m_GrabbedHandle), y)));
284 m_LineEditAvailable =
true;
Abstract base class for transfer function editing canvases.
void SetMin(double min)
Set the minimum scalar value and update the lower display bound.
virtual int GetFunctionSize()=0
Get the number of function points.
double m_Min
Minimum data range value.
double GetMax()
Get the maximum scalar value of the data range.
double m_Max
Maximum data range value.
void SetUpper(double upper)
Set the upper display bound (visible range end).
virtual int AddFunctionPoint(double x, double val)=0
Add a function point at (x, val).
virtual double GetFunctionX(int index)=0
Get the x (scalar) value of a function point.
void PaintHistogram(QPainter &p)
Paint the histogram as a background overlay.
void SetMax(double max)
Set the maximum scalar value and update the upper display bound.
void SetX(float x)
Set the x coordinate of the currently grabbed handle.
void SetQLineEdits(QLineEdit *xEdit, QLineEdit *yEdit)
Connect QLineEdit widgets for displaying/editing the selected handle coordinates.
void paintEvent(QPaintEvent *e) override
Default paint event handler.
void SetY(float y)
Set the y coordinate of the currently grabbed handle.
virtual void MoveFunctionPoint(int index, std::pair< double, double > pos)=0
Move a function point to a new position.
void keyPressEvent(QKeyEvent *e) override
Handle keyboard input for point manipulation (Delete, arrow keys).
std::pair< double, double > ValidateCoord(std::pair< double, double > x)
Clamp coordinates to valid histogram range and [0, 1] for y.
void mouseMoveEvent(QMouseEvent *mouseEvent) override
Handle mouse move: drag the grabbed handle.
void mousePressEvent(QMouseEvent *mouseEvent) override
Handle mouse press: add or remove function points, select handles.
virtual void DoubleClickOnHandle(int handle)=0
Called when a handle is double-clicked (e.g. to open a color dialog).
QmitkTransferFunctionCanvas(QWidget *parent=nullptr, Qt::WindowFlags f={})
Construct the transfer function canvas.
double m_Lower
Lower display bound.
int m_GrabbedHandle
Index of the currently grabbed (selected) handle, or -1.
void SetHistogram(mitk::SimpleHistogram *histogram)
Set the histogram to display as background.
void SetImmediateUpdate(bool state)
Enable or disable immediate rendering updates during interaction.
double GetLower()
Get the lower display bound.
virtual int GetNearHandle(int x, int y, unsigned int maxSquaredDistance=100)=0
Find a handle near the given canvas position.
virtual void RemoveFunctionPoint(double x)=0
Remove the function point at position x.
void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override
Handle double-click on a handle.
mitk::SimpleHistogram * GetHistogram()
Get the associated histogram.
double m_Upper
Upper display bound.
std::pair< double, double > CanvasToFunction(std::pair< int, int > canvasPoint)
Convert canvas pixel coordinates to function coordinates.
std::pair< int, int > FunctionToCanvas(std::pair< double, double > functionPoint)
Convert function coordinates to canvas pixel coordinates.
double GetMin()
Get the minimum scalar value of the data range.
virtual double GetFunctionY(int index)=0
Get the y (function) value of a function point.
void SetLower(double lower)
Set the lower display bound (visible range start).
mitk::SimpleHistogram * m_Histogram
The background histogram.
void mouseReleaseEvent(QMouseEvent *mouseEvent) override
Handle mouse release: trigger repaint.
double GetUpper()
Get the upper display bound.
static RenderingManager * GetInstance()
Get the RenderingManager singleton instance.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Request a deferred update for all registered render windows.
Abstract base class for simple histograms with double values.
virtual double GetMin() const =0
Returns the minimum value of the histogram.
virtual double GetMax() const =0
Returns the maximum value of the histogram.