Refactored RenderingScenery and STL containers usage
This commit is contained in:
parent
2aed1f07ae
commit
19ac6936b0
37 changed files with 261 additions and 289 deletions
5
Makefile
5
Makefile
|
@ -1,6 +1,7 @@
|
|||
BUILDMODE=release
|
||||
BUILDPATH=./build/${BUILDMODE}
|
||||
LIBRARY_PATH=${BUILDPATH}/rendering:${BUILDPATH}/exploring:${BUILDPATH}/system:${BUILDPATH}/basics:${BUILDPATH}/definition:${BUILDPATH}/render/opengl:${BUILDPATH}/render/software:${BUILDPATH}/tests/googletest
|
||||
BUILD_SPEC=linux-g++
|
||||
|
||||
all:build
|
||||
|
||||
|
@ -9,9 +10,9 @@ dirs:
|
|||
|
||||
makefiles:dirs
|
||||
ifeq (${BUILDMODE}, release)
|
||||
@+cd ${BUILDPATH} && qmake ../../src/paysages.pro -r -spec linux-clang
|
||||
@+cd ${BUILDPATH} && qmake ../../src/paysages.pro -r -spec $(BUILD_SPEC)
|
||||
else
|
||||
@+cd ${BUILDPATH} && qmake ../../src/paysages.pro -r -spec linux-clang CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug
|
||||
@+cd ${BUILDPATH} && qmake ../../src/paysages.pro -r -spec $(BUILD_SPEC) CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug
|
||||
endif
|
||||
|
||||
build:makefiles
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "Curve.h"
|
||||
|
||||
const int MAX_NB_POINTS = 30;
|
||||
|
||||
#include <cstring>
|
||||
#include "PackStream.h"
|
||||
|
||||
const int MAX_NB_POINTS = 30;
|
||||
|
||||
Curve::Curve()
|
||||
{
|
||||
nbpoints = 0;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "RandomGenerator.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#define MAX_LEVEL_COUNT 30
|
||||
|
||||
|
|
|
@ -17,14 +17,13 @@ BaseDefinition::BaseDefinition(BaseDefinition* parent):
|
|||
|
||||
BaseDefinition::~BaseDefinition()
|
||||
{
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
for (auto child:children)
|
||||
{
|
||||
delete it.next();
|
||||
delete child;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDefinition::setName(const QString &name)
|
||||
void BaseDefinition::setName(const std::string &name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
@ -44,20 +43,18 @@ Scenery* BaseDefinition::getScenery()
|
|||
void BaseDefinition::save(PackStream* stream) const
|
||||
{
|
||||
stream->write(name);
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
for (auto child: children)
|
||||
{
|
||||
it.next()->save(stream);
|
||||
child->save(stream);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDefinition::load(PackStream* stream)
|
||||
{
|
||||
name = stream->readString();
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
for (auto child: children)
|
||||
{
|
||||
it.next()->load(stream);
|
||||
child->load(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,18 +66,17 @@ void BaseDefinition::copy(BaseDefinition* destination) const
|
|||
|
||||
void BaseDefinition::validate()
|
||||
{
|
||||
QListIterator<BaseDefinition*> it(children);
|
||||
while (it.hasNext())
|
||||
for (auto child: children)
|
||||
{
|
||||
it.next()->validate();
|
||||
child->validate();
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDefinition::addChild(BaseDefinition* child)
|
||||
{
|
||||
if (not children.contains(child))
|
||||
if (std::find(children.begin(), children.end(), child) != children.end())
|
||||
{
|
||||
children.append(child);
|
||||
children.push_back(child);
|
||||
child->parent = this;
|
||||
child->root = this->root;
|
||||
}
|
||||
|
@ -88,5 +84,13 @@ void BaseDefinition::addChild(BaseDefinition* child)
|
|||
|
||||
void BaseDefinition::removeChild(BaseDefinition* child)
|
||||
{
|
||||
children.removeOne(child);
|
||||
std::vector<BaseDefinition*>::iterator it = std::find(children.begin(), children.end(), child);
|
||||
if (it != children.end())
|
||||
{
|
||||
children.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("Trying to remove not found child from '%s'", name.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
|
||||
#include "definition_global.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace paysages {
|
||||
namespace system {class PackStream;}
|
||||
namespace definition {
|
||||
|
||||
/**
|
||||
|
@ -25,8 +21,8 @@ public:
|
|||
virtual void copy(BaseDefinition* destination) const;
|
||||
virtual void validate();
|
||||
|
||||
inline const QString& getName() const {return name;}
|
||||
virtual void setName(const QString &name);
|
||||
inline const std::string &getName() const {return name;}
|
||||
virtual void setName(const std::string &name);
|
||||
|
||||
virtual Scenery* getScenery();
|
||||
|
||||
|
@ -40,8 +36,8 @@ protected:
|
|||
private:
|
||||
BaseDefinition* parent;
|
||||
BaseDefinition* root;
|
||||
QString name;
|
||||
QList<BaseDefinition*> children;
|
||||
std::string name;
|
||||
std::vector<BaseDefinition*> children;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,12 +25,11 @@ void Layers::copy(BaseDefinition* destination_) const
|
|||
|
||||
null_layer->copy(destination->null_layer);
|
||||
|
||||
QListIterator<BaseDefinition*> it(layers);
|
||||
while (it.hasNext())
|
||||
for (auto layer: layers)
|
||||
{
|
||||
int position = destination->addLayer();
|
||||
BaseDefinition* new_layer = destination->getLayer(position);
|
||||
it.next()->copy(new_layer);
|
||||
layer->copy(new_layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,12 +48,12 @@ void Layers::setMaxLayerCount(int max_layer_count)
|
|||
|
||||
int Layers::count() const
|
||||
{
|
||||
return layers.count();
|
||||
return layers.size();
|
||||
}
|
||||
|
||||
BaseDefinition* Layers::getLayer(int position) const
|
||||
{
|
||||
if (position >= 0 and position < layers.size())
|
||||
if (position >= 0 and position < (int)layers.size())
|
||||
{
|
||||
return layers[position];
|
||||
}
|
||||
|
@ -67,19 +66,24 @@ BaseDefinition* Layers::getLayer(int position) const
|
|||
|
||||
int Layers::findLayer(BaseDefinition* layer) const
|
||||
{
|
||||
int result = layers.indexOf(layer);
|
||||
if (result < 0)
|
||||
int i = 0;
|
||||
for (auto it:layers)
|
||||
{
|
||||
qWarning("Layer %p not found, on a total of %d, returning %d", layer, layers.size(), result);
|
||||
if (it == layer)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
qWarning("Layer %p not found, on a total of %d, returning %d", layer, layers.size(), -1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Layers::addLayer(BaseDefinition* layer)
|
||||
{
|
||||
if (layers.size() < max_layer_count)
|
||||
if ((int)layers.size() < max_layer_count)
|
||||
{
|
||||
layers.append(layer);
|
||||
layers.push_back(layer);
|
||||
addChild(layer);
|
||||
return layers.size() - 1;
|
||||
}
|
||||
|
@ -97,10 +101,11 @@ int Layers::addLayer()
|
|||
|
||||
void Layers::removeLayer(int position)
|
||||
{
|
||||
if (position >= 0 and position < layers.size())
|
||||
if (position >= 0 and position < (int)layers.size())
|
||||
{
|
||||
BaseDefinition* removed = layers.takeAt(position);
|
||||
BaseDefinition* removed = layers[position];
|
||||
removeChild(removed);
|
||||
layers.erase(layers.begin() + position);
|
||||
delete removed;
|
||||
}
|
||||
}
|
||||
|
@ -112,9 +117,11 @@ void Layers::removeLayer(BaseDefinition* layer)
|
|||
|
||||
void Layers::moveLayer(int old_position, int new_position)
|
||||
{
|
||||
if (old_position >= 0 and old_position < layers.size() and new_position >= 0 and new_position < layers.size())
|
||||
if (old_position >= 0 and old_position < (int)layers.size() and new_position >= 0 and new_position < (int)layers.size())
|
||||
{
|
||||
layers.move(old_position, new_position);
|
||||
BaseDefinition* layer = layers[old_position];
|
||||
layers.erase(layers.begin() + old_position);
|
||||
layers.insert(layers.begin() + new_position, layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
public:
|
||||
LayerConstructor layer_constructor;
|
||||
int max_layer_count;
|
||||
QList<BaseDefinition*> layers;
|
||||
std::vector<BaseDefinition*> layers;
|
||||
BaseDefinition* null_layer;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Scenery.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
|
||||
#include "NoiseGenerator.h"
|
||||
#include "PackStream.h"
|
||||
|
@ -11,6 +12,9 @@
|
|||
#include "TexturesDefinition.h"
|
||||
#include "WaterDefinition.h"
|
||||
|
||||
static const double APP_HEADER = 19866544632.125;
|
||||
static const int DATA_VERSION = 1;
|
||||
|
||||
Scenery::Scenery():
|
||||
BaseDefinition(NULL)
|
||||
{
|
||||
|
@ -59,6 +63,53 @@ void Scenery::validate()
|
|||
checkCameraAboveGround();
|
||||
}
|
||||
|
||||
Scenery::FileOperationResult Scenery::saveGlobal(const std::string &filepath) const
|
||||
{
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (not stream.bindToFile(filepath, true))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
app_header = (double)APP_HEADER;
|
||||
stream.write(&app_header);
|
||||
version_header = (double)DATA_VERSION;
|
||||
stream.write(&version_header);
|
||||
|
||||
save(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
||||
Scenery::FileOperationResult Scenery::loadGlobal(const std::string &filepath)
|
||||
{
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (not stream.bindToFile(filepath, false))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
stream.read(&app_header);
|
||||
if (app_header != APP_HEADER)
|
||||
{
|
||||
return FILE_OPERATION_APP_MISMATCH;
|
||||
}
|
||||
|
||||
stream.read(&version_header);
|
||||
if ((int)version_header != DATA_VERSION)
|
||||
{
|
||||
return FILE_OPERATION_VERSION_MISMATCH;
|
||||
}
|
||||
|
||||
load(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
||||
Scenery* Scenery::getScenery()
|
||||
{
|
||||
return this;
|
||||
|
|
|
@ -15,6 +15,16 @@ namespace definition {
|
|||
*/
|
||||
class DEFINITIONSHARED_EXPORT Scenery: public BaseDefinition
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
FILE_OPERATION_OK,
|
||||
FILE_OPERATION_IOERROR,
|
||||
FILE_OPERATION_APP_MISMATCH,
|
||||
FILE_OPERATION_VERSION_MISMATCH
|
||||
} FileOperationResult;
|
||||
|
||||
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||
|
||||
public:
|
||||
Scenery();
|
||||
|
||||
|
@ -24,9 +34,12 @@ public:
|
|||
virtual void validate() override;
|
||||
virtual void copy(BaseDefinition *destination) const override;
|
||||
|
||||
FileOperationResult saveGlobal(const std::string &filepath) const;
|
||||
FileOperationResult loadGlobal(const std::string &filepath);
|
||||
|
||||
virtual Scenery* getScenery() override;
|
||||
|
||||
void autoPreset(int seed);
|
||||
void autoPreset(int seed=0);
|
||||
|
||||
void setAtmosphere(AtmosphereDefinition* atmosphere);
|
||||
inline AtmosphereDefinition* getAtmosphere() const {return atmosphere;}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "TerrainHeightMap.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "PackStream.h"
|
||||
#include "Memory.h"
|
||||
#include "TerrainDefinition.h"
|
||||
#include "TerrainHeightMapBrush.h"
|
||||
#include "Interpolation.h"
|
||||
#include "NoiseGenerator.h"
|
||||
#include <cassert>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Zone.h"
|
||||
|
||||
#include <cstring>
|
||||
#include "Curve.h"
|
||||
#include "PackStream.h"
|
||||
#include "Vector3.h"
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
#include "main.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "Scenery.h"
|
||||
|
||||
void startRender(SoftwareRenderer* renderer, char* outputpath, RenderArea::RenderParams params)
|
||||
{
|
||||
|
@ -156,25 +155,29 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
printf("Initializing ...\n");
|
||||
paysagesInit();
|
||||
Scenery* scenery = new Scenery();
|
||||
|
||||
if (conf_file_path)
|
||||
{
|
||||
paysagesLoad(conf_file_path);
|
||||
scenery->loadGlobal(conf_file_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
scenery->autoPreset();
|
||||
}
|
||||
|
||||
for (outputcount = 0; outputcount < conf_first_picture + conf_nb_pictures; outputcount++)
|
||||
{
|
||||
AtmosphereDefinition* atmo = RenderingScenery::getCurrent()->getAtmosphere();
|
||||
AtmosphereDefinition* atmo = scenery->getAtmosphere();
|
||||
atmo->hour = (int)floor(conf_daytime_start * 24.0);
|
||||
atmo->minute = (int)floor(fmod(conf_daytime_start, 1.0 / 24.0) * 24.0 * 60.0);
|
||||
atmo->validate();
|
||||
|
||||
CameraDefinition* camera = RenderingScenery::getCurrent()->getCamera();
|
||||
CameraDefinition* camera = scenery->getCamera();
|
||||
Vector3 step = {conf_camera_step_x, conf_camera_step_y, conf_camera_step_z};
|
||||
camera->setLocation(camera->getLocation().add(step));
|
||||
|
||||
renderer = new SoftwareRenderer(RenderingScenery::getCurrent());
|
||||
renderer = new SoftwareRenderer(scenery);
|
||||
renderer->setPreviewCallbacks(NULL, NULL, _previewUpdate);
|
||||
|
||||
if (outputcount >= conf_first_picture)
|
||||
|
@ -189,7 +192,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
printf("Cleaning up ...\n");
|
||||
paysagesQuit();
|
||||
delete scenery;
|
||||
|
||||
printf("\rDone. \n");
|
||||
|
||||
|
|
24
src/interface/desktop/DesktopScenery.cpp
Normal file
24
src/interface/desktop/DesktopScenery.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "DesktopScenery.h"
|
||||
|
||||
#include "common/mainwindow.h"
|
||||
|
||||
static DesktopScenery _main_scenery;
|
||||
|
||||
void DesktopScenery::save(PackStream *stream) const
|
||||
{
|
||||
Scenery::save(stream);
|
||||
|
||||
MainWindow::instance()->guiSave(stream);
|
||||
}
|
||||
|
||||
void DesktopScenery::load(PackStream *stream)
|
||||
{
|
||||
Scenery::load(stream);
|
||||
|
||||
MainWindow::instance()->guiLoad(stream);
|
||||
}
|
||||
|
||||
DesktopScenery* DesktopScenery::getCurrent()
|
||||
{
|
||||
return &_main_scenery;
|
||||
}
|
17
src/interface/desktop/DesktopScenery.h
Normal file
17
src/interface/desktop/DesktopScenery.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef DESKTOPSCENERY_H
|
||||
#define DESKTOPSCENERY_H
|
||||
|
||||
#include "desktop_global.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
|
||||
class DesktopScenery: public Scenery
|
||||
{
|
||||
public:
|
||||
virtual void save(PackStream* stream) const override;
|
||||
virtual void load(PackStream* stream) override;
|
||||
|
||||
static DesktopScenery* getCurrent();
|
||||
};
|
||||
|
||||
#endif // DESKTOPSCENERY_H
|
|
@ -1,42 +0,0 @@
|
|||
#include "RenderingScenery.h"
|
||||
|
||||
static RenderingScenery _main_scenery;
|
||||
|
||||
RenderingScenery::RenderingScenery()
|
||||
{
|
||||
_custom_load = NULL;
|
||||
_custom_save = NULL;
|
||||
_custom_data = NULL;
|
||||
}
|
||||
|
||||
RenderingScenery* RenderingScenery::getCurrent()
|
||||
{
|
||||
return &_main_scenery;
|
||||
}
|
||||
|
||||
void RenderingScenery::setCustomSaveCallbacks(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
|
||||
{
|
||||
_custom_save = callback_save;
|
||||
_custom_load = callback_load;
|
||||
_custom_data = data;
|
||||
}
|
||||
|
||||
void RenderingScenery::save(PackStream* stream) const
|
||||
{
|
||||
Scenery::save(stream);
|
||||
|
||||
if (_custom_save)
|
||||
{
|
||||
_custom_save(stream, _custom_data);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingScenery::load(PackStream* stream)
|
||||
{
|
||||
Scenery::load(stream);
|
||||
|
||||
if (_custom_load)
|
||||
{
|
||||
_custom_load(stream, _custom_data);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef RENDERINGSCENERY_H
|
||||
#define RENDERINGSCENERY_H
|
||||
|
||||
#include "desktop_global.h"
|
||||
|
||||
#include "Scenery.h"
|
||||
|
||||
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
|
||||
|
||||
/**
|
||||
* @brief Global scenery management
|
||||
*
|
||||
* This class contains the whole scenery definition.
|
||||
*/
|
||||
class RenderingScenery: public Scenery
|
||||
{
|
||||
public:
|
||||
RenderingScenery();
|
||||
|
||||
static RenderingScenery* getCurrent();
|
||||
|
||||
void setCustomSaveCallbacks(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
|
||||
|
||||
virtual void save(PackStream* stream) const override;
|
||||
virtual void load(PackStream* stream) override;
|
||||
|
||||
private:
|
||||
SceneryCustomDataCallback _custom_save;
|
||||
SceneryCustomDataCallback _custom_load;
|
||||
void* _custom_data;
|
||||
};
|
||||
|
||||
#endif // RENDERINGSCENERY_H
|
|
@ -77,7 +77,7 @@ QStringList BaseFormLayer::getLayers()
|
|||
{
|
||||
for (int i = 0; i < _layers_modified->count(); i++)
|
||||
{
|
||||
result << _layers_modified->getLayer(i)->getName();
|
||||
result << QString::fromStdString(_layers_modified->getLayer(i)->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void BaseFormLayer::layerAddedEvent()
|
|||
int layer = _layers_modified->addLayer();
|
||||
if (layer >= 0)
|
||||
{
|
||||
_layers_modified->getLayer(layer)->setName(layer_name);
|
||||
_layers_modified->getLayer(layer)->setName(layer_name.toStdString());
|
||||
|
||||
BaseForm::layerAddedEvent();
|
||||
|
||||
|
@ -128,7 +128,7 @@ void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
|
|||
{
|
||||
if (_layers_modified)
|
||||
{
|
||||
_layers_modified->getLayer(layer)->setName(new_name);
|
||||
_layers_modified->getLayer(layer)->setName(new_name.toStdString());
|
||||
}
|
||||
|
||||
BaseForm::layerRenamedEvent(layer, new_name);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "dialogrender.h"
|
||||
#include "dialogexplorer.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "CameraDefinition.h"
|
||||
|
@ -77,7 +77,7 @@ void FreeFormHelper::startManaging()
|
|||
connect(this, SIGNAL(needGlobalRefreshing()), _form_widget, SLOT(refreshFromFellowData()));
|
||||
connect(this, SIGNAL(needReverting()), _form_widget, SLOT(updateLocalDataFromScenery()));
|
||||
connect(this, SIGNAL(needCommitting()), _form_widget, SLOT(commitLocalDataToScenery()));
|
||||
connect(this, SIGNAL(needAlterRenderer(Renderer*)), _form_widget, SLOT(alterRenderer(Renderer*)));
|
||||
connect(this, SIGNAL(needAlterRenderer(SoftwareRenderer*)), _form_widget, SLOT(alterRenderer(SoftwareRenderer*)));
|
||||
|
||||
processGlobalRefresh();
|
||||
}
|
||||
|
@ -232,12 +232,12 @@ void FreeFormHelper::processApplyClicked()
|
|||
|
||||
void FreeFormHelper::processExploreClicked()
|
||||
{
|
||||
SoftwareRenderer renderer(RenderingScenery::getCurrent());
|
||||
SoftwareRenderer renderer(DesktopScenery::getCurrent());
|
||||
|
||||
emit needAlterRenderer(&renderer);
|
||||
|
||||
CameraDefinition camera;
|
||||
RenderingScenery::getCurrent()->getCamera(&camera);
|
||||
DesktopScenery::getCurrent()->getCamera(&camera);
|
||||
|
||||
DialogExplorer* dialog = new DialogExplorer(_form_widget, &camera, false, &renderer);
|
||||
dialog->exec();
|
||||
|
@ -246,7 +246,7 @@ void FreeFormHelper::processExploreClicked()
|
|||
|
||||
void FreeFormHelper::processRenderClicked()
|
||||
{
|
||||
SoftwareRenderer renderer(RenderingScenery::getCurrent());
|
||||
SoftwareRenderer renderer(DesktopScenery::getCurrent());
|
||||
|
||||
emit needAlterRenderer(&renderer);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "dialogexplorer.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "PackStream.h"
|
||||
#include "tools.h"
|
||||
|
||||
|
@ -127,11 +127,9 @@ MainWindow::MainWindow() :
|
|||
ui->tool_panel->hide();
|
||||
//ui->menuBar->hide();
|
||||
|
||||
RenderingScenery::getCurrent()->setCustomSaveCallbacks(MainWindow::guiSaveCallback, MainWindow::guiLoadCallback, this);
|
||||
|
||||
// FIXME AutoPreset has already been called by paysagesInit but we need to redo it here because
|
||||
// the auto apply on FormRender overwrites the camera. Delete this when the render form is no longer a BaseForm.
|
||||
RenderingScenery::getCurrent()->autoPreset(0);
|
||||
DesktopScenery::getCurrent()->autoPreset(0);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
|
@ -164,7 +162,7 @@ void MainWindow::refreshAll()
|
|||
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
|
||||
osd->clearItems();
|
||||
PreviewOsdItem* item = osd->newItem(50, 50);
|
||||
item->drawCamera(RenderingScenery::getCurrent()->getCamera());
|
||||
item->drawCamera(DesktopScenery::getCurrent()->getCamera());
|
||||
item->setToolTip(QString(tr("Camera")));
|
||||
|
||||
emit refreshed();
|
||||
|
@ -179,7 +177,7 @@ void MainWindow::fileNew()
|
|||
{
|
||||
if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
RenderingScenery::getCurrent()->autoPreset(0);
|
||||
DesktopScenery::getCurrent()->autoPreset(0);
|
||||
refreshAll();
|
||||
}
|
||||
}
|
||||
|
@ -194,12 +192,12 @@ void MainWindow::fileSave()
|
|||
filepath = filepath.append(".p3d");
|
||||
}
|
||||
|
||||
FileOperationResult result = paysagesSave((char*) filepath.toStdString().c_str());
|
||||
Scenery::FileOperationResult result = DesktopScenery::getCurrent()->saveGlobal(filepath.toStdString());
|
||||
switch (result)
|
||||
{
|
||||
case FILE_OPERATION_OK:
|
||||
case Scenery::FILE_OPERATION_OK:
|
||||
break;
|
||||
case FILE_OPERATION_IOERROR:
|
||||
case Scenery::FILE_OPERATION_IOERROR:
|
||||
QMessageBox::critical(this, tr("Paysages 3D - File saving error"), tr("Can't write specified file : %1").arg(filepath));
|
||||
break;
|
||||
default:
|
||||
|
@ -215,19 +213,19 @@ void MainWindow::fileLoad()
|
|||
QString filepath = QFileDialog::getOpenFileName(this, tr("Paysages 3D - Choose a scenery file to load"), QString(), tr("Paysages 3D Scenery (*.p3d)"));
|
||||
if (!filepath.isNull())
|
||||
{
|
||||
FileOperationResult result = paysagesLoad((char*) filepath.toStdString().c_str());
|
||||
Scenery::FileOperationResult result = DesktopScenery::getCurrent()->loadGlobal(filepath.toStdString());
|
||||
switch (result)
|
||||
{
|
||||
case FILE_OPERATION_OK:
|
||||
case Scenery::FILE_OPERATION_OK:
|
||||
refreshAll();
|
||||
break;
|
||||
case FILE_OPERATION_IOERROR:
|
||||
case Scenery::FILE_OPERATION_IOERROR:
|
||||
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("Can't read specified file : %1").arg(filepath));
|
||||
break;
|
||||
case FILE_OPERATION_APP_MISMATCH:
|
||||
case Scenery::FILE_OPERATION_APP_MISMATCH:
|
||||
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file doesn't look like a Paysages 3D file : %1").arg(filepath));
|
||||
break;
|
||||
case FILE_OPERATION_VERSION_MISMATCH:
|
||||
case Scenery::FILE_OPERATION_VERSION_MISMATCH:
|
||||
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file was created with an incompatible Paysages 3D version : %1").arg(filepath));
|
||||
break;
|
||||
default:
|
||||
|
@ -262,7 +260,7 @@ void MainWindow::explore3D()
|
|||
CameraDefinition* camera = new CameraDefinition;
|
||||
int result;
|
||||
|
||||
RenderingScenery::getCurrent()->getCamera(camera);
|
||||
DesktopScenery::getCurrent()->getCamera(camera);
|
||||
|
||||
DialogExplorer* dialog = new DialogExplorer(this, camera, true);
|
||||
result = dialog->exec();
|
||||
|
@ -271,23 +269,13 @@ void MainWindow::explore3D()
|
|||
|
||||
if (result == QDialog::Accepted)
|
||||
{
|
||||
RenderingScenery::getCurrent()->setCamera(camera);
|
||||
DesktopScenery::getCurrent()->setCamera(camera);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
delete camera;
|
||||
}
|
||||
|
||||
void MainWindow::guiSaveCallback(PackStream* stream, void* data)
|
||||
{
|
||||
((MainWindow*) data)->guiSave(stream);
|
||||
}
|
||||
|
||||
void MainWindow::guiLoadCallback(PackStream* stream, void* data)
|
||||
{
|
||||
((MainWindow*) data)->guiLoad(stream);
|
||||
}
|
||||
|
||||
void MainWindow::guiSave(PackStream* stream)
|
||||
{
|
||||
// Save all tabs status
|
||||
|
|
|
@ -24,12 +24,13 @@ public:
|
|||
|
||||
virtual bool event(QEvent* event);
|
||||
|
||||
void guiSave(PackStream* stream);
|
||||
void guiLoad(PackStream* stream);
|
||||
|
||||
static inline MainWindow* instance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
static void guiSaveCallback(PackStream* stream, void* data);
|
||||
static void guiLoadCallback(PackStream* stream, void* data);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -57,9 +58,6 @@ private:
|
|||
static MainWindow* _instance;
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
void guiSave(PackStream* stream);
|
||||
void guiLoad(PackStream* stream);
|
||||
|
||||
QVector<BaseForm*> _forms;
|
||||
FormRender* _form_render;
|
||||
};
|
||||
|
|
|
@ -56,7 +56,7 @@ HEADERS += \
|
|||
textures/PreviewCumul.h \
|
||||
textures/DialogTexturesLayer.h \
|
||||
desktop_global.h \
|
||||
RenderingScenery.h
|
||||
DesktopScenery.h
|
||||
|
||||
SOURCES += \
|
||||
terrain/widgetheightmap.cpp \
|
||||
|
@ -104,7 +104,7 @@ SOURCES += \
|
|||
textures/PreviewLayerLook.cpp \
|
||||
textures/PreviewCumul.cpp \
|
||||
textures/DialogTexturesLayer.cpp \
|
||||
RenderingScenery.cpp
|
||||
DesktopScenery.cpp
|
||||
|
||||
FORMS += \
|
||||
terrain/dialogterrainpainting.ui \
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <cmath>
|
||||
|
||||
#include "AtmosphereColorPreviewRenderer.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
|
||||
|
@ -56,13 +56,13 @@ FormAtmosphere::~FormAtmosphere()
|
|||
|
||||
void FormAtmosphere::revertConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getAtmosphere(_definition);
|
||||
DesktopScenery::getCurrent()->getAtmosphere(_definition);
|
||||
BaseForm::revertConfig();
|
||||
}
|
||||
|
||||
void FormAtmosphere::applyConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->setAtmosphere(_definition);
|
||||
DesktopScenery::getCurrent()->setAtmosphere(_definition);
|
||||
BaseForm::applyConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "formclouds.h"
|
||||
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "CloudsDefinition.h"
|
||||
#include "CloudLayerDefinition.h"
|
||||
|
@ -60,14 +60,14 @@ FormClouds::~FormClouds()
|
|||
|
||||
void FormClouds::revertConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getClouds(_definition);
|
||||
DesktopScenery::getCurrent()->getClouds(_definition);
|
||||
BaseFormLayer::revertConfig();
|
||||
}
|
||||
|
||||
void FormClouds::applyConfig()
|
||||
{
|
||||
BaseFormLayer::applyConfig();
|
||||
RenderingScenery::getCurrent()->setClouds(_definition);
|
||||
DesktopScenery::getCurrent()->setClouds(_definition);
|
||||
}
|
||||
|
||||
void FormClouds::layerReadCurrentFrom(void* layer_definition)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "dialogrender.h"
|
||||
#include "inputcamera.h"
|
||||
#include "tools.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "PackStream.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "BasePreview.h"
|
||||
|
@ -30,7 +30,7 @@ BaseForm(parent, true)
|
|||
disablePreviewsUpdate();
|
||||
|
||||
_preview_landscape = new BasePreview(this);
|
||||
_preview_landscape_renderer = new SceneryTopDownPreviewRenderer(RenderingScenery::getCurrent());
|
||||
_preview_landscape_renderer = new SceneryTopDownPreviewRenderer(DesktopScenery::getCurrent());
|
||||
addPreview(_preview_landscape, QString(tr("Top-down preview")));
|
||||
_preview_landscape->setRenderer(_preview_landscape_renderer);
|
||||
|
||||
|
@ -81,13 +81,13 @@ void FormRender::loadPack(PackStream* stream)
|
|||
|
||||
void FormRender::revertConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getCamera(_camera);
|
||||
DesktopScenery::getCurrent()->getCamera(_camera);
|
||||
BaseForm::revertConfig();
|
||||
}
|
||||
|
||||
void FormRender::applyConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->setCamera(_camera);
|
||||
DesktopScenery::getCurrent()->setCamera(_camera);
|
||||
BaseForm::applyConfig();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void FormRender::startQuickRender()
|
|||
{
|
||||
delete _renderer;
|
||||
}
|
||||
_renderer = new SoftwareRenderer(RenderingScenery::getCurrent());
|
||||
_renderer = new SoftwareRenderer(DesktopScenery::getCurrent());
|
||||
_renderer_inited = true;
|
||||
|
||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||
|
@ -119,7 +119,7 @@ void FormRender::startRender()
|
|||
{
|
||||
delete _renderer;
|
||||
}
|
||||
_renderer = new SoftwareRenderer(RenderingScenery::getCurrent());
|
||||
_renderer = new SoftwareRenderer(DesktopScenery::getCurrent());
|
||||
_renderer_inited = true;
|
||||
|
||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "formtextures.h"
|
||||
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "tools.h"
|
||||
#include "CameraDefinition.h"
|
||||
|
@ -144,14 +144,14 @@ FormTextures::~FormTextures()
|
|||
|
||||
void FormTextures::revertConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getTextures(_definition);
|
||||
DesktopScenery::getCurrent()->getTextures(_definition);
|
||||
BaseFormLayer::revertConfig();
|
||||
}
|
||||
|
||||
void FormTextures::applyConfig()
|
||||
{
|
||||
BaseFormLayer::applyConfig();
|
||||
RenderingScenery::getCurrent()->setTextures(_definition);
|
||||
DesktopScenery::getCurrent()->setTextures(_definition);
|
||||
}
|
||||
|
||||
void FormTextures::layerReadCurrentFrom(void* layer_definition)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <cmath>
|
||||
|
||||
#include "tools.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "BasePreview.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "WaterDefinition.h"
|
||||
|
@ -63,13 +63,13 @@ FormWater::~FormWater()
|
|||
|
||||
void FormWater::revertConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getWater(_definition);
|
||||
DesktopScenery::getCurrent()->getWater(_definition);
|
||||
BaseForm::revertConfig();
|
||||
}
|
||||
|
||||
void FormWater::applyConfig()
|
||||
{
|
||||
RenderingScenery::getCurrent()->setWater(_definition);
|
||||
DesktopScenery::getCurrent()->setWater(_definition);
|
||||
BaseForm::applyConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
#include <QColorDialog>
|
||||
#include "Color.h"
|
||||
|
||||
#include "lighting/SmallPreviewColor.h"
|
||||
#include "tools.h"
|
||||
|
@ -12,7 +13,9 @@ InputColor::InputColor(QWidget* form, QString label, Color* value):
|
|||
BaseInput(form, label),
|
||||
_original(value)
|
||||
{
|
||||
_preview = new SmallPreviewColor(form, &_edited);
|
||||
_edited = new Color();
|
||||
|
||||
_preview = new SmallPreviewColor(form, _edited);
|
||||
_preview->setMinimumSize(50, 20);
|
||||
_control = new QPushButton(tr("Edit"), form);
|
||||
_control->setMaximumWidth(150);
|
||||
|
@ -28,24 +31,24 @@ void InputColor::updatePreview()
|
|||
|
||||
void InputColor::applyValue()
|
||||
{
|
||||
*_original = _edited;
|
||||
*_original = *_edited;
|
||||
BaseInput::applyValue();
|
||||
}
|
||||
|
||||
void InputColor::revert()
|
||||
{
|
||||
_edited = *_original;
|
||||
*_edited = *_original;
|
||||
BaseInput::revert();
|
||||
}
|
||||
|
||||
void InputColor::chooseColor()
|
||||
{
|
||||
QColor col = QColorDialog::getColor(colorToQColor(_edited), _control);
|
||||
QColor col = QColorDialog::getColor(colorToQColor(*_edited), _control);
|
||||
if (col.isValid())
|
||||
{
|
||||
_edited.r = col.redF();
|
||||
_edited.g = col.greenF();
|
||||
_edited.b = col.blueF();
|
||||
_edited->r = col.redF();
|
||||
_edited->g = col.greenF();
|
||||
_edited->b = col.blueF();
|
||||
applyValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <QWidget>
|
||||
#include "baseinput.h"
|
||||
|
||||
#include "shared/types.h"
|
||||
|
||||
class InputColor:public BaseInput
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -23,7 +21,7 @@ private slots:
|
|||
|
||||
private:
|
||||
Color* _original;
|
||||
Color _edited;
|
||||
Color* _edited;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "TerrainShapePreviewRenderer.h"
|
||||
#include "common/freeformhelper.h"
|
||||
#include "tools.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "TerrainDefinition.h"
|
||||
#include "TerrainHeightMap.h"
|
||||
|
||||
|
@ -85,12 +85,12 @@ void MainTerrainForm::refreshFromFellowData()
|
|||
|
||||
void MainTerrainForm::updateLocalDataFromScenery()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getTerrain(_terrain);
|
||||
DesktopScenery::getCurrent()->getTerrain(_terrain);
|
||||
}
|
||||
|
||||
void MainTerrainForm::commitLocalDataToScenery()
|
||||
{
|
||||
RenderingScenery::getCurrent()->setTerrain(_terrain);
|
||||
DesktopScenery::getCurrent()->setTerrain(_terrain);
|
||||
}
|
||||
|
||||
void MainTerrainForm::alterRenderer(SoftwareRenderer* renderer)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../common/freeformhelper.h"
|
||||
#include "../common/freelayerhelper.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "TexturesDefinition.h"
|
||||
#include "TextureLayerDefinition.h"
|
||||
#include "previewmaterial.h"
|
||||
|
@ -83,7 +83,7 @@ void MainTexturesForm::updateLayers()
|
|||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
ui->layersGrid->setItem(n - 1 - i, 0, item);
|
||||
|
||||
item = new QTableWidgetItem(layer->getName());
|
||||
item = new QTableWidgetItem(QString::fromStdString(layer->getName()));
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
ui->layersGrid->setItem(n - 1 - i, 1, item);
|
||||
|
||||
|
@ -132,12 +132,12 @@ void MainTexturesForm::selectPreset(int preset)
|
|||
|
||||
void MainTexturesForm::updateLocalDataFromScenery()
|
||||
{
|
||||
RenderingScenery::getCurrent()->getTextures(textures);
|
||||
DesktopScenery::getCurrent()->getTextures(textures);
|
||||
}
|
||||
|
||||
void MainTexturesForm::commitLocalDataToScenery()
|
||||
{
|
||||
RenderingScenery::getCurrent()->setTextures(textures);
|
||||
DesktopScenery::getCurrent()->setTextures(textures);
|
||||
}
|
||||
|
||||
void MainTexturesForm::refreshFromLocalData()
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <QDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include "shared/types.h"
|
||||
#include "Color.h"
|
||||
|
||||
static inline QColor colorToQColor(Color color)
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#include "main.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "tools/data.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "Scenery.h"
|
||||
#include "PackStream.h"
|
||||
#include "main.h"
|
||||
|
||||
#define APP_HEADER 198632.125
|
||||
|
||||
void paysagesInit()
|
||||
{
|
||||
|
@ -22,50 +18,3 @@ void paysagesInit()
|
|||
void paysagesQuit()
|
||||
{
|
||||
}
|
||||
|
||||
FileOperationResult paysagesSave(char* filepath)
|
||||
{
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (!stream.bindToFile(filepath, true))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
app_header = (double)APP_HEADER;
|
||||
stream.write(&app_header);
|
||||
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
||||
stream.write(&version_header);
|
||||
|
||||
RenderingScenery::getCurrent()->save(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
||||
FileOperationResult paysagesLoad(char* filepath)
|
||||
{
|
||||
PackStream stream;
|
||||
double app_header, version_header;
|
||||
|
||||
if (!stream.bindToFile(filepath, false))
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
stream.read(&app_header);
|
||||
if (app_header != APP_HEADER)
|
||||
{
|
||||
return FILE_OPERATION_APP_MISMATCH;
|
||||
}
|
||||
|
||||
stream.read(&version_header);
|
||||
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
|
||||
{
|
||||
return FILE_OPERATION_VERSION_MISMATCH;
|
||||
}
|
||||
|
||||
RenderingScenery::getCurrent()->load(&stream);
|
||||
|
||||
return FILE_OPERATION_OK;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
#ifndef _PAYSAGES_MAIN_H_
|
||||
#define _PAYSAGES_MAIN_H_
|
||||
|
||||
#define PAYSAGES_CURRENT_DATA_VERSION 1
|
||||
|
||||
#include "rendering_global.h"
|
||||
|
||||
typedef enum {
|
||||
FILE_OPERATION_OK,
|
||||
FILE_OPERATION_IOERROR,
|
||||
FILE_OPERATION_APP_MISMATCH,
|
||||
FILE_OPERATION_VERSION_MISMATCH
|
||||
} FileOperationResult;
|
||||
|
||||
RENDERINGSHARED_EXPORT void paysagesInit();
|
||||
RENDERINGSHARED_EXPORT void paysagesQuit();
|
||||
RENDERINGSHARED_EXPORT FileOperationResult paysagesSave(char* filepath);
|
||||
RENDERINGSHARED_EXPORT FileOperationResult paysagesLoad(char* filepath);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,11 +22,11 @@ PackStream::~PackStream()
|
|||
}
|
||||
}
|
||||
|
||||
bool PackStream::bindToFile(const char* filepath, bool write)
|
||||
bool PackStream::bindToFile(const std::string &filepath, bool write)
|
||||
{
|
||||
if (not file and not stream)
|
||||
{
|
||||
file = new QFile(filepath);
|
||||
file = new QFile(QString::fromStdString(filepath));
|
||||
if (not file->open(write ? QIODevice::WriteOnly : QIODevice::ReadOnly))
|
||||
{
|
||||
return false;
|
||||
|
@ -37,7 +37,7 @@ bool PackStream::bindToFile(const char* filepath, bool write)
|
|||
return stream != NULL;
|
||||
}
|
||||
|
||||
void PackStream::write(const int*value)
|
||||
void PackStream::write(const int *value)
|
||||
{
|
||||
if (stream and value)
|
||||
{
|
||||
|
@ -62,11 +62,11 @@ void PackStream::write(const char *value, int max_length)
|
|||
}
|
||||
}
|
||||
|
||||
void PackStream::write(const QString &value)
|
||||
void PackStream::write(const std::string &value)
|
||||
{
|
||||
if (stream)
|
||||
{
|
||||
*stream << value;
|
||||
*stream << QString::fromStdString(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,16 +101,16 @@ void PackStream::read(char* value, int max_length)
|
|||
}
|
||||
}
|
||||
|
||||
QString PackStream::readString()
|
||||
std::string PackStream::readString()
|
||||
{
|
||||
if (stream and not stream->atEnd())
|
||||
{
|
||||
QString output;
|
||||
*stream >> output;
|
||||
return output;
|
||||
return output.toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define PACKSTREAM_H
|
||||
|
||||
#include "system_global.h"
|
||||
#include <QString>
|
||||
|
||||
class QFile;
|
||||
class QDataStream;
|
||||
|
||||
|
@ -20,17 +20,17 @@ public:
|
|||
PackStream();
|
||||
~PackStream();
|
||||
|
||||
bool bindToFile(const char* filepath, bool write=false);
|
||||
bool bindToFile(const std::string &filepath, bool write=false);
|
||||
|
||||
void write(const int *value);
|
||||
void write(const double *value);
|
||||
void write(const char *value, const int max_length);
|
||||
void write(const QString &value);
|
||||
void write(const std::string &value);
|
||||
|
||||
void read(int* value);
|
||||
void read(double* value);
|
||||
void read(char* value, int max_length);
|
||||
QString readString();
|
||||
std::string readString();
|
||||
|
||||
private:
|
||||
QFile* file;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "AtmosphereDefinition.h"
|
||||
#include "AtmosphereRenderer.h"
|
||||
#include "AtmosphereResult.h"
|
||||
#include "RenderingScenery.h"
|
||||
#include "Scenery.h"
|
||||
#include "System.h"
|
||||
|
||||
#define OUTPUT_WIDTH 400
|
||||
|
@ -18,7 +18,8 @@ static Color _postProcessFragment(SoftwareRenderer* renderer, Vector3 location,
|
|||
|
||||
TEST(Bruneton, AerialPerspective1)
|
||||
{
|
||||
SoftwareRenderer renderer;
|
||||
Scenery scenery;
|
||||
SoftwareRenderer renderer(&scenery);
|
||||
renderer.render_width = 800;
|
||||
renderer.render_height = 600;
|
||||
renderer.render_quality = 1;
|
||||
|
@ -44,12 +45,14 @@ TEST(Bruneton, AerialPerspective1)
|
|||
|
||||
TEST(Bruneton, AerialPerspective2)
|
||||
{
|
||||
AtmosphereDefinition* atmo = RenderingScenery::getCurrent()->getAtmosphere();
|
||||
Scenery scenery;
|
||||
|
||||
AtmosphereDefinition* atmo = scenery.getAtmosphere();
|
||||
atmo->hour = 6;
|
||||
atmo->minute = 30;
|
||||
atmo->validate();
|
||||
|
||||
SoftwareRenderer renderer;
|
||||
SoftwareRenderer renderer(&scenery);
|
||||
renderer.render_width = 800;
|
||||
renderer.render_height = 600;
|
||||
renderer.render_quality = 1;
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST(Layers, NullLayer)
|
|||
EXPECT_EQ(NULL, layer->getParent());
|
||||
EXPECT_EQ(layer, layer->getRoot());
|
||||
|
||||
EXPECT_EQ(QString(), layer->getName());
|
||||
EXPECT_EQ("", layer->getName());
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, layers1.count());
|
||||
|
@ -50,9 +50,9 @@ TEST(Layers, copy)
|
|||
EXPECT_EQ(0, layers2.count());
|
||||
layers1.copy(&layers2);
|
||||
EXPECT_EQ(1, layers2.count());
|
||||
EXPECT_EQ(QString("test"), layers1.getLayer(0)->getName());
|
||||
EXPECT_EQ("test", layers1.getLayer(0)->getName());
|
||||
EXPECT_EQ(&layers1, layers1.getLayer(0)->getParent());
|
||||
EXPECT_EQ(QString("test"), layers2.getLayer(0)->getName());
|
||||
EXPECT_EQ("test", layers2.getLayer(0)->getName());
|
||||
EXPECT_EQ(&layers2, layers2.getLayer(0)->getParent());
|
||||
EXPECT_NE(layers1.getLayer(0), layers2.getLayer(0));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue