Opensim Control Panel BRIGADOON-0013
This program provides a control panel for an Open Simulator Instance
Loading...
Searching...
No Matches
MainWindow Class Reference

#include <mainwindow.h>

Inheritance diagram for MainWindow:
[legend]
Collaboration diagram for MainWindow:
[legend]

Public Slots

void UpdateLocation (REMOTE_REGION_ADDRESS RegionAddress)

Signals

void ListInputDirectory (void)

Public Member Functions

 MainWindow (QWidget *parent=nullptr)
 ~MainWindow ()
 MainWindow (QWidget *parent=nullptr)
 ~MainWindow ()

Data Fields

Loggerlog
 Pointer to the Log Class.

Private Slots

void GetInputDir (void)
void GetOutputDir (void)
void WorldAreaChanged (REMOTE_WORLD_SIZE WorldSize)
void WorldSidesChanged (REMOTE_WORLD_SIDES WorldSides)
void DisableXYSize (Qt::CheckState)
void EnableAutoCalc (void)

Private Member Functions

QString GetDirectoryName (QString DefaultDirectory)

Private Attributes

Ui::MainWindow * ui
DatabaseManagerdb_manager
 Pointer to the Database Class.
DirClassdir_manager
AreaCalculatorarea_calc

Detailed Description

Definition at line 18 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow() [1/2]

MainWindow::MainWindow ( QWidget * parent = nullptr)

Definition at line 5 of file mainwindow.cpp.

