Skip to content

Commit

Permalink
allow showing start and end genome marks simultaneously
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Oct 14, 2023
1 parent 3dbec2f commit 8034b04
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
11 changes: 7 additions & 4 deletions source/EngineInterface/PreviewDescriptionConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace
{
RealVector2D pos;
int nodeIndex = 0;
CellPreviewDescription::NodePos nodePos = CellPreviewDescription::NodePos::Intermediate;
bool partStart = false;
bool partEnd = false;
bool constructorWithMultiConstruction = false;

int executionOrderNumber = 0;
Expand Down Expand Up @@ -178,10 +179,10 @@ namespace
cellIntern.connectionIndices.insert(index + 1);
}
if (partIndex == 0) {
cellIntern.nodePos = CellPreviewDescription::NodePos::Start;
cellIntern.partStart = true;
}
if (partIndex == toInt(genome.cells.size()) - 1) {
cellIntern.nodePos = CellPreviewDescription::NodePos::End;
cellIntern.partEnd = true;
}

//find nearby cells
Expand Down Expand Up @@ -345,8 +346,10 @@ namespace
.executionOrderNumber = cell.executionOrderNumber,
.color = cell.color,
.nodeIndex = cell.nodeIndex,
.partStart = cell.partStart,
.partEnd = cell.partEnd,
.multipleConstructor = cell.constructorWithMultiConstruction,
.nodePos = cell.nodePos};
};
result.cells.emplace_back(cellPreview);
for (auto const& connectionIndex : cell.connectionIndices) {
auto const& otherCell = previewIntern.cells.at(connectionIndex);
Expand Down
9 changes: 2 additions & 7 deletions source/EngineInterface/PreviewDescriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ struct CellPreviewDescription
int executionOrderNumber = 0;
int color = 0;
int nodeIndex = 0;
bool partStart = false;
bool partEnd = false;
bool multipleConstructor = false;

enum class NodePos
{
Start,
Intermediate,
End
} nodePos = NodePos::Intermediate;
};

struct ConnectionPreviewDescription
Expand Down
20 changes: 14 additions & 6 deletions source/Gui/AlienImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,16 +1033,24 @@ bool AlienImGui::ShowPreviewDescription(PreviewDescription const& desc, float& z
for (auto const& cell : desc.cells) {
auto cellPos = (cell.pos - upperLeft) * cellSize + offset;
auto length = cellSize / 4;
if (cell.nodePos != CellPreviewDescription::NodePos::Intermediate) {
auto color = cell.nodePos == CellPreviewDescription::NodePos::Start
? Const::GenomePreviewStartColor
: Const::GenomePreviewEndColor;

if (cell.partStart != cell.partEnd) {
drawList->AddTriangleFilled(
{cellPos.x + length, cellPos.y},
{cellPos.x + length * 2, cellPos.y - length / 2},
{cellPos.x + length * 2, cellPos.y + length / 2},
color);
cell.partStart ? Const::GenomePreviewStartColor : Const::GenomePreviewEndColor);
}
if (cell.partStart && cell.partEnd) {
drawList->AddTriangleFilled(
{cellPos.x + length, cellPos.y - length},
{cellPos.x + length * 2, cellPos.y - length * 3 / 2},
{cellPos.x + length * 2, cellPos.y - length / 2},
Const::GenomePreviewStartColor);
drawList->AddTriangleFilled(
{cellPos.x + length, cellPos.y + length},
{cellPos.x + length * 2, cellPos.y + length / 2},
{cellPos.x + length * 2, cellPos.y + length * 3 / 2},
Const::GenomePreviewEndColor);
}
if (cell.multipleConstructor) {
drawList->AddLine(
Expand Down

0 comments on commit 8034b04

Please sign in to comment.