17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-03 14:20:21 +01:00

Catenary editor: keep catenary parts out of node editing, pick and drag anchor poles

This commit is contained in:
2026-10-26 19:51:15 +01:00
parent 5f93c7c20d
commit d794b1e736
10 changed files with 142 additions and 7 deletions

View File

@@ -2099,6 +2099,27 @@ catenary_scene_file_included( std::string const &File ) {
if( auto *file { file_named( File ) }; file != nullptr ) { file->created = false; }
}
int
catenary_scene_part_owner( void const *Part, std::size_t &Index ) {
if( Part == nullptr ) { return 0; }
auto const has = [ Part ]( std::vector<TAnimModel *> const &Parts ) {
return std::any_of( Parts.begin(), Parts.end(), [ Part ]( TAnimModel const *Model ) { return static_cast<void const *>( Model ) == Part; } );
};
for( std::size_t index = 0; index < Suspensions.size(); ++index ) {
if( false == Suspensions[ index ].removed && has( Suspensions[ index ].parts ) ) { Index = index; return 1; }
}
for( std::size_t index = 0; index < Gantries.size(); ++index ) {
if( false == Gantries[ index ].removed && has( Gantries[ index ].parts ) ) { Index = index; return 2; }
}
for( std::size_t index = 0; index < Anchors.size(); ++index ) {
if( false == Anchors[ index ].removed && has( Anchors[ index ].parts ) ) { Index = index; return 3; }
}
for( std::size_t index = 0; index < Chains.size(); ++index ) {
if( false == Chains[ index ].removed && has( Chains[ index ].middle_parts ) ) { Index = index; return 4; }
}
return 0;
}
std::size_t
catenary_scene_file_layer( std::string const &File ) {
auto const found { FileLayers.find( File ) };

View File

@@ -43,6 +43,9 @@ catenary::cantilever_catalog const *catenary_scene_catalog();
catenary::layout_tables const &catenary_scene_layout();
// opisany katalog konstrukcji dla edytora (traction_catalog.txt): kategorie, grupy, rodziny kart, grupy słupów; pusty gdy brak pliku
catenary::structure_catalog const &catenary_scene_structures();
// do czego należy model wstawiony przez sieć (część wysięgnika, słupa, bramki, kotwienia): 1 podwieszenie, 2 bramka, 3 kotwienie,
// 4 łańcuch (kotwienie środkowe); Index - jego numer. 0 gdy to nie część sieci
int catenary_scene_part_owner( void const *Part, std::size_t &Index );
// liczba miejsc na liście podwieszeń (z usuniętymi)
std::size_t catenary_scene_size();
// podwieszenie o podanym numerze; nullptr gdy usunięte albo numer spoza listy

View File

@@ -30,6 +30,8 @@ catenary_part_detach( TAnimModel *Model ) {
if( Model == nullptr ) { return; }
scene::Layers.count( Model->layer(), scene::layer_item::model, -1 );
Model->layer( null_handle );
// edytor nie rusza jej jak zwykłego modelu (przesunięta albo usunięta osobno odpadłaby od sieci, która ją trzyma)
Model->m_catenary = true;
}
void
@@ -52,6 +54,7 @@ catenary_span_create( std::string const &Name, double const RangeMax, double con
cParser parser( Body );
auto *span { new TTraction( nodedata ) };
span->Load( &parser, glm::dvec3() );
span->m_catenary = true;
if( false == simulation::Traction.insert( span ) ) {
ErrorLog( "Bad scenario: duplicate traction piece name \"" + span->name() + "\" made by a catenary chain" );
}