osci-render/Source/parser/FileParser.cpp

48 wiersze
1.2 KiB
C++
Czysty Zwykły widok Historia

#include "FileParser.h"
#include "../shape/Line.h"
2023-02-05 17:39:02 +00:00
#include "../shape/Arc.h"
#include <numbers>
FileParser::FileParser() {}
void FileParser::parse(juce::String extension, std::unique_ptr<juce::InputStream> stream) {
object = nullptr;
camera = nullptr;
svg = nullptr;
if (extension == ".obj") {
2023-02-05 19:36:50 +00:00
object = std::make_shared<WorldObject>(stream->readEntireStreamAsString().toStdString());
camera = std::make_shared<Camera>(1.0, 0, 0, 0.0);
2023-01-19 20:46:41 +00:00
camera->findZPos(*object);
} else if (extension == ".svg") {
2023-02-05 19:36:50 +00:00
svg = std::make_shared<SvgParser>(stream->readEntireStreamAsString());
}
}
std::vector<std::unique_ptr<Shape>> FileParser::next() {
2023-02-05 19:36:50 +00:00
auto tempObject = object;
auto tempCamera = camera;
auto tempSvg = svg;
if (tempObject != nullptr && tempCamera != nullptr) {
return tempCamera->draw(*tempObject);
} else if (tempSvg != nullptr) {
return tempSvg->draw();
}
auto tempShapes = std::vector<std::unique_ptr<Shape>>();
2023-02-05 17:39:02 +00:00
tempShapes.push_back(std::make_unique<Arc>(0, 0, 0.5, 0.5, std::numbers::pi / 4.0, 2 * std::numbers::pi));
return tempShapes;
}
bool FileParser::isActive() {
return active;
}
void FileParser::disable() {
active = false;
}
void FileParser::enable() {
active = true;
}