Commit 58de62aa authored by Maciej Suminski's avatar Maciej Suminski

High contrast mode with showing the selected layer on the top.

parent 1367d33c
...@@ -819,6 +819,13 @@ void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) ...@@ -819,6 +819,13 @@ void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
} }
void CAIRO_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth )
{
// Cairo does not have any possibilities to change the depth coordinate of stored items,
// it depends only on the order of drawing
}
void CAIRO_GAL::Flush() void CAIRO_GAL::Flush()
{ {
storePath(); storePath();
......
...@@ -1635,6 +1635,13 @@ void OPENGL_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) ...@@ -1635,6 +1635,13 @@ void OPENGL_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
} }
void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth )
{
vboItems[aGroupNumber]->ChangeDepth( aDepth );
vboNeedsUpdate = true;
}
void OPENGL_GAL::computeUnitCircle() void OPENGL_GAL::computeUnitCircle()
{ {
displayListCircle = glGenLists( 1 ); displayListCircle = glGenLists( 1 );
......
...@@ -94,6 +94,20 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor ) ...@@ -94,6 +94,20 @@ void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
} }
void VBO_ITEM::ChangeDepth( int aDepth )
{
VBO_VERTEX* vertexPtr = GetVertices();
for( unsigned int i = 0; i < m_size; ++i )
{
vertexPtr->z = aDepth;
// Move on to the next vertex
vertexPtr++;
}
}
void VBO_ITEM::Finish() void VBO_ITEM::Finish()
{ {
// The unknown-sized item has just ended, so we need to inform the container about it // The unknown-sized item has just ended, so we need to inform the container about it
......
...@@ -40,8 +40,9 @@ ...@@ -40,8 +40,9 @@
using namespace KiGfx; using namespace KiGfx;
// Static constants // Static constants
const unsigned int VIEW::VIEW_MAX_LAYERS = 64; const int VIEW::VIEW_MAX_LAYERS = 64;
const int VIEW::TOP_LAYER = -1; // Top layer depth
const int VIEW::TOP_LAYER = -1;
void VIEW::AddLayer( int aLayer, bool aDisplayOnly ) void VIEW::AddLayer( int aLayer, bool aDisplayOnly )
{ {
...@@ -303,6 +304,7 @@ void VIEW::sortLayers() ...@@ -303,6 +304,7 @@ void VIEW::sortLayers()
void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder ) void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
{ {
m_layers[aLayer].renderingOrder = aRenderingOrder; m_layers[aLayer].renderingOrder = aRenderingOrder;
sortLayers(); sortLayers();
} }
...@@ -319,6 +321,7 @@ struct VIEW::updateItemsColor ...@@ -319,6 +321,7 @@ struct VIEW::updateItemsColor
// Obtain the color that should be used for coloring the item // Obtain the color that should be used for coloring the item
const COLOR4D color = painter->GetColor( aItem, layer ); const COLOR4D color = painter->GetColor( aItem, layer );
int group = aItem->getGroup( layer ); int group = aItem->getGroup( layer );
wxASSERT( group >= 0 );
gal->ChangeGroupColor( group, color ); gal->ChangeGroupColor( group, color );
} }
...@@ -356,11 +359,45 @@ void VIEW::UpdateAllLayersColor() ...@@ -356,11 +359,45 @@ void VIEW::UpdateAllLayersColor()
} }
struct VIEW::changeItemsDepth
{
changeItemsDepth( int aLayer, int aDepth, GAL* aGal ) :
layer( aLayer ), depth( aDepth ), gal( aGal )
{
}
void operator()( VIEW_ITEM* aItem )
{
int group = aItem->getGroup( layer );
if( group >= 0 )
gal->ChangeGroupDepth( group, depth );
}
int layer, depth;
GAL* gal;
};
void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
{
BOX2I r;
r.SetMaximum();
changeItemsDepth visitor( aLayer, aDepth, m_gal );
m_layers[aLayer].items->Query( r, visitor );
}
void VIEW::SetTopLayer( int aLayer ) void VIEW::SetTopLayer( int aLayer )
{ {
// Restore previous order // Restore previous order
if( m_topLayer.enabled ) if( m_topLayer.enabled )
{
m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder; m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder;
ChangeLayerDepth( m_topLayer.id, m_topLayer.renderingOrder );
}
if( aLayer >= 0 && aLayer < VIEW_MAX_LAYERS ) if( aLayer >= 0 && aLayer < VIEW_MAX_LAYERS )
{ {
...@@ -370,7 +407,10 @@ void VIEW::SetTopLayer( int aLayer ) ...@@ -370,7 +407,10 @@ void VIEW::SetTopLayer( int aLayer )
// Apply new settings only if the option is enabled // Apply new settings only if the option is enabled
if( m_enableTopLayer ) if( m_enableTopLayer )
{
m_layers[aLayer].renderingOrder = TOP_LAYER; m_layers[aLayer].renderingOrder = TOP_LAYER;
ChangeLayerDepth( aLayer, TOP_LAYER );
}
// Set the flag saying that settings stored in m_topLayer are valid // Set the flag saying that settings stored in m_topLayer are valid
m_topLayer.enabled = true; m_topLayer.enabled = true;
...@@ -396,12 +436,15 @@ void VIEW::EnableTopLayer( bool aEnable ) ...@@ -396,12 +436,15 @@ void VIEW::EnableTopLayer( bool aEnable )
if( aEnable ) if( aEnable )
{ {
m_layers[m_topLayer.id].renderingOrder = TOP_LAYER; m_layers[m_topLayer.id].renderingOrder = TOP_LAYER;
ChangeLayerDepth( m_topLayer.id, TOP_LAYER );
} }
else else
{ {
m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder; m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder;
ChangeLayerDepth( m_topLayer.id, m_topLayer.renderingOrder );
} }
} }
sortLayers();
m_enableTopLayer = aEnable; m_enableTopLayer = aEnable;
} }
...@@ -416,7 +459,7 @@ struct VIEW::drawItem ...@@ -416,7 +459,7 @@ struct VIEW::drawItem
void operator()( VIEW_ITEM* aItem ) void operator()( VIEW_ITEM* aItem )
{ {
GAL* gal = view->GetGAL(); GAL* gal = view->GetGAL();
if( view->m_useGroups ) if( view->m_useGroups )
{ {
......
...@@ -212,6 +212,9 @@ public: ...@@ -212,6 +212,9 @@ public:
/// @copydoc GAL::ChangeGroupColor() /// @copydoc GAL::ChangeGroupColor()
virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ); virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor );
/// @copydoc GAL::ChangeGroupDepth()
virtual void ChangeGroupDepth( int aGroupNumber, int aDepth );
/// @copydoc GAL::DeleteGroup() /// @copydoc GAL::DeleteGroup()
virtual void DeleteGroup( int aGroupNumber ); virtual void DeleteGroup( int aGroupNumber );
......
...@@ -371,6 +371,14 @@ public: ...@@ -371,6 +371,14 @@ public:
*/ */
virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) = 0; virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) = 0;
/**
* @brief Changes the depth (Z-axis position) of the group.
*
* @param aGroupNumber is the group number.
* @param aDepth is the new depth.
*/
virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) = 0;
/** /**
* @brief Delete the group from the memory. * @brief Delete the group from the memory.
* *
......
...@@ -237,6 +237,9 @@ public: ...@@ -237,6 +237,9 @@ public:
/// @copydoc GAL::ChangeGroupColor() /// @copydoc GAL::ChangeGroupColor()
virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ); virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor );
/// @copydoc GAL::ChangeGroupDepth()
virtual void ChangeGroupDepth( int aGroupNumber, int aDepth );
/// @copydoc GAL::DeleteGroup() /// @copydoc GAL::DeleteGroup()
virtual void DeleteGroup( int aGroupNumber ); virtual void DeleteGroup( int aGroupNumber );
......
...@@ -116,6 +116,13 @@ public: ...@@ -116,6 +116,13 @@ public:
*/ */
void ChangeColor( const COLOR4D& aColor ); void ChangeColor( const COLOR4D& aColor );
/**
* Function ChangeDepth()
* Moves all vertices to the specified depth.
* @param aDepth is the new depth for vertices.
*/
void ChangeDepth( int aDepth );
///< Informs the container that there will be no more vertices for the current VBO_ITEM ///< Informs the container that there will be no more vertices for the current VBO_ITEM
void Finish(); void Finish();
......
...@@ -215,7 +215,6 @@ public: ...@@ -215,7 +215,6 @@ public:
*/ */
double ToScreen( double aCoord, bool aAbsolute = true ) const; double ToScreen( double aCoord, bool aAbsolute = true ) const;
/** /**
* Function GetScreenPixelSize() * Function GetScreenPixelSize()
* Returns the size of the our rendering area, in pixels. * Returns the size of the our rendering area, in pixels.
...@@ -232,7 +231,6 @@ public: ...@@ -232,7 +231,6 @@ public:
*/ */
void AddLayer( int aLayer, bool aDisplayOnly = false ); void AddLayer( int aLayer, bool aDisplayOnly = false );
/** /**
* Function ClearLayer() * Function ClearLayer()
* Removes all items from a given layer. * Removes all items from a given layer.
...@@ -279,6 +277,14 @@ public: ...@@ -279,6 +277,14 @@ public:
*/ */
void UpdateAllLayersColor(); void UpdateAllLayersColor();
/**
* Function ChangeLayerDepth()
* Changes the depth of items on the given layer.
* @param aLayer is a number of the layer to be updated.
* @param aDepth is the new depth.
*/
void ChangeLayerDepth( int aLayer, int aDepth );
/** /**
* Function SetTopLayer() * Function SetTopLayer()
* Sets given layer to be displayed on the top or sets back the default order of layers. * Sets given layer to be displayed on the top or sets back the default order of layers.
...@@ -324,8 +330,8 @@ public: ...@@ -324,8 +330,8 @@ public:
*/ */
bool IsDynamic() const { return m_dynamic; } bool IsDynamic() const { return m_dynamic; }
static const unsigned int VIEW_MAX_LAYERS; ///* maximum number of layers that may be shown static const int VIEW_MAX_LAYERS; ///* maximum number of layers that may be shown
static const int TOP_LAYER; ///* layer number for displaying items on the top static const int TOP_LAYER; ///* layer number for displaying items on the top
private: private:
struct VIEW_LAYER struct VIEW_LAYER
...@@ -353,6 +359,7 @@ private: ...@@ -353,6 +359,7 @@ private:
struct recacheItem; struct recacheItem;
struct drawItem; struct drawItem;
struct updateItemsColor; struct updateItemsColor;
struct changeItemsDepth;
///* Saves current top layer settings in order to restore it when it's not top anymore ///* Saves current top layer settings in order to restore it when it's not top anymore
VIEW_LAYER m_topLayer; VIEW_LAYER m_topLayer;
......
...@@ -361,6 +361,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer ) ...@@ -361,6 +361,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
// Set display settings for high contrast mode // Set display settings for high contrast mode
KiGfx::VIEW* view = myframe->GetGalCanvas()->GetView(); KiGfx::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->SetActiveLayer( aLayer ); view->GetPainter()->GetSettings()->SetActiveLayer( aLayer );
view->UpdateAllLayersColor();
view->SetTopLayer( aLayer ); view->SetTopLayer( aLayer );
#endif /* KICAD_GAL */ #endif /* KICAD_GAL */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment