KiCad PCB EDA Suite
pns_tune_status_popup.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2015 CERN
5  * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 2 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "eda_draw_frame.h"
23 #include "pns_tune_status_popup.h"
24 #include "pns_router.h"
25 #include "pns_meander_placer.h"
26 
28 {
29  PNS::MEANDER_PLACER_BASE* placer = dynamic_cast<PNS::MEANDER_PLACER_BASE*>( aRouter->Placer() );
30 
31  if( !placer )
32  return;
33 
34  EDA_DRAW_FRAME* frame = static_cast<EDA_DRAW_FRAME*>( GetParent() );
35 
36  SetText( placer->TuningInfo( frame->GetUserUnits() ) );
37 
38  // Determine the background color first and choose a contrasting value
39  COLOR4D bg( m_panel->GetBackgroundColour() );
40  double h, s, l;
41  bg.ToHSL( h, s, l );
42 
43  switch( placer->TuningStatus() )
44  {
46  if( l < 0.5 )
47  SetTextColor( wxColor( 0, 255, 0 ) );
48  else
49  SetTextColor( wxColor( 0, 128, 0 ) );
50 
51  break;
53  if( l < 0.5 )
54  SetTextColor( wxColor( 255, 128, 128 ) );
55  else
56  SetTextColor( wxColor( 128, 64, 64 ) );
57 
58  break;
60  if( l < 0.5 )
61  SetTextColor( wxColor( 24, 24, 255 ) );
62  else
63  SetTextColor( wxColor( 19, 19, 195 ) );
64 
65  break;
66  }
67 }
68 
Class MEANDER_PLACER_BASE.
void SetTextColor(const wxColour &aColor)
Change text color.
PLACEMENT_ALGO * Placer()
Definition: pns_router.h:218
The base class for create windows for drawing purpose.
virtual TUNING_STATUS TuningStatus() const =0
Function TuningStatus()
virtual const wxString TuningInfo(EDA_UNITS_T aUnits) const =0
Function TuningInfo()
wxPanel * m_panel
Definition: status_popup.h:68
void UpdateStatus(PNS::ROUTER *aRouter)
void ToHSL(double &aOutHue, double &aOutSaturation, double &aOutValue) const
Function ToHSL() Converts current color (stored in RGB) to HSL format.
Definition: color4d.cpp:152
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
void SetText(const wxString &aText)
Display a text.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39