← Back to team overview

kicad-developers team mailing list archive

Re: Calling PCB_DRAW_PANEL_GAL::SyncLayersVisibility from python?

 

Continuing to review, it appears I am wrong. PCB_EDIT_FRAME:sLV does in fact synchronize the checkboxes, but also calls PCB_DRAW_PANEL_GAL::SLV to do the background synchronization of the layers.
Thank you jp, and I apologize for not researching sufficiently your answer before posting.
So at this point, how do we get PCB_EDIT_FRAME:sLV exposed in python?

| 
| void PCB_EDIT_FRAME::syncLayerVisibilities | ( |  | ) |  |

 | protected |

Function syncLayerVisibilities updates each "Layer" checkbox in the layer widget according to each layer's current visibility determined by IsLayerVisible(), and is helpful immediately after loading a BOARD which may have state information in it.Definition at line 913 of file pcbframe.cpp.Referenced by OpenProjectFiles(). 914 { 915  m_Layers->SyncLayerVisibilities(); 916  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); 917 } 

    On Tuesday, August 22, 2017 12:27 PM, Greg Smith <ecomputerd@xxxxxxxxx> wrote:
 

 Thank you jp!
This appears to not actually be true and reveals (I think) an inconsistency in the KiCad code.
PCB_DRAW_PANEL_GAL::SyncLayersVisibility
is VERY different from
PCB_EDIT_FRAME::syncLayerVisibilities 
PCB_DRAW_PANEL_GAL::SLV modifies the visibility of the layers themselves, taking care of behind the scenes after the visiblity on the layer is changed.
PCB_EDIT_FRAME::sLV seems to only update the checkboxes based on what is retured from IsLayerVisible().
My current problem I think is solved by PCB_DRAW_PANEL_GAL::SLV, while another problem I have worked around is solved by PCB_EDIT_FRAME:sLV.
See workaround for checkboxes here:https://github.com/HiGregSmith/LayerViewSet/blob/master/layerviewset.pyLines 483-504 def GetCheckBoxes()Lines 523-526 Using GetCheckBoxes()
References:
PCB_DRAW_PANEL_GALhttp://docs.kicad-pcb.org/doxygen/classPCB__DRAW__PANEL__GAL.html#a7ecbe9cb97f645749c4217c71244aad9
Function SyncLayersVisibility Updates "visibility" property of each layer of a given BOARD.
which includes:m_view->SetLayerVisible( i, aBoard->IsLayerVisible( PCB_LAYER_ID( i ) ) );
which is defined as:     {  389         wxASSERT( aLayer < (int) m_layers.size() );  390   391         if( m_layers[aLayer].visible != aVisible )  392         {  393             // Target has to be redrawn after changing its visibility  394             MarkTargetDirty( m_layers[aLayer].target );  395             m_layers[aLayer].visible = aVisible;  396         }  397     }


While PCB_EDIT_FRAMEsyncRenderStates () to update checkboxes from "IsElementVisible"syncLayerVisibilities () to update checkboxes from "IsLayerVisible"
Function syncLayerWidgetLayer updates the currently layer "selection" within the PCB_LAYER_WIDGET
 

    On Tuesday, August 22, 2017 10:03 AM, jp charras <jp.charras@xxxxxxxxxx> wrote:
 

 Le 22/08/2017 à 14:42, Greg Smith a écrit :
> 
> How do I call PCB_DRAW_PANEL_GAL::SyncLayersVisibility from python? I can't find where it exists in
> the python hierarchy.
> https://bugs.launchpad.net/kicad/+bug/1712233
> 
> I believe it's the solution to fixing a bug that prevents LayerViewSet.py from working well.
> https://github.com/HiGregSmith/LayerViewSet
> https://forum.kicad.info/t/layerviewset-main-thread-a-python-script-for-manipulating-visible-layers/7400/23
> <https://forum.kicad.info/t/layerviewset-main-thread-a-python-script-for-manipulating-visible-layers/7400/23?u=higreg>
> 
> Tomasz Wlostowski (twlostow) was kind enough to point out the possible solution to getting the layer
> visibilities updated in OpenGL canvas. Thank you, Tomasz!
> 


You could need to call:

ReFillLayerWidget();
ReCreateLayerBox();
syncLayerVisibilities();
syncLayerWidgetLayer();
syncRenderStates();

All are methods of the board editor (PCB_EDIT_FRAME) not the PCB_DRAW_PANEL_GAL.


-- 
Jean-Pierre CHARRAS

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to    : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help  : https://help.launchpad.net/ListHelp


   

   

Follow ups

References