kicad-developers team mailing list archive
Mailing list archive
Re: Elements visibility
2009/10/1 Isaac <isaacbavaresco@...>:
> I think that the method of signaling the visibility of layers and classesof elements by the use of a bit in their colors a bit clumsy and makes harder to implement some ideas.
> At first I thought that it would be too hard to change, but last night I dived into the KiCAD source code to understand it better, and found that itmay not be that hard. Only 26 or so source files are involved in the procss.
> 1) The macro ITEM_NOT_SHOW is present in only 26 different files (less innewer revisions);
> 2) The member g_DesignSettings.m_LayerColor is present in only 25 source files;
> Then I tentatively started to change things.
> I created a member "int m_VisibleLayers" (intended to be a bit-mask) to the class EDA_BoardDesignSettings and some accessor methods ( bool IsLayerVisible(int layer), void SetLayerVisibility(int layer, bool state) ) and replaced all the occurrences of expressions like "color & ITEM_NOT_SHOW" in thesources.
> It worked well, there are just five files left to change to finish the job.
> Some questions:
> a) Would the accessor methods overhead make any difference in performance? If so, I could declare them inline or replace them by macros, it would look almost the same;
> b) Would this break other's ongoing work? (If you think so, please let meknow).
> c) Do these changes violate any rules?
I found the whole colour system clumsy (although of course, it has
good reasons for it's roots). I changed colors from being an array of
structs to an array of a new class. This held a wxColour internally
and I also created setters and getters for visibility.
I felt it was the right way to go, and will improve the code
readability a lot. There were plenty of bits of code that would
greatly benefit from the colours being in a class.
I think as much bit-masking as possible should go.
There are a couple of messages between me and Jean-Pierre on the
subject about a month or so ago. Search for Layer Properties Dialog.