Commit d63dcbcc authored by Alison Cellard's avatar Alison Cellard

Plugins : Signal display : Put all channel in same drawing area,

made autotranslate signal optional and not by default
Signed-off-by: default avatarAlison Cellard <alison.cellard@inria.fr>
parent 498708b7
......@@ -8,4 +8,6 @@ CMakeLists.txt.*
externals/*/
*~
*.swp
.project
.cproject
......@@ -52,11 +52,19 @@ CSignalChannelDisplay::CSignalChannelDisplay(
,m_eCurrentSignalMode(DisplayMode_GlobalBestFit)
,m_ui64LatestDisplayedTime(0)
,m_bRedrawAll(false)
,m_bUseOffset(true)
,m_bMultiView(false)
{
//creates the drawing area
m_pDrawingArea = gtk_drawing_area_new();
gtk_widget_set_size_request(m_pDrawingArea, i32ChannelDisplayWidthRequest, i32ChannelDisplayHeightRequest);
//Set background color (White)
GdkColor l_oBackgroundColor;
l_oBackgroundColor.red = 65535;l_oBackgroundColor.green = 65535;l_oBackgroundColor.blue = 65535;
gtk_widget_modify_bg(m_pDrawingArea, GTK_STATE_NORMAL, &l_oBackgroundColor);
//creates the left ruler
m_pLeftRuler = new CSignalDisplayLeftRuler(i32LeftRulerWidthRequest, i32LeftRulerHeightRequest);
......@@ -267,6 +275,13 @@ void CSignalChannelDisplay::draw(const GdkRectangle& rExposedArea)
return;
}
//draw grid if grid toggled
/* if(m_pParentDisplayView->m_bShowGrid)
{
drawGridLines(m_ui32Height/10,m_ui32Width/10);
}*/
//updates the left ruler
float64 l_f64MaximumDisplayedValue = m_f64TranslateY - ( (0 - ((m_ui32Height*m_f64ZoomScaleY)/2) + (m_f64ZoomTranslateY* m_f64ZoomScaleY)) / (m_f64ScaleY * m_f64ZoomScaleY * m_ui32Height) );
float64 l_f64MinimumDisplayedValue = m_f64TranslateY - ( (m_ui32Height - ((m_ui32Height*m_f64ZoomScaleY)/2) + (m_f64ZoomTranslateY* m_f64ZoomScaleY)) / (m_f64ScaleY * m_f64ZoomScaleY * m_ui32Height) );
......@@ -435,7 +450,7 @@ void CSignalChannelDisplay::checkTranslation(float64& rDisplayedValueRange)
float64 l_f64CurrentMaximum;
float64 l_f64CurrentMinimum;
for(size_t k=0 ; k<m_oChannelList.size() ; k++)
for(size_t k=0 ; k<m_oChannelList.size() ; k++)
{
//get local min/max
m_pDatabase->getDisplayedChannelLocalMinMaxValue(m_oChannelList[k], l_f64CurrentMinimum, l_f64CurrentMaximum);
......@@ -457,8 +472,8 @@ void CSignalChannelDisplay::checkTranslation(float64& rDisplayedValueRange)
if(m_eCurrentSignalMode == DisplayMode_GlobalBestFit)
{
//compute Y coord of local max and min
gint l_iMaxY = (gint)getSampleYCoordinate(m_f64LocalMaximum);
gint l_iMinY = (gint)getSampleYCoordinate(m_f64LocalMinimum);
gint l_iMaxY = (gint)getSampleYCoordinate(m_f64LocalMaximum, 0);
gint l_iMinY = (gint)getSampleYCoordinate(m_f64LocalMinimum, 0);
//translate signal if some data is plotted out of the window
if(l_iMaxY < 0 || l_iMinY > (int32)m_ui32Height-1)
......@@ -475,6 +490,8 @@ void CSignalChannelDisplay::setGlobalBestFitParameters(const float64& rRange, co
{
m_f64ScaleX = 1;
m_f64VerticalScale = rRange;
float64 l_f64LocalMediumValue = (m_f64LocalMaximum + m_f64LocalMinimum) / 2;
m_f64MaximumTopMargin = l_f64LocalMediumValue + rRange/2 + rMargin;
......@@ -502,7 +519,7 @@ void CSignalChannelDisplay::updateDisplayParameters()
//compute the translation needed to center the signal correctly in the window
m_f64TranslateX = 0;
m_f64TranslateY = (m_f64MaximumTopMargin + m_f64MinimumBottomMargin) / 2;
m_f64TranslateY = (m_f64MaximumTopMargin + m_f64MinimumBottomMargin) / (2 * m_oChannelList.size()) ;
//reflect changes
redrawAllAtNextRefresh();
......@@ -557,10 +574,37 @@ float64 CSignalChannelDisplay::getSampleXCoordinate(uint32 ui32BufferPosition, u
return (f64XOffset + ui32BufferPosition*m_f64WidthPerBuffer + ui32SampleIndex*m_f64PointStep - m_f64TranslateX) * m_f64ScaleX;
}
float64 CSignalChannelDisplay::getSampleYCoordinate(float64 f64Value)
float64 CSignalChannelDisplay::getSampleYCoordinate(float64 f64Value, uint32 ui32ChannelIndex, bool debug)
{
//TODO : precompute some factors!
return m_f64ScaleY*m_f64ZoomScaleY*m_ui32Height* (m_f64TranslateY-f64Value) + (m_ui32Height*m_f64ZoomScaleY)/2 - m_f64ZoomTranslateY*m_f64ZoomScaleY;
float64 l_f64sizePerChannel = m_ui32Height/(float64)m_oChannelList.size();
float64 l_f64nChannel = m_oChannelList.size();
//Autotranslation on
if(m_pParentDisplayView->m_bAutoTranslation)
{
return m_f64ScaleY*m_f64ZoomScaleY*l_f64sizePerChannel*(m_f64TranslateY-f64Value)+(l_f64nChannel-ui32ChannelIndex)*l_f64sizePerChannel*m_f64ZoomScaleY - m_f64ZoomTranslateY*m_f64ZoomScaleY - l_f64sizePerChannel/2;
}
//Autotranslation off
else
{
return m_f64ScaleY*m_f64ZoomScaleY*l_f64sizePerChannel*(-f64Value)+(l_f64nChannel-ui32ChannelIndex)*l_f64sizePerChannel*m_f64ZoomScaleY - m_f64ZoomScaleY - l_f64sizePerChannel/2;
}
}
float64 CSignalChannelDisplay::getSampleYMultiViewCoordinate(float64 f64Value, uint32 ui32ChannelIndex, bool debug)
{
//Autotranslation on
if(m_pParentDisplayView->m_bAutoTranslation)
{
return m_f64ScaleY*m_f64ZoomScaleY*m_ui32Height* (m_f64TranslateY-f64Value) + (m_ui32Height*m_f64ZoomScaleY)/2 - m_f64ZoomTranslateY*m_f64ZoomScaleY;
}
//Autotranslation off
else
{
return m_f64ScaleY*m_f64ZoomScaleY*m_ui32Height* (-f64Value) + (m_ui32Height*m_f64ZoomScaleY)/2 - m_f64ZoomScaleY;
}
}
boolean CSignalChannelDisplay::drawSignals(uint32 ui32FirstBufferToDisplay, uint32 ui32LastBufferToDisplay, uint32 ui32FirstSampleToDisplay, float64 f64FirstBufferStartX)
......@@ -577,7 +621,7 @@ boolean CSignalChannelDisplay::drawSignals(uint32 ui32FirstBufferToDisplay, uint
for(size_t k=0; k<m_oChannelList.size(); k++)
{
if(m_oChannelList.size()!=1)
if(m_bMultiView)
{
m_pParentDisplayView->getMultiViewColor(m_oChannelList[k], l_oLineColor);
}
......@@ -607,9 +651,18 @@ boolean CSignalChannelDisplay::drawSignals(uint32 ui32FirstBufferToDisplay, uint
//for all samples in current buffer
for(uint32 i = (j==ui32FirstBufferToDisplay)?ui32FirstSampleToDisplay:0; i<l_ui32SamplesPerBuffer; i++, l_ui64PointIndex++)
{
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].first = getSampleXCoordinate(j - ui32FirstBufferToDisplay, i, f64FirstBufferStartX);
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].second = getSampleYCoordinate(l_pCurrentChannelSampleBuffer[i]);
if(m_bMultiView)
{
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].first = getSampleXCoordinate(j - ui32FirstBufferToDisplay, i, f64FirstBufferStartX);
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].second = getSampleYMultiViewCoordinate(l_pCurrentChannelSampleBuffer[i], k, true);
}
else
{
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].first = getSampleXCoordinate(j - ui32FirstBufferToDisplay, i, f64FirstBufferStartX);
(m_pParentDisplayView->m_pRawPoints)[l_ui64PointIndex].second = getSampleYCoordinate(l_pCurrentChannelSampleBuffer[i], k, true);
}
}
}
//crop points
......@@ -672,6 +725,7 @@ boolean CSignalChannelDisplay::drawSignals(uint32 ui32FirstBufferToDisplay, uint
gdk_gc_set_rgb_fg_color(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE(m_pDrawingArea)], &l_oLineColor);
gdk_gc_set_line_attributes(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_BEVEL);
return true;
}
......@@ -710,13 +764,60 @@ void CSignalChannelDisplay::drawZeroLine()
gdk_gc_set_line_attributes(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_BUTT, GDK_JOIN_BEVEL);
//draw Y=0 line
gint l_iZeroY = (gint)getSampleYCoordinate(0);
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 0, l_iZeroY, m_ui32Width ,l_iZeroY);
if(m_bMultiView)
{
gint l_iZeroY = (gint)getSampleYMultiViewCoordinate(0,0);
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 0, l_iZeroY, m_ui32Width ,l_iZeroY);
}
else
{
for(uint32 k = 0; k< m_oChannelList.size();k++)
{
gint l_iZeroY = (gint)getSampleYCoordinate(0,k);
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 0, l_iZeroY, m_ui32Width ,l_iZeroY);
}
}
//switch back to normal line
gdk_gc_set_line_attributes(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_BEVEL);
}
void CSignalChannelDisplay::drawGridLines(float64 X_Step, float64 Y_Step)
{
//set color of grid
GdkColor l_oGridColor;
l_oGridColor.red = 254*65535/255; l_oGridColor.green = 195*65535/255; l_oGridColor.blue = 172*65535/255;
gdk_gc_set_rgb_fg_color(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE(m_pDrawingArea)], &l_oGridColor);
//draw grid
for(uint32 k = 0; k< m_oChannelList.size();k++)
{
gint l_iZeroY = (gint)getSampleYCoordinate(0,k);
//draw horizontal lines
for(uint32 i = 0; i< m_ui32Height; i++)
{
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 0, l_iZeroY+i*Y_Step, m_ui32Width ,l_iZeroY+i*Y_Step);
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], 0, l_iZeroY-i*Y_Step, m_ui32Width ,l_iZeroY-i*Y_Step);
}
//draw vertical lines
for(uint32 i = 0; i< m_ui32Width; i++)
{
gdk_draw_line(m_pDrawingArea->window, m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE (m_pDrawingArea)], i*X_Step, 0, i*X_Step , m_ui32Height);
}
}
//set color back to default (black)
GdkColor l_oBlack;
l_oBlack.red = 0; l_oBlack.green = 0; l_oBlack.blue = 0;
gdk_gc_set_rgb_fg_color(m_pDrawingArea->style->fg_gc[GTK_WIDGET_STATE(m_pDrawingArea)], &l_oBlack);
}
//
//CALLBACKS
//
......
......@@ -202,7 +202,10 @@ namespace OpenViBEPlugins
* \return Y coordinate of sample
*/
OpenViBE::float64 getSampleYCoordinate(
OpenViBE::float64 f64Value);
OpenViBE::float64 f64Value, OpenViBE::uint32 ui32ChannelIndex, bool debug=false);
OpenViBE::float64 getSampleYMultiViewCoordinate(
OpenViBE::float64 f64Value, OpenViBE::uint32 ui32ChannelIndex, bool debug=false);
/**
* \brief Draw signals (and stimulations, if any) displayed by this channel
......@@ -231,6 +234,15 @@ namespace OpenViBEPlugins
*/
void drawZeroLine();
/**
* \brief Draw grid in background
* \param f64 X_Step step between vertical lines of the grid
* \param f64 Y_Step step between horizontal lines of the grid
*/
void drawGridLines(
OpenViBE::float64 X_Step,
OpenViBE::float64 Y_Step);
public:
//! Left ruler displaying signal scale
CSignalDisplayLeftRuler* m_pLeftRuler;
......@@ -287,6 +299,11 @@ namespace OpenViBEPlugins
OpenViBE::uint64 m_ui64LatestDisplayedTime;
//! Should the whole window be redrawn at next redraw?
OpenViBE::boolean m_bRedrawAll;
OpenViBE::boolean m_bUseOffset;
OpenViBE::float64 m_f64VerticalScale;
OpenViBE::boolean m_bMultiView;
};
}
......
......@@ -136,6 +136,9 @@ namespace OpenViBEPlugins
OpenViBE::boolean onCustomVerticalScaleChangedCB(
::GtkSpinButton* pSpinButton);
OpenViBE::boolean onAutoTranslationToggledCB(
GtkToggleButton* pToggleButton);
/**
* \brief Get a channel display object
* \param ui32ChannelIndex Index of channel display
......@@ -204,6 +207,9 @@ namespace OpenViBEPlugins
//!Show bottom time ruler when true
OpenViBE::boolean m_bShowBottomRuler;
//!Show background grid when true
OpenViBE::boolean m_bShowGrid;
//! Time of displayed signals at the left of channel displays
OpenViBE::uint64 m_ui64LeftmostDisplayedTime;
......@@ -232,6 +238,7 @@ namespace OpenViBEPlugins
OpenViBE::float64 m_f64CustomVerticalScaleValue;
//@}
//! The database that contains the information to use to draw the signals
CBufferDatabase * m_pBufferDatabase;
......@@ -246,6 +253,9 @@ namespace OpenViBEPlugins
//! Flag set to true once multi view configuration dialog is initialized
OpenViBE::boolean m_bMultiViewInitialized;
OpenViBE::boolean m_bAutoTranslation;
//! Vector of indices of selected channels
std::map<OpenViBE::uint32, OpenViBE::boolean> m_vMultiViewSelectedChannels;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment