diff --git a/src/3rdParty/salomesmesh/src/DriverSTL/Basics_Utils.cpp b/src/3rdParty/salomesmesh/src/DriverSTL/Basics_Utils.cpp index cbbbc769c0..23c5083fdf 100644 --- a/src/3rdParty/salomesmesh/src/DriverSTL/Basics_Utils.cpp +++ b/src/3rdParty/salomesmesh/src/DriverSTL/Basics_Utils.cpp @@ -1,132 +1,132 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : Basics_Utils.cxx -// Autor : Alexander A. BORODIN -// Module : SALOME -// - -#include "Basics_Utils.hxx" -#include -#include - -#ifndef WIN32 -#include -#include -#include -#endif - - -namespace Kernel_Utils -{ - // threadsafe - std::string GetHostname() - { - int ls = 100, r = 1; - char *s; - - while (ls < 10000 && r) - { - ls *= 2; - s = new char[ls]; - r = gethostname(s, ls-1);//threadsafe see man 7 pthread - switch (r) - { - case 0: - break; - default: -#ifdef EINVAL - case EINVAL: -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: -#endif -#ifdef WIN32 - case WSAEFAULT: -#endif - delete [] s; - continue; - } - - } - - if (r != 0) - { - s = new char[50]; - strcpy(s, "localhost"); - } - - // remove all after '.' - char *aDot = (strchr(s,'.')); - if (aDot) aDot[0] = '\0'; - - std::string p = s; - delete [] s; - return p; - } - - Localizer::Localizer() - { - myCurLocale = setlocale(LC_NUMERIC, 0); - setlocale(LC_NUMERIC, "C"); - } - - Localizer::~Localizer() - { - setlocale(LC_NUMERIC, myCurLocale.c_str()); - } - - std::string GetGUID( GUIDtype type ) - { - std::string guid; - - switch ( type ) { - case DefUserID: - guid = "FFFFFFFF-D9CD-11d6-945D-1050DA506788"; break; - case ObjectdID: - guid = "C08F3C95-F112-4023-8776-78F1427D0B6D"; break; - } - - return guid; - } - -#ifndef WIN32 - void print_traceback() - { - void *array[50]; - size_t size; - char **strings; - size_t i; - - size = backtrace (array, 40); - strings = backtrace_symbols (array, size); - - for (i = 0; i < size; i++) - { - std::cerr << strings[i] << std::endl; - } - - free (strings); - } -#else - #if (_MSC_VER >= 1400) // Visual Studio 2005 - #include +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : Basics_Utils.cxx +// Autor : Alexander A. BORODIN +// Module : SALOME +// + +#include "Basics_Utils.hxx" +#include +#include + +#ifndef WIN32 +#include +#include +#include +#endif + + +namespace Kernel_Utils +{ + // threadsafe + std::string GetHostname() + { + int ls = 100, r = 1; + char *s; + + while (ls < 10000 && r) + { + ls *= 2; + s = new char[ls]; + r = gethostname(s, ls-1);//threadsafe see man 7 pthread + switch (r) + { + case 0: + break; + default: +#ifdef EINVAL + case EINVAL: +#endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: +#endif +#ifdef WIN32 + case WSAEFAULT: +#endif + delete [] s; + continue; + } + + } + + if (r != 0) + { + s = new char[50]; + strcpy(s, "localhost"); + } + + // remove all after '.' + char *aDot = (strchr(s,'.')); + if (aDot) aDot[0] = '\0'; + + std::string p = s; + delete [] s; + return p; + } + + Localizer::Localizer() + { + myCurLocale = setlocale(LC_NUMERIC, 0); + setlocale(LC_NUMERIC, "C"); + } + + Localizer::~Localizer() + { + setlocale(LC_NUMERIC, myCurLocale.c_str()); + } + + std::string GetGUID( GUIDtype type ) + { + std::string guid; + + switch ( type ) { + case DefUserID: + guid = "FFFFFFFF-D9CD-11d6-945D-1050DA506788"; break; + case ObjectdID: + guid = "C08F3C95-F112-4023-8776-78F1427D0B6D"; break; + } + + return guid; + } + +#ifndef WIN32 + void print_traceback() + { + void *array[50]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 40); + strings = backtrace_symbols (array, size); + + for (i = 0; i < size; i++) + { + std::cerr << strings[i] << std::endl; + } + + free (strings); + } +#else + #if (_MSC_VER >= 1400) // Visual Studio 2005 + #include int setenv(const char *name, const char *value, int rewrite) { std::stringstream sstr; @@ -134,8 +134,8 @@ namespace Kernel_Utils if(rewrite || std::string(getenv(name)).length() == 0) return _putenv(sstr.str().c_str()); else return -1; - } - #endif -#endif - -} + } + #endif +#endif + +} diff --git a/src/Tools/embedded/wxWidgets/wxWidgetsMain.cpp b/src/Tools/embedded/wxWidgets/wxWidgetsMain.cpp index 98f5804534..ab5135925e 100644 --- a/src/Tools/embedded/wxWidgets/wxWidgetsMain.cpp +++ b/src/Tools/embedded/wxWidgets/wxWidgetsMain.cpp @@ -15,16 +15,16 @@ #pragma hdrstop #endif //__BORLANDC__ -#include "wxWidgetsMain.h" -#undef _POSIX_C_SOURCE +#include "wxWidgetsMain.h" +#undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE -#include -#include -#include +#include +#include +#include #include -#ifdef __WXGTK__ -# include "wx/gtk/win_gtk.h" -#endif +#ifdef __WXGTK__ +# include "wx/gtk/win_gtk.h" +#endif //helper functions enum wxbuildinfoformat { @@ -66,22 +66,22 @@ END_EVENT_TABLE() wxWidgetsFrame::wxWidgetsFrame(wxFrame *frame, const wxString& title) : wxFrame(frame, -1, title) { - if (!Py_IsInitialized()) { - static std::vector argv; - argv.push_back((char*)"wxwidgetsDialog"); + if (!Py_IsInitialized()) { + static std::vector argv; + argv.push_back((char*)"wxwidgetsDialog"); static int argc = 1; Py_SetProgramName(argv[0]); Py_Initialize(); PySys_SetArgv(argc, &(argv[0])); } - + #if wxUSE_MENUS // create a menu bar wxMenuBar* mbar = new wxMenuBar(); wxMenu* fileMenu = new wxMenu(_T("")); fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application")); mbar->Append(fileMenu, _("&File")); - + wxMenu* freecadMenu = new wxMenu(_T("")); freecadMenu->Append(idMenuLoad, _("Load"), _("Load FreeCAD module")); freecadMenu->Append(idMenuNewDocument, _("New document"), _("Create new document in the FreeCAD module")); @@ -142,25 +142,25 @@ void wxWidgetsFrame::OnLoad(wxCommandEvent &event) PyObject* result = PyRun_String(cmd.str().c_str(), Py_file_input, dict, dict); if (result) { - Py_DECREF(result); - wxMenuBar* mbar = GetMenuBar(); - wxMenu* menu = mbar->GetMenu(1); + Py_DECREF(result); + wxMenuBar* mbar = GetMenuBar(); + wxMenu* menu = mbar->GetMenu(1); menu->Enable(idMenuLoad, false); menu->Enable(idMenuNewDocument, true); menu->Enable(idMenuEmbed, true); } else { - PyObject *ptype, *pvalue, *ptrace; - PyErr_Fetch(&ptype, &pvalue, &ptrace); - PyObject* pystring = PyObject_Str(pvalue); - const char* error = PyString_AsString(pystring); + PyObject *ptype, *pvalue, *ptrace; + PyErr_Fetch(&ptype, &pvalue, &ptrace); + PyObject* pystring = PyObject_Str(pvalue); + const char* error = PyString_AsString(pystring); wxString msg = wxString::FromAscii(error); wxMessageBox(msg, _("Error")); - Py_DECREF(pystring); + Py_DECREF(pystring); } Py_DECREF(dict); } -} +} void wxWidgetsFrame::OnNewDocument(wxCommandEvent &event) { @@ -174,27 +174,27 @@ void wxWidgetsFrame::OnNewDocument(wxCommandEvent &event) Py_DECREF(result); } else { - PyObject *ptype, *pvalue, *ptrace; - PyErr_Fetch(&ptype, &pvalue, &ptrace); - PyObject* pystring = PyObject_Str(pvalue); - const char* error = PyString_AsString(pystring); + PyObject *ptype, *pvalue, *ptrace; + PyErr_Fetch(&ptype, &pvalue, &ptrace); + PyObject* pystring = PyObject_Str(pvalue); + const char* error = PyString_AsString(pystring); wxString msg = wxString::FromAscii(error); wxMessageBox(msg, _("Error")); - Py_DECREF(pystring); + Py_DECREF(pystring); } Py_DECREF(dict); -} +} void wxWidgetsFrame::OnEmbed(wxCommandEvent &event) -{ - void* hwnd = 0; -#if defined (_WIN32) - hwnd = this->GetHWND(); -#elif defined(__WXGTK__) - //http://old.nabble.com/wxWindow-and-x11-td2853615.html - //GdkWindow *window = GTK_PIZZA()->bin_window; - //GDK_WINDOW_XWINDOW( window ); - //hwnd = window; +{ + void* hwnd = 0; +#if defined (_WIN32) + hwnd = this->GetHWND(); +#elif defined(__WXGTK__) + //http://old.nabble.com/wxWindow-and-x11-td2853615.html + //GdkWindow *window = GTK_PIZZA()->bin_window; + //GDK_WINDOW_XWINDOW( window ); + //hwnd = window; #endif PyObject* main = PyImport_AddModule("__main__"); PyObject* dict = PyModule_GetDict(main); @@ -215,24 +215,24 @@ void wxWidgetsFrame::OnEmbed(wxCommandEvent &event) PyObject* result = PyRun_String(cmd.str().c_str(), Py_file_input, dict, dict); if (result) { Py_DECREF(result); - wxMenuBar* mbar = GetMenuBar(); - wxMenu* menu = mbar->GetMenu(1); + wxMenuBar* mbar = GetMenuBar(); + wxMenu* menu = mbar->GetMenu(1); menu->Enable(idMenuEmbed, true); } else { - PyObject *ptype, *pvalue, *ptrace; - PyErr_Fetch(&ptype, &pvalue, &ptrace); - PyObject* pystring = PyObject_Str(pvalue); - const char* error = PyString_AsString(pystring); + PyObject *ptype, *pvalue, *ptrace; + PyErr_Fetch(&ptype, &pvalue, &ptrace); + PyObject* pystring = PyObject_Str(pvalue); + const char* error = PyString_AsString(pystring); wxString msg = wxString::FromAscii(error); wxMessageBox(msg, _("Error")); - Py_DECREF(pystring); + Py_DECREF(pystring); } Py_DECREF(dict); -} +} void wxWidgetsFrame::OnAbout(wxCommandEvent &event) { - wxString msg = wxbuildinfo(long_f); + wxString msg = wxbuildinfo(long_f); wxMessageBox(msg, _("Welcome to...")); -} +}