3d viewer: Add high quality mode option is realistic mode (Shows holes in copper zones, but with longer calculation time)

Gal: fix a very minor issue: the keys to switch between copper layers are now - and + (according to the doc and the normall mode), instead of - and =
This commit is contained in:
jean-pierre charras 2014-07-21 18:26:18 +02:00
parent 2f7b9bcd71
commit 38027eb998
7 changed files with 90 additions and 52 deletions

View File

@ -188,12 +188,21 @@ static inline void SetGLCopperColor()
glColor4f( 255.0*lum, 223.0*lum, 0.0*lum, 1.0 );
}
// Helper function: initialize the color to draw the epoxy layers
// ( body board and solder mask layers) in realistic mode.
// Helper function: initialize the color to draw the epoxy
// body board in realistic mode.
static inline void SetGLEpoxyColor( double aTransparency = 1.0 )
{
// Generates an epoxy color, near board color
const double lum = 0.2/255.0;
glColor4f( 255.0*lum, 218.0*lum, 110.0*lum, aTransparency );
}
// Helper function: initialize the color to draw the
// solder mask layers in realistic mode.
static inline void SetGLSolderMaskColor( double aTransparency = 1.0 )
{
// Generates a solder mask color
const double lum = 0.2/255.0;
glColor4f( 100.0*lum, 255.0*lum, 180.0*lum, aTransparency );
}
@ -217,7 +226,7 @@ static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
case B_Mask:
case F_Mask:
SetGLEpoxyColor( 0.7 );
SetGLSolderMaskColor( 0.7 );
break;
default:
@ -237,6 +246,12 @@ static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
void EDA_3D_CANVAS::BuildBoard3DView()
{
BOARD* pcb = GetBoard();
// If hightQualityMode is true, holes are correctly removed from copper zones areas.
// If hightQualityMode is false, holes are not removed from copper zones areas,
// but the calculation time is twice shorter.
bool hightQualityMode = g_Parm_3D_Visu.HightQualityMode();
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// Number of segments to convert a circle to polygon
@ -276,7 +291,6 @@ void EDA_3D_CANVAS::BuildBoard3DView()
CPOLYGONS_LIST currLayerHoles; // Contains holes for the current layer
bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once
bool hightQualityMode = false;
LSET cu_set = LSET::AllCuMask( g_Parm_3D_Visu.m_CopperLayersCount );
@ -520,7 +534,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
BOARD* pcb = GetBoard();
// Number of segments to draw a circle using segments
const int segcountforcircle = 16;
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations
@ -736,7 +750,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
*/
void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
{
const int segcountforcircle = 16;
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
BOARD* pcb = GetBoard();

View File

@ -45,6 +45,7 @@ static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyUseHQinRealisticMode[] = wxT( "UseHQinRealisticMode" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
static const wxChar keyShowGridSize[] = wxT( "Grid3DSize" );
@ -159,6 +160,9 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
aCfg->Read( keyUseHQinRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, tmp );
aCfg->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
@ -210,6 +214,7 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyUseHQinRealisticMode, prms.GetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowGrid, prms.GetFlag( FL_GRID ) );
aCfg->Write( keyShowGridSize, prms.m_3D_Grid );
@ -363,6 +368,11 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
NewDisplay();
return;
case ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE:
g_Parm_3D_Visu.SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, isChecked );
NewDisplay();
return;
case ID_MENU3D_SHOW_BOARD_BODY:
g_Parm_3D_Visu.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
NewDisplay();

View File

@ -153,11 +153,19 @@ void EDA_3D_FRAME::CreateMenuBar()
menuBar->Append( prefsMenu, _( "&Preferences" ) );
AddMenuItem( prefsMenu, ID_MENU3D_REALISTIC_MODE,
_( "Realistic Mode" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
_( "Realistic Mode" ),
KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
AddMenuItem( prefsMenu, ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
_( "Max Quality in Realistic Mode" ),
_( "When using max quality, holes are removed from copper zones, "
"but the calculation time is longer" ),
KiBitmap( green_xpm ), wxITEM_CHECK );
prefsMenu->AppendSeparator();
AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose background color" ), KiBitmap( palette_xpm ) );
_( "Choose Background Color" ), KiBitmap( palette_xpm ) );
AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
@ -231,7 +239,10 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
wxMenuItem* item;
// Set the state of toggle menus according to the current display options
item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
item->Check(g_Parm_3D_Visu.GetFlag( FL_USE_REALISTIC_MODE ) );
item->Check( g_Parm_3D_Visu.IsRealisticMode() );
item = menuBar->FindItem( ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE );
item->Check( g_Parm_3D_Visu.HightQualityMode() );
item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
item->Check( g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) );

View File

@ -41,6 +41,7 @@ enum id_3dview_frm
ID_MENU3D_ECO_ONOFF,
ID_MENU3D_SHOW_BOARD_BODY,
ID_MENU3D_REALISTIC_MODE,
ID_MENU3D_MAX_QUALITY_FOR_REALISTIC_MODE,
ID_END_COMMAND_3D,
ID_TOOL_SET_VISIBLE_ITEMS,

View File

@ -62,9 +62,9 @@ INFO3D_VISU::INFO3D_VISU()
m_CopperLayersCount = 2;
m_BoardSettings = NULL;
m_CopperThickness = 0;
m_EpoxyThickness = 0;
m_NonCopperLayerThickness = 0;
m_copperThickness = 0;
m_epoxyThickness = 0;
m_nonCopperLayerThickness = 0;
// default all special item layers Visible
for( ii = 0; ii < FL_LAST; ii++ )
@ -72,6 +72,7 @@ INFO3D_VISU::INFO3D_VISU()
SetFlag( FL_GRID, false );
SetFlag( FL_USE_COPPER_THICKNESS, false );
SetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE, false );
}
@ -107,36 +108,36 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
m_BiuTo3Dunits = 2.0 / std::max( m_BoardSize.x, m_BoardSize.y );
m_EpoxyThickness = aBoard->GetDesignSettings().GetBoardThickness() * m_BiuTo3Dunits;
m_epoxyThickness = aBoard->GetDesignSettings().GetBoardThickness() * m_BiuTo3Dunits;
// TODO use value defined by user (currently use default values by ctor
m_CopperThickness = COPPER_THICKNESS * m_BiuTo3Dunits;
m_NonCopperLayerThickness = TECH_LAYER_THICKNESS * m_BiuTo3Dunits;
m_copperThickness = COPPER_THICKNESS * m_BiuTo3Dunits;
m_nonCopperLayerThickness = TECH_LAYER_THICKNESS * m_BiuTo3Dunits;
// Init Z position of each layer
// calculate z position for each copper layer
// Z = 0 is the z position of the back (bottom) layer (layer id = 31)
// Z = m_EpoxyThickness is the z position of the front (top) layer (layer id = 0)
// Z = m_epoxyThickness is the z position of the front (top) layer (layer id = 0)
// all unused copper layer z position are set to 0
int layer;
int copper_layers_cnt = m_CopperLayersCount;
for( layer = 0; layer < copper_layers_cnt; layer++ )
{
m_LayerZcoord[layer] =
m_EpoxyThickness - (m_EpoxyThickness * layer / (copper_layers_cnt - 1));
m_layerZcoord[layer] =
m_epoxyThickness - (m_epoxyThickness * layer / (copper_layers_cnt - 1));
}
#define layerThicknessMargin 1.1
double zpos_offset = m_NonCopperLayerThickness * layerThicknessMargin;
double zpos_copper_back = - layerThicknessMargin*m_CopperThickness/2;
double zpos_copper_front = m_EpoxyThickness + layerThicknessMargin*m_CopperThickness/2;
double zpos_offset = m_nonCopperLayerThickness * layerThicknessMargin;
double zpos_copper_back = - layerThicknessMargin*m_copperThickness/2;
double zpos_copper_front = m_epoxyThickness + layerThicknessMargin*m_copperThickness/2;
// Fill remaining unused copper layers and back layer zpos
// with 0
for( ; layer < MAX_CU_LAYERS; layer++ )
{
m_LayerZcoord[layer] = 0;
m_layerZcoord[layer] = 0;
}
// calculate z position for each non copper layer
@ -184,22 +185,22 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
break;
}
m_LayerZcoord[layer_id] = zpos;
m_layerZcoord[layer_id] = zpos;
}
}
/* return the Z position of 3D shapes, in 3D Units
* aIsFlipped: true for modules on Front (top) layer, false
* if on back (bottom) layer
* Note: in draw functions, the copper has a thickness = m_CopperThickness
* Vias and tracks are draw with the top side position = m_CopperThickness/2
* and the bottom side position = -m_CopperThickness/2 from the Z layer position
* Note: in draw functions, the copper has a thickness = m_copperThickness
* Vias and tracks are draw with the top side position = m_copperThickness/2
* and the bottom side position = -m_copperThickness/2 from the Z layer position
*/
double INFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped )
{
if( aIsFlipped )
return m_LayerZcoord[B_Cu] - ( m_CopperThickness / 2 );
return m_layerZcoord[B_Cu] - ( m_copperThickness / 2 );
else
return m_LayerZcoord[F_Cu] + ( m_CopperThickness / 2 );
return m_layerZcoord[F_Cu] + ( m_copperThickness / 2 );
}

View File

@ -71,6 +71,7 @@ enum DISPLAY3D_FLG {
FL_USE_COPPER_THICKNESS,
FL_SHOW_BOARD_BODY,
FL_USE_REALISTIC_MODE,
FL_USE_MAXQUALITY_IN_REALISTIC_MODE,
FL_LAST
};
@ -95,10 +96,10 @@ public:
double m_CurrentZpos; // temporary storage of current value of Z position,
// used in some calculation
private:
double m_LayerZcoord[LAYER_ID_COUNT]; // Z position of each layer (normalized)
double m_CopperThickness; // Copper thickness (normalized)
double m_EpoxyThickness; // Epoxy thickness (normalized)
double m_NonCopperLayerThickness; // Non copper layers thickness
double m_layerZcoord[LAYER_ID_COUNT]; // Z position of each layer (normalized)
double m_copperThickness; // Copper thickness (normalized)
double m_epoxyThickness; // Epoxy thickness (normalized)
double m_nonCopperLayerThickness; // Non copper layers thickness
bool m_drawFlags[FL_LAST]; // Enable/disable flags (see DISPLAY3D_FLG list)
public: INFO3D_VISU();
@ -133,7 +134,7 @@ public: INFO3D_VISU();
*/
int GetLayerZcoordBIU( int aLayerId )
{
return KiROUND( m_LayerZcoord[aLayerId] / m_BiuTo3Dunits );
return KiROUND( m_layerZcoord[aLayerId] / m_BiuTo3Dunits );
}
/**
@ -147,11 +148,10 @@ public: INFO3D_VISU();
*/
int GetCopperThicknessBIU() const
{
bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS )
// || GetFlag( FL_USE_REALISTIC_MODE )
;
bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS );
return use_thickness ?
KiROUND( m_CopperThickness / m_BiuTo3Dunits )
KiROUND( m_copperThickness / m_BiuTo3Dunits )
: 0;
}
@ -161,7 +161,7 @@ public: INFO3D_VISU();
*/
int GetEpoxyThicknessBIU() const
{
return KiROUND( m_EpoxyThickness / m_BiuTo3Dunits );
return KiROUND( m_epoxyThickness / m_BiuTo3Dunits );
}
/**
@ -177,7 +177,7 @@ public: INFO3D_VISU();
// || GetFlag( FL_USE_REALISTIC_MODE )
;
return use_thickness ?
KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits )
KiROUND( m_nonCopperLayerThickness / m_BiuTo3Dunits )
: 0;
}
@ -197,6 +197,7 @@ public: INFO3D_VISU();
}
bool IsRealisticMode() { return GetFlag( FL_USE_REALISTIC_MODE ); }
bool HightQualityMode() { return GetFlag( FL_USE_MAXQUALITY_IN_REALISTIC_MODE ); }
};
extern INFO3D_VISU g_Parm_3D_Visu;

View File

@ -208,7 +208,7 @@ TOOL_ACTION COMMON_ACTIONS::layerBottom( "pcbnew.Control.layerBottom",
"", "" );
TOOL_ACTION COMMON_ACTIONS::layerNext( "pcbnew.Control.layerNext",
AS_GLOBAL, '=',
AS_GLOBAL, '+',
"", "" );
TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.Control.layerPrev",