6 : QMainWindow(parent)
7 , ui(new Ui::MainWindow)
8{
9 ui->setupUi(this);
10
11 // Setup the Setting Parameters for the Program
12 QCoreApplication::setOrganizationName("Brigadoon");
13 QCoreApplication::setOrganizationDomain("little-sense.au");
14 QCoreApplication::setApplicationName("Terrain Editor");
15
16
17 // Load the Log
18 qRegisterMetaType<REMOTE_LOG_ENTRY>("REMOTE_LOG_ENTRY"); // Register Custom Meta Types for the "QObject::connect" Definitions
19 log = new Logger(ui);
20 log->Add(LOG_DEBUG, MODE_CONFIG, "Logger \"log\" has been opened.");
21
22 // Load the Default Directories from Setup
23 QSettings settings;
24 ui->SourceDirectory->setText( settings.value( "Directories/InputDir").toString());
25 ui->DestinationDirectory->setText(settings.value( "Directories/OutputDir").toString());
26
27 // Create the Database Control Class
28 db_manager = new DatabaseManager(ui);
29 QObject::connect(db_manager, SIGNAL(SendLogEntry(REMOTE_LOG_ENTRY)), log, SLOT(RemoteLog(REMOTE_LOG_ENTRY)));
30 db_manager->ReconnectDatabase();
31
32 // Create the Directory Class
33 dir_manager = new DirClass();
34 QObject::connect(dir_manager, SIGNAL(SendLogEntry(REMOTE_LOG_ENTRY)), log, SLOT(RemoteLog(REMOTE_LOG_ENTRY)));
35 dir_manager->SetInputDirectory(ui->SourceDirectory->text());
36 dir_manager->SetInputTable(ui->InputRegionTable);
37 dir_manager->SetOutputTable(ui->OutputRegionTable);
38 log->Add(LOG_DEBUG, MODE_CONFIG, "Directory Class has been opened.");
39
40 // Load the Area Calculator
41 area_calc = new AreaCalculator();
42 QObject::connect(area_calc, SIGNAL(SendLogEntry(REMOTE_LOG_ENTRY)), log, SLOT(RemoteLog(REMOTE_LOG_ENTRY)));
43 log->Add(LOG_DEBUG, MODE_CONFIG, "AreaCalculator Class has been opened.");
44
45 // Load up the Connection Links
46 QObject::connect(ui->SourceSelect, SIGNAL(released()), this, SLOT(GetInputDir()));
47 QObject::connect(ui->DestinationSelect, SIGNAL(released()), this, SLOT(GetOutputDir()));
48
49 QObject::connect(ui->DestinationSelect, SIGNAL(released()), this, SLOT(GetOutputDir()));
50
51 qRegisterMetaType<REMOTE_WORLD_SIZE>("REMOTE_WORLD_SIZE"); // Register Custom Meta Types for the "QObject::connect" Definitions
52 qRegisterMetaType<REMOTE_WORLD_SIDES>("REMOTE_WORLD_SIDES");
53 qRegisterMetaType<REMOTE_REGION_ADDRESS>("REMOTE_REGION_ADDRESS");
54 QObject::connect(ui->WorldXSize, SIGNAL(valueChanged(int)), area_calc, SLOT(WorldXChanged(int)));
55 QObject::connect(ui->WorldYSize, SIGNAL(valueChanged(int)), area_calc, SLOT(WorldYChanged(int)));
56 QObject::connect(dir_manager, SIGNAL(SendRegionLocation(REMOTE_REGION_ADDRESS)),this, SLOT(UpdateLocation(REMOTE_REGION_ADDRESS)));
57 QObject::connect(area_calc, SIGNAL(SendWorldArea(REMOTE_WORLD_SIZE)), this, SLOT(WorldAreaChanged(REMOTE_WORLD_SIZE)));
58 QObject::connect(area_calc, SIGNAL(SendWorldSides(REMOTE_WORLD_SIDES)), this, SLOT(WorldSidesChanged(REMOTE_WORLD_SIDES)));
59
60 QObject::connect(area_calc, SIGNAL(IncludeNewRegion(REMOTE_REGION_ADDRESS)), this, SLOT(UpdateLocation(REMOTE_REGION_ADDRESS)));
61
62 QObject::connect(ui->LowerXLocation, SIGNAL(valueChanged(int)), area_calc, SLOT(LowerXChanged(int)));
63 QObject::connect(ui->UpperXLocation, SIGNAL(valueChanged(int)), area_calc, SLOT(UpperXChanged(int)));
64 QObject::connect(ui->LowerYLocation, SIGNAL(valueChanged(int)), area_calc, SLOT(LowerYChanged(int)));
65 QObject::connect(ui->UpperYLocation, SIGNAL(valueChanged(int)), area_calc, SLOT(UpperYChanged(int)));
66
67 QObject::connect(ui->Region_x1, SIGNAL(pressed()), area_calc, SLOT(Regionx1Pressed()));
68 QObject::connect(ui->Region_x4, SIGNAL(pressed()), area_calc, SLOT(Regionx4Pressed()));
69 QObject::connect(ui->Region_x16, SIGNAL(pressed()), area_calc, SLOT(Regionx16Pressed()));
70
71 QObject::connect(ui->AutoCalcSize, SIGNAL(checkStateChanged(Qt::CheckState) ), area_calc, SLOT(AutoCalcChanged(Qt::CheckState)));
72 QObject::connect(ui->AutoCalcSize, SIGNAL(checkStateChanged(Qt::CheckState) ), area_calc, SLOT(AutoCalcChanged(Qt::CheckState)));
73 QObject::connect(ui->AutoCalcSize, SIGNAL(checkStateChanged(Qt::CheckState) ), this, SLOT(DisableXYSize(Qt::CheckState)));
74
75 qRegisterMetaType<QList<DIR_INFO>>("REMOTE_DIR_INFO");
76 QObject::connect(ui->ProcessInputDirectory, SIGNAL(pressed()), dir_manager, SLOT(ListInputDirectory(void)));
77 QObject::connect(ui->ProcessInputDirectory, SIGNAL(pressed()), this, SLOT(EnableAutoCalc(void)));
78}
AreaCalculator * area_calc
Definition mainwindow.h:47
void GetInputDir(void)
void EnableAutoCalc(void)
Ui::MainWindow * ui
Definition mainwindow.h:37
void WorldAreaChanged(REMOTE_WORLD_SIZE WorldSize)
void ListInputDirectory(void)
void WorldSidesChanged(REMOTE_WORLD_SIDES WorldSides)
Logger * log
Pointer to the Log Class.
Definition mainwindow.h:30
void DisableXYSize(Qt::CheckState)
void UpdateLocation(REMOTE_REGION_ADDRESS RegionAddress)
void GetOutputDir(void)
DatabaseManager * db_manager
Pointer to the Database Class.
Definition mainwindow.h:43
DirClass * dir_manager
Definition mainwindow.h:45
@ LOG_DEBUG
Definition logger.h:56
@ MODE_CONFIG
Definition logger.h:26

