Commit 96a44436 authored by saubatn's avatar saubatn

UPDATED Remove target launcher.


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@756 ec899d31-69d1-42ba-9299-647d76f65fb3
parent d2b07ab5
......@@ -102,6 +102,9 @@ MMLComponent::MMLComponent(const QString & fileName) throw(AbortException) : Com
// ---------------------- destructor ----------------------------
MMLComponent::~MMLComponent() {
cout << "delete MMLComponent" << endl;
/*if (exportedMml!="")
remove(exportedMml.toStdString().c_str());
*/
......@@ -111,15 +114,17 @@ MMLComponent::~MMLComponent() {
}
//mmlGUI->getMonitoringManager()->setPml(NULL);
if (mmlGUI) {
delete mmlGUI;
mmlGUI = NULL;
}
if (display) {
delete display;
display = NULL;
}
if (mmlGUI) {
delete mmlGUI;
mmlGUI = NULL;
}
if (myPopupMenu) {
delete myPopupMenu;
......
......@@ -45,144 +45,145 @@
MMLDisplay::MMLDisplay(MMLComponent* mmlManager):QObject()
{
this->mmlManager=mmlManager;
QObject* qobj=(QObject*)(mmlManager->getMonitoringGuiManager());
QObject* qobj2=(QObject*)(mmlManager->getMonitoringGuiManager()->getDialog());
connect(qobj, SIGNAL(changed()), this, SLOT(updateDisplay()));
connect(qobj2, SIGNAL(monitorsChanged()), this, SLOT(updateMonitorsTable()));
connect(qobj, SIGNAL(reconnectPml()), this, SLOT(connectPml()));
monitorDisplay=NULL;
// add two column in monitors table for displaying monitors
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
int i=table->columnCount();
table->setColumnCount(i+2);
QTableWidgetItem* item1 = new QTableWidgetItem();
item1->setText(tr("Display"));
table->setHorizontalHeaderItem(i,item1);
QTableWidgetItem* item2 = new QTableWidgetItem();
item2->setText(tr("Display Type"));
table->setHorizontalHeaderItem(i+1,item2);
this->mmlManager=mmlManager;
QObject* qobj=(QObject*)(mmlManager->getMonitoringGuiManager());
QObject* qobj2=(QObject*)(mmlManager->getMonitoringGuiManager()->getDialog());
connect(qobj, SIGNAL(changed()), this, SLOT(updateDisplay()));
connect(qobj2, SIGNAL(monitorsChanged()), this, SLOT(updateMonitorsTable()));
connect(qobj, SIGNAL(reconnectPml()), this, SLOT(connectPml()));
monitorDisplay=NULL;
// add two column in monitors table for displaying monitors
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
int i=table->columnCount();
table->setColumnCount(i+2);
QTableWidgetItem* item1 = new QTableWidgetItem();
item1->setText(tr("Display"));
table->setHorizontalHeaderItem(i,item1);
QTableWidgetItem* item2 = new QTableWidgetItem();
item2->setText(tr("Display Type"));
table->setHorizontalHeaderItem(i+1,item2);
}
MMLDisplay::~MMLDisplay()
{
if (monitorDisplay)
delete monitorDisplay;
cout << "delete MMLDisplay" << endl;
if (monitorDisplay)
delete monitorDisplay;
}
// ---------------------- updateDisplay ----------------------------
void MMLDisplay::updateDisplay() {
double pos[3];
AtomDC* adc;
Atom* a;
PMManagerDC* pmMgr=mmlManager->getPMManager();
PhysicalModel* pm = mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getPml();
StructuralComponent * theAtoms = pm->getAtoms();
for ( unsigned int i = 0; i < theAtoms->getNumberOfStructures();i++ ) {
// get the target index
a = ( Atom * ) theAtoms->getStructure ( i );
// activate the target's 3D representation
adc = pmMgr->getDC ( a );
if ( adc != NULL ) {
a->getPosition ( pos );
adc->resetAlreadyMovedFlag();
adc->setPosition ( pos[0], pos[1], pos[2] );
double pos[3];
AtomDC* adc;
Atom* a;
PMManagerDC* pmMgr=mmlManager->getPMManager();
PhysicalModel* pm = mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getPml();
StructuralComponent * theAtoms = pm->getAtoms();
for ( unsigned int i = 0; i < theAtoms->getNumberOfStructures(); i++ ) {
// get the target index
a = ( Atom * ) theAtoms->getStructure ( i );
// activate the target's 3D representation
adc = pmMgr->getDC ( a );
if ( adc != NULL ) {
a->getPosition ( pos );
adc->resetAlreadyMovedFlag();
adc->setPosition ( pos[0], pos[1], pos[2] );
}
}
}
//Update monitor display
if (monitorDisplay)
monitorDisplay->update();
camitk::InteractiveViewer::get3DViewer()->refreshRenderer();
//Update monitor display
if (monitorDisplay)
monitorDisplay->update();
camitk::InteractiveViewer::get3DViewer()->refreshRenderer();
}
// ---------------------- connectMonitor ----------------------------
void MMLDisplay::connectMonitor()
{
Monitor* m=NULL;
std::string s="";
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0;i < table->rowCount();i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked()){
m=mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
QComboBox* qcb=(QComboBox*)(table->cellWidget(i,6));
s=qcb->currentText().toStdString();
{
Monitor* m=NULL;
std::string s="";
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0; i < table->rowCount(); i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked()) {
m=mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
QComboBox* qcb=(QComboBox*)(table->cellWidget(i,6));
s=qcb->currentText().toStdString();
}
}
}
if (m){
if (monitorDisplay){
monitorDisplay->hide();
delete monitorDisplay;
if (m) {
if (monitorDisplay) {
monitorDisplay->hide();
delete monitorDisplay;
}
MMLMonitorDisplayFactory* fact=MMLMonitorDisplayFactory::getInstance();
monitorDisplay=fact->createMonitorDisplay(s,m,mmlManager);
}
MMLMonitorDisplayFactory* fact=MMLMonitorDisplayFactory::getInstance();
monitorDisplay=fact->createMonitorDisplay(s,m,mmlManager);
}
updateDisplay();
updateDisplay();
}
// ---------------------- updateMonitorsTable ----------------------------
void MMLDisplay::updateMonitorsTable()
{
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0;i < table->rowCount();i++) {
QRadioButton* r=new QRadioButton();
table->setCellWidget(i ,5 , r);
connect(r,SIGNAL(toggled(bool)),this,SLOT(connectMonitor()));
// create a combo box to choose how to display monitor
QComboBox* cbox=new QComboBox();
Monitor* monitor=mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
MMLMonitorDisplayFactory* fact=MMLMonitorDisplayFactory::getInstance();
for (unsigned int j = 0;j < fact->getNumberOfDisplaysByType(monitor->getValueType());j++){
std::string s=fact->getDisplayByType(monitor->getValueType(),j);
cbox->insertItem(j,s.c_str());
}
table->setCellWidget(i ,6 , cbox);
connect(cbox,SIGNAL(currentIndexChanged(int)),this,SLOT(connectMonitor()));
for (int i = 0; i < table->rowCount(); i++) {
QRadioButton* r=new QRadioButton();
table->setCellWidget(i ,5 , r);
connect(r,SIGNAL(toggled(bool)),this,SLOT(connectMonitor()));
// create a combo box to choose how to display monitor
QComboBox* cbox=new QComboBox();
Monitor* monitor=mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
MMLMonitorDisplayFactory* fact=MMLMonitorDisplayFactory::getInstance();
for (unsigned int j = 0; j < fact->getNumberOfDisplaysByType(monitor->getValueType()); j++) {
std::string s=fact->getDisplayByType(monitor->getValueType(),j);
cbox->insertItem(j,s.c_str());
}
table->setCellWidget(i ,6 , cbox);
connect(cbox,SIGNAL(currentIndexChanged(int)),this,SLOT(connectMonitor()));
}
}
//--------------- refreshModified ---------------------------------
Monitor* MMLDisplay::getDisplayedMonitor()
{
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0;i < table->rowCount();i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked())
return mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
}
return NULL;
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0; i < table->rowCount(); i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked())
return mmlManager->getMonitoringGuiManager()->getMonitoringManager()->getMonitor(i);
}
return NULL;
}
int MMLDisplay::getDisplayedMonitorLine()
{
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0;i < table->rowCount();i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked())
return i;
}
return -1;
QTableWidget* table=mmlManager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
for (int i = 0; i < table->rowCount(); i++) {
QRadioButton* qrb=(QRadioButton*)(table->cellWidget(i,5));
if (qrb->isChecked())
return i;
}
return -1;
}
void MMLDisplay::connectPml()
{
mmlManager->connectPml();
mmlManager->connectPml();
}
......@@ -25,13 +25,17 @@
#include "MMLMonitorDisplay.h"
#include <iostream>
using namespace std;
MMLMonitorDisplay::MMLMonitorDisplay(Monitor* monitor,MMLComponent* manager):QObject()
{
this->monitor=monitor;
this->manager=manager;
this->monitor=monitor;
this->manager=manager;
}
MMLMonitorDisplay::~MMLMonitorDisplay()
{
cout << "delete MMLMonitorDisplay (empty destructor)" << endl;
}
......@@ -36,134 +36,138 @@ bool tabularRegistered=MMLMonitorDisplayFactory::getInstance()->registerClass<Ta
Tabular::Tabular(Monitor* monitor, MMLComponent* manager): MMLMonitorDisplay(monitor, manager)
{
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
line=manager->getDisplay()->getDisplayedMonitorLine();
int j=t->columnCount();
oldRowSize=t->rowHeight(line);
t->setColumnCount(j+1);
QTableWidgetItem* item = new QTableWidgetItem();
item->setText(("Tabular"));
t->setHorizontalHeaderItem(j,item);
table= new QTableWidget;
table->setEditTriggers(0);
t->setCellWidget(line,j,table);
table->installEventFilter(this);
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
line=manager->getDisplay()->getDisplayedMonitorLine();
int j=t->columnCount();
oldRowSize=t->rowHeight(line);
t->setColumnCount(j+1);
QTableWidgetItem* item = new QTableWidgetItem();
item->setText(("Tabular"));
t->setHorizontalHeaderItem(j,item);
table= new QTableWidget;
table->setEditTriggers(0);
t->setCellWidget(line,j,table);
table->installEventFilter(this);
}
Tabular::~Tabular()
{
if (table)
delete table;
if (table)
{
cout << "delete tabular" << endl;
// TODO : check why it crashed, see bug 116
delete table;
}
}
// ---------------------- update ----------------------------
void Tabular::update()
{
table->clear();
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
QString s;
QStringList labels;
switch(monitor->getValueType()){
table->clear();
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
QString s;
QStringList labels;
switch(monitor->getValueType()) {
case Monitor::SCALAR:
table->setColumnCount(1);
table->setRowCount(1);
table->setItem(0, 0, new QTableWidgetItem(s.setNum(monitor->getValue(0))));
table->verticalHeader()->hide();
table->horizontalHeader()->hide();
break;
table->setColumnCount(1);
table->setRowCount(1);
table->setItem(0, 0, new QTableWidgetItem(s.setNum(monitor->getValue(0))));
table->verticalHeader()->hide();
table->horizontalHeader()->hide();
break;
case Monitor::SCALARSET:
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(1);
for (unsigned int j=0;j<monitor->getNumberOfIndex();j++){
QTableWidgetItem* item1 = new QTableWidgetItem();
item1->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item1);
table->setItem(0, j, new QTableWidgetItem(s.setNum(monitor->getValue(j))));
}
table->verticalHeader()->hide();
t->setRowHeight(line,3*table->rowHeight(0));
break;
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(1);
for (unsigned int j=0; j<monitor->getNumberOfIndex(); j++) {
QTableWidgetItem* item1 = new QTableWidgetItem();
item1->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item1);
table->setItem(0, j, new QTableWidgetItem(s.setNum(monitor->getValue(j))));
}
table->verticalHeader()->hide();
t->setRowHeight(line,3*table->rowHeight(0));
break;
case Monitor::VECTORSET:
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(3);
for (unsigned int j=0;j<monitor->getNumberOfIndex();j++){
QTableWidgetItem* item2 = new QTableWidgetItem();
item2->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item2);
for (unsigned int i=0;i<3;i++){
table->setItem(i, j, new QTableWidgetItem(s.setNum(monitor->getValue(3*j+i))));
}
}
labels << "x" << "y" << "z";
table->setVerticalHeaderLabels(labels);
t->setRowHeight(line,5*table->rowHeight(0));
break;
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(3);
for (unsigned int j=0; j<monitor->getNumberOfIndex(); j++) {
QTableWidgetItem* item2 = new QTableWidgetItem();
item2->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item2);
for (unsigned int i=0; i<3; i++) {
table->setItem(i, j, new QTableWidgetItem(s.setNum(monitor->getValue(3*j+i))));
}
}
labels << "x" << "y" << "z";
table->setVerticalHeaderLabels(labels);
t->setRowHeight(line,5*table->rowHeight(0));
break;
case Monitor::MATRIX_33SET:
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(6);
for (unsigned int j=0;j<monitor->getNumberOfIndex();j++){
QTableWidgetItem* item3 = new QTableWidgetItem();
item3->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item3);
for (unsigned int i=0;i<6;i++){
table->setItem(i, j, new QTableWidgetItem(s.setNum(monitor->getValue(6*j+i))));
}
}
labels << "1,1" << "1,2" << "1,3" << "2,1" << "2,2" << "2,3" << "3,1" << "3,2" << "3,3";
table->setVerticalHeaderLabels(labels);
t->setRowHeight(line,9*table->rowHeight(0));
break;
}
table->setColumnCount(monitor->getNumberOfIndex());
table->setRowCount(6);
for (unsigned int j=0; j<monitor->getNumberOfIndex(); j++) {
QTableWidgetItem* item3 = new QTableWidgetItem();
item3->setText(s.setNum(monitor->getIndexOfValues(j)));
table->setHorizontalHeaderItem(j,item3);
for (unsigned int i=0; i<6; i++) {
table->setItem(i, j, new QTableWidgetItem(s.setNum(monitor->getValue(6*j+i))));
}
}
labels << "1,1" << "1,2" << "1,3" << "2,1" << "2,2" << "2,3" << "3,1" << "3,2" << "3,3";
table->setVerticalHeaderLabels(labels);
t->setRowHeight(line,9*table->rowHeight(0));
break;
}
}
// ---------------------- hide ----------------------------
void Tabular::hide()
{
table->clear();
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
int i=t->columnCount();
t->removeColumn(i-1);
t->setColumnCount(i-1);
t->setRowHeight(line,oldRowSize);
table->clear();
QTableWidget* t=manager->getMonitoringGuiManager()->getDialog()->getMonitorsTableWidget();
int i=t->columnCount();
t->removeColumn(i-1);
t->setColumnCount(i-1);
t->setRowHeight(line,oldRowSize);
}
// ---------------------- copy ----------------------------
void Tabular::copy()
{
QList<QTableWidgetSelectionRange> list=table->selectedRanges();
if (list.size()>0){
QTableWidgetSelectionRange range = list[0];
QString str;
for (int i = 0; i < range.rowCount(); ++i) {
if (i > 0)
str += "\n";
for (int j = 0; j < range.columnCount(); ++j) {
if (j > 0)
str += " ";
str += table->item(range.topRow() + i, range.leftColumn() + j)->text();
}
QList<QTableWidgetSelectionRange> list=table->selectedRanges();
if (list.size()>0) {
QTableWidgetSelectionRange range = list[0];
QString str;
for (int i = 0; i < range.rowCount(); ++i) {
if (i > 0)
str += "\n";
for (int j = 0; j < range.columnCount(); ++j) {
if (j > 0)
str += " ";
str += table->item(range.topRow() + i, range.leftColumn() + j)->text();
}
}
QApplication::clipboard()->setText(str);
}
QApplication::clipboard()->setText(str);
}
}
// ---------------------- eventFilter ----------------------------
bool Tabular::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::ContextMenu) {
QMouseEvent *mEvent = static_cast<QMouseEvent *>(event);
QMenu menu(table);
menu.addAction("special copy for spreadsheet", this, SLOT(copy()));
menu.exec(mEvent->globalPos());
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
if (event->type() == QEvent::ContextMenu) {
QMouseEvent *mEvent = static_cast<QMouseEvent *>(event);
QMenu menu(table);
menu.addAction("special copy for spreadsheet", this, SLOT(copy()));
menu.exec(mEvent->globalPos());
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
......@@ -46,6 +46,7 @@ MonitoringGuiManager::MonitoringGuiManager()
//--------------- Destructor ---------------------------------
MonitoringGuiManager::~MonitoringGuiManager()
{
std::cout << "delete MonitoringGuiManager" << std::endl;
if (driver)
delete driver;
if (dialog)
......
......@@ -35,13 +35,4 @@ add_subdirectory(cmake) # for cmake module installation
# CEP packaging (only works if this is a stand-alone CEP
camitk_sub_project_validate(${CMAKE_BINARY_DIR})
camitk_sdk_packaging(DESCRIPTION ${CEP_DESCRIPTION})
# For Microsoft Visual C++, sets the default application for the "ALL_BUILD" project
# This is the default application launched in debug.
if ( MSVC )
create_default_target_launcher_special(
${CEP_DEFAULT_APPLICATION}
EXTERNAL_COMMAND "${CAMITK_BIN_DIR}/${CEP_DEFAULT_APPLICATION}-debug.exe"
)
endif()
camitk_sdk_packaging(DESCRIPTION ${CEP_DESCRIPTION})
\ No newline at end of file
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