58 lines
2.5 KiB
C++
58 lines
2.5 KiB
C++
#pragma once
|
|
#include "FluidSim/Machine.hpp"
|
|
#include "FluidSim/Desktop/OrbitCamera.hpp"
|
|
#include <SFML/Graphics.hpp>
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
namespace fluidsim::port::desktop {
|
|
struct BuilderRay {Vec3 origin,direction;};
|
|
BuilderRay builder_ray(const OrbitCamera&,sf::FloatRect,sf::Vector2f);
|
|
std::optional<sf::Vector2f> builder_project(const OrbitCamera&,sf::FloatRect,Vec3);
|
|
// Returns metres along the ray; OBBs and duct centerlines use the rendered dimensions.
|
|
std::optional<float> builder_pick_part(const MachinePart&,BuilderRay,float tolerance=0);
|
|
Vec3 builder_rotate_world(Vec3 euler,unsigned axis,float degrees);
|
|
struct BuilderPipeLocation {std::size_t segment{};Vec3 local_point;float screen_distance{};};
|
|
std::optional<BuilderPipeLocation> builder_pipe_location(const OrbitCamera&,sf::FloatRect,const MachinePart&,sf::Vector2f);
|
|
struct MachinePlaybackStats {double simulation_seconds{};std::uint64_t underruns{};std::size_t buffered{};double speed{1};bool paused{};};
|
|
enum class WorkshopView {ThreeD,Logic,Split};
|
|
class MachineBuilder {
|
|
public:
|
|
MachineBuilder();
|
|
~MachineBuilder();
|
|
const MachineDocument& document()const;
|
|
std::vector<std::uint32_t> selected_parts()const;
|
|
void set_document(MachineDocument,std::filesystem::path source={});
|
|
bool load_file(const std::filesystem::path&);
|
|
void start_test();
|
|
void stop_test();
|
|
bool testing()const;
|
|
MachinePlaybackStats playback_stats()const;
|
|
void set_test_speed(double);
|
|
void pause_test();
|
|
void step_test();
|
|
std::vector<MachineMeasurement> measurements()const;
|
|
bool export_measurements(const std::filesystem::path&);
|
|
bool finished()const;
|
|
bool wants_close_window()const;
|
|
bool handle_event(const sf::Event&,sf::Vector2u);
|
|
void update();
|
|
void draw(sf::RenderWindow&,const sf::Font*);
|
|
static sf::FloatRect viewport(sf::Vector2u);
|
|
sf::FloatRect workspace_viewport(sf::Vector2u)const;
|
|
sf::FloatRect logic_viewport(sf::Vector2u)const;
|
|
WorkshopView workspace_view()const;
|
|
void set_workspace_view(WorkshopView);
|
|
std::uint32_t selected_logic_node()const;
|
|
std::vector<LogicNodeState> logic_values()const;
|
|
sf::FloatRect logic_node_rectangle(std::uint32_t,sf::Vector2u)const;
|
|
sf::Vector2f logic_pin_position(std::uint32_t,const std::string&,sf::Vector2u)const;
|
|
void restore_workspace_preferences();
|
|
const OrbitCamera& camera()const;
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
void run_machine_builder(sf::RenderWindow&,const sf::Font*,const std::filesystem::path& file={},bool play=false);
|
|
}
|