References area_calc, db_manager, dir_manager, DisableXYSize(), EnableAutoCalc(), GetInputDir(), GetOutputDir(), ListInputDirectory(), log, LOG_DEBUG, MainWindow(), MODE_CONFIG, ui, UpdateLocation(), WorldAreaChanged(), and WorldSidesChanged().

Referenced by MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MainWindow() [1/2]

MainWindow::~MainWindow ( )

Definition at line 80 of file mainwindow.cpp.

81{
82 // Save the Data Directories if required
83 if (ui->SaveDirectoriesOnExit->isChecked())
84 {
85 QSettings settings;
86 settings.setValue( "Directories/InputDir", ui->SourceDirectory->text());
87 settings.setValue( "Directories/OutputDir", ui->DestinationDirectory->text());
88 }
89
90 // Close Down the Classes, as required
91 delete db_manager; // Save Database Parameters, If Required
92 delete log; // Save Log Parameters, If Required
93
94 delete ui;
95}

References db_manager, log, and ui.

◆ MainWindow() [2/2]

MainWindow::MainWindow ( QWidget * parent = nullptr)

◆ ~MainWindow() [2/2]

MainWindow::~MainWindow ( )

References ui.

Member Function Documentation

◆ DisableXYSize

void MainWindow::DisableXYSize ( Qt::CheckState State)
privateslot

Definition at line 136 of file mainwindow.cpp.

137{
138 bool enable_state = (bool)State;
139
140 ui->WorldXSize->setReadOnly(enable_state);
141 ui->WorldYSize->setReadOnly(enable_state);
142 if (!enable_state)
143 {
144 ui->WorldXSize->setValue(0);
145 ui->WorldYSize->setValue(0);
146 ui->LowerXLocation->setValue(0);
147 ui->LowerYLocation->setValue(0);
148 ui->UpperXLocation->setValue(0);
149 ui->UpperYLocation->setValue(0);
150 }
151}

References ui.

Referenced by MainWindow().

Here is the caller graph for this function:

◆ EnableAutoCalc

void MainWindow::EnableAutoCalc ( void )
privateslot

Definition at line 158 of file mainwindow.cpp.

159{
160 ui->AutoCalcSize->setCheckState(Qt::Checked);
161}

References ui.

Referenced by MainWindow().

Here is the caller graph for this function:

◆ GetDirectoryName()

QString MainWindow::GetDirectoryName ( QString DefaultDirectory)
private

Definition at line 153 of file mainwindow.cpp.

