66 menuFile->addSeparator();
67 menuFile->addAction(actionExit);
74 statusView->setColumnCount(2);
75 statusView->setHeaderLabels(QStringList()<< tr (
"Label") << tr (
"Value"));
77 statusView->sortByColumn(0);
78 statusView->setFocus();
110 qRegisterMetaType<string>(
"string");
111 qRegisterMetaType<QString>(
"QString");
112 qRegisterMetaType< QVector<QString> >(
"QVector<QString>");
118 connect(actionExit, SIGNAL(triggered()),
this, SLOT(close()));
119 connect(actionSaveLog, SIGNAL(triggered()),
this, SLOT(
save()));
120 connect(actionSaveLogAs, SIGNAL(triggered()),
this, SLOT(
saveAs()));
121 connect(actionLoadConfiguration, SIGNAL(triggered()),
this, SLOT(
open()));
122 connect(actionHideDebugMsgs, SIGNAL(triggered(
bool)),
this, SLOT(
hideDebugMsgs(
bool)));
123 connect(actionAboutRegMAS, SIGNAL(triggered()),
this, SLOT(
about()));
124 connect(actionRegMASDocumentation, SIGNAL(triggered()),
this, SLOT(
showDocumentation()));
125 connect(actionFitMap, SIGNAL(triggered()), mapBox, SLOT(fitInWindow()));
126 connect(
this, SIGNAL(
resized()),mapBox, SLOT(fitInWindow()));
127 connect(viewResultsButton, SIGNAL(clicked()),
this, SLOT(
openResults()));
132 connect(&
modelMainThread, SIGNAL(updatePixelToGui(QString,
int,
int, QColor)),
this, SLOT (
updatePixel(QString,
int,
int, QColor)));
149 connect(&
modelMainThread, SIGNAL( fitInWindowToGui()), mapBox, SLOT(fitInWindow()));
151 connect(mapBox, SIGNAL( queryRequestOnPx(
int,
int,
bool) ), &
modelMainThread, SLOT ( checkQuery(
int,
int,
bool) ) );
152 connect(&
modelMainThread,SIGNAL(publishQueryResults(
const QString&)), pxInfoArea, SLOT (setHtml(
const QString&)));
153 connect(&
modelMainThread,SIGNAL(activateTab(
int)), tabWidget, SLOT (setCurrentIndex(
int)));
253 int t = QMessageBox::warning(
256 tr(
"The model is still running.\n"
257 "Do you want to stop it?"),
258 QMessageBox::Yes | QMessageBox::Default,
259 QMessageBox::Cancel | QMessageBox::Escape
261 if (t == QMessageBox::Yes) {
264 }
else if (t == QMessageBox::Cancel) {
270 int r = QMessageBox::warning(
273 tr(
"The model log has not been saved.\n"
274 "Do you want to save it?"),
276 QMessageBox::No | QMessageBox::Default,
277 QMessageBox::Cancel | QMessageBox::Escape
279 if (r == QMessageBox::Yes) {
281 }
else if (r == QMessageBox::Cancel) {
530 map<string, QTreeWidgetItem*>::iterator p;
531 QTreeWidgetItem *parentItem;
535 parentItem = p->second;
536 QTreeWidgetItem *node =
new QTreeWidgetItem(parentItem);
537 svIndex.insert(pair<string, QTreeWidgetItem*>(itemID, node));
538 node->setText(0, text.c_str());
542 QString tempString2 = itemID.c_str();
543 QString tempString3 = parentID.c_str();
544 tempString =
"**** ERROR, Coud not add sub item "+tempString2+
" to the Model Status Viewer. Parent item ("+tempString3+
") doesn't found.";
545 logArea->append(tempString);
609 static int simulationCounter = 0;
612 map<string, QTreeWidgetItem*>::iterator p;
618 QTreeWidgetItem* svGeneralNode =
new QTreeWidgetItem(statusView);
619 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general", svGeneralNode));
620 svGeneralNode -> setText(0,
"General");
621 QTreeWidgetItem* svYearItem =
new QTreeWidgetItem(svGeneralNode);
622 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_year", svYearItem));
623 svYearItem->setText(0,
"year");
624 svYearItem->setText(1,
"0");
625 QTreeWidgetItem* svTotalPlotsItem =
new QTreeWidgetItem(svGeneralNode);
626 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_total plots", svTotalPlotsItem));
627 svTotalPlotsItem->setText(0,
"total plots");
628 svTotalPlotsItem->setText(1,
"0");
629 QTreeWidgetItem* svTotalLandItem =
new QTreeWidgetItem(svGeneralNode);
630 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_total land", svTotalLandItem));
631 svTotalLandItem->setText(0,
"total land");
632 QTreeWidgetItem* svTotalAgrLandItem =
new QTreeWidgetItem(svGeneralNode);
633 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_total agr land", svTotalAgrLandItem));
634 svTotalAgrLandItem->setText(0,
"total agr land");
635 QTreeWidgetItem* svOwnedAgrLandItem =
new QTreeWidgetItem(svGeneralNode);
636 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_owned agr land", svOwnedAgrLandItem));
637 svOwnedAgrLandItem->setText(0,
"owned agr land");
638 QTreeWidgetItem* svRentedAgrLandItem =
new QTreeWidgetItem(svGeneralNode);
639 svIndex.insert(pair<string, QTreeWidgetItem*>(
"general_rented agr land", svRentedAgrLandItem));
640 svRentedAgrLandItem->setText(0,
"rented agr land");
642 QTreeWidgetItem* svManagersNode =
new QTreeWidgetItem(statusView);
643 svIndex.insert(pair<string, QTreeWidgetItem*>(
"managers", svManagersNode));
644 svManagersNode->setText(0,
"Managers");
646 QTreeWidgetItem* svAgentsNode =
new QTreeWidgetItem(statusView);
647 svIndex.insert(pair<string, QTreeWidgetItem*>(
"agents", svAgentsNode));
648 svAgentsNode->setText(0,
"Agents");
651 layerSelector->clear();
653 pxInfoArea->setHtml(
"<i>Tip: Right click over a plot to retrieve its values across layers.</i>");
658 if (simulationCounter) logArea->append(
"***WARNING: You are running more simulations from the GUI without closing/reopening it. It should works, but there are no guarantees. The best way is to run only one simulation from the GUI, eventually closing and opening FFSM again for further simulations.");
void stopModelMainThread()
void setCurrentLogFileName(const QString &fileName)
ScenarioSelectionWidget * scenarioWidget
ThreadManager modelMainThread
void treeViewerItemChangeValue(string itemID, string newValue)
Change value to an existing item in the Status Viewer.
void resetGUIForNewSimulation()
Reset the graphical elements for a new simulation // Send the request of getting the pixel info to th...
void treeViewerAddItem(string text, string itemID, string parentID)
e.g. manager_farmer_manager agents or agent_12345_ownedHa
void treeViewerItemRemove(string itemID)
void pauseOrResumeModelMainThread()
QLabel * yearSBLabel
Status bar current year label.
void closeEvent(QCloseEvent *event)
Manage the event of closing the application.
QString strippedName(const QString &fullFileName)
void setOutputDirName(string outputDirName_h)
void resizeEvent(QResizeEvent *event)
Manage the event of resizing the application.
void receiveScenarioOptions(const QVector< QString > &scenarios_h)
void updateRecentFileActions()
void setUnsavedStatus(bool unsavedStatus_h)
bool debugMsgsEnable
Allow debug messages to be show in the logArea.
map< string, QTreeWidgetItem * > svIndex
Map containing the ID and the pointers to the status viewer.
QAction * separatorAction
void updateImage(QString layerName_h, const QImage &image_h)
void setCurrentModelFileName(const QString &fileName)
void addLayer(QString layerName_h, QString layerLabel_h)
void processLogArea(const QString &message_h)
void switchToLayer(QString layerName_h)
void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h)
QAction * recentFileActions[MaxRecentFiles]
void startModelMainThread()
void hideDebugMsgs(bool hide)
bool saveLogFile(const QString &logFileName)
void switchToLayerFromLayerSelector(int layerIndex_h)