##// END OF EJS Templates
Progress bar added to the plugin
Progress bar added to the plugin

File last commit:

r55:4ea52012da18 default
r57:71cb087f0080 default
Show More
wfpage.cpp
602 lines | 16.0 KiB | text/x-c | CppLexer
First version of the gse-lesia module...
r23 #include "wfpage.h"
Minor updates to the rmapplugin...
r45 #include <stdio.h>
First version of the gse-lesia module...
r23
WFPage::WFPage(QWidget *parent) :
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 QMainWindow(parent)
First version of the gse-lesia module...
r23 {
Minor updates to the rmapplugin...
r45
pageTitle = "default";
wfPlot_v = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
wfPlot_e1 = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
wfPlot_e2 = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
wfPlot_b1 = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
wfPlot_b2 = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
wfPlot_b3 = new WFPlot(this, WFDISPLAY_XMAX, WFDISPLAY_YMAX);
First version of the gse-lesia module...
r23 //
Minor upgrade on rmapplugin...
r27 wfPlot_v->customPlot->setTitle("v");
wfPlot_e1->customPlot->setTitle("e1");
First version of the gse-lesia module...
r23 wfPlot_e2->customPlot->setTitle("e2");
wfPlot_b1->customPlot->setTitle("b1");
wfPlot_b2->customPlot->setTitle("b2");
wfPlot_b3->customPlot->setTitle("b3");
//
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 /*mainLayout = new QGridLayout;
First version of the gse-lesia module...
r23 mainLayout->addWidget(wfPlot_v, 0, 0, 1, 1);
mainLayout->addWidget(wfPlot_e1, 0, 1, 1, 1);
mainLayout->addWidget(wfPlot_e2, 0, 2, 1, 1);
mainLayout->addWidget(wfPlot_b1, 1, 0, 1, 1);
mainLayout->addWidget(wfPlot_b2, 1, 1, 1, 1);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 mainLayout->addWidget(wfPlot_b3, 1, 2, 1, 1);*/
First version of the gse-lesia module...
r23 //
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 dockV = NULL;
dockE1 = NULL;
dockE2 = NULL;
dockB1 = NULL;
dockB2 = NULL;
dockB3 = NULL;
title of the dockwidgets removed
r40 titleWidgetV = new QWidget();
titleWidgetE1 = new QWidget();
titleWidgetE2 = new QWidget();
titleWidgetB1 = new QWidget();
titleWidgetB2 = new QWidget();
titleWidgetB3 = new QWidget();
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 logFileName = new QLabel();
Minor bugs corrected in wfdisplay
r43 logFile = new QFile();
Minor updates to the rmapplugin...
r45
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 logFileEn = false;
dashboard tab added to the rmapplugin...
r46 storageEnabled = false;
allowDataStorage = false;
indexOffset = 0;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 createToolBar();
Minor updates to the rmapplugin...
r45 readSettings();
First version of the gse-lesia module...
r23 }
void WFPage::displayOnPlot(short *data, unsigned char num)
{
dashboard tab added to the rmapplugin...
r46 fillDataBuffer( data, num );
Minor updates to the rmapplugin...
r45
First version of the gse-lesia module...
r23 switch(num){
case 0:
dashboard tab added to the rmapplugin...
r46 wfPlot_v->displayOnPlot(data, DEFAULT_SIZE);
break;
case 1:
wfPlot_e1->displayOnPlot(data, DEFAULT_SIZE);
break;
case 2:
wfPlot_e2->displayOnPlot(data, DEFAULT_SIZE);
break;
case 3:
wfPlot_b1->displayOnPlot(data, DEFAULT_SIZE);
break;
case 4:
wfPlot_b2->displayOnPlot(data, DEFAULT_SIZE);
break;
case 5:
wfPlot_b3->displayOnPlot(data, DEFAULT_SIZE);
break;
}
}
void WFPage::initDataBuffer()
{
for (unsigned int i = 0; i < DEFAULT_SIZE; i++)
{
dataBuffer[i].clear();
}
}
void WFPage::fillDataBuffer(short *data, unsigned char num)
{
if ( (storageEnabled == true) | (allowDataStorage==true) ) // store data in buffers
{
switch(num) {
case 0 :
initDataBuffer();
for (unsigned int i=0; i<DEFAULT_SIZE; i++)
Minor updates to the rmapplugin...
r45 {
dashboard tab added to the rmapplugin...
r46 dataBuffer[i].append(QByteArray::number(data[i]));
dataBuffer[i].append(' ');
}
allowDataStorage = true;
break;
case 1 :
case 2 :
case 3 :
case 4 :
if (allowDataStorage==true) {
for (unsigned int i=0; i<DEFAULT_SIZE; i++)
Minor updates to the rmapplugin...
r45 {
dashboard tab added to the rmapplugin...
r46 dataBuffer[i].append(QByteArray::number(data[i]));
dataBuffer[i].append(' ');
Minor updates to the rmapplugin...
r45 }
}
First version of the gse-lesia module...
r23 break;
dashboard tab added to the rmapplugin...
r46
case 5 :
if (allowDataStorage==true) {
for (unsigned int i=0; i<DEFAULT_SIZE; i++)
{
dataBuffer[i].append(QByteArray::number(data[i]));
dataBuffer[i].append(' ');
}
storeDataBuffer();
allowDataStorage = false;
}
First version of the gse-lesia module...
r23 break;
dashboard tab added to the rmapplugin...
r46
default:
First version of the gse-lesia module...
r23 break;
dashboard tab added to the rmapplugin...
r46
}
}
}
void WFPage::storeDataBuffer()
{
for (int i = 0; i < DEFAULT_SIZE; i++ )
{
*(this->logFileStrm) << (i + indexOffset) << " " << dataBuffer[i] << endl;
}
indexOffset = indexOffset + DEFAULT_SIZE;
if (storageEnabled == false){
this->logFileStrm->flush();
this->logFile->waitForBytesWritten(3000);
this->logFile->close();
First version of the gse-lesia module...
r23 }
}
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34
void WFPage::createToolBar()
{
radio_v = new QRadioButton(tr("v"));
radio_e1 = new QRadioButton(tr("e1"));
radio_e2 = new QRadioButton(tr("e2"));
radio_b1 = new QRadioButton(tr("b1"));
radio_b2 = new QRadioButton(tr("b2"));
radio_b3 = new QRadioButton(tr("b3"));
radio_tabify = new QRadioButton(tr("tabify"));
radio_v->setAutoExclusive(false);
radio_e1->setAutoExclusive(false);
radio_e2->setAutoExclusive(false);
radio_b1->setAutoExclusive(false);
radio_b2->setAutoExclusive(false);
radio_b3->setAutoExclusive(false);
radio_tabify->setAutoExclusive(false);
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 button_selectAll = new QPushButton(tr("select all"));
button_storeWfrm = new QPushButton(tr("REC"));
Minor updates to the rmapplugin...
r45 button_chooseDir = new QPushButton(tr("choose dir"));
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 myToolBar = new QToolBar("select");
myToolBar->addWidget(radio_v);
myToolBar->addWidget(radio_e1);
myToolBar->addWidget(radio_e2);
myToolBar->addWidget(radio_b1);
myToolBar->addWidget(radio_b2);
myToolBar->addWidget(radio_b3);
myToolBar->addSeparator();
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 myToolBar->addWidget(button_selectAll);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 myToolBar->addWidget(radio_tabify);
Minor updates to the rmapplugin...
r45 myToolBar->addSeparator();
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 myToolBar->addWidget(button_storeWfrm);
Minor updates to the rmapplugin...
r45 myToolBar->addWidget(button_chooseDir);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34
addToolBar(Qt::LeftToolBarArea, myToolBar);
radio_tabify->setChecked(true);
connect(this->radio_v, SIGNAL(clicked(bool)), this, SLOT(actionRadioV(bool)));
connect(this->radio_e1, SIGNAL(clicked(bool)), this, SLOT(actionRadioE1(bool)));
connect(this->radio_e2, SIGNAL(clicked(bool)), this, SLOT(actionRadioE2(bool)));
connect(this->radio_b1, SIGNAL(clicked(bool)), this, SLOT(actionRadioB1(bool)));
connect(this->radio_b2, SIGNAL(clicked(bool)), this, SLOT(actionRadioB2(bool)));
connect(this->radio_b3, SIGNAL(clicked(bool)), this, SLOT(actionRadioB3(bool)));
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 connect(this->button_selectAll, SIGNAL(clicked()), this, SLOT(selectAll()));
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 connect(this->radio_tabify, SIGNAL(clicked(bool)), this, SLOT(organizeDocks()));
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 connect(this->button_storeWfrm, SIGNAL(clicked()), this, SLOT(storeWfrm()));
Minor updates to the rmapplugin...
r45 connect(this->button_chooseDir, SIGNAL(clicked()), this, SLOT(chooseDir()));
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
void WFPage::actionRadioV(bool state)
{
if (state == true)
{
if (dockV == NULL)
{
dockV = new QDockWidget("V", this);
dockV->setWidget(wfPlot_v);
title of the dockwidgets removed
r40 dockV->setTitleBarWidget(titleWidgetV);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockV);
}
organizeDocks();
}
void WFPage::actionRadioE1(bool state)
{
if (state == true)
{
if (dockE1 == NULL)
{
dockE1 = new QDockWidget("E1", this);
dockE1->setWidget(wfPlot_e1);
title of the dockwidgets removed
r40 dockE1->setTitleBarWidget(titleWidgetE1);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockE1);
}
organizeDocks();
}
void WFPage::actionRadioE2(bool state)
{
if (state == true)
{
if (dockE2 == NULL)
{
dockE2 = new QDockWidget("E2", this);
dockE2->setWidget(wfPlot_e2);
title of the dockwidgets removed
r40 dockE2->setTitleBarWidget(titleWidgetE2);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockE2);
}
organizeDocks();
}
void WFPage::actionRadioB1(bool state)
{
if (state == true)
{
if (dockB1 == NULL)
{
dockB1 = new QDockWidget("B1", this);
dockB1->setWidget(wfPlot_b1);
title of the dockwidgets removed
r40 dockB1->setTitleBarWidget(titleWidgetB1);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockB1);
}
organizeDocks();
}
void WFPage::actionRadioB2(bool state)
{
if (state == true)
{
if (dockB2 == NULL)
{
dockB2 = new QDockWidget("B2", this);
dockB2->setWidget(wfPlot_b2);
title of the dockwidgets removed
r40 dockB2->setTitleBarWidget(titleWidgetB2);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockB2);
}
organizeDocks();
}
void WFPage::actionRadioB3(bool state)
{
if (state == true)
{
if (dockB3 == NULL)
{
dockB3 = new QDockWidget("B3", this);
dockB3->setWidget(wfPlot_b3);
title of the dockwidgets removed
r40 dockB3->setTitleBarWidget(titleWidgetB3);
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
}
else
{
this->removeDockWidget(dockB3);
}
organizeDocks();
}
void WFPage::buildDockList()
{
dockList.clear();
if (radio_v->isChecked())
{
dockList.append(dockV);
removeDockWidget(dockV);
}
if (radio_e1->isChecked())
{
dockList.append(dockE1);
removeDockWidget(dockE1);
}
if (radio_e2->isChecked())
{
dockList.append(dockE2);
removeDockWidget(dockE2);
}
if (radio_b1->isChecked())
{
dockList.append(dockB1);
removeDockWidget(dockB1);
}
if (radio_b2->isChecked())
{
dockList.append(dockB2);
removeDockWidget(dockB2);
}
if (radio_b3->isChecked())
{
dockList.append(dockB3);
removeDockWidget(dockB3);
}
}
void WFPage::organizeDocks()
{
if (radio_tabify->isChecked())
{
tabify();
}
else
{
unTabify();
}
lfrsgse is a QMainWindow...
r39 wfPlot_v->resize(wfPlot_v->minimumSizeHint());
wfPlot_e1->resize(wfPlot_e1->minimumSizeHint());
wfPlot_e2->resize(wfPlot_e2->minimumSizeHint());
wfPlot_b1->resize(wfPlot_b1->minimumSizeHint());
wfPlot_b2->resize(wfPlot_b2->minimumSizeHint());
wfPlot_b3->resize(wfPlot_b3->minimumSizeHint());
this->resize(this->minimumSizeHint());
admin@pc-p-leroy3.LAB-LPP.LOCAL
QDockWidgets used for the waveform displays...
r34 }
void WFPage::unTabify()
{
buildDockList();
switch(dockList.size())
{
case 0:
break;
case 1:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
dockList.at(0)->show();
break;
case 2:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
dockList.at(0)->show();
dockList.at(1)->show();
break;
case 3:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(2));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
break;
case 4:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
break;
case 5:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(4));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
break;
case 6:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(4));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(5));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
dockList.at(5)->show();
break;
default:
break;
}
}
void WFPage::tabify()
{
buildDockList();
switch(dockList.size())
{
case 0:
break;
case 1:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
dockList.at(0)->show();
break;
case 2:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
dockList.at(0)->show();
dockList.at(1)->show();
break;
case 3:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
break;
case 4:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
break;
case 5:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
tabifyDockWidget(dockList.at(3), dockList.at(4));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
break;
case 6:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
tabifyDockWidget(dockList.at(3), dockList.at(4));
tabifyDockWidget(dockList.at(4), dockList.at(5));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
dockList.at(5)->show();
break;
default:
break;
}
}
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 void WFPage::selectAll()
{
radio_v->click();
radio_e1->click();
radio_e2->click();
radio_b1->click();
radio_b2->click();
radio_b3->click();
}
void WFPage::storeWfrm()
{
if (logFileEn == false)
{
dashboard tab added to the rmapplugin...
r46 buildFileName();
indexOffset = 0;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 button_storeWfrm->setText(tr("STOP"));
logFileEn = true;
}
else
{
dashboard tab added to the rmapplugin...
r46 // disable storage
storageEnabled = false;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 button_storeWfrm->setText(tr("REC"));
logFileEn = false;
}
}
dashboard tab added to the rmapplugin...
r46 void WFPage::buildFileName()
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 {
Function added to the plugin to store packets in CSV format.
r55 QTime time;
QDate date;
QString dateTime;
Minor updates to the rmapplugin...
r45 QString prefix;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
Function added to the plugin to store packets in CSV format.
r55 date = QDate::currentDate();
time = QTime::currentTime();
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
Function added to the plugin to store packets in CSV format.
r55 dateTime = QString::number( date.year() ) + "_"
+ QString::number( date.month() ) + "_"
+ QString::number( date.day() ) + "-"
+ QString::number( time.hour() ) + "_"
+ QString::number( time.minute() ) + "_"
+ QString::number( time.second() );
prefix = defaultStorageDirectory + "/" + dateTime + "_" + pageTitle ;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
dashboard tab added to the rmapplugin...
r46 if(this->logFile->isOpen()) this->logFile->close();
this->logFile->setFileName( prefix + ".data");
if(this->logFile->open(QIODevice::WriteOnly)) this->logFileStrm = new QTextStream(this->logFile);
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
dashboard tab added to the rmapplugin...
r46 *(this->logFileStrm) << "time V E1 E2 B1 B2 B3 " << endl;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
dashboard tab added to the rmapplugin...
r46 storageEnabled = true;
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42
}
void WFPage::logFileEnDisable(bool state)
{
if(state==true)
{
this->logFileEn = true;
}
else if(state==false)
{
this->logFileEn = false;
}
}
void WFPage::closeEvent(QCloseEvent *event)
{
Minor updates to the rmapplugin...
r45 writeSettings();
admin@pc-p-leroy3.LAB-LPP.LOCAL
Development of the waveform storage ability of the lfrgse
r42 event->accept();
}
Minor updates to the rmapplugin...
r45
void WFPage::readSettings()
{
QSettings settings("lpp", "lfrsgse");
defaultStorageDirectory = settings.value("defaultStorageDirectory", QDir::homePath()).toString();
}
void WFPage::writeSettings()
{
QSettings settings("lpp", "lfrsgse");
settings.setValue("defaultStorageDirectory", defaultStorageDirectory);
}
void WFPage::chooseDir()
{
defaultStorageDirectory = QFileDialog::getExistingDirectory(this,
"choose the directory",
QDir::homePath(),
QFileDialog::ShowDirsOnly);
}