Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rgleason committed Jul 12, 2018
2 parents b05ed48 + 7f3b876 commit 82aae2c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 186 deletions.
180 changes: 0 additions & 180 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,183 +49,3 @@ INCLUDE("cmake/PluginInstall.cmake")
INCLUDE("cmake/PluginLocalization.cmake")
INCLUDE("cmake/PluginPackage.cmake")

#**************************************************************************************************
# define minimum cmake version
# CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2)
# # This should be 2.8.0 to have FindGTK2 module
# IF (COMMAND cmake_policy)
# CMAKE_POLICY(SET CMP0003 OLD)
# CMAKE_POLICY(SET CMP0005 OLD)
# CMAKE_POLICY(SET CMP0011 OLD)
# ENDIF (COMMAND cmake_policy)
#
# PROJECT(NmeaConverter_pi)
#
# SET(PACKAGE_NAME NmeaConverter_pi)
# SET(PLUGIN_SOURCE_DIR .)
# MESSAGE (STATUS "*** Building ${PACKAGE_NAME} ***")
# #SET(CMAKE_BUILD_TYPE Debug)
#
# IF (PREFIX)
# SET(CMAKE_INSTALL_PREFIX ${PREFIX})
# ENDIF (PREFIX)
#
# SET(PARENT opencpn)
# SET(PREFIX_BIN bin)
# SET(PREFIX_INCLUDE include)
# SET(PREFIX_DATA share)
# SET(PREFIX_PARENTDATA ${PREFIX_DATA}/${PARENT})
#
# INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src)
#
# # require proper c++
# #ADD_DEFINITIONS( "-Wall -ansi -pedantic -Wno-variadic-macros" )
# #TODO: Should we use -fno-stack-protector
# # IF NOT DEBUGGING CFLAGS="-O2 -march=native"
# IF(NOT WIN32)
# ADD_DEFINITIONS( "-Wall -g -fexceptions -fvisibility=hidden" )
#
# IF(NOT APPLE)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
# ELSE(NOT APPLE)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl")
# ENDIF(NOT APPLE)
#
# ENDIF(NOT WIN32)
#
# # Add some definitions to satisfy MS
# IF(WIN32)
# ADD_DEFINITIONS(-D__MSVC__)
# ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
# ENDIF(WIN32)
#
#
# SET(wxWidgets_USE_LIBS base core net xml html adv)
# SET(BUILD_SHARED_LIBS TRUE)
# FIND_PACKAGE(wxWidgets REQUIRED)
#
# INCLUDE(${wxWidgets_USE_FILE})
#
# FIND_PACKAGE(Gettext REQUIRED)
#
# # For convenience we define the sources as a variable. You can add
# # header files and cpp/c files and CMake will sort them out
#
#
# SET(SRC_NMEATRANSLATOR
# src/NmeaConverter_pi.h
# src/NmeaConverter_pi.cpp
# src/ec_defs.h
# src/ec_engine.h
# src/ec_engine.cpp
# )
#
#
# ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_NMEATRANSLATOR} )
#
# IF(WIN32)
# SET(OPENCPN_IMPORT_LIB "../../../${CMAKE_CFG_INTDIR}/${PARENT}")
# TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OPENCPN_IMPORT_LIB} )
# ADD_DEPENDENCIES(${PACKAGE_NAME} ${PARENT})
# ENDIF(WIN32)
#
# TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${wxWidgets_LIBRARIES} )
#
# IF(UNIX)
# INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${PREFIX_PARENTDATA}/plugins)
# ENDIF(UNIX)
#
# IF(WIN32)
# INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins")
# ENDIF(WIN32)
#
#
# # define minimum cmake version
# CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2)
# # This should be 2.8.0 to have FindGTK2 module
# IF (COMMAND cmake_policy)
# CMAKE_POLICY(SET CMP0003 OLD)
# CMAKE_POLICY(SET CMP0005 OLD)
# CMAKE_POLICY(SET CMP0011 OLD)
# ENDIF (COMMAND cmake_policy)
#
# PROJECT(NmeaConvertor_pi)
#
# SET(PACKAGE_NAME NmeaConvertor_pi)
# SET(PLUGIN_SOURCE_DIR ..)
# MESSAGE (STATUS "*** Building ${PACKAGE_NAME} ***")
#
# #SET(CMAKE_BUILD_TYPE Debug)
#
# IF (PREFIX)
# SET(CMAKE_INSTALL_PREFIX ${PREFIX})
# ENDIF (PREFIX)
#
# SET(PARENT opencpn)
# SET(PREFIX_BIN bin)
# SET(PREFIX_INCLUDE include)
# SET(PREFIX_DATA share)
# SET(PREFIX_PARENTDATA ${PREFIX_DATA}/${PARENT})
#
# INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
#
# # require proper c++
# #ADD_DEFINITIONS( "-Wall -ansi -pedantic -Wno-variadic-macros" )
# #TODO: Should we use -fno-stack-protector
# # IF NOT DEBUGGING CFLAGS="-O2 -march=native"
# IF(NOT WIN32)
# ADD_DEFINITIONS( "-Wall -g -fexceptions -fvisibility=hidden" )
#
# IF(NOT APPLE)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
# ELSE(NOT APPLE)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl")
# ENDIF(NOT APPLE)
#
# ENDIF(NOT WIN32)
#
# # Add some definitions to satisfy MS
# IF(WIN32)
# ADD_DEFINITIONS(-D__MSVC__)
# ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
# ENDIF(WIN32)
#
#
# SET(wxWidgets_USE_LIBS base core net xml html adv)
# SET(BUILD_SHARED_LIBS TRUE)
# FIND_PACKAGE(wxWidgets REQUIRED)
#
# INCLUDE(${wxWidgets_USE_FILE})
#
# FIND_PACKAGE(Gettext REQUIRED)
#
# # For convenience we define the sources as a variable. You can add
# # header files and cpp/c files and CMake will sort them out
#
#
# SET(SRC_NMEACONVERTOR
# src/NmeaConverter_pi.h
# src/NmeaConverter_pi.cpp
# src/ec_defs.h
# src/ec_engine.h
# src/ec_engine.cpp
# )
#
#
# ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_NMEACONVERTOR} )
#
# IF(WIN32)
# SET(OPENCPN_IMPORT_LIB "../../../${CMAKE_CFG_INTDIR}/${PARENT}")
# TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OPENCPN_IMPORT_LIB} )
# ADD_DEPENDENCIES(${PACKAGE_NAME} ${PARENT})
# ENDIF(WIN32)
#
# TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${wxWidgets_LIBRARIES} )
#
# IF(UNIX)
# INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${PREFIX_PARENTDATA}/plugins)
# ENDIF(UNIX)
#
# IF(WIN32)
# INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins")
# ENDIF(WIN32)
18 changes: 15 additions & 3 deletions src/NmeaConverter_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool NmeaConverter_pi::nmeaIsValid( wxString &sentence)
return r;
}

int NmeaConverter_pi::AddObjectToMap( nmeaSendObj* object, SentenceSendMode Mode, int RepTime)
int NmeaConverter_pi::AddObjectToMap( nmeaSendObj* object, SentenceSendMode Mode, int RepTime, bool Degr)
{
int index;
if ( ObjectMap.empty() ) // map is wxEmptyString
Expand All @@ -158,6 +158,7 @@ int NmeaConverter_pi::AddObjectToMap( nmeaSendObj* object, SentenceSendMode Mode
ObjectMap[index] = object;
object->SetSendMode( Mode );
object->SetRepeatTime( RepTime );
object->UseDegrees = Degr;
return index;
}
void NmeaConverter_pi::ClearAllObjectsInMap()
Expand Down Expand Up @@ -227,6 +228,7 @@ bool NmeaConverter_pi::SaveConfig( void )
pConf->Write( _T("FormatString"),CurrObj->GetFormatStr() );
pConf->Write( _T("SendMode"),int(CurrObj->GetSendMode() ) );
pConf->Write( _T("RepeatTime"),int(CurrObj->GetRepeatTime() ) );
pConf->Write( _T("CalcDegrees"),bool(CurrObj->UseDegrees ) );
i++;
}
return true;
Expand All @@ -253,7 +255,9 @@ bool NmeaConverter_pi::LoadConfig( void )
pConf->Read( _T("SendMode"), &SendModeInt, int(ALLVAL) );
int RepTime;
pConf->Read( _T("RepeatTime"), &RepTime, 1 );
AddObjectToMap( new nmeaSendObj( this, FormatS), SentenceSendMode(SendModeInt), RepTime );
bool UseDeg;
pConf->Read( _T("CalcDegrees"), &UseDeg, false );
AddObjectToMap( new nmeaSendObj( this, FormatS), SentenceSendMode(SendModeInt), RepTime, UseDeg );

}
return true;
Expand Down Expand Up @@ -435,6 +439,7 @@ void nmeaSendObj::ComputeOutputSentence()
}
wxString result;
wxEcEngine calc;
if (UseDegrees) calc.SetTrigonometricMode(wxECA_DEGREE);
if (calc.SetFormula( formattokenarray[j] ))
{
result = wxString::Format(wxT("%.*f"), NoOfDecimals, calc.Compute() );
Expand Down Expand Up @@ -746,7 +751,7 @@ BEGIN_EVENT_TABLE( nmeaSendObjectDlg, wxDialog )
EVT_TEXT( ID_TEXTCTRL, nmeaSendObjectDlg::OnTextctrlTextUpdated )
EVT_BUTTON( ID_BUTTON_OK1, nmeaSendObjectDlg::OnButtonOkClick )
EVT_BUTTON( ID_BUTTON_CANCEL, nmeaSendObjectDlg::OnButtonCancelClick )

EVT_CHECKBOX( ID_CHECKBOXDEG, nmeaSendObjectDlg::OnUseDegreesClick )
END_EVENT_TABLE()


Expand Down Expand Up @@ -811,6 +816,8 @@ void nmeaSendObjectDlg::CreateControls()
wxStaticText* itemStaticText1 = new wxStaticText( itemDialog1, wxID_STATIC, _("seconds."), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText1, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);

itemCheckBoxUseDegrees = new wxCheckBox( itemDialog1, ID_CHECKBOXDEG, _("Calculate using degrees"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(itemCheckBoxUseDegrees, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

itemStaticTextSendString = new wxStaticText( itemDialog1, wxID_STATIC, _("Output sentence comes here;-)"), wxPoint(5, 60), wxSize(300, -1), 0 );
itemStaticTextSendString->SetForegroundColour(wxColour(0, 0, 255));
Expand Down Expand Up @@ -852,6 +859,7 @@ void nmeaSendObjectDlg::SetSendObjOfThisDlg( nmeaSendObj* object)
itemSpinCtrl->Enable(true);
}
itemSpinCtrl->SetValue( SendObjOfThisDlg->GetRepeatTime() );
itemCheckBoxUseDegrees->SetValue( SendObjOfThisDlg->UseDegrees );
}

void nmeaSendObjectDlg::SetOutputStrTxt(wxString str)
Expand Down Expand Up @@ -896,6 +904,10 @@ void nmeaSendObjectDlg::OnButtonCancelClick( wxCommandEvent& event )
this->EndModal( wxID_CANCEL );
event.Skip();
}
void nmeaSendObjectDlg::OnUseDegreesClick ( wxCommandEvent& event )
{
SendObjOfThisDlg->UseDegrees = itemCheckBoxUseDegrees->GetValue();
}

bool nmeaSendObjectDlg::ShowToolTips()
{
Expand Down
8 changes: 7 additions & 1 deletion src/NmeaConverter_pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class NmeaConverter_pi : public opencpn_plugin_18
bool SaveConfig( void );
bool LoadConfig( void );
bool nmeaIsValid( wxString &sentence);
int AddObjectToMap( nmeaSendObj* object, SentenceSendMode Mode = ALLVAL, int RepTime = 1);
int AddObjectToMap( nmeaSendObj* object, SentenceSendMode Mode = ALLVAL, int RepTime = 1, bool Degr = false );
void ClearAllObjectsInMap();
wxString ComputeChecksum( wxString sentence );
wxString ReadNmeaInputToken(wxString SentencePlusNumber);
Expand Down Expand Up @@ -127,6 +127,7 @@ class nmeaSendObj : wxObject
void SetRepeatTime( int rtime);
int GetRepeatTime(){ return RepeatTime;}
NmeaConverter_pi* plugin;
bool UseDegrees;
private:
wxString FormatString;
wxArrayString NeededVariables;
Expand All @@ -139,6 +140,7 @@ class nmeaSendObj : wxObject
//wxTimer* m_timer;
bool DlgActive;
bool ValidFormatStr;

SentenceSendMode SendMode;
int RepeatTime;
localTimer* p_timer;
Expand Down Expand Up @@ -240,6 +242,7 @@ class PreferenceDlg: public wxDialog
#define ID_TEXTCTRL 10004
#define ID_BUTTON_OK1 10005
#define ID_BUTTON_CANCEL 10006
#define ID_CHECKBOXDEG 10008
#define SYMBOL_NMEASENDOBJECTDLG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_NMEASENDOBJECTDLG_TITLE _("nmeaSendObjectDlg")
#define SYMBOL_NMEASENDOBJECTDLG_IDNAME ID_NMEASENDOBJECT
Expand Down Expand Up @@ -273,9 +276,11 @@ class nmeaSendObjectDlg: public wxDialog
void OnTextctrlTextUpdated( wxCommandEvent& event );
void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
void OnUseDegreesClick ( wxCommandEvent& event );
wxBitmap GetBitmapResource( const wxString& name );
wxIcon GetIconResource( const wxString& name );
static bool ShowToolTips();

nmeaSendObj* SendObjOfThisDlg;
wxSpinCtrl* itemSpinCtrl;
wxRadioButton* itemRadioButtonVal;
Expand All @@ -284,6 +289,7 @@ class nmeaSendObjectDlg: public wxDialog
wxTextCtrl* itemTextCtrlFormatStrCtr;
wxButton* itemOKButton;
wxButton* itemCancelButton;
wxCheckBox* itemCheckBoxUseDegrees;
};


Expand Down
4 changes: 2 additions & 2 deletions src/ec_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ void wxEcEngine::ResetConstants()
{
m_constants.clear();
SetConstant(wxT("deg"), M_PI/180.0);
SetConstant(wxT("e"), exp(1.0));
SetConstant(wxT("g"), 9.80665);
//SetConstant(wxT("e"), exp(1.0));
//SetConstant(wxT("g"), 9.80665);
SetConstant(wxT("pi"), M_PI);
SetConstant(wxT("percent"), 0.01);
return;
Expand Down

0 comments on commit 82aae2c

Please sign in to comment.