Add machine workshop, typed logic, mechanics and sensor-driven ECUs
This commit is contained in:
45
include/FluidSim/Desktop/LogicEditor.hpp
Normal file
45
include/FluidSim/Desktop/LogicEditor.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include "FluidSim/Machine.hpp"
|
||||
#include "FluidSim/Desktop/WorkshopLayout.hpp"
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace fluidsim::port::desktop {
|
||||
struct LogicEditorHooks {
|
||||
MachineDocument& document;
|
||||
const MachineSnapshot* live{};
|
||||
bool shift{};
|
||||
std::function<bool(const std::function<void()>&)> edit;
|
||||
std::function<void(std::uint32_t,bool)> boolean_control;
|
||||
std::function<void(std::uint32_t,double)> number_control;
|
||||
std::function<void()> release_buttons;
|
||||
std::function<void(std::uint32_t)> select_physical,focus_physical;
|
||||
std::function<void(const std::string&)> status;
|
||||
std::function<void()> example;
|
||||
};
|
||||
class LogicEditor {
|
||||
public:
|
||||
LogicEditor();
|
||||
~LogicEditor();
|
||||
void reset_document();
|
||||
void deactivate(const LogicEditorHooks&);
|
||||
bool editing_text()const;
|
||||
bool active_gesture()const;
|
||||
std::uint32_t selected_node()const;
|
||||
void select_node(std::uint32_t,const MachineDocument&);
|
||||
void select_part_reference(std::uint32_t,const MachineDocument&);
|
||||
void fit(const LogicGraph&,sf::FloatRect,bool selection_only=false);
|
||||
void reveal(std::uint32_t,const MachineDocument&,sf::FloatRect);
|
||||
sf::Vector2f project(LogicPosition,sf::FloatRect)const;
|
||||
LogicPosition unproject(sf::Vector2f,sf::FloatRect)const;
|
||||
sf::FloatRect node_rect(const LogicNode&,sf::FloatRect)const;
|
||||
sf::Vector2f pin_position(const LogicNode&,const std::string&,sf::FloatRect)const;
|
||||
// Panels can be owned independently in split view; the canvas is always live.
|
||||
bool event(const sf::Event&,const LogicEditorHooks&,const WorkshopLayout&,sf::FloatRect canvas,bool panels);
|
||||
void draw(sf::RenderWindow&,const sf::Font*,const LogicEditorHooks&,const WorkshopLayout&,sf::FloatRect canvas,bool panels);
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user