Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Grib plugin to use same screen size as main application #893

Merged
merged 1 commit into from Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion include/ocpn_plugin.h
Expand Up @@ -50,7 +50,7 @@ class wxGLContext;
// PlugIns conforming to API Version less then the most modern will also
// be correctly supported.
#define API_VERSION_MAJOR 1
#define API_VERSION_MINOR 14
#define API_VERSION_MINOR 15

// Fwd Definitions
class wxFileConfig;
Expand Down Expand Up @@ -524,6 +524,14 @@ class DECL_EXP opencpn_plugin_114 : public opencpn_plugin_113

};

class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114
{
public:
opencpn_plugin_115(void *pmgr);
virtual ~opencpn_plugin_115();

};

//------------------------------------------------------------------
// Route and Waypoint PlugIn support
//
Expand Down Expand Up @@ -1216,4 +1224,8 @@ extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT;
extern DECL_EXP void PlugInAISDrawGL( wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp );
extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement, const wxColour color);

// API 1.15
extern DECL_EXP double PlugInGetDisplaySizeMM();


#endif //_PLUGIN_H_
11 changes: 3 additions & 8 deletions plugins/grib_pi/src/GribOverlayFactory.cpp
Expand Up @@ -238,16 +238,11 @@ GRIBOverlayFactory::GRIBOverlayFactory( GRIBUICtrlBar &dlg )
#endif

if(wxGetDisplaySize().x > 0){
#ifdef __WXGTK__
GdkScreen *screen = gdk_screen_get_default();
m_pixelMM = (double)gdk_screen_get_monitor_width_mm(screen, 0) / wxGetDisplaySize().x;
#else
m_pixelMM = (double)wxGetDisplaySizeMM().x / wxGetDisplaySize().x;
#endif
m_pixelMM = wxMax(.02, m_pixelMM); // protect against bad data
m_pixelMM = PlugInGetDisplaySizeMM() / wxGetDisplaySize().x;
m_pixelMM = wxMax(.02, m_pixelMM); // protect against bad data
}
else
m_pixelMM = 0.27; // semi-standard number...
m_pixelMM = 0.27; // semi-standard number...