154{
155 return(QFileDialog::getExistingDirectory(this, "Select Directory", DefaultDirectory, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
156}

Referenced by GetInputDir(), and GetOutputDir().

Here is the caller graph for this function:

◆ GetInputDir

void MainWindow::GetInputDir ( void )
privateslot

Definition at line 124 of file mainwindow.cpp.

125{
126 QString selected_directory = GetDirectoryName(ui->SourceDirectory->text());
127 if (selected_directory != "") ui->SourceDirectory->setText(selected_directory);
128}
QString GetDirectoryName(QString DefaultDirectory)

References GetDirectoryName(), and ui.

Referenced by MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOutputDir

void MainWindow::GetOutputDir ( void )
privateslot

Definition at line 130 of file mainwindow.cpp.

131{
132 QString selected_directory = GetDirectoryName(ui->DestinationDirectory->text());
133 if (selected_directory != "") ui->DestinationDirectory->setText(selected_directory);
134}

References GetDirectoryName(), and ui.

Referenced by MainWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ListInputDirectory

void MainWindow::ListInputDirectory ( void )
signal

Referenced by MainWindow().

Here is the caller graph for this function:

◆ UpdateLocation

void MainWindow::UpdateLocation ( REMOTE_REGION_ADDRESS RegionAddress)
slot

Definition at line 163 of file mainwindow.cpp.

164{
165 if ((ui->LowerXLocation->value() == 0) || ( ui->LowerXLocation->value() > RegionAddress.RegionXLocation)) ui->LowerXLocation->setValue(RegionAddress.RegionXLocation);
166 if (ui->UpperXLocation->value() < RegionAddress.RegionXLocation) ui->UpperXLocation->setValue(RegionAddress.RegionXLocation);
167
168 if ((ui->LowerYLocation->value() == 0) || ( ui->LowerYLocation->value() > RegionAddress.RegionYLocation)) ui->LowerYLocation->setValue(RegionAddress.RegionYLocation);
169 if (ui->UpperYLocation->value() < RegionAddress.RegionYLocation) ui->UpperYLocation->setValue(RegionAddress.RegionYLocation);
170}

References REMOTE_REGION_ADDRESS::RegionXLocation, REMOTE_REGION_ADDRESS::RegionYLocation, and ui.

Referenced by MainWindow().

Here is the caller graph for this function:

◆ WorldAreaChanged

void MainWindow::WorldAreaChanged ( REMOTE_WORLD_SIZE WorldSize)
privateslot

Definition at line 103 of file mainwindow.cpp.

104{
105 float world_area_formatted;
106 QString world_area_string;
107
108 // Show the World's Land Area
109 if (WorldSize.WorldArea >= 1E06)
110 {
111 world_area_formatted = WorldSize.WorldArea / 1E06;
112 ui->WorldSize->setText( QString::number(world_area_formatted));
113 ui->WorldAreaLabel->setText("sq. km");
114 }
115 else
116 {
117 ui->WorldSize->setText( QString::number(WorldSize.WorldArea));
118 ui->WorldAreaLabel->setText("sq. m");
119 }
120
121 ui->MaxRegions->setText( QString::number(WorldSize.WorldRegionCount));
122}

References ui, REMOTE_WORLD_SIZE::WorldArea, and REMOTE_WORLD_SIZE::WorldRegionCount.

Referenced by MainWindow().

Here is the caller graph for this function:

◆ WorldSidesChanged

void MainWindow::WorldSidesChanged ( REMOTE_WORLD_SIDES WorldSides)
privateslot

Definition at line 97 of file mainwindow.cpp.

98{
99 ui->WorldXSize->setValue(WorldSides.WorldXSize);
100 ui->WorldYSize->setValue(WorldSides.WorldYSize);
101}

References ui, REMOTE_WORLD_SIDES::WorldXSize, and REMOTE_WORLD_SIDES::WorldYSize.

Referenced by MainWindow().

Here is the caller graph for this function:

Field Documentation

◆ area_calc

AreaCalculator* MainWindow::area_calc
private

Definition at line 47 of file mainwindow.h.

Referenced by MainWindow().

◆ db_manager

DatabaseManager* MainWindow::db_manager
private

Pointer to the Database Class.

Definition at line 43 of file mainwindow.h.

Referenced by MainWindow(), and ~MainWindow().

◆ dir_manager

DirClass* MainWindow::dir_manager
private

Definition at line 45 of file mainwindow.h.

Referenced by MainWindow().

◆ log

Logger* MainWindow::log

Pointer to the Log Class.

Definition at line 30 of file mainwindow.h.

Referenced by MainWindow(), and ~MainWindow().

◆ ui

Ui::MainWindow * MainWindow::ui
private

The documentation for this class was generated from the following files: