Add preference for 3d-model-highlight-on-rollover.

Fixes https://gitlab.com/kicad/code/kicad/issues/8349
This commit is contained in:
Jeff Young 2021-05-11 20:52:28 +01:00
parent c49af57c2a
commit ac58a3f9f0
14 changed files with 130 additions and 43 deletions

View File

@ -98,6 +98,7 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRI
loadCommonSettings();
m_boardAdapter.SetFlag( FL_USE_SELECTION, false );
m_boardAdapter.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, false );
// Create the manager
m_toolManager = new TOOL_MANAGER;

View File

@ -111,6 +111,7 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
SetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, false );
SetFlag( FL_USE_SELECTION, true );
SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, true );
m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );

View File

@ -112,7 +112,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, BOARD*
m_opengl_supports_raytracing( true ),
m_render_raytracing_was_requested( false ),
m_accelerator3DShapes( nullptr ),
m_currentIntersectedBoardItem( nullptr )
m_currentRollOverItem( nullptr )
{
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::EDA_3D_CANVAS" );
@ -701,23 +701,23 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
RAY mouseRay = getRayAtCurrrentMousePosition();
BOARD_ITEM *intersectedBoardItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
BOARD_ITEM *rollOverItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
if( intersectedBoardItem )
if( rollOverItem )
{
if( intersectedBoardItem != m_currentIntersectedBoardItem )
if( rollOverItem != m_currentRollOverItem )
{
m_3d_render_ogl_legacy->SetCurrentIntersectedBoardItem( intersectedBoardItem );
m_currentIntersectedBoardItem = intersectedBoardItem;
m_3d_render_ogl_legacy->SetCurrentRollOverItem( rollOverItem );
m_currentRollOverItem = rollOverItem;
Request_refresh();
}
switch( intersectedBoardItem->Type() )
switch( rollOverItem->Type() )
{
case PCB_PAD_T:
{
PAD* pad = dynamic_cast<PAD*>( intersectedBoardItem );
PAD* pad = dynamic_cast<PAD*>( rollOverItem );
if( pad && pad->IsOnCopperLayer() )
{
@ -731,7 +731,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
case PCB_FOOTPRINT_T:
{
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT *>( intersectedBoardItem );
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( rollOverItem );
if( footprint )
reporter.Report( footprint->GetReference() );
@ -742,7 +742,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
case PCB_VIA_T:
case PCB_ARC_T:
{
TRACK* track = dynamic_cast<TRACK *>( intersectedBoardItem );
TRACK* track = dynamic_cast<TRACK*>( rollOverItem );
if( track )
{
@ -755,7 +755,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
case PCB_ZONE_T:
{
ZONE* zone = dynamic_cast<ZONE*>( intersectedBoardItem );
ZONE* zone = dynamic_cast<ZONE*>( rollOverItem );
if( zone && zone->IsOnCopperLayer() )
{
@ -772,16 +772,16 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
}
else
{
if( ( m_currentIntersectedBoardItem != nullptr ) &&
if( ( m_currentRollOverItem != nullptr ) &&
( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY ) )
{
m_3d_render_ogl_legacy->SetCurrentIntersectedBoardItem( nullptr );
m_3d_render_ogl_legacy->SetCurrentRollOverItem( nullptr );
Request_refresh();
reporter.Report( "" );
}
m_currentIntersectedBoardItem = nullptr;
m_currentRollOverItem = nullptr;
}
}
}

View File

@ -287,7 +287,7 @@ private:
CONTAINER_3D m_3DShapes_container; // Holds 3D shapes from footprints
ACCELERATOR_3D* m_accelerator3DShapes; // used for mouse over searching
BOARD_ITEM* m_currentIntersectedBoardItem;
BOARD_ITEM* m_currentRollOverItem;
/**
* Trace mask used to enable or disable the trace output of this class.

View File

@ -47,6 +47,7 @@ enum DISPLAY3D_FLG
FL_FP_ATTRIBUTES_VIRTUAL,
FL_USE_SELECTION,
FL_HIGHLIGHT_ROLLOVER_ITEM,
FL_SHOW_BOARD_BODY,
FL_MOUSEWHEEL_PANNING,

View File

@ -62,7 +62,7 @@ RENDER_3D_LEGACY::RENDER_3D_LEGACY( BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) :
m_circleTexture = 0;
m_grid = 0;
m_lastGridType = GRID3D_TYPE::NONE;
m_currentIntersectedBoardItem = nullptr;
m_currentRollOverItem = nullptr;
m_boardWithHoles = nullptr;
m_3dModelMap.clear();
@ -1179,16 +1179,25 @@ void RENDER_3D_LEGACY::render3dModelsSelected( bool aRenderTopOrBot, bool aRende
// Go for all footprints
for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
{
const bool isIntersected = ( fp == m_currentIntersectedBoardItem );
bool highlight = false;
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) && !isIntersected
&& ( ( aRenderSelectedOnly && !fp->IsSelected() )
|| ( !aRenderSelectedOnly && fp->IsSelected() ) ) )
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) )
{
continue;
if( fp == m_currentRollOverItem )
{
if( aRenderSelectedOnly )
highlight = m_boardAdapter.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM );
else if( !fp->IsSelected() )
continue;
}
else if( ( aRenderSelectedOnly && !fp->IsSelected() )
|| ( !aRenderSelectedOnly && fp->IsSelected() ) )
{
continue;
}
}
if( isIntersected && aRenderSelectedOnly )
if( highlight )
{
glEnable( GL_POLYGON_OFFSET_LINE );
glPolygonOffset( 8.0, 1.0 );
@ -1203,12 +1212,12 @@ void RENDER_3D_LEGACY::render3dModelsSelected( bool aRenderTopOrBot, bool aRende
if( ( aRenderTopOrBot && !fp->IsFlipped() )
|| ( !aRenderTopOrBot && fp->IsFlipped() ) )
{
renderFootprint( fp, aRenderTransparentOnly, isIntersected );
renderFootprint( fp, aRenderTransparentOnly, highlight );
}
}
}
if( isIntersected && aRenderSelectedOnly )
if( highlight )
{
// Restore
glDisable( GL_POLYGON_OFFSET_LINE );
@ -1282,12 +1291,12 @@ void RENDER_3D_LEGACY::renderFootprint( const FOOTPRINT* aFootprint, bool aRende
// values have changed. cache the matrix somewhere.
glm::mat4 mtx( 1 );
mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.z ), { 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.y ), { 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.x ), { 1.0f, 0.0f, 0.0f } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.z ),
{ 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.y ),
{ 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.x ),
{ 1.0f, 0.0f, 0.0f } );
mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
glMultMatrixf( glm::value_ptr( mtx ) );

View File

@ -67,9 +67,9 @@ public:
int GetWaitForEditingTimeOut() override;
void SetCurrentIntersectedBoardItem( BOARD_ITEM* aCurrentIntersectedBoardItem )
void SetCurrentRollOverItem( BOARD_ITEM* aRollOverItem )
{
m_currentIntersectedBoardItem = aCurrentIntersectedBoardItem;
m_currentRollOverItem = aRollOverItem;
}
private:
@ -198,20 +198,21 @@ private:
OPENGL_RENDER_LIST* m_outerViaThroughHoles;
OPENGL_RENDER_LIST* m_outerThroughHoleRings;
LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter
GLuint m_circleTexture;
LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter
GLuint m_circleTexture;
GLuint m_grid; ///< oGL list that stores current grid
GRID3D_TYPE m_lastGridType; ///< Stores the last grid type.
GLuint m_grid; ///< oGL list that stores current grid
GRID3D_TYPE m_lastGridType; ///< Stores the last grid type.
OPENGL_RENDER_LIST* m_vias;
OPENGL_RENDER_LIST* m_padHoles;
MAP_3DMODEL m_3dModelMap;
MAP_3DMODEL m_3dModelMap;
BOARD_ITEM* m_currentIntersectedBoardItem;
BOARD_ITEM* m_currentRollOverItem;
SHAPE_POLY_SET m_antiBoardPolys; ///< The negative polygon representation of the board outline.
SHAPE_POLY_SET m_antiBoardPolys; ///< The negative polygon representation of the board
///< outline.
};
#endif // RENDER_3D_LEGACY_H_

View File

@ -65,6 +65,8 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
"render.opengl_copper_thickness", &m_Render.opengl_copper_thickness, true ) );
m_params.emplace_back( new PARAM<bool>(
"render.opengl_show_model_bbox", &m_Render.opengl_show_model_bbox, false ) );
m_params.emplace_back( new PARAM<bool>(
"render.epengl_highlight_on_rollover", &m_Render.opengl_highlight_on_rollover, true ) );
m_params.emplace_back( new PARAM<bool>(
"render.opengl_AA_disableOnMove", &m_Render.opengl_AA_disableOnMove, false ) );
m_params.emplace_back( new PARAM<bool>(

View File

@ -41,6 +41,7 @@ public:
bool opengl_render_bbox_only_OnMove;
bool opengl_copper_thickness;
bool opengl_show_model_bbox;
bool opengl_highlight_on_rollover;
KIGFX::COLOR4D opengl_selection_color;
bool raytrace_anti_aliasing;

View File

@ -200,6 +200,7 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow()
// OpenGL options
m_checkBoxCuThickness->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) );
m_checkBoxBoundingBoxes->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
m_checkBoxHighlightOnRollOver->SetValue( m_settings.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM ) );
m_checkBoxDisableAAMove->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE ) );
m_checkBoxDisableMoveThickness->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE ) );
@ -281,6 +282,7 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
// OpenGL options
m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, m_checkBoxCuThickness->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, m_checkBoxBoundingBoxes->GetValue() );
m_settings.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, m_checkBoxHighlightOnRollOver->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, m_checkBoxDisableAAMove->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE,
m_checkBoxDisableMoveThickness->GetValue() );

View File

@ -168,6 +168,9 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
m_checkBoxCuThickness = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show copper thickness"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOpenGLRenderoptions->Add( m_checkBoxCuThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxHighlightOnRollOver = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Highlight items on rollover"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOpenGLRenderoptions->Add( m_checkBoxHighlightOnRollOver, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerOpenGL->Add( sbSizerOpenGLRenderoptions, 0, wxALL|wxEXPAND, 5 );
@ -175,7 +178,7 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
sbSizerOtherOptions = new wxStaticBoxSizer( new wxStaticBox( m_panelOpenGL, wxID_ANY, _("Other Options") ), wxVERTICAL );
wxFlexGridSizer* fgSizer7;
fgSizer7 = new wxFlexGridSizer( 2, 2, 2, 0 );
fgSizer7 = new wxFlexGridSizer( 2, 2, 0, 0 );
fgSizer7->SetFlexibleDirection( wxBOTH );
fgSizer7->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

View File

@ -1888,6 +1888,70 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Highlight items on rollover</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkBoxHighlightOnRollOver</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -1917,7 +1981,7 @@
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">2</property>
<property name="vgap">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>

View File

@ -71,6 +71,7 @@ class DIALOG_3D_VIEW_OPTIONS_BASE : public DIALOG_SHIM
wxPanel* m_panelOpenGL;
wxCheckBox* m_checkBoxBoundingBoxes;
wxCheckBox* m_checkBoxCuThickness;
wxCheckBox* m_checkBoxHighlightOnRollOver;
wxStaticText* m_staticText221;
wxChoice* m_choiceAntiAliasing;
wxStaticText* m_staticText231;

View File

@ -509,6 +509,7 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
// OpenGL options
TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
TRANSFER_SETTING( FL_HIGHLIGHT_ROLLOVER_ITEM, opengl_highlight_on_rollover );
TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
TRANSFER_SETTING( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE,
opengl_thickness_disableOnMove );
@ -681,8 +682,8 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
TRANSFER_SETTING( opengl_thickness_disableOnMove,
FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_highlight_on_rollover, FL_HIGHLIGHT_ROLLOVER_ITEM );
TRANSFER_SETTING( opengl_thickness_disableOnMove, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );