Skip to content

Commit

Permalink
#4921 added Bad Port markers (#4988)
Browse files Browse the repository at this point in the history
  • Loading branch information
cybercop23 authored Dec 7, 2024
1 parent 2dd1432 commit a17ca70
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions xLights/ControllerModelDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class BaseCMObject
{
return (mouse.y < _location.y);
}
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped) = 0;
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped, std::string badPorts) = 0;
virtual void DrawIcon(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale)
{
}
Expand Down Expand Up @@ -403,6 +403,10 @@ class PortCMObject : public BaseCMObject
return nullptr;
}

int GetPortNumber() const {
return _port;
};

int GetBasePort() const
{
return ((_port - 1) / 4) * 4 + 1;
Expand Down Expand Up @@ -509,7 +513,7 @@ class PortCMObject : public BaseCMObject
{
return "PORT";
}
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped) override
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped, std::string badPorts) override
{
auto origBrush = dc.GetBrush();
auto origPen = dc.GetPen();
Expand All @@ -532,6 +536,14 @@ class PortCMObject : public BaseCMObject
{
max = _caps->GetMaxPixelsAt40FPS_SR();
}
if (!badPorts.empty() && ContainsBetweenCommas("," + badPorts + ",", std::to_string(GetPortNumber()))) {
wxRect rect = wxRect(_location * scale + offset, _size * scale);
wxBrush shadeBrush(wxColour(255, 0, 128));
wxBrush oldBrush = dc.GetBrush();
dc.SetBrush(shadeBrush);
dc.DrawRectangle(rect);
dc.SetBrush(oldBrush);
}
if (p->Channels() > max * 3) {
// draw indicator that this port is not able to achieve 40 FPS
dc.SetPen(*wxTRANSPARENT_PEN);
Expand Down Expand Up @@ -1028,7 +1040,7 @@ class SRCMObject : public BaseCMObject
{
return "SR";
}
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped) override
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped, std::string badPorts) override
{
auto origBrush = dc.GetBrush();
auto origPen = dc.GetPen();
Expand Down Expand Up @@ -1347,7 +1359,7 @@ class ModelCMObject : public BaseCMObject
{
return "MODEL";
}
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped) override
virtual void Draw(wxDC& dc, int portMargin, wxPoint mouse, wxPoint adjustedMouse, wxSize offset, float scale, bool printing, bool border, Model* lastDropped, std::string badPorts) override
{
auto origBrush = dc.GetBrush();
auto origPen = dc.GetPen();
Expand Down Expand Up @@ -2612,7 +2624,7 @@ wxBitmap ControllerModelDialog::RenderPicture(int startY, int startX, int width,
if (it->GetType() != "MODEL") {
if (it->GetRect().GetY() > startY && it->GetRect().GetY() < endY &&
it->GetRect().GetX() > startX && it->GetRect().GetX() < endX) {
it->Draw(dc, 0, wxPoint(0, 0), wxPoint(0, 0), wxSize(-startX, rowPos - startY), 1, true, true, nullptr);
it->Draw(dc, 0, wxPoint(0, 0), wxPoint(0, 0), wxSize(-startX, rowPos - startY), 1, true, true, nullptr, "");
}
}
}
Expand All @@ -2621,7 +2633,7 @@ wxBitmap ControllerModelDialog::RenderPicture(int startY, int startX, int width,
if (it->GetType() == "MODEL") {
if (it->GetRect().GetY() > startY && it->GetRect().GetY() < endY &&
it->GetRect().GetX() > startX && it->GetRect().GetX() < endX) {
it->Draw(dc, 0, wxPoint(0, 0), wxPoint(0, 0), wxSize(-startX, rowPos - startY), 1, true, true, nullptr);
it->Draw(dc, 0, wxPoint(0, 0), wxPoint(0, 0), wxSize(-startX, rowPos - startY), 1, true, true, nullptr, "");
}
}
}
Expand Down Expand Up @@ -3518,7 +3530,7 @@ void ControllerModelDialog::OnPanelControllerLeftDown(wxMouseEvent& event)
wxBitmap bmp(32, 32);
wxMemoryDC dc;
dc.SelectObject(bmp);
it->Draw(dc, portMargin, wxPoint(-4, -4), wxPoint(-4, -4), wxSize(-1 * it->GetRect().GetLeft(), -1 * it->GetRect().GetTop()), 1, false, false, _lastDropped);
it->Draw(dc, portMargin, wxPoint(-4, -4), wxPoint(-4, -4), wxSize(-1 * it->GetRect().GetLeft(), -1 * it->GetRect().GetTop()), 1, false, false, _lastDropped, "");

#ifdef __linux__
wxIcon dragCursor;
Expand Down Expand Up @@ -4236,14 +4248,14 @@ void ControllerModelDialog::OnPanelControllerPaint(wxPaintEvent& event)
// draw the SR first
for (const auto& it : _controllers) {
if (it->GetType() == "SR") {
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped);
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped, "");
}
}

// now draw the models
for (const auto& it : _controllers) {
if (it->GetType() == "MODEL") {
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped);
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped, "");
}
}

Expand All @@ -4252,9 +4264,14 @@ void ControllerModelDialog::OnPanelControllerPaint(wxPaintEvent& event)
dc.SetPen(__backgroundPen);
dc.SetBrush(__backgroundBrush);
dc.DrawRectangle(0, 0, _controllers.front()->GetRect().GetRight() + 2, _controllers.back()->GetRect().GetBottom() + 10);

auto ctrlDesc = this->_title;
ctrlDesc.erase(std::remove(ctrlDesc.begin(), ctrlDesc.end(), ' '), ctrlDesc.end());
std::string badPorts = ctrlDesc.substr(ctrlDesc.find("BadPorts:") + 9);

for (const auto& it : _controllers) {
if (it->GetType() == "PORT") {
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped);
it->Draw(dc, portMargin, mouse, adjustedMouse, wxSize(0, 0), 1, false, true, _lastDropped, badPorts);
}
}

Expand Down Expand Up @@ -4387,7 +4404,7 @@ void ControllerModelDialog::OnPanelModelsPaint(wxPaintEvent& event)
dc.SetFont(font);

for (const auto& it : _models) {
it->Draw(dc, 0, mouse, mouse, wxSize(0, 0), 1, false, true, nullptr);
it->Draw(dc, 0, mouse, mouse, wxSize(0, 0), 1, false, true, nullptr, "");
}
}

Expand Down Expand Up @@ -4419,7 +4436,7 @@ void ControllerModelDialog::OnPanelModelsLeftDown(wxMouseEvent& event)
wxBitmap bmp(32, 32);
wxMemoryDC dc;
dc.SelectObject(bmp);
it->Draw(dc, 0, wxPoint(-4, -4), wxPoint(-4, -4), wxSize(-1 * it->GetRect().GetLeft(), -1 * it->GetRect().GetTop()), 1, false, false, nullptr);
it->Draw(dc, 0, wxPoint(-4, -4), wxPoint(-4, -4), wxSize(-1 * it->GetRect().GetLeft(), -1 * it->GetRect().GetTop()), 1, false, false, nullptr, "");

#ifdef __linux__
wxIcon dragCursor;
Expand Down

0 comments on commit a17ca70

Please sign in to comment.