m_pGribTimelineRecordSet = NULL;
m_last_vp_scale = 0.;
Expand Down
11 changes: 2 additions & 9 deletions plugins/grib_pi/src/IsoLine.cpp
Expand Up @@ -171,19 +171,12 @@ double round_msvc (double x)
IsoLine::IsoLine(double val, double coeff, double offset, const GribRecord *rec_)
{
if(wxGetDisplaySize().x > 0){

#ifdef __WXGTK__
GdkScreen *screen = gdk_screen_get_default();
m_pixelMM = (double)gdk_screen_get_monitor_width_mm(screen, 0) / wxGetDisplaySize().x;
#else
m_pixelMM = (double)wxGetDisplaySizeMM().x / wxGetDisplaySize().x;
#endif

m_pixelMM = PlugInGetDisplaySizeMM() / wxGetDisplaySize().x;
m_pixelMM = wxMax(.02, m_pixelMM); // protect against bad data
}
else
m_pixelMM = 0.27; // semi-standard number...

value = val/coeff-offset;

rec = rec_;
Expand Down
2 changes: 1 addition & 1 deletion plugins/grib_pi/src/grib_pi.cpp
Expand Up @@ -73,7 +73,7 @@ extern int m_DialogStyle;
//---------------------------------------------------------------------------------------------------------

grib_pi::grib_pi(void *ppimgr)
:opencpn_plugin_112(ppimgr)
:opencpn_plugin_115(ppimgr)
{
// Create the PlugIn icons
initialize_images();
Expand Down
4 changes: 2 additions & 2 deletions plugins/grib_pi/src/grib_pi.h
Expand Up @@ -38,7 +38,7 @@
#define PLUGIN_VERSION_MINOR 1

#define MY_API_VERSION_MAJOR 1
#define MY_API_VERSION_MINOR 12
#define MY_API_VERSION_MINOR 15

#include "../../../include/ocpn_plugin.h"

Expand All @@ -62,7 +62,7 @@
#define SEPARATED_HORIZONTAL 2 // dialog separated shown honrizontaly
#define SEPARATED_VERTICAL 3 // dialog separated shown vaerticaly

class grib_pi : public opencpn_plugin_112
class grib_pi : public opencpn_plugin_115
{
public:
grib_pi(void *ppimgr);
Expand Down
48 changes: 35 additions & 13 deletions src/pluginmanager.cpp
Expand Up @@ -507,6 +507,7 @@ bool PlugInManager::CallLateInit(void)
case 112:
case 113:
case 114:
case 115:
if(pic->m_cap_flag & WANTS_LATE_INIT) {
wxString msg(_T("PlugInManager: Calling LateInit PlugIn: "));
msg += pic->m_plugin_file;
Expand Down Expand Up @@ -539,6 +540,7 @@ void PlugInManager::SendVectorChartObjectInfo(const wxString &chart, const wxStr
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_112 *ppi = dynamic_cast<opencpn_plugin_112 *>(pic->m_pplugin);
if(ppi)
Expand Down Expand Up @@ -1302,6 +1304,9 @@ PlugInContainer *PlugInManager::LoadPlugIn(wxString plugin_file)
case 114:
pic->m_pplugin = dynamic_cast<opencpn_plugin_114*>(plug_in);
break;
case 115:
pic->m_pplugin = dynamic_cast<opencpn_plugin_115*>(plug_in);
break;

default:
break;
Expand Down Expand Up @@ -1367,13 +1372,13 @@ bool PlugInManager::RenderAllCanvasOverlayPlugIns( ocpnDC &dc, const ViewPort &v
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_18 *ppi = dynamic_cast<opencpn_plugin_18 *>(pic->m_pplugin);
if(ppi)
ppi->RenderOverlay(*pdc, &pivp);
break;
}

default:
break;
}
Expand Down Expand Up @@ -1420,13 +1425,13 @@ bool PlugInManager::RenderAllCanvasOverlayPlugIns( ocpnDC &dc, const ViewPort &v
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_18 *ppi = dynamic_cast<opencpn_plugin_18 *>(pic->m_pplugin);
if(ppi)
b_rendered = ppi->RenderOverlay(mdc, &pivp);
break;
}

default:
{
b_rendered = pic->m_pplugin->RenderOverlay(&mdc, &pivp);
Expand Down Expand Up @@ -1483,6 +1488,7 @@ bool PlugInManager::RenderAllGLCanvasOverlayPlugIns( wxGLContext *pcontext, cons
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_18 *ppi = dynamic_cast<opencpn_plugin_18 *>(pic->m_pplugin);
if(ppi)
Expand All @@ -1507,24 +1513,23 @@ bool PlugInManager::SendMouseEventToPlugins( wxMouseEvent &event)
PlugInContainer *pic = plugin_array.Item(i);
if(pic->m_bEnabled && pic->m_bInitState)
{
if(pic->m_cap_flag & WANTS_MOUSE_EVENTS){
if(pic->m_cap_flag & WANTS_MOUSE_EVENTS)
{
switch(pic->m_api_version)
{
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_112 *ppi = dynamic_cast<opencpn_plugin_112*>(pic->m_pplugin);
if(ppi)
if(ppi->MouseEventHook( event ))
bret = true;
break;
}

default:
break;
if(ppi)
if(ppi->MouseEventHook( event ))
bret = true;
break;
}
default:
break;
}
}
}
Expand All @@ -1547,13 +1552,13 @@ bool PlugInManager::SendKeyEventToPlugins( wxKeyEvent &event)
{
case 113:
case 114:
case 115:
{
opencpn_plugin_113 *ppi = dynamic_cast<opencpn_plugin_113*>(pic->m_pplugin);
if(ppi && ppi->KeyboardEventHook( event ))
bret = true;
break;
}

default:
break;
}
Expand Down Expand Up @@ -1609,6 +1614,7 @@ void NotifySetupOptionsPlugin( PlugInContainer *pic )
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_19 *ppi = dynamic_cast<opencpn_plugin_19 *>(pic->m_pplugin);
if(ppi) {
Expand Down Expand Up @@ -1785,6 +1791,7 @@ void PlugInManager::SendMessageToAllPlugins(const wxString &message_id, const wx
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_18 *ppi = dynamic_cast<opencpn_plugin_18 *>(pic->m_pplugin);
if(ppi)
Expand Down Expand Up @@ -1864,13 +1871,13 @@ void PlugInManager::SendPositionFixToAllPlugIns(GenericPosDatEx *ppos)
case 112:
case 113:
case 114:
case 115:
{
opencpn_plugin_18 *ppi = dynamic_cast<opencpn_plugin_18 *>(pic->m_pplugin);
if(ppi)
ppi->SetPositionFixEx(pfix_ex);
break;
}

default:
break;
}
Expand Down Expand Up @@ -3740,6 +3747,15 @@ opencpn_plugin_114::~opencpn_plugin_114(void)
{
}

// Opencpn_Plugin_115 Implementation
opencpn_plugin_115::opencpn_plugin_115(void *pmgr)
: opencpn_plugin_114(pmgr)
{
}

opencpn_plugin_115::~opencpn_plugin_115(void)
{
}

// Helper and interface classes

Expand Down Expand Up @@ -6354,3 +6370,9 @@ bool PlugInSetFontColor(const wxString TextElement, const wxColour color)
return FontMgr::Get().SetFontColor(TextElement, color);
}

/* API 1.15 */

double PlugInGetDisplaySizeMM()
{
return g_Platform->GetDisplaySizeMM();
}