├── .gitignore ├── GcodeSenderGUIthreads.pro ├── GrblController.iss ├── GrblController.qrc ├── LICENSE ├── QextSerialPort ├── qextserialenumerator.cpp ├── qextserialenumerator.h ├── qextserialenumerator_linux.cpp ├── qextserialenumerator_osx.cpp ├── qextserialenumerator_p.h ├── qextserialenumerator_unix.cpp ├── qextserialenumerator_win.cpp ├── qextserialport.cpp ├── qextserialport.h ├── qextserialport.pri ├── qextserialport_global.h ├── qextserialport_p.h ├── qextserialport_unix.cpp └── qextserialport_win.cpp ├── README ├── TODO ├── about.cpp ├── about.h ├── about.ui ├── arcitem.cpp ├── arcitem.h ├── atomicintbool.cpp ├── atomicintbool.h ├── controlparams.cpp ├── controlparams.h ├── coord3d.cpp ├── coord3d.h ├── definitions.h ├── fixqt4headers.pl ├── gcode.cpp ├── gcode.h ├── grbl.ico ├── grbl.rc ├── grbldialog.cpp ├── grbldialog.h ├── grbldialog.ui ├── images.rcc ├── img ├── Thumbs.db ├── down.PNG ├── down.gif ├── left.PNG ├── left.gif ├── logotiny.PNG ├── logotiny.gif ├── right.PNG ├── right.gif ├── up.PNG ├── up.gif └── zapmaker-logo-130.png ├── itemtobase.cpp ├── itemtobase.h ├── lineitem.cpp ├── lineitem.h ├── linux-installer ├── config │ └── config.xml └── packages │ └── org.zapmaker.GrblController │ ├── data │ └── trlocale │ │ ├── GrblController_fr.qm │ │ └── GrblController_xx.qm │ └── meta │ ├── license.txt │ └── package.xml ├── log4qt ├── appender.h ├── appenderskeleton.cpp ├── appenderskeleton.h ├── basicconfigurator.cpp ├── basicconfigurator.h ├── consoleappender.cpp ├── consoleappender.h ├── dailyrollingfileappender.cpp ├── dailyrollingfileappender.h ├── fileappender.cpp ├── fileappender.h ├── helpers │ ├── classlogger.cpp │ ├── classlogger.h │ ├── configuratorhelper.cpp │ ├── configuratorhelper.h │ ├── datetime.cpp │ ├── datetime.h │ ├── factory.cpp │ ├── factory.h │ ├── initialisationhelper.cpp │ ├── initialisationhelper.h │ ├── logerror.cpp │ ├── logerror.h │ ├── logobject.cpp │ ├── logobject.h │ ├── logobjectptr.cpp │ ├── logobjectptr.h │ ├── optionconverter.cpp │ ├── optionconverter.h │ ├── patternformatter.cpp │ ├── patternformatter.h │ ├── properties.cpp │ └── properties.h ├── hierarchy.cpp ├── hierarchy.h ├── layout.cpp ├── layout.h ├── level.cpp ├── level.h ├── log4qt.cpp ├── log4qt.h ├── log4qt.pri ├── logger.cpp ├── logger.h ├── loggerrepository.cpp ├── loggerrepository.h ├── loggingevent.cpp ├── loggingevent.h ├── logmanager.cpp ├── logmanager.h ├── mdc.cpp ├── mdc.h ├── ndc.cpp ├── ndc.h ├── patternlayout.cpp ├── patternlayout.h ├── propertyconfigurator.cpp ├── propertyconfigurator.h ├── rollingfileappender.cpp ├── rollingfileappender.h ├── simplelayout.cpp ├── simplelayout.h ├── spi │ ├── filter.cpp │ └── filter.h ├── ttcclayout.cpp ├── ttcclayout.h ├── varia │ ├── debugappender.cpp │ ├── debugappender.h │ ├── denyallfilter.cpp │ ├── denyallfilter.h │ ├── levelmatchfilter.cpp │ ├── levelmatchfilter.h │ ├── levelrangefilter.cpp │ ├── levelrangefilter.h │ ├── listappender.cpp │ ├── listappender.h │ ├── nullappender.cpp │ ├── nullappender.h │ ├── stringmatchfilter.cpp │ └── stringmatchfilter.h ├── writerappender.cpp └── writerappender.h ├── log4qtdef.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── options.cpp ├── options.h ├── options.ui ├── pointitem.cpp ├── pointitem.h ├── positem.cpp ├── positem.h ├── qrc_images.cpp ├── renderarea.cpp ├── renderarea.h ├── renderitemlist.cpp ├── renderitemlist.h ├── rs232.cpp ├── rs232.h ├── termiosext.h ├── timer.cpp ├── timer.h ├── trlocale ├── GrblController_fr.qm ├── GrblController_fr.ts ├── GrblController_xx.qm └── GrblController_xx.ts ├── version.h ├── wininfoafter.txt ├── wininfobefore.txt └── winlicense.txt /.gitignore: -------------------------------------------------------------------------------- 1 | GcodeSenderGUIthreads.pro.user 2 | Makefile 3 | Makefile.Debug 4 | Makefile.Release 5 | debug/ 6 | release/ 7 | favs.txt 8 | object_script.GcodeSenderGUI.Debug 9 | object_script.GcodeSenderGUI.Release 10 | settings 11 | ui_*.h 12 | Output/ 13 | android/ 14 | GrblController 15 | *.o 16 | moc_*.cpp 17 | qrc_*.cpp 18 | *.stash 19 | GrblController-local.iss 20 | -------------------------------------------------------------------------------- /GcodeSenderGUIthreads.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2012-02-13 T17:48:40 4 | # 5 | # (fourth axis modifications and translation added by LETARTARE 2013-08-03) 6 | #------------------------------------------------- 7 | 8 | QT += core gui widgets 9 | 10 | TARGET = GrblController 11 | TEMPLATE = app 12 | 13 | include(QextSerialPort/qextserialport.pri) 14 | include(log4qt/log4qt.pri) 15 | 16 | 17 | SOURCES += main.cpp\ 18 | mainwindow.cpp \ 19 | rs232.cpp \ 20 | options.cpp \ 21 | grbldialog.cpp \ 22 | about.cpp \ 23 | gcode.cpp \ 24 | timer.cpp \ 25 | atomicintbool.cpp \ 26 | coord3d.cpp \ 27 | renderarea.cpp \ 28 | positem.cpp \ 29 | renderitemlist.cpp \ 30 | lineitem.cpp \ 31 | itemtobase.cpp \ 32 | arcitem.cpp \ 33 | pointitem.cpp \ 34 | controlparams.cpp 35 | 36 | HEADERS += mainwindow.h \ 37 | rs232.h \ 38 | options.h \ 39 | grbldialog.h \ 40 | definitions.h \ 41 | about.h \ 42 | images.rcc \ 43 | gcode.h \ 44 | timer.h \ 45 | atomicintbool.h \ 46 | coord3d.h \ 47 | log4qtdef.h \ 48 | renderarea.h \ 49 | positem.h \ 50 | renderitemlist.h \ 51 | lineitem.h \ 52 | itemtobase.h \ 53 | arcitem.h \ 54 | pointitem.h \ 55 | termiosext.h \ 56 | controlparams.h \ 57 | version.h 58 | 59 | FORMS += mainwindow.ui \ 60 | options.ui \ 61 | grbldialog.ui \ 62 | about.ui 63 | 64 | RESOURCES += GrblController.qrc 65 | 66 | RC_FILE = grbl.rc 67 | 68 | OTHER_FILES += \ 69 | android/AndroidManifest.xml \ 70 | android/res/drawable/icon.png \ 71 | android/res/drawable/logo.png \ 72 | android/res/drawable-hdpi/icon.png \ 73 | android/res/drawable-ldpi/icon.png \ 74 | android/res/drawable-mdpi/icon.png \ 75 | android/res/layout/splash.xml \ 76 | android/res/values/libs.xml \ 77 | android/res/values/strings.xml \ 78 | android/res/values-de/strings.xml \ 79 | android/res/values-el/strings.xml \ 80 | android/res/values-es/strings.xml \ 81 | android/res/values-et/strings.xml \ 82 | android/res/values-fa/strings.xml \ 83 | android/res/values-fr/strings.xml \ 84 | android/res/values-id/strings.xml \ 85 | android/res/values-it/strings.xml \ 86 | android/res/values-ja/strings.xml \ 87 | android/res/values-ms/strings.xml \ 88 | android/res/values-nb/strings.xml \ 89 | android/res/values-nl/strings.xml \ 90 | android/res/values-pl/strings.xml \ 91 | android/res/values-pt-rBR/strings.xml \ 92 | android/res/values-ro/strings.xml \ 93 | android/res/values-rs/strings.xml \ 94 | android/res/values-ru/strings.xml \ 95 | android/res/values-zh-rCN/strings.xml \ 96 | android/res/values-zh-rTW/strings.xml \ 97 | android/src/org/kde/necessitas/ministro/IMinistro.aidl \ 98 | android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \ 99 | android/src/org/kde/necessitas/origo/QtActivity.java \ 100 | android/src/org/kde/necessitas/origo/QtApplication.java \ 101 | android/version.xml 102 | 103 | # Translations 104 | TRANSLATIONS += trlocale/GrblController_xx.ts 105 | TRANSLATIONS += trlocale/GrblController_fr.ts 106 | -------------------------------------------------------------------------------- /GrblController.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Grbl Controller" 5 | #define MyAppVersion "3.6.1" 6 | #define MyAppPublisher "Zapmaker" 7 | #define MyAppURL "http://zapmaker.org" 8 | #define MyAppExeName "GrblController.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. 12 | ; Do not use the same AppId value in installers for other applications. 13 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 14 | AppId={{2DC56D0D-0673-4954-9BDE-3D664965BA97} 15 | AppName={#MyAppName} 16 | AppVersion={#MyAppVersion} 17 | ;AppVerName={#MyAppName} {#MyAppVersion} 18 | AppPublisher={#MyAppPublisher} 19 | AppPublisherURL={#MyAppURL} 20 | AppSupportURL={#MyAppURL} 21 | AppUpdatesURL={#MyAppURL} 22 | DefaultDirName={pf}\{#MyAppName} 23 | DefaultGroupName={#MyAppName} 24 | AllowNoIcons=yes 25 | LicenseFile=C:\dev\github\GrblHoming\winlicense.txt 26 | InfoBeforeFile=C:\dev\github\GrblHoming\wininfobefore.txt 27 | InfoAfterFile=C:\dev\github\GrblHoming\wininfoafter.txt 28 | OutputBaseFilename=GrblController361Setup 29 | Compression=lzma 30 | SolidCompression=yes 31 | 32 | [Languages] 33 | Name: "english"; MessagesFile: "compiler:Default.isl" 34 | 35 | [Tasks] 36 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 37 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 38 | 39 | [Files] 40 | Source: "C:\dev\github\GrblHoming\release\GrblController.exe"; DestDir: "{app}"; Flags: ignoreversion 41 | Source: "C:\dev\github\GrblHoming\trlocale\*.qm"; DestDir: "{app}\trlocale"; Flags: ignoreversion 42 | Source: "C:\Qt\4.8.3\bin\libgcc_s_dw2-1.dll"; DestDir: "{app}"; Flags: ignoreversion 43 | Source: "C:\Qt\4.8.3\bin\mingwm10.dll"; DestDir: "{app}"; Flags: ignoreversion 44 | Source: "C:\Qt\4.8.3\bin\QtCore4.dll"; DestDir: "{app}"; Flags: ignoreversion 45 | Source: "C:\Qt\4.8.3\bin\QtGui4.dll"; DestDir: "{app}"; Flags: ignoreversion 46 | Source: "C:\mingw\bin\libstdc++-6.dll"; DestDir: "{app}"; Flags: ignoreversion 47 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 48 | 49 | [Icons] 50 | Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 51 | Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" 52 | Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" 53 | Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 54 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon 55 | 56 | [Run] 57 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 58 | 59 | -------------------------------------------------------------------------------- /GrblController.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/down.PNG 4 | img/left.PNG 5 | img/logotiny.PNG 6 | img/right.PNG 7 | img/up.PNG 8 | img/zapmaker-logo-130.png 9 | 10 | 11 | -------------------------------------------------------------------------------- /QextSerialPort/qextserialenumerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2000-2003 Wayne Roth 3 | ** Copyright (c) 2004-2007 Stefan Sander 4 | ** Copyright (c) 2007 Michal Policht 5 | ** Copyright (c) 2008 Brandon Fosdick 6 | ** Copyright (c) 2009-2010 Liam Staskawicz 7 | ** Copyright (c) 2011 Debao Zhang 8 | ** All right reserved. 9 | ** Web: http://code.google.com/p/qextserialport/ 10 | ** 11 | ** Permission is hereby granted, free of charge, to any person obtaining 12 | ** a copy of this software and associated documentation files (the 13 | ** "Software"), to deal in the Software without restriction, including 14 | ** without limitation the rights to use, copy, modify, merge, publish, 15 | ** distribute, sublicense, and/or sell copies of the Software, and to 16 | ** permit persons to whom the Software is furnished to do so, subject to 17 | ** the following conditions: 18 | ** 19 | ** The above copyright notice and this permission notice shall be 20 | ** included in all copies or substantial portions of the Software. 21 | ** 22 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | ** 30 | ****************************************************************************/ 31 | 32 | #ifndef _QEXTSERIALENUMERATOR_H_ 33 | #define _QEXTSERIALENUMERATOR_H_ 34 | 35 | #include 36 | #include 37 | #include "qextserialport_global.h" 38 | 39 | struct QextPortInfo { 40 | QString portName; ///< Port name. 41 | QString physName; ///< Physical name. 42 | QString friendName; ///< Friendly name. 43 | QString enumName; ///< Enumerator name. 44 | int vendorID; ///< Vendor ID. 45 | int productID; ///< Product ID 46 | }; 47 | 48 | class QextSerialEnumeratorPrivate; 49 | class QEXTSERIALPORT_EXPORT QextSerialEnumerator : public QObject 50 | { 51 | Q_OBJECT 52 | Q_DECLARE_PRIVATE(QextSerialEnumerator) 53 | public: 54 | QextSerialEnumerator(QObject *parent=0); 55 | ~QextSerialEnumerator(); 56 | 57 | static QList getPorts(); 58 | void setUpNotifications(); 59 | 60 | Q_SIGNALS: 61 | void deviceDiscovered(const QextPortInfo &info); 62 | void deviceRemoved(const QextPortInfo &info); 63 | 64 | private: 65 | Q_DISABLE_COPY(QextSerialEnumerator) 66 | #if defined(Q_OS_LINUX) && !defined(QESP_NO_UDEV) 67 | Q_PRIVATE_SLOT(d_func(), void _q_deviceEvent()) 68 | #endif 69 | QextSerialEnumeratorPrivate *d_ptr; 70 | }; 71 | 72 | #endif /*_QEXTSERIALENUMERATOR_H_*/ 73 | -------------------------------------------------------------------------------- /QextSerialPort/qextserialenumerator_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2000-2003 Wayne Roth 3 | ** Copyright (c) 2004-2007 Stefan Sander 4 | ** Copyright (c) 2007 Michal Policht 5 | ** Copyright (c) 2008 Brandon Fosdick 6 | ** Copyright (c) 2009-2010 Liam Staskawicz 7 | ** Copyright (c) 2011 Debao Zhang 8 | ** Copyright (c) 2012 Doug Brown 9 | ** All right reserved. 10 | ** Web: http://code.google.com/p/qextserialport/ 11 | ** 12 | ** Permission is hereby granted, free of charge, to any person obtaining 13 | ** a copy of this software and associated documentation files (the 14 | ** "Software"), to deal in the Software without restriction, including 15 | ** without limitation the rights to use, copy, modify, merge, publish, 16 | ** distribute, sublicense, and/or sell copies of the Software, and to 17 | ** permit persons to whom the Software is furnished to do so, subject to 18 | ** the following conditions: 19 | ** 20 | ** The above copyright notice and this permission notice shall be 21 | ** included in all copies or substantial portions of the Software. 22 | ** 23 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | ** 31 | ****************************************************************************/ 32 | #ifndef _QEXTSERIALENUMERATOR_P_H_ 33 | #define _QEXTSERIALENUMERATOR_P_H_ 34 | 35 | // 36 | // W A R N I N G 37 | // ------------- 38 | // 39 | // This file is not part of the QESP API. It exists for the convenience 40 | // of other QESP classes. This header file may change from version to 41 | // version without notice, or even be removed. 42 | // 43 | // We mean it. 44 | // 45 | 46 | #include "qextserialenumerator.h" 47 | 48 | #ifdef Q_OS_WIN 49 | // needed for mingw to pull in appropriate dbt business... 50 | // probably a better way to do this 51 | // http://mingw-users.1079350.n2.nabble.com/DEV-BROADCAST-DEVICEINTERFACE-was-not-declared-in-this-scope-td3552762.html 52 | # ifdef __MINGW32__ 53 | # ifndef _WIN32_WINNT 54 | # define _WIN32_WINNT 0x0500 55 | # endif 56 | # ifndef _WIN32_WINDOWS 57 | # define _WIN32_WINDOWS 0x0500 58 | # endif 59 | # ifndef WINVER 60 | # define WINVER 0x0500 61 | # endif 62 | # endif 63 | # include 64 | #endif /*Q_OS_WIN*/ 65 | 66 | #ifdef Q_OS_MAC 67 | # include 68 | #endif /*Q_OS_MAC*/ 69 | 70 | #if defined(Q_OS_LINUX) && !defined(QESP_NO_UDEV) 71 | # include 72 | extern "C" { 73 | # include 74 | } 75 | #endif 76 | 77 | class QextSerialRegistrationWidget; 78 | class QextSerialEnumeratorPrivate 79 | { 80 | Q_DECLARE_PUBLIC(QextSerialEnumerator) 81 | public: 82 | QextSerialEnumeratorPrivate(QextSerialEnumerator *enumrator); 83 | ~QextSerialEnumeratorPrivate(); 84 | void platformSpecificInit(); 85 | void platformSpecificDestruct(); 86 | 87 | static QList getPorts_sys(); 88 | bool setUpNotifications_sys(bool setup); 89 | 90 | #ifdef Q_OS_WIN 91 | LRESULT onDeviceChanged(WPARAM wParam, LPARAM lParam); 92 | bool matchAndDispatchChangedDevice(const QString &deviceID, const GUID &guid, WPARAM wParam); 93 | # ifdef QT_GUI_LIB 94 | QextSerialRegistrationWidget *notificationWidget; 95 | # endif 96 | #endif /*Q_OS_WIN*/ 97 | 98 | #ifdef Q_OS_MAC 99 | /*! 100 | * Search for serial ports using IOKit. 101 | * \param infoList list with result. 102 | */ 103 | static void iterateServicesOSX(io_object_t service, QList &infoList); 104 | static bool getServiceDetailsOSX(io_object_t service, QextPortInfo *portInfo); 105 | void onDeviceDiscoveredOSX(io_object_t service); 106 | void onDeviceTerminatedOSX(io_object_t service); 107 | friend void deviceDiscoveredCallbackOSX(void *ctxt, io_iterator_t serialPortIterator); 108 | friend void deviceTerminatedCallbackOSX(void *ctxt, io_iterator_t serialPortIterator); 109 | 110 | IONotificationPortRef notificationPortRef; 111 | #endif // Q_OS_MAC 112 | 113 | #if defined(Q_OS_LINUX) && !defined(QESP_NO_UDEV) 114 | QSocketNotifier *notifier; 115 | int notifierFd; 116 | struct udev *udev; 117 | struct udev_monitor *monitor; 118 | 119 | void _q_deviceEvent(); 120 | #endif 121 | 122 | private: 123 | QextSerialEnumerator *q_ptr; 124 | }; 125 | 126 | #endif //_QEXTSERIALENUMERATOR_P_H_ 127 | -------------------------------------------------------------------------------- /QextSerialPort/qextserialenumerator_unix.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2000-2003 Wayne Roth 3 | ** Copyright (c) 2004-2007 Stefan Sander 4 | ** Copyright (c) 2007 Michal Policht 5 | ** Copyright (c) 2008 Brandon Fosdick 6 | ** Copyright (c) 2009-2010 Liam Staskawicz 7 | ** Copyright (c) 2011 Debao Zhang 8 | ** All right reserved. 9 | ** Web: http://code.google.com/p/qextserialport/ 10 | ** 11 | ** Permission is hereby granted, free of charge, to any person obtaining 12 | ** a copy of this software and associated documentation files (the 13 | ** "Software"), to deal in the Software without restriction, including 14 | ** without limitation the rights to use, copy, modify, merge, publish, 15 | ** distribute, sublicense, and/or sell copies of the Software, and to 16 | ** permit persons to whom the Software is furnished to do so, subject to 17 | ** the following conditions: 18 | ** 19 | ** The above copyright notice and this permission notice shall be 20 | ** included in all copies or substantial portions of the Software. 21 | ** 22 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | ** 30 | ****************************************************************************/ 31 | 32 | #include "qextserialenumerator.h" 33 | #include "qextserialenumerator_p.h" 34 | #include 35 | 36 | void QextSerialEnumeratorPrivate::platformSpecificInit() 37 | { 38 | } 39 | 40 | void QextSerialEnumeratorPrivate::platformSpecificDestruct() 41 | { 42 | } 43 | 44 | QList QextSerialEnumeratorPrivate::getPorts_sys() 45 | { 46 | QList infoList; 47 | QESP_WARNING("Enumeration for POSIX systems (except Linux) is not implemented yet."); 48 | return infoList; 49 | } 50 | 51 | bool QextSerialEnumeratorPrivate::setUpNotifications_sys(bool setup) 52 | { 53 | Q_UNUSED(setup) 54 | QESP_WARNING("Notifications for *Nix/FreeBSD are not implemented yet"); 55 | return false; 56 | } 57 | -------------------------------------------------------------------------------- /QextSerialPort/qextserialport.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | PUBLIC_HEADERS += $$PWD/qextserialport.h \ 5 | $$PWD/qextserialenumerator.h \ 6 | $$PWD/qextserialport_global.h 7 | 8 | HEADERS += $$PUBLIC_HEADERS \ 9 | $$PWD/qextserialport_p.h \ 10 | $$PWD/qextserialenumerator_p.h \ 11 | 12 | SOURCES += $$PWD/qextserialport.cpp \ 13 | $$PWD/qextserialenumerator.cpp 14 | unix { 15 | SOURCES += $$PWD/qextserialport_unix.cpp 16 | linux* { 17 | SOURCES += $$PWD/qextserialenumerator_linux.cpp 18 | } else:macx { 19 | SOURCES += $$PWD/qextserialenumerator_osx.cpp 20 | } else { 21 | SOURCES += $$PWD/qextserialenumerator_unix.cpp 22 | } 23 | } 24 | win32:SOURCES += $$PWD/qextserialport_win.cpp \ 25 | $$PWD/qextserialenumerator_win.cpp 26 | 27 | linux*{ 28 | !qesp_linux_udev:DEFINES += QESP_NO_UDEV 29 | qesp_linux_udev: LIBS += -ludev 30 | } 31 | 32 | macx:LIBS += -framework IOKit -framework CoreFoundation 33 | win32:LIBS += -lsetupapi -ladvapi32 -luser32 34 | 35 | # moc doesn't detect Q_OS_LINUX correctly, so add this to make it work 36 | linux*:DEFINES += __linux__ 37 | -------------------------------------------------------------------------------- /QextSerialPort/qextserialport_global.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2000-2003 Wayne Roth 3 | ** Copyright (c) 2004-2007 Stefan Sander 4 | ** Copyright (c) 2007 Michal Policht 5 | ** Copyright (c) 2008 Brandon Fosdick 6 | ** Copyright (c) 2009-2010 Liam Staskawicz 7 | ** Copyright (c) 2011 Debao Zhang 8 | ** All right reserved. 9 | ** Web: http://code.google.com/p/qextserialport/ 10 | ** 11 | ** Permission is hereby granted, free of charge, to any person obtaining 12 | ** a copy of this software and associated documentation files (the 13 | ** "Software"), to deal in the Software without restriction, including 14 | ** without limitation the rights to use, copy, modify, merge, publish, 15 | ** distribute, sublicense, and/or sell copies of the Software, and to 16 | ** permit persons to whom the Software is furnished to do so, subject to 17 | ** the following conditions: 18 | ** 19 | ** The above copyright notice and this permission notice shall be 20 | ** included in all copies or substantial portions of the Software. 21 | ** 22 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 | ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | ** 30 | ****************************************************************************/ 31 | 32 | #ifndef QEXTSERIALPORT_GLOBAL_H 33 | #define QEXTSERIALPORT_GLOBAL_H 34 | 35 | #include 36 | 37 | #ifdef QEXTSERIALPORT_BUILD_SHARED 38 | # define QEXTSERIALPORT_EXPORT Q_DECL_EXPORT 39 | #elif defined(QEXTSERIALPORT_USING_SHARED) 40 | # define QEXTSERIALPORT_EXPORT Q_DECL_IMPORT 41 | #else 42 | # define QEXTSERIALPORT_EXPORT 43 | #endif 44 | 45 | // ### for compatible with old version. should be removed in QESP 2.0 46 | #ifdef _TTY_NOWARN_ 47 | # define QESP_NO_WARN 48 | #endif 49 | #ifdef _TTY_NOWARN_PORT_ 50 | # define QESP_NO_PORTABILITY_WARN 51 | #endif 52 | 53 | /*if all warning messages are turned off, flag portability warnings to be turned off as well*/ 54 | #ifdef QESP_NO_WARN 55 | # define QESP_NO_PORTABILITY_WARN 56 | #endif 57 | 58 | /*macros for warning and debug messages*/ 59 | #ifdef QESP_NO_PORTABILITY_WARN 60 | # define QESP_PORTABILITY_WARNING while (false)qWarning 61 | #else 62 | # define QESP_PORTABILITY_WARNING qWarning 63 | #endif /*QESP_NOWARN_PORT*/ 64 | 65 | #ifdef QESP_NO_WARN 66 | # define QESP_WARNING while (false)qWarning 67 | #else 68 | # define QESP_WARNING qWarning 69 | #endif /*QESP_NOWARN*/ 70 | 71 | #endif // QEXTSERIALPORT_GLOBAL_H 72 | 73 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | This file contains enhancements the developer and user community would like to see: 2 | 3 | 4 | Planned for 3.4.x 5 | - Bug fixes 6 | Planned for 3.5: 7 | - (What is the problem here? Run is shown, then Idle when stopped) Detect machine state at end of run and display it properly (i.e. "transitioning" when it is still moving) 8 | - Every second or so, if not scrolled to bottom, scroll to bottom of status 9 | - Allow reload of same file from same location 10 | - After a run, suppress $$ output with a single line 11 | - Report system settings at beginning of log file. Include OS. 12 | - Can't see drill holes under axis, move axes under toolpaths? 13 | - Create test plan (i.e. verify all text appears correctly on all platforms) 14 | - Display detected version of Grbl 15 | - Speed limit for X and Y like the Z speed limit 16 | 17 | Planned for 3.6: 18 | - Implement support for Grbl 0.8c "homing" feature (using limit switches) 19 | - UI support for homing limit switches 20 | - Restore "Tool change" feature, including popup dialog 21 | - Option to engage stepper lock (include fade out rate setting - start time of fade, end time of fade, requires hw mod) 22 | - Display current feedrate in mm/sec or in/sec 23 | - Add additional rs232 error logging value (-1 is not very useful) 24 | - Analyze file ahead of time and determine if it will go beyond extents 25 | - Update manual since 3.3 26 | 27 | Planned for 3.7 28 | - Switch to compiling using Qt 5 29 | - Auto-scale widgets to full screen size 30 | - Localization ready code 31 | - Don't fail on timeout waiting for command - let user continue if they want 32 | - Pick up from where left off (if GC dies due to PC falling asleep, etc.) 33 | - Look at all hardware connection options of Grbl on the shield and make 34 | sure that we have some way to control those, i.e. spindle control. 35 | - Clear log button 36 | - Print current GRBL settings 37 | - Add option to always use last working port, even if it isn't currently connected 38 | 39 | Primary: 40 | - Save/Load current GRBL settings from disk 41 | - Suppress some bookkeeping output from the status window 42 | - Add local Help linked from main screen and options dialog 43 | - When parsing for visualizer, if bad value arg, warn user 44 | - If nothing appears in visualizer, attempt to diagnose and explain to user 45 | - If get error from grbl, provide command that generated error on same line 46 | - Allow user to choose how to handle unspecified units in file for visualizer 47 | - Fix Zero position next to begin? 48 | - Show drill holes as larger dots? 49 | - Build in calibration pattern 50 | - Build in "flatten table feature" 51 | - File viewer 52 | - Estimate bounds based on both toolpaths and tool diameter, not just toolpaths 53 | 54 | Secondary: 55 | - Make GC generic to support controllers other than Grbl 56 | - Recent files list under 'Files' 57 | - Restore "Favorites" feature 58 | - Provide diagnostic response view 59 | - Provide counter showing time waiting for a response if time > 5s 60 | - Estimated time to completion (this can acutally be computed from feedrates) 61 | 62 | Notes pulled from https://github.com/grbl/grbl/issues/202 63 | 64 | Move Z to upper clear position. (<- another parameter?) 65 | Stop the spindle. 66 | X and Y to the change tool coordinates. 67 | A way to adjust new Z (manual for me) and perhaps new speed for the spindle (manual for me). 68 | When ready (~) start cycle? to continue with the new tool with the same X and Y initial coordinates than the last tool. -------------------------------------------------------------------------------- /about.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * about.cpp 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #include "about.h" 11 | #include "version.h" 12 | #include "ui_about.h" 13 | 14 | About::About(QWidget *parent) : 15 | QDialog(parent), 16 | ui(new Ui::About) 17 | { 18 | ui->setupUi(this); 19 | 20 | ui->labelProductAndVersion->setText(GRBL_CONTROLLER_NAME_AND_VERSION); 21 | } 22 | 23 | About::~About() 24 | { 25 | delete ui; 26 | } 27 | -------------------------------------------------------------------------------- /about.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * about.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef ABOUT_H 11 | #define ABOUT_H 12 | 13 | #include 14 | #include "definitions.h" 15 | 16 | namespace Ui { 17 | class About; 18 | } 19 | 20 | class About : public QDialog 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit About(QWidget *parent = 0); 26 | ~About(); 27 | 28 | private: 29 | Ui::About *ui; 30 | }; 31 | 32 | #endif // ABOUT_H 33 | -------------------------------------------------------------------------------- /about.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | About 4 | 5 | 6 | 7 | 0 8 | 0 9 | 414 10 | 214 11 | 12 | 13 | 14 | About... 15 | 16 | 17 | 18 | 19 | 40 20 | 170 21 | 341 22 | 32 23 | 24 | 25 | 26 | Qt::Horizontal 27 | 28 | 29 | QDialogButtonBox::Ok 30 | 31 | 32 | 33 | 34 | 35 | 10 36 | 30 37 | 151 38 | 61 39 | 40 | 41 | 42 | 43 | 44 | 45 | Qt::PlainText 46 | 47 | 48 | :/img/logotiny.PNG 49 | 50 | 51 | 52 | 53 | 54 | 180 55 | 70 56 | 201 57 | 91 58 | 59 | 60 | 61 | The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 62 | 63 | 64 | true 65 | 66 | 67 | 68 | 69 | 70 | 180 71 | 10 72 | 211 73 | 51 74 | 75 | 76 | 77 | 78 | 12 79 | 75 80 | true 81 | 82 | 83 | 84 | Grbl Controller 85 | 86 | 87 | 88 | 89 | 90 | 330 91 | 10 92 | 71 93 | 16 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 20 104 | 120 105 | 130 106 | 33 107 | 108 | 109 | 110 | 111 | 112 | 113 | :/img/zapmaker-logo-130.png 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | buttonBox 123 | accepted() 124 | About 125 | accept() 126 | 127 | 128 | 248 129 | 254 130 | 131 | 132 | 157 133 | 274 134 | 135 | 136 | 137 | 138 | buttonBox 139 | rejected() 140 | About 141 | reject() 142 | 143 | 144 | 316 145 | 260 146 | 147 | 148 | 286 149 | 274 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /arcitem.cpp: -------------------------------------------------------------------------------- 1 | #include "arcitem.h" 2 | 3 | ArcItem::ArcItem(double sx1, double sy1, double ex1, double ey1, double centx1, double centy1, bool cw1, int index1) 4 | : ItemToBase(index1), sx(sx1), sy(sy1), ex(ex1), ey(ey1), centx(centx1), centy(centy1), cw(cw1), radius(0), angleStart(0), angleDelta(0) 5 | { 6 | } 7 | 8 | PosItem ArcItem::computeExtents() 9 | { 10 | PosItem extents(sx, sy, ex, ey); 11 | 12 | radius = qSqrt(((sx - centx) * (sx - centx)) + ((sy - centy) * (sy - centy))); 13 | 14 | if (cw) 15 | { 16 | double angle1 = qAtan2(ey - centy, ex - centx); 17 | double angle2 = qAtan2(sy - centy, sx - centx); 18 | 19 | if (angle1 > 0 && angle2 < 0) 20 | angle2 += TWO_PI; 21 | 22 | angleStart = angle2; 23 | angleDelta = angle1 - angle2; 24 | } 25 | else 26 | { 27 | double angle1 = qAtan2(sy - centy, sx - centx); 28 | double angle2 = qAtan2(ey - centy, ex - centx); 29 | 30 | if (angle1 > 0 && angle2 < 0) 31 | angle2 += TWO_PI; 32 | 33 | angleStart = angle2; 34 | angleDelta = angle1 - angle2; 35 | } 36 | 37 | // sample points along the curve 38 | double angleEnd = angleStart + angleDelta; 39 | for (double angle = angleStart; 40 | (angleDelta < 0 ? angle > angleEnd : angle < angleEnd); 41 | angle += (angleDelta < 0 ? -0.4 : 0.4)) 42 | { 43 | double x = qCos(angle) * radius + centx; 44 | double y = qSin(angle) * radius + centy; 45 | 46 | PosItem curr(x, y, x, y); 47 | 48 | // expand rectange if it exceeds our last rectangle 49 | extents.expand(curr); 50 | } 51 | 52 | return extents; 53 | } 54 | 55 | void ArcItem::addToPath(QPainterPath& path) 56 | { 57 | // need to convert our coordinates into arcTo arguments (rectangle boxes and angles, etc.) 58 | // Also, we are at this point in screen coordinates, not machine coordinates, i.e. Y positive is down! 59 | 60 | // first, we know for a fact that we are dealing with a circular arc, not an ellipse 61 | // (code could be put here to verify that is true) 62 | // Thus our radius is also our bounding box determined from the center of the arc/circle 63 | 64 | if (cw) 65 | { 66 | path.moveTo(screenX(sx), screenY(sy)); 67 | } 68 | else 69 | { 70 | path.moveTo(screenX(ex), screenY(ey)); 71 | } 72 | 73 | double x = centx - radius; 74 | double y = centy + radius; 75 | double wd = radius * 2; 76 | double ht = wd; 77 | 78 | double fx = screenX(x); 79 | double fy = screenY(y); 80 | double w = wd * scale; 81 | double h = ht * scale; 82 | 83 | double angleStartDeg = toDegrees(angleStart); 84 | double angleDeltaDeg = toDegrees(angleDelta); 85 | 86 | path.arcTo(fx, fy, w, h, angleStartDeg, angleDeltaDeg); 87 | 88 | path.moveTo(screenX(ex), screenY(ey)); 89 | } 90 | 91 | void ArcItem::moveToFirst(QPainterPath& path) 92 | { 93 | // not applicable! generate error! 94 | Q_UNUSED(path); 95 | } 96 | 97 | double ArcItem::getXScr() 98 | { 99 | return screenX(ex); 100 | } 101 | 102 | double ArcItem::getYScr() 103 | { 104 | return screenY(ey); 105 | } 106 | 107 | double ArcItem::getXRaw() 108 | { 109 | return ex; 110 | } 111 | 112 | double ArcItem::getYRaw() 113 | { 114 | return ey; 115 | } 116 | 117 | double ArcItem::toDegrees(double rad) 118 | { 119 | return 360 * rad / TWO_PI; 120 | } 121 | -------------------------------------------------------------------------------- /arcitem.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCITEM_H 2 | #define ARCITEM_H 3 | #include 4 | #include "itemtobase.h" 5 | 6 | #define TWO_PI (2 * 3.1415926) 7 | 8 | class ArcItem : public ItemToBase 9 | { 10 | public: 11 | ArcItem(double sx1, double sy1, double ex1, double ey1, double centx1, double centy1, bool cw, int index); 12 | 13 | void moveToFirst(QPainterPath& path); 14 | void addToPath(QPainterPath& path); 15 | PosItem computeExtents(); 16 | 17 | double getXScr(); 18 | double getYScr(); 19 | double getXRaw(); 20 | double getYRaw(); 21 | 22 | double toDegrees(double rad); 23 | 24 | private: 25 | double sx; 26 | double sy; 27 | double ex; 28 | double ey; 29 | double centx; 30 | double centy; 31 | bool cw; 32 | 33 | double radius; 34 | double angleStart; 35 | double angleDelta; 36 | 37 | }; 38 | 39 | #endif // ARCITEM_H 40 | -------------------------------------------------------------------------------- /atomicintbool.cpp: -------------------------------------------------------------------------------- 1 | #include "atomicintbool.h" 2 | 3 | AtomicIntBool::AtomicIntBool(int newValue /* = 0 */) 4 | : value(newValue) 5 | { 6 | } 7 | 8 | void AtomicIntBool::set(int newValue) 9 | { 10 | value.fetchAndStoreRelaxed(newValue); 11 | } 12 | 13 | int AtomicIntBool::get() 14 | { 15 | return value.fetchAndAddRelaxed(0); 16 | } 17 | /* 18 | int AtomicIntBool::getAndClear() 19 | { 20 | return value.fetchAndStoreRelease(0); 21 | } 22 | */ 23 | -------------------------------------------------------------------------------- /atomicintbool.h: -------------------------------------------------------------------------------- 1 | #ifndef ATOMICINTBOOL_H 2 | #define ATOMICINTBOOL_H 3 | 4 | #include 5 | 6 | // we wrap QAtomicInt because it is possible to accidentally 7 | // access the non-atomic operations of the class (look at the 8 | // header for QAtomicInt to see what I mean, and thus setting 9 | // a value directly against one of these variables will access 10 | // the non-atomic method) 11 | class AtomicIntBool 12 | { 13 | public: 14 | AtomicIntBool(int newValue = 0); 15 | void set(int newValue); 16 | int get(); 17 | 18 | private: 19 | QAtomicInt value; 20 | }; 21 | 22 | #endif // ATOMICINTBOOL_H 23 | -------------------------------------------------------------------------------- /controlparams.cpp: -------------------------------------------------------------------------------- 1 | #include "controlparams.h" 2 | 3 | ControlParams::ControlParams() 4 | : waitTime(LONG_WAIT_SEC), zJogRate(DEFAULT_Z_JOG_RATE), 5 | useMm(true), zRateLimit(false), zRateLimitAmount(DEFAULT_Z_LIMIT_RATE), 6 | xyRateAmount(DEFAULT_XY_RATE), 7 | useAggressivePreload(false), filterFileCommands(false), 8 | reducePrecision(false), grblLineBufferLen(DEFAULT_GRBL_LINE_BUFFER_LEN), 9 | useFourAxis(false), charSendDelayMs(DEFAULT_CHAR_SEND_DELAY_MS), 10 | fourthAxisType(FOURTH_AXIS_A), usePositionRequest(true), 11 | positionRequestType(PREQ_ALWAYS_NO_IDLE_CHK), postionRequestTimeMilliSec(DEFAULT_POS_REQ_FREQ_MSEC), 12 | waitForJogToComplete(true) 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /controlparams.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTROLPARAMS_H 2 | #define CONTROLPARAMS_H 3 | 4 | #include "definitions.h" 5 | 6 | #define SHORT_WAIT_SEC 2 7 | #define LONG_WAIT_SEC 100 8 | 9 | class ControlParams 10 | { 11 | public: 12 | ControlParams(); 13 | 14 | public: 15 | int waitTime; 16 | double zJogRate; 17 | bool useMm; 18 | bool zRateLimit; 19 | double zRateLimitAmount; 20 | double xyRateAmount; 21 | bool useAggressivePreload; 22 | bool filterFileCommands; 23 | bool reducePrecision; 24 | int grblLineBufferLen; 25 | bool useFourAxis; 26 | int charSendDelayMs; 27 | char fourthAxisType; 28 | bool usePositionRequest; 29 | QString positionRequestType; 30 | int postionRequestTimeMilliSec; 31 | bool waitForJogToComplete; 32 | }; 33 | 34 | #endif // CONTROLPARAMS_H 35 | -------------------------------------------------------------------------------- /coord3d.cpp: -------------------------------------------------------------------------------- 1 | #include "coord3d.h" 2 | 3 | Coord3D::Coord3D() 4 | : x(0.0), y(0.0), z(0.0), fourth(0.0), stoppedZ(true), sliderZIndex(0) 5 | { 6 | } 7 | 8 | bool Coord3D::operator==(const Coord3D& rhs) 9 | { 10 | return (x == rhs.x && y == rhs.y && z == rhs.z && fourth == rhs.fourth) ; 11 | } 12 | -------------------------------------------------------------------------------- /coord3d.h: -------------------------------------------------------------------------------- 1 | #ifndef COORD3D_H 2 | #define COORD3D_H 3 | 4 | #include 5 | 6 | class Coord3D 7 | { 8 | public: 9 | Coord3D(); 10 | bool operator==(const Coord3D& rhs); 11 | 12 | public: 13 | float x; 14 | float y; 15 | float z; 16 | float fourth; 17 | bool stoppedZ; 18 | int sliderZIndex; 19 | }; 20 | 21 | Q_DECLARE_METATYPE ( Coord3D ) 22 | 23 | #endif // COORD3D_H 24 | -------------------------------------------------------------------------------- /definitions.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * definitions.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef DEFINITIONS_H 11 | #define DEFINITIONS_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include "atomicintbool.h" 17 | 18 | #define DEFAULT_WAIT_TIME_SEC 100 19 | 20 | #define DEFAULT_Z_JOG_RATE 260.0 21 | #define DEFAULT_Z_LIMIT_RATE 100.0 22 | #define DEFAULT_XY_RATE 2000.0 23 | 24 | #define DEFAULT_GRBL_LINE_BUFFER_LEN 50 25 | #define DEFAULT_CHAR_SEND_DELAY_MS 0 26 | 27 | #define MM_IN_AN_INCH 25.4 28 | #define PRE_HOME_Z_ADJ_MM 5.0 29 | 30 | #define REQUEST_CURRENT_POS "?" 31 | #define SETTINGS_COMMAND_V08a "$" 32 | #define SETTINGS_COMMAND_V08c "$$" 33 | #define REQUEST_PARSER_STATE_V08c "$G" 34 | #define SET_UNLOCK_STATE_V08c "$X" 35 | 36 | #define REGEXP_SETTINGS_LINE "(\\d+)\\s*=\\s*([\\w\\.]+)\\s*\\(([^\\)]*)\\)" 37 | 38 | #define OPEN_BUTTON_TEXT "Open" 39 | #define CLOSE_BUTTON_TEXT "Close / Reset" 40 | 41 | #define LOG_MSG_TYPE_DIAG "DIAG" 42 | #define LOG_MSG_TYPE_STATUS "STATUS" 43 | 44 | /// LETARTARE : one axis choice U or V or W or A or B or C 45 | #define FOURTH_AXIS_U 'U' 46 | #define FOURTH_AXIS_V 'V' 47 | #define FOURTH_AXIS_W 'W' 48 | /// <-- 49 | #define FOURTH_AXIS_A 'A' 50 | #define FOURTH_AXIS_B 'B' 51 | #define FOURTH_AXIS_C 'C' 52 | 53 | #define PREQ_ALWAYS "always" 54 | #define PREQ_ALWAYS_NO_IDLE_CHK "alwaysWithoutIdleChk" 55 | #define PREQ_NOT_WHEN_MANUAL "notWhenManual" 56 | 57 | #define DEFAULT_POS_REQ_FREQ_SEC 1.0 58 | #define DEFAULT_POS_REQ_FREQ_MSEC 1000 59 | 60 | extern AtomicIntBool g_enableDebugLog; 61 | 62 | void status(const char *str, ...); 63 | void diag(const char *str, ...); 64 | void err(const char *str, ...); 65 | void warn(const char *str, ...); 66 | void info(const char *str, ...); 67 | 68 | #endif // DEFINITIONS_H 69 | -------------------------------------------------------------------------------- /grbl.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/grbl.ico -------------------------------------------------------------------------------- /grbl.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON_GRBL ICON DISCARDABLE "grbl.ico" -------------------------------------------------------------------------------- /grbldialog.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * grbldialog.cpp 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #include "grbldialog.h" 11 | #include "ui_grbldialog.h" 12 | 13 | GrblDialog::GrblDialog(QWidget *parent, GCode *gc) : 14 | QDialog(parent), 15 | gcode(gc), 16 | ui(new Ui::GrblDialog), 17 | tableRowCount(0) 18 | { 19 | ui->setupUi(this); 20 | connect(ui->btnCancel,SIGNAL(clicked()),this,SLOT(Cancel())); 21 | connect(ui->btnOk,SIGNAL(clicked()),this,SLOT(Ok())); 22 | connect(this, SIGNAL(sendGcodeAndGetResult(int, QString)), gcode, SLOT(sendGcodeAndGetResult(int, QString))); 23 | connect(gcode, SIGNAL(gcodeResult(int, QString)), this, SLOT(gcodeResult(int, QString))); 24 | 25 | ui->btnCancel->setEnabled(false); 26 | ui->btnOk->setEnabled(false); 27 | 28 | QStringList labels; 29 | labels << tr("Value") << tr("Item"); 30 | ui->table->setHorizontalHeaderLabels(labels); 31 | #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) 32 | ui->table->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); 33 | #else 34 | ui->table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); 35 | #endif 36 | ui->table->verticalHeader()->hide(); 37 | ui->table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 38 | ui->table->setShowGrid(true); 39 | } 40 | 41 | GrblDialog::~GrblDialog() 42 | { 43 | delete ui; 44 | } 45 | 46 | void GrblDialog::getSettings() 47 | { 48 | emit sendGcodeAndGetResult(GDLG_CMD_ID_GET, SETTINGS_COMMAND_V08a); 49 | } 50 | 51 | void GrblDialog::gcodeResult(int id, QString result) 52 | { 53 | switch (id) 54 | { 55 | case GDLG_CMD_ID_GET: 56 | { 57 | originalValues.clear(); 58 | changeFlags.clear(); 59 | 60 | if (result.size() > 0) 61 | { 62 | QRegExp rx(QString("\\$") + REGEXP_SETTINGS_LINE); 63 | int pos = 0; 64 | QStringList fieldValues; 65 | QStringList descriptions; 66 | while ((pos = rx.indexIn(result, pos)) != -1) 67 | { 68 | int matched = rx.matchedLength(); 69 | //QString extracted = received.mid(pos, matched); 70 | pos += matched; 71 | 72 | if (rx.captureCount() > 0) 73 | { 74 | QStringList list = rx.capturedTexts(); 75 | if (list.size() == 4) 76 | { 77 | fieldValues.append(list.at(2)); 78 | descriptions.append(list.at(3)); 79 | } 80 | } 81 | } 82 | 83 | tableRowCount = fieldValues.size(); 84 | ui->table->setRowCount(0); 85 | ui->table->setColumnCount(2); 86 | 87 | int i; 88 | for (i = 0; i < tableRowCount; i++) 89 | { 90 | ui->table->insertRow(i); 91 | ui->table->setItem(i, 0, new QTableWidgetItem(fieldValues.at(i))); 92 | 93 | QTableWidgetItem *descWidget = new QTableWidgetItem(descriptions.at(i)); 94 | descWidget->setFlags(Qt::NoItemFlags); 95 | 96 | ui->table->setItem(i, 1, descWidget); 97 | 98 | ui->table->item(i, 0)->setFont(QFont("Tahoma",10,87,false)); 99 | ui->table->item(i, 1)->setFont(QFont("Tahoma",10,-1,false)); 100 | 101 | originalValues.append(fieldValues.at(i)); 102 | changeFlags.append(false); 103 | } 104 | 105 | ui->table->resizeColumnsToContents(); 106 | int colWidthValues = ui->table->columnWidth(0); 107 | ui->table->setColumnWidth(0, colWidthValues + 10); 108 | 109 | connect(ui->table,SIGNAL(cellChanged(int,int)),this,SLOT(changeValues(int,int))); 110 | } 111 | else 112 | { 113 | ui->table->setRowCount(0); 114 | ui->table->setColumnCount(2); 115 | } 116 | ui->btnCancel->setEnabled(true); 117 | ui->btnOk->setEnabled(true); 118 | break; 119 | } 120 | case GDLG_CMD_ID_SET: 121 | break; 122 | } 123 | } 124 | 125 | void GrblDialog::Cancel() 126 | { 127 | this->close(); 128 | } 129 | 130 | void GrblDialog::changeValues(int row, int col) 131 | { 132 | Q_UNUSED(col); 133 | 134 | if ((ui->table->item(row,0)->text() != originalValues.at(row)) 135 | && ui->table->item(row,0)->text().length() > 0) 136 | { 137 | changeFlags.replace(row, true); 138 | } 139 | } 140 | 141 | void GrblDialog::Ok() 142 | { 143 | for(int i = 0; i < tableRowCount; i++) 144 | { 145 | if (changeFlags.at(i) == true) 146 | { 147 | QString strline = "$"; 148 | strline.append(QString::number(i)).append("=").append(ui->table->item(i,0)->text()).append('\r'); 149 | emit sendGcodeAndGetResult(GDLG_CMD_ID_SET, strline); 150 | } 151 | } 152 | this->close(); 153 | } 154 | 155 | -------------------------------------------------------------------------------- /grbldialog.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * grbldialog.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef GRBLDIALOG_H 11 | #define GRBLDIALOG_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "definitions.h" 19 | #include "mainwindow.h" 20 | #include "gcode.h" 21 | 22 | namespace Ui { 23 | class GrblDialog; 24 | } 25 | 26 | #define GDLG_CMD_ID_GET 1 27 | #define GDLG_CMD_ID_SET 2 28 | 29 | 30 | class GrblDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit GrblDialog(QWidget *parent, GCode *gcode); 36 | ~GrblDialog(); 37 | 38 | //variables 39 | GCode *gcode; 40 | 41 | //methods 42 | void getSettings(); 43 | 44 | signals: 45 | void sendGcodeAndGetResult(int id, QString cmd); 46 | 47 | public slots: 48 | //buttons 49 | void Ok(); 50 | void Cancel(); 51 | //Column Widget 52 | void changeValues(int row, int col); 53 | void gcodeResult(int id, QString result); 54 | 55 | private: 56 | Ui::GrblDialog *ui; 57 | QStringList originalValues; 58 | QList changeFlags; 59 | int tableRowCount; 60 | 61 | }; 62 | 63 | #endif // GRBLDIALOG_H 64 | -------------------------------------------------------------------------------- /grbldialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GrblDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 440 10 | 438 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Grbl Settings 21 | 22 | 23 | 24 | 25 | 50 26 | 390 27 | 75 28 | 31 29 | 30 | 31 | 32 | Apply 33 | 34 | 35 | 36 | 37 | 38 | 280 39 | 390 40 | 75 41 | 31 42 | 43 | 44 | 45 | Close 46 | 47 | 48 | 49 | 50 | 51 | 10 52 | 20 53 | 411 54 | 351 55 | 56 | 57 | 58 | 59 | 10 60 | 0 61 | 62 | 63 | 64 | Qt::ImhNone 65 | 66 | 67 | 30 68 | 69 | 70 | true 71 | 72 | 73 | 2 74 | 75 | 76 | true 77 | 78 | 79 | 40 80 | 81 | 82 | 40 83 | 84 | 85 | true 86 | 87 | 88 | 30 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /img/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/Thumbs.db -------------------------------------------------------------------------------- /img/down.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/down.PNG -------------------------------------------------------------------------------- /img/down.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/down.gif -------------------------------------------------------------------------------- /img/left.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/left.PNG -------------------------------------------------------------------------------- /img/left.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/left.gif -------------------------------------------------------------------------------- /img/logotiny.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/logotiny.PNG -------------------------------------------------------------------------------- /img/logotiny.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/logotiny.gif -------------------------------------------------------------------------------- /img/right.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/right.PNG -------------------------------------------------------------------------------- /img/right.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/right.gif -------------------------------------------------------------------------------- /img/up.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/up.PNG -------------------------------------------------------------------------------- /img/up.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/up.gif -------------------------------------------------------------------------------- /img/zapmaker-logo-130.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/img/zapmaker-logo-130.png -------------------------------------------------------------------------------- /itemtobase.cpp: -------------------------------------------------------------------------------- 1 | #include "itemtobase.h" 2 | 3 | ItemToBase::ItemToBase(int index1) 4 | : scale(1), height(100), offsetx(50), offsety(50), index(index1) 5 | { 6 | } 7 | 8 | ItemToBase::~ItemToBase() 9 | { 10 | } 11 | 12 | void ItemToBase::setParams(double scale1, double height1, double offsetx1, double offsety1) 13 | { 14 | scale = scale1; 15 | height = height1; 16 | offsetx = offsetx1; 17 | offsety = offsety1; 18 | } 19 | 20 | double ItemToBase::screenX(double fx) 21 | { 22 | return (fx * scale) + offsetx; 23 | } 24 | 25 | double ItemToBase::screenY(double fy) 26 | { 27 | return height - ((fy * scale) + offsety); 28 | } 29 | -------------------------------------------------------------------------------- /itemtobase.h: -------------------------------------------------------------------------------- 1 | #ifndef ITEMTOBASE_H 2 | #define ITEMTOBASE_H 3 | #include 4 | #include "stdio.h" 5 | #include "positem.h" 6 | 7 | class ItemToBase 8 | { 9 | public: 10 | ItemToBase(int index); 11 | virtual ~ItemToBase() ; 12 | 13 | virtual void moveToFirst(QPainterPath& path) = 0; 14 | virtual void addToPath(QPainterPath& path) = 0; 15 | virtual PosItem computeExtents() = 0; 16 | 17 | virtual double getXScr() = 0; 18 | virtual double getYScr() = 0; 19 | virtual double getXRaw() = 0; 20 | virtual double getYRaw() = 0; 21 | 22 | void setParams(double scale, double height, double offsetx, double offsety); 23 | 24 | double screenX(double x); 25 | double screenY(double y); 26 | 27 | int getIndex() { return index; } 28 | 29 | protected: 30 | double scale; 31 | double height; 32 | double offsetx; 33 | double offsety; 34 | int index; 35 | }; 36 | 37 | #endif // ITEMTOBASE_H 38 | -------------------------------------------------------------------------------- /lineitem.cpp: -------------------------------------------------------------------------------- 1 | #include "lineitem.h" 2 | 3 | LineItem::LineItem(double x1, double y1, int index1) 4 | : ItemToBase(index1), x(x1), y(y1) 5 | { 6 | } 7 | 8 | LineItem::LineItem(double x1, double y1, bool stretchX1, double length1) 9 | : ItemToBase(0), x(x1), y(y1), stretchX(stretchX1), length(length1) 10 | { 11 | } 12 | 13 | PosItem LineItem::computeExtents() 14 | { 15 | PosItem curr(x, y, x, y); 16 | return curr; 17 | } 18 | 19 | void LineItem::addToPath(QPainterPath& path) 20 | { 21 | path.lineTo(screenX(x), screenY(y)); 22 | } 23 | 24 | void LineItem::moveToFirst(QPainterPath& path) 25 | { 26 | path.moveTo(screenX(x), screenY(y)); 27 | } 28 | 29 | double LineItem::getXScr() 30 | { 31 | return screenX(x); 32 | } 33 | 34 | double LineItem::getYScr() 35 | { 36 | return screenY(y); 37 | } 38 | 39 | double LineItem::getXRaw() 40 | { 41 | return x; 42 | } 43 | 44 | double LineItem::getYRaw() 45 | { 46 | return y; 47 | } 48 | 49 | void LineItem::drawTo(QPainterPath& path) 50 | { 51 | if (stretchX) 52 | { 53 | path.moveTo(screenX(x), screenY(y) + length); 54 | path.lineTo(screenX(x), screenY(y) - length); 55 | } 56 | else 57 | { 58 | path.moveTo(screenX(x) + length, screenY(y)); 59 | path.lineTo(screenX(x) - length, screenY(y)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lineitem.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEITEM_H 2 | #define LINEITEM_H 3 | #include "itemtobase.h" 4 | 5 | class LineItem : public ItemToBase 6 | { 7 | public: 8 | LineItem(double x1, double y1, int index); 9 | LineItem(double x1, double y1, bool stretchX, double length); 10 | 11 | void moveToFirst(QPainterPath& path); 12 | void addToPath(QPainterPath& path); 13 | PosItem computeExtents(); 14 | 15 | void drawTo(QPainterPath& path); 16 | 17 | double getXScr(); 18 | double getYScr(); 19 | double getXRaw(); 20 | double getYRaw(); 21 | 22 | private: 23 | double x; 24 | double y; 25 | bool stretchX; 26 | double length; 27 | }; 28 | 29 | #endif // LINEITEM_H 30 | -------------------------------------------------------------------------------- /linux-installer/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Grbl Controller 4 | 3.6.1 5 | Grbl Controller Installer 6 | zapmaker 7 | http://zapmaker.org 8 | Grbl Controller 9 | @HomeDir@/GrblController 10 | 11 | -------------------------------------------------------------------------------- /linux-installer/packages/org.zapmaker.GrblController/data/trlocale/GrblController_fr.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/linux-installer/packages/org.zapmaker.GrblController/data/trlocale/GrblController_fr.qm -------------------------------------------------------------------------------- /linux-installer/packages/org.zapmaker.GrblController/data/trlocale/GrblController_xx.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/linux-installer/packages/org.zapmaker.GrblController/data/trlocale/GrblController_xx.qm -------------------------------------------------------------------------------- /linux-installer/packages/org.zapmaker.GrblController/meta/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Grbl Controller app 4 | You may need to run app as root to access serial port 5 | 3.6.1 6 | 2014-06-08 7 | 8 | 9 | 10 | true 11 | 12 | 13 | -------------------------------------------------------------------------------- /log4qt/appender.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: appender.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ********************************************************************************/ 24 | 25 | #ifndef LOG4QT_APPENDER_H 26 | #define LOG4QT_APPENDER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/helpers/logobject.h" 34 | 35 | #include "log4qt/helpers/logobjectptr.h" 36 | 37 | #include "log4qt/logger.h" 38 | 39 | 40 | /****************************************************************************** 41 | * Declarations 42 | ******************************************************************************/ 43 | 44 | namespace Log4Qt 45 | { 46 | 47 | class Filter; 48 | class Layout; 49 | class LoggingEvent; 50 | 51 | /*! 52 | * \brief The class Appender is the base class for all Appenders. 53 | * 54 | * To allow the whole hirarchy to be an ascendant of QObject Appender is 55 | * not an interface. 56 | * 57 | * \note All the functions declared in this class are thread-safe. 58 | * 59 | * \note The ownership and lifetime of objects of this class are managed. 60 | * See \ref Ownership "Object ownership" for more details. 61 | */ 62 | class Appender : public LogObject 63 | { 64 | Q_OBJECT 65 | 66 | /*! 67 | * The property holds the Layout used by the Appender. 68 | * 69 | * \sa layout(), setLayout() 70 | */ 71 | Q_PROPERTY(Layout* layout READ layout WRITE setLayout) 72 | 73 | /*! 74 | * The property holds the name of the Appender. 75 | * 76 | * \sa name(), setName() 77 | */ 78 | Q_PROPERTY(QString name READ name WRITE setName) 79 | 80 | /*! 81 | * The property holds if the Appender requires a Layout or not. 82 | * 83 | * \sa requiresLayout(), setRequiresLayout() 84 | */ 85 | Q_PROPERTY(bool requiresLayout READ requiresLayout) 86 | 87 | public: 88 | Appender(QObject *pParent = 0); 89 | virtual ~Appender(); 90 | private: 91 | Appender(const Appender &rOther); // Not implemented 92 | Appender &operator=(const Appender &rOther); // Not implemented 93 | 94 | public: 95 | // JAVA: ErrorHandler* errorHandler(); 96 | virtual Filter *filter() const = 0; 97 | virtual QString name() const = 0; 98 | virtual Layout *layout() const = 0; 99 | virtual bool requiresLayout() const = 0; 100 | // JAVA: void setErrorHandler(ErrorHandler *pErrorHandler); 101 | virtual void setLayout(Layout *pLayout) = 0; 102 | virtual void setName(const QString &rName) = 0; 103 | 104 | virtual void addFilter(Filter *pFilter) = 0; 105 | virtual void clearFilters() = 0; 106 | virtual void close() = 0; 107 | virtual void doAppend(const LoggingEvent &rEvent) = 0; 108 | }; 109 | 110 | 111 | /************************************************************************** 112 | * Operators, Helper 113 | **************************************************************************/ 114 | 115 | 116 | /************************************************************************** 117 | * Inline 118 | **************************************************************************/ 119 | 120 | inline Appender::Appender(QObject *pParent) : 121 | LogObject(pParent) 122 | {} 123 | 124 | inline Appender::~Appender() 125 | {} 126 | 127 | 128 | } // namespace Log4Qt 129 | 130 | 131 | // Q_DECLARE_TYPEINFO(Log4Qt::Appender, Q_COMPLEX_TYPE); // Use default 132 | Q_DECLARE_TYPEINFO(Log4Qt::LogObjectPtr, Q_MOVABLE_TYPE); 133 | 134 | 135 | #endif // LOG4QT_APPENDER_H 136 | -------------------------------------------------------------------------------- /log4qt/basicconfigurator.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: basicconfigurator.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/basicconfigurator.h" 33 | 34 | #include 35 | #include 36 | #include 37 | #include "log4qt/consoleappender.h" 38 | #include "log4qt/helpers/configuratorhelper.h" 39 | #include "log4qt/helpers/logobjectptr.h" 40 | #include "log4qt/logmanager.h" 41 | #include "log4qt/patternlayout.h" 42 | #include "log4qt/varia/listappender.h" 43 | 44 | 45 | 46 | namespace Log4Qt 47 | { 48 | 49 | 50 | /************************************************************************** 51 | * Declarations 52 | **************************************************************************/ 53 | 54 | 55 | 56 | /************************************************************************** 57 | * C helper functions 58 | **************************************************************************/ 59 | 60 | 61 | 62 | /************************************************************************** 63 | * Class implementation: BasicConfigurator 64 | **************************************************************************/ 65 | 66 | 67 | bool BasicConfigurator::configure() 68 | { 69 | LogObjectPtr list = new ListAppender; 70 | list->setName(QLatin1String("BasicConfigurator")); 71 | list->setConfiguratorList(true); 72 | list->setThreshold(Level::ERROR_INT); 73 | LogManager::logLogger()->addAppender(list); 74 | 75 | PatternLayout *p_layout = new PatternLayout(PatternLayout::TTCC_CONVERSION_PATTERN); 76 | p_layout->setName(QLatin1String("BasicConfigurator TTCC")); 77 | p_layout->activateOptions(); 78 | ConsoleAppender *p_appender = new ConsoleAppender(p_layout, ConsoleAppender::STDOUT_TARGET); 79 | p_appender->setName(QLatin1String("BasicConfigurator stdout")); 80 | p_appender->activateOptions(); 81 | LogManager::rootLogger()->addAppender(p_appender); 82 | 83 | LogManager::logLogger()->removeAppender(list); 84 | ConfiguratorHelper::setConfigureError(list->list()); 85 | return (list->list().count() == 0); 86 | } 87 | 88 | 89 | void BasicConfigurator::configure(Appender *pAppender) 90 | { 91 | LogManager::rootLogger()->addAppender(pAppender); 92 | } 93 | 94 | 95 | void BasicConfigurator::resetConfiguration() 96 | { 97 | LogManager::resetConfiguration(); 98 | } 99 | 100 | 101 | 102 | /************************************************************************** 103 | * Implementation: Operators, Helper 104 | **************************************************************************/ 105 | 106 | 107 | } // namespace Log4Qt 108 | -------------------------------------------------------------------------------- /log4qt/basicconfigurator.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: basicconfigurator.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_BASICCONFIGURATOR_H 26 | #define LOG4QT_BASICCONFIGURATOR_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | 34 | #include 35 | #include "log4qt/log4qt.h" 36 | 37 | 38 | /****************************************************************************** 39 | * Declarations 40 | ******************************************************************************/ 41 | 42 | namespace Log4Qt 43 | { 44 | 45 | class Appender; 46 | 47 | /*! 48 | * \brief The class BasicConfigurator provides a simple package 49 | * configuration. 50 | * 51 | * \note All the functions declared in this class are thread-safe. 52 | */ 53 | class BasicConfigurator 54 | { 55 | private: 56 | BasicConfigurator(); // Not implemented 57 | // BasicConfigurator(const BasicConfigurator &rOther); // Use compiler default 58 | // virtual ~BasicConfigurator(); // Use compiler default 59 | // BasicConfigurator &operator=(const BasicConfigurator &rOther); // Use compiler default 60 | 61 | public: 62 | static bool configure(); 63 | static void configure(Appender *pAppender); 64 | static void resetConfiguration(); 65 | }; 66 | 67 | 68 | /************************************************************************** 69 | * Operators, Helper 70 | **************************************************************************/ 71 | 72 | 73 | /************************************************************************** 74 | * Inline 75 | **************************************************************************/ 76 | 77 | 78 | } // namspace Log4Qt 79 | 80 | 81 | // Q_DECLARE_TYPEINFO(Log4Qt::BasicConfigurator, Q_MOVABLE_TYPE); // Use default 82 | 83 | 84 | #endif // LOG4QT_BASICCONFIGURATOR_H 85 | -------------------------------------------------------------------------------- /log4qt/helpers/classlogger.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: classlogger.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * changes: Sep 2008, Martin Heinrich: 10 | * - Replaced usage of q_atomic_test_and_set_ptr with 11 | * QAtomicPointer 12 | * 13 | * 14 | * Copyright 2007 - 2008 Martin Heinrich 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | ******************************************************************************/ 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Dependencies 34 | ******************************************************************************/ 35 | 36 | 37 | #include "log4qt/helpers/classlogger.h" 38 | 39 | #include 40 | #include "log4qt/logmanager.h" 41 | 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | 47 | /************************************************************************** 48 | * Declarations 49 | **************************************************************************/ 50 | 51 | 52 | 53 | /************************************************************************** 54 | * C helper functions 55 | **************************************************************************/ 56 | 57 | 58 | 59 | /************************************************************************** 60 | * Class implementation: ClassLogger 61 | **************************************************************************/ 62 | 63 | 64 | ClassLogger::ClassLogger() : 65 | mpLogger(0) 66 | { 67 | } 68 | 69 | 70 | Logger *ClassLogger::logger(const QObject *pObject) 71 | { 72 | Q_ASSERT_X(pObject, "ClassLogger::logger()", "pObject must not be null"); 73 | #if QT_VERSION < QT_VERSION_CHECK(4, 4, 0) 74 | if (!mpLogger) 75 | q_atomic_test_and_set_ptr(&mpLogger, 76 | 0, 77 | LogManager::logger(QLatin1String(pObject->metaObject()->className()))); 78 | return const_cast(mpLogger); 79 | #elif QT_VERSION < QT_VERSION_CHECK(5, 0, 0) 80 | if (!static_cast(mpLogger)) 81 | mpLogger.testAndSetOrdered(0, 82 | LogManager::logger(QLatin1String(pObject->metaObject()->className()))); 83 | return const_cast(static_cast(mpLogger)); 84 | #else 85 | if (!static_cast(mpLogger.loadAcquire())) 86 | mpLogger.testAndSetOrdered(0, 87 | LogManager::logger(QLatin1String(pObject->metaObject()->className()))); 88 | return const_cast(static_cast(mpLogger.loadAcquire())); 89 | #endif 90 | } 91 | 92 | 93 | 94 | /************************************************************************** 95 | * Implementation: Operators, Helper 96 | **************************************************************************/ 97 | 98 | 99 | 100 | } // namespace Log4Qt 101 | -------------------------------------------------------------------------------- /log4qt/helpers/classlogger.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: classlogger.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * changes: Sep 2008, Martin Heinrich: 10 | * - Replaced usage of q_atomic_test_and_set_ptr with 11 | * QAtomicPointer 12 | * 13 | * 14 | * Copyright 2007 - 2008 Martin Heinrich 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | ******************************************************************************/ 29 | 30 | #ifndef LOG4QT_CLASSLOGGER_H 31 | #define LOG4QT_CLASSLOGGER_H 32 | 33 | 34 | /****************************************************************************** 35 | * Dependencies 36 | ******************************************************************************/ 37 | 38 | #include 39 | #if QT_VERSION >= QT_VERSION_CHECK(4, 4, 0) 40 | # include 41 | # ifndef Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE 42 | # warning "QAtomicPointer test and set is not native. The class Log4Qt::ClassLogger is not thread-safe." 43 | # endif 44 | #endif 45 | 46 | 47 | /****************************************************************************** 48 | * Declarations 49 | ******************************************************************************/ 50 | 51 | namespace Log4Qt 52 | { 53 | class Logger; 54 | 55 | /*! 56 | * \brief The class ClassLogger provides logging for a QObject derived 57 | * class. 58 | * 59 | * The class ClassLogger provides a logger for a specified QObject derived 60 | * object. It is used by \ref LOG4QT_DECLARE_QCLASS_LOGGER to implement the 61 | * member functions provided by the macro. 62 | * 63 | * \note All the functions declared in this class are thread-safe. 64 | * 65 | * \sa LOG4QT_DECLARE_QCLASS_LOGGER 66 | */ 67 | class ClassLogger 68 | { 69 | public: 70 | /*! 71 | * Creates a ClassLogger object. 72 | */ 73 | ClassLogger(); 74 | // ~ClassLogger(); // Use compiler default 75 | // ClassLogger(const ClassLogger &rOther); // Use compiler default 76 | // ClassLogger &operator=(const ClassLogger &rOther); // Use compiler default 77 | 78 | /*! 79 | * Returns a pointer to a Logger named after the class of the object 80 | * \a pObject. 81 | * 82 | * On the first invocation the Logger is requested by a call to 83 | * LogManager::logger(const char *pName). The pointer is stored to be 84 | * returned on subsequent invocations. 85 | * 86 | * \sa LogManager::logger(const char *pName) 87 | */ 88 | Logger *logger(const QObject *pObject); 89 | 90 | private: 91 | #if QT_VERSION < QT_VERSION_CHECK(4, 4, 0) 92 | volatile Logger *mpLogger; 93 | #else 94 | mutable QAtomicPointer mpLogger; 95 | #endif 96 | }; 97 | 98 | 99 | /****************************************************************************** 100 | * Operators, Helper 101 | ******************************************************************************/ 102 | 103 | 104 | /************************************************************************** 105 | * Inline 106 | **************************************************************************/ 107 | 108 | 109 | } // namespace Log4Qt 110 | 111 | 112 | // Q_DECLARE_TYPEinfo(Log4Qt::ClassLogger, Q_COMPLEX_TYPE); // Use default 113 | 114 | 115 | #endif // LOG4QT_CLASSLOGGER_H 116 | -------------------------------------------------------------------------------- /log4qt/helpers/configuratorhelper.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: configuratorhelper.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/helpers/configuratorhelper.h" 33 | 34 | #include 35 | #include 36 | #include "log4qt/helpers/initialisationhelper.h" 37 | 38 | 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | 44 | /************************************************************************** 45 | * Declarations 46 | **************************************************************************/ 47 | 48 | 49 | 50 | /************************************************************************** 51 | * C helper functions 52 | **************************************************************************/ 53 | 54 | 55 | 56 | /************************************************************************** 57 | * Class implementation: ConfiguratorHelper 58 | **************************************************************************/ 59 | 60 | 61 | ConfiguratorHelper::ConfiguratorHelper() : 62 | mObjectGuard(), 63 | mConfigurationFile(), 64 | mpConfigureFunc(0), 65 | mpConfigurationFileWatch(0), 66 | mConfigureError() 67 | { 68 | } 69 | 70 | 71 | ConfiguratorHelper::~ConfiguratorHelper() 72 | { 73 | delete mpConfigurationFileWatch; 74 | } 75 | 76 | 77 | LOG4QT_IMPLEMENT_INSTANCE(ConfiguratorHelper) 78 | 79 | 80 | void ConfiguratorHelper::doConfigurationFileChanged(const QString &rFileName) 81 | { 82 | QMutexLocker locker(&mObjectGuard); 83 | 84 | if (!mpConfigureFunc) 85 | return; 86 | mpConfigureFunc(rFileName); 87 | // Shall we hold the lock while emitting the signal? 88 | emit configurationFileChanged(rFileName, mConfigureError.count() > 0); 89 | } 90 | 91 | 92 | 93 | void ConfiguratorHelper::doSetConfigurationFile(const QString &rFileName, 94 | ConfigureFunc pConfigureFunc) 95 | { 96 | QMutexLocker locker(&mObjectGuard); 97 | 98 | mConfigurationFile.clear(); 99 | mpConfigureFunc = 0; 100 | delete mpConfigurationFileWatch; 101 | if (rFileName.isEmpty()) 102 | return; 103 | 104 | mConfigurationFile = rFileName; 105 | mpConfigureFunc = pConfigureFunc; 106 | mpConfigurationFileWatch = new QFileSystemWatcher(); 107 | mpConfigurationFileWatch->addPath(rFileName); 108 | connect(mpConfigurationFileWatch, 109 | SIGNAL(fileChanged(const QString &)), 110 | SLOT(configurationFileChanged(const QString &))); 111 | } 112 | 113 | 114 | 115 | /************************************************************************** 116 | * Implementation: Operators, Helper 117 | **************************************************************************/ 118 | 119 | 120 | #ifndef QT_NO_DEBUG_STREAM 121 | QDebug operator<<(QDebug debug, 122 | const ConfiguratorHelper &rConfiguratorHelper) 123 | { 124 | debug.nospace() << "ConfiguratorHelper(" 125 | << "configurationfile:" << ConfiguratorHelper::configurationFile() 126 | << "configurefunc:" << rConfiguratorHelper.mpConfigureFunc 127 | << "filesystemwatcher:" << rConfiguratorHelper.mpConfigurationFileWatch 128 | << ")"; 129 | return debug.space(); 130 | } 131 | #endif // QT_NO_DEBUG_STREAM 132 | 133 | 134 | 135 | } // namespace Log4Qt 136 | 137 | -------------------------------------------------------------------------------- /log4qt/helpers/logobject.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: logobject.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | /****************************************************************************** 27 | * Dependencies 28 | ******************************************************************************/ 29 | 30 | 31 | #include "log4qt/helpers/logobject.h" 32 | 33 | #include 34 | 35 | 36 | 37 | namespace Log4Qt 38 | { 39 | 40 | 41 | /************************************************************************** 42 | * Declarations 43 | **************************************************************************/ 44 | 45 | 46 | 47 | /************************************************************************** 48 | * C helper functions 49 | **************************************************************************/ 50 | 51 | 52 | 53 | /************************************************************************** 54 | * Class implementation: LogObject 55 | **************************************************************************/ 56 | 57 | 58 | 59 | /************************************************************************** 60 | * Implementation: Operators, Helper 61 | **************************************************************************/ 62 | 63 | 64 | #ifndef QT_NO_DEBUG_STREAM 65 | QDebug operator<<(QDebug debug, 66 | const LogObject &rLogObject) 67 | { 68 | return rLogObject.debug(debug); 69 | } 70 | #endif // QT_NO_DEBUG_STREAM 71 | 72 | 73 | 74 | } // namespace Log4Qt 75 | -------------------------------------------------------------------------------- /log4qt/helpers/logobjectptr.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: logobjectptr.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | /****************************************************************************** 27 | * Dependencies 28 | ******************************************************************************/ 29 | 30 | 31 | #include "log4qt/helpers/logobjectptr.h" 32 | 33 | #include 34 | 35 | 36 | 37 | namespace Log4Qt 38 | { 39 | 40 | 41 | /************************************************************************** 42 | * Declarations 43 | **************************************************************************/ 44 | 45 | 46 | 47 | /************************************************************************** 48 | * C helper functions 49 | **************************************************************************/ 50 | 51 | 52 | 53 | /************************************************************************** 54 | * Class implementation: LogObjectPtr 55 | **************************************************************************/ 56 | 57 | 58 | 59 | /************************************************************************** 60 | * Implementation: Operators, Helper 61 | **************************************************************************/ 62 | 63 | 64 | 65 | } // namespace Log4Qt 66 | -------------------------------------------------------------------------------- /log4qt/hierarchy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: hierarchy.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_HIERARCHY_H 26 | #define LOG4QT_HIERARCHY_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/loggerrepository.h" 34 | 35 | #include 36 | #include 37 | 38 | 39 | /****************************************************************************** 40 | * Declarations 41 | ******************************************************************************/ 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | /*! 47 | * \brief The class Hierarchy implements a logger repository. 48 | * 49 | * \note All the functions declared in this class are thread-safe. 50 | */ 51 | class Hierarchy : public LoggerRepository 52 | { 53 | public: 54 | Hierarchy(); 55 | // Hierarchy(const Hierarchy &rOther); // Use compiler default 56 | virtual ~Hierarchy(); 57 | // Hierarchy &operator=(const Hierarchy &rOther); // Use compiler default 58 | 59 | public: 60 | virtual bool exists(const QString &rName) const; 61 | virtual Logger *logger(const QString &rName); 62 | virtual QList loggers() const; 63 | // JAVA: virtual Logger *logger(const String &rName, LoggerFactory *pFactory); 64 | virtual Logger *rootLogger() const; 65 | virtual Level threshold() const; 66 | virtual void setThreshold(Level level); 67 | virtual void setThreshold(const QString &rThreshold); 68 | 69 | // JAVA: void clear(); 70 | virtual bool isDisabled(Level level); 71 | virtual void resetConfiguration(); 72 | virtual void shutdown(); 73 | 74 | // JAVA: virtual void addHierarchyEventListener(HierarchyEventListener *pEventListener); 75 | // JAVA: virtual void emitNoAppenderWarning(Logger *plogger) const; 76 | // JAVA: virtual void fireAddAppenderEvent(Logger *plogger, Appender *pAppender) const; 77 | 78 | // JAVA: void addRenderer(const QString &rClass, ObjectRenderer *pObjectRenderer); 79 | // JAVA: QHash getRendererMap() const; 80 | // JAVA: setRenderer(const QString &rClass, ObjectRenderer *pObjectRenderer); 81 | 82 | protected: 83 | #ifndef QT_NO_DEBUG_STREAM 84 | /*! 85 | * Writes all object member variables to the given debug stream \a rDebug and 86 | * returns the stream. 87 | * 88 | * 89 | * %Hierarchy(loggers:6 threshold:"ALL" root-level:"DEBUG" root-appenders:0) 90 | * 91 | * \sa QDebug, operator<<(QDebug debug, const LoggerRepository &rLoggerRepository) 92 | */ 93 | virtual QDebug debug(QDebug &rdebug) const; 94 | #endif 95 | 96 | private: 97 | Logger *createLogger(const QString &rName); 98 | void resetLogger(Logger *pLogger, Level level) const; 99 | 100 | private: 101 | mutable QReadWriteLock mObjectGuard; 102 | QHash mLoggers; 103 | volatile bool mHandleQtMessages; 104 | Level mThreshold; 105 | Logger *mpRootLogger; 106 | }; 107 | 108 | 109 | /************************************************************************** 110 | * Operators, Helper 111 | **************************************************************************/ 112 | 113 | 114 | /************************************************************************** 115 | * Inline 116 | **************************************************************************/ 117 | 118 | inline Logger *Hierarchy::rootLogger() const 119 | { // QReadLocker locker(&mObjectGuard); // Constant for object lifetime 120 | return mpRootLogger; } 121 | 122 | inline Level Hierarchy::threshold() const 123 | { // QReadLocker locker(&mObjectGuard); // Level is threadsafe 124 | return mThreshold; } 125 | 126 | inline void Hierarchy::setThreshold(Level level) 127 | { // QReadLocker locker(&mObjectGuard); // Level is threadsafe 128 | mThreshold = level; } 129 | 130 | inline bool Hierarchy::isDisabled(Level level) 131 | { // QReadLocker locker(&mObjectGuard); // Level is threadsafe 132 | return level < mThreshold; } 133 | 134 | 135 | } // namespace Log4Qt 136 | 137 | 138 | // Q_DECLARE_TYPEINFO(Log4Qt::Hierarchy, Q_COMPLEX_TYPE); // Use default 139 | 140 | 141 | #endif // LOG4QT_HIERARCHY_H 142 | -------------------------------------------------------------------------------- /log4qt/layout.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: layout.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/layout.h" 33 | 34 | #include 35 | #include "log4qt/loggingevent.h" 36 | #include "log4qt/logmanager.h" 37 | 38 | 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | 44 | /*************************************************************************** 45 | * Declarations 46 | **************************************************************************/ 47 | 48 | 49 | 50 | /************************************************************************** 51 | * C helper functions 52 | **************************************************************************/ 53 | 54 | 55 | 56 | /************************************************************************** 57 | * Class implementation: Layout 58 | **************************************************************************/ 59 | 60 | 61 | QString Layout::contentType() const 62 | { 63 | return QString::fromLatin1("text/plain"); 64 | } 65 | 66 | 67 | void Layout::activateOptions() 68 | { 69 | } 70 | 71 | 72 | QString Layout::endOfLine() 73 | { 74 | // There seams to be no function in Qt for this 75 | 76 | #ifdef Q_OS_WIN32 77 | return QLatin1String("\r\n"); 78 | #endif // Q_OS_WIN32 79 | //#ifdef Q_OS_MAC 80 | // return QLatin1String("\r"); 81 | //#endif // Q_OS_MAC 82 | return QLatin1String("\n"); 83 | } 84 | 85 | 86 | /************************************************************************** 87 | * Implementation: Operators, Helper 88 | **************************************************************************/ 89 | 90 | 91 | } // namespace Log4Qt 92 | -------------------------------------------------------------------------------- /log4qt/layout.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: layout.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_LAYOUT_H 26 | #define LOG4QT_LAYOUT_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/helpers/logobject.h" 34 | 35 | #include "log4qt/helpers/logobjectptr.h" 36 | #include "log4qt/log4qt.h" 37 | 38 | 39 | /****************************************************************************** 40 | * Declarations 41 | ******************************************************************************/ 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | class LoggingEvent; 47 | 48 | /*! 49 | * \brief The class Layout is the base class for all layouts. 50 | * 51 | * \note The ownership and lifetime of objects of this class are managed. See 52 | * \ref Ownership "Object ownership" for more details. 53 | */ 54 | class Layout : public LogObject 55 | { 56 | Q_OBJECT 57 | 58 | /*! 59 | * The property holds the content type of the layout. 60 | * 61 | * \sa contentType() 62 | */ 63 | Q_PROPERTY(QString footercontentType READ contentType) 64 | /*! 65 | * The property holds the footer used by the layout. 66 | * 67 | * \sa footer(), setFooter() 68 | */ 69 | Q_PROPERTY(QString footer READ footer WRITE setFooter) 70 | /*! 71 | * The property holds the header used by the layout. 72 | * 73 | * \sa header(), setHeader() 74 | */ 75 | Q_PROPERTY(QString header READ header WRITE setHeader) 76 | 77 | public: 78 | Layout(QObject *pParent = 0); 79 | virtual ~Layout(); 80 | private: 81 | Layout(const Layout &rOther); // Not implemented 82 | Layout &operator=(const Layout &rOther); // Not implemented 83 | 84 | public: 85 | virtual QString contentType() const; 86 | QString footer() const; 87 | QString header() const; 88 | // JAVA: virtual bool ignoresThrowable() const; 89 | QString name() const; 90 | void setFooter(const QString &rFooter); 91 | void setHeader(const QString &rHeader); 92 | void setName(const QString &rName); 93 | // JAVA: void setIgnoresThrowable(bool) const; 94 | 95 | virtual void activateOptions(); 96 | virtual QString format(const LoggingEvent &rEvent) = 0; 97 | 98 | /*! 99 | * Returns the end of line seperator for the operating system. 100 | * 101 | * Windows: \\r\\n 102 | * Mac: \\r 103 | * UNIX: \\n 104 | */ 105 | static QString endOfLine(); 106 | 107 | // Member variables 108 | private: 109 | QString mFooter; 110 | QString mHeader; 111 | }; 112 | 113 | 114 | /************************************************************************** 115 | * Operators, Helper 116 | **************************************************************************/ 117 | 118 | 119 | /************************************************************************** 120 | * Inline 121 | **************************************************************************/ 122 | 123 | inline Layout::Layout(QObject *pParent) : 124 | LogObject(pParent) 125 | {} 126 | 127 | inline Layout::~Layout() 128 | {} 129 | 130 | inline QString Layout::footer() const 131 | { return mFooter; } 132 | 133 | inline QString Layout::header() const 134 | { return mHeader; } 135 | 136 | inline QString Layout::name() const 137 | { return objectName(); } 138 | 139 | inline void Layout::setFooter(const QString &rFooter) 140 | { mFooter = rFooter; } 141 | 142 | inline void Layout::setHeader(const QString &rHeader) 143 | { mHeader = rHeader; } 144 | 145 | inline void Layout::setName(const QString &rName) 146 | { setObjectName(rName); } 147 | 148 | 149 | } // namespace Log4Qt 150 | 151 | 152 | // Q_DECLARE_TYPEINFO(Log4Qt::Layout, Q_COMPLEX_TYPE); // Use default 153 | Q_DECLARE_TYPEINFO(Log4Qt::LogObjectPtr, Q_MOVABLE_TYPE); 154 | 155 | 156 | #endif // LOG4QT_LAYOUT_H 157 | -------------------------------------------------------------------------------- /log4qt/log4qt.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: logging.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | *****************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | *Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/log4qt.h" 33 | 34 | 35 | 36 | namespace Log4Qt 37 | { 38 | 39 | 40 | /************************************************************************** 41 | * Declarations 42 | **************************************************************************/ 43 | 44 | 45 | 46 | /************************************************************************** 47 | * C helper functions 48 | **************************************************************************/ 49 | 50 | 51 | 52 | /************************************************************************** 53 | *Implementation: Operators, Helper 54 | **************************************************************************/ 55 | 56 | 57 | 58 | } // namespace Log4Qt 59 | -------------------------------------------------------------------------------- /log4qt/log4qt.pri: -------------------------------------------------------------------------------- 1 | # ******************************************************************************* 2 | # 3 | # package: Log4Qt 4 | # file: log4qt.pri 5 | # created: September 2007 6 | # author: Martin Heinrich 7 | # 8 | # 9 | # Copyright 2007 Martin Heinrich 10 | # 11 | # Licensed under the Apache License, Version 2.0 (the "License"); 12 | # you may not use this file except in compliance with the License. 13 | # You may obtain a copy of the License at 14 | # 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | # 17 | # Unless required by applicable law or agreed to in writing, software 18 | # distributed under the License is distributed on an "AS IS" BASIS, 19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | # See the License for the specific language governing permissions and 21 | # limitations under the License. 22 | # 23 | # ******************************************************************************* 24 | 25 | INCLUDEPATH += $$PWD/.. 26 | DEPENDPATH += $$PWD/.. 27 | HEADERS += \ 28 | $$PWD/appender.h \ 29 | $$PWD/appenderskeleton.h \ 30 | $$PWD/basicconfigurator.h \ 31 | $$PWD/consoleappender.h \ 32 | $$PWD/dailyrollingfileappender.h \ 33 | $$PWD/fileappender.h \ 34 | $$PWD/helpers/classlogger.h \ 35 | $$PWD/helpers/configuratorhelper.h \ 36 | $$PWD/helpers/datetime.h \ 37 | $$PWD/helpers/factory.h \ 38 | $$PWD/helpers/initialisationhelper.h \ 39 | $$PWD/helpers/logerror.h \ 40 | $$PWD/helpers/logobject.h \ 41 | $$PWD/helpers/logobjectptr.h \ 42 | $$PWD/helpers/optionconverter.h \ 43 | $$PWD/helpers/patternformatter.h \ 44 | $$PWD/helpers/properties.h \ 45 | $$PWD/hierarchy.h \ 46 | $$PWD/layout.h \ 47 | $$PWD/level.h \ 48 | $$PWD/log4qt.h \ 49 | $$PWD/logger.h \ 50 | $$PWD/loggerrepository.h \ 51 | $$PWD/loggingevent.h \ 52 | $$PWD/logmanager.h \ 53 | $$PWD/mdc.h \ 54 | $$PWD/ndc.h \ 55 | $$PWD/patternlayout.h \ 56 | $$PWD/propertyconfigurator.h \ 57 | $$PWD/rollingfileappender.h \ 58 | $$PWD/simplelayout.h \ 59 | $$PWD/spi/filter.h \ 60 | $$PWD/ttcclayout.h \ 61 | $$PWD/writerappender.h \ 62 | $$PWD/varia/debugappender.h \ 63 | $$PWD/varia/denyallfilter.h \ 64 | $$PWD/varia/nullappender.h \ 65 | $$PWD/varia/levelmatchfilter.h \ 66 | $$PWD/varia/levelrangefilter.h \ 67 | $$PWD/varia/listappender.h \ 68 | $$PWD/varia/stringmatchfilter.h 69 | 70 | SOURCES += \ 71 | $$PWD/appenderskeleton.cpp \ 72 | $$PWD/basicconfigurator.cpp \ 73 | $$PWD/consoleappender.cpp \ 74 | $$PWD/dailyrollingfileappender.cpp \ 75 | $$PWD/fileappender.cpp \ 76 | $$PWD/helpers/classlogger.cpp \ 77 | $$PWD/helpers/configuratorhelper.cpp \ 78 | $$PWD/helpers/datetime.cpp \ 79 | $$PWD/helpers/factory.cpp \ 80 | $$PWD/helpers/initialisationhelper.cpp \ 81 | $$PWD/helpers/logerror.cpp \ 82 | $$PWD/helpers/logobject.cpp \ 83 | $$PWD/helpers/logobjectptr.cpp \ 84 | $$PWD/helpers/optionconverter.cpp \ 85 | $$PWD/helpers/patternformatter.cpp \ 86 | $$PWD/helpers/properties.cpp \ 87 | $$PWD/hierarchy.cpp \ 88 | $$PWD/layout.cpp \ 89 | $$PWD/level.cpp \ 90 | $$PWD/log4qt.cpp \ 91 | $$PWD/logger.cpp \ 92 | $$PWD/loggerrepository.cpp \ 93 | $$PWD/loggingevent.cpp \ 94 | $$PWD/logmanager.cpp \ 95 | $$PWD/mdc.cpp \ 96 | $$PWD/ndc.cpp \ 97 | $$PWD/patternlayout.cpp \ 98 | $$PWD/propertyconfigurator.cpp \ 99 | $$PWD/rollingfileappender.cpp \ 100 | $$PWD/simplelayout.cpp \ 101 | $$PWD/spi/filter.cpp \ 102 | $$PWD/ttcclayout.cpp \ 103 | $$PWD/writerappender.cpp \ 104 | $$PWD/varia/debugappender.cpp \ 105 | $$PWD/varia/denyallfilter.cpp \ 106 | $$PWD/varia/nullappender.cpp \ 107 | $$PWD/varia/levelmatchfilter.cpp \ 108 | $$PWD/varia/levelrangefilter.cpp \ 109 | $$PWD/varia/listappender.cpp \ 110 | $$PWD/varia/stringmatchfilter.cpp 111 | -------------------------------------------------------------------------------- /log4qt/loggerrepository.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: loggerrepository.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/loggerrepository.h" 33 | 34 | #include 35 | 36 | 37 | 38 | namespace Log4Qt 39 | { 40 | 41 | 42 | /************************************************************************** 43 | * Declarations 44 | **************************************************************************/ 45 | 46 | 47 | 48 | /************************************************************************** 49 | * C helper functions 50 | **************************************************************************/ 51 | 52 | 53 | 54 | /************************************************************************** 55 | * Class implementation: LoggerRepository 56 | **************************************************************************/ 57 | 58 | 59 | 60 | /************************************************************************** 61 | * Implementation: Operators, Helper 62 | **************************************************************************/ 63 | 64 | 65 | #ifndef QT_NO_DEBUG_STREAM 66 | QDebug operator<<(QDebug debug, 67 | const LoggerRepository &rLoggerRepository) 68 | { 69 | return rLoggerRepository.debug(debug); 70 | } 71 | #endif // QT_NO_DEBUG_STREAM 72 | 73 | 74 | 75 | } // namespace Log4Qt 76 | -------------------------------------------------------------------------------- /log4qt/loggerrepository.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: loggerrepository.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_LOGGERREPOSITORY_H 26 | #define LOG4QT_LOGGERREPOSITORY_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include 34 | #include "log4qt/level.h" 35 | 36 | 37 | /****************************************************************************** 38 | * Declarations 39 | ******************************************************************************/ 40 | 41 | namespace Log4Qt 42 | { 43 | 44 | class Logger; 45 | 46 | /*! 47 | * \brief The class LoggerRepository is abstract base class for a logger 48 | * repository. 49 | */ 50 | class LoggerRepository 51 | { 52 | public: 53 | // LoggerRepository(); // Use compiler default 54 | // LoggerRepository(const LoggerRepository &rOther); // Use compiler default 55 | // virtual ~LoggerRepository(); // Use compiler default 56 | // LoggerRepository &operator=(const LoggerRepository &rOther); // Use compiler default 57 | 58 | public: 59 | virtual bool exists(const QString &rName) const = 0; 60 | virtual Logger *logger(const QString &rName) = 0; 61 | // JAVA: virtual Logger *logger(const String &rName, LoggerFactory *pFactory); 62 | virtual QList loggers() const = 0; 63 | virtual Logger *rootLogger() const = 0; 64 | virtual Level threshold() const = 0; 65 | virtual void setThreshold(Level level) = 0; 66 | virtual void setThreshold(const QString &rThreshold) = 0; 67 | 68 | virtual bool isDisabled(Level level) = 0; 69 | virtual void resetConfiguration() = 0; 70 | virtual void shutdown() = 0; 71 | 72 | // JAVA: virtual void addHierarchyEventListener(HierarchyEventListener *pEventListener); 73 | // JAVA: virtual void emitNoAppenderWarning(Logger *plogger) const; 74 | // JAVA: virtual void fireAddAppenderEvent(Logger *plogger, Appender *pAppender) const; 75 | 76 | protected: 77 | #ifndef QT_NO_DEBUG_STREAM 78 | /*! 79 | *\relates LoggerRepository 80 | * 81 | * Writes all object member variables to the given debug stream \a rDebug 82 | * and returns the stream. 83 | * 84 | * The member function is used by 85 | * QDebug operator<<(QDebug debug, const LoggerRepository &rLoggerRepository) 86 | * to generate class specific output. 87 | * 88 | * \sa QDebug operator<<(QDebug debug, const LoggerRepository &rLoggerRepository) 89 | */ 90 | virtual QDebug debug(QDebug &rDebug) const = 0; 91 | friend QDebug operator<<(QDebug debug, 92 | const LoggerRepository &rLoggerRepository); 93 | #endif 94 | }; 95 | 96 | 97 | /****************************************************************************** 98 | * Operators, Helper 99 | ******************************************************************************/ 100 | 101 | #ifndef QT_NO_DEBUG_STREAM 102 | /*! 103 | * \relates LoggerRepository 104 | * Writes all object member variables to the given debug stream \a debug 105 | * and returns the stream. 106 | * 107 | * To handle subclassing the function uses the virtual member function 108 | * debug(). This allows each class to generate its own output. 109 | * 110 | * \sa QDebug, debug() 111 | */ 112 | QDebug operator<<(QDebug debug, 113 | const LoggerRepository &rLoggerRepository); 114 | #endif 115 | 116 | 117 | /************************************************************************** 118 | * Inline 119 | **************************************************************************/ 120 | 121 | 122 | } // namespace Log4Qt 123 | 124 | 125 | // Q_DECLARE_TYPEINFO(Log4Qt::LoggerRepository, Q_COMPLEX_TYPE); // Use default 126 | 127 | 128 | #endif // LOG4QT_LOGGERREPOSITORY_H 129 | -------------------------------------------------------------------------------- /log4qt/mdc.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: mdc.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * changes Feb 2009, Martin Heinrich 10 | * - Fixed unreferenced formal parameter warning by using 11 | * Q_UNUSED in operator<<. 12 | * 13 | * 14 | * Copyright 2007 - 2009 Martin Heinrich 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | *****************************************************************************/ 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Dependencies 34 | ******************************************************************************/ 35 | 36 | 37 | #include "log4qt/mdc.h" 38 | 39 | #include 40 | #include 41 | #include 42 | #include "log4qt/helpers/initialisationhelper.h" 43 | #include "log4qt/logger.h" 44 | 45 | 46 | 47 | namespace Log4Qt 48 | { 49 | 50 | 51 | /************************************************************************** 52 | * Declarations 53 | **************************************************************************/ 54 | 55 | 56 | 57 | /************************************************************************** 58 | * C helper functions 59 | **************************************************************************/ 60 | 61 | 62 | 63 | /************************************************************************** 64 | * Class implementation: MDC 65 | **************************************************************************/ 66 | 67 | 68 | QString MDC::get(const QString &rKey) 69 | { 70 | if (!instance()->mHash.hasLocalData()) 71 | return QString(); 72 | 73 | return instance()->mHash.localData()->value(rKey); 74 | } 75 | 76 | 77 | QHash MDC::context() 78 | { 79 | if (!instance()->mHash.hasLocalData()) 80 | return QHash(); 81 | 82 | return *instance()->mHash.localData(); 83 | } 84 | 85 | 86 | LOG4QT_IMPLEMENT_INSTANCE(MDC) 87 | 88 | 89 | QHash *MDC::localData() 90 | { 91 | if (!instance()->mHash.hasLocalData()) 92 | instance()->mHash.setLocalData(new QHash); 93 | return instance()->mHash.localData(); 94 | } 95 | 96 | 97 | 98 | /************************************************************************** 99 | * Implementation: Operators, Helper 100 | **************************************************************************/ 101 | 102 | 103 | #ifndef QT_NO_DEBUG_STREAM 104 | QDebug operator<<(QDebug debug, const MDC &rMDC) 105 | { 106 | Q_UNUSED(rMDC); // To avoid warning C4100 on VS 2008 107 | debug.nospace() << "MDC(" 108 | << "thread:" << QThread::currentThread()->objectName() << " " 109 | << "context:" << rMDC.context() 110 | << ")"; 111 | return debug.space(); 112 | } 113 | #endif // QT_NO_DEBUG_STREAM 114 | 115 | 116 | } // namespace Log4Qt 117 | -------------------------------------------------------------------------------- /log4qt/mdc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: mdc.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_MDC_H 26 | #define LOG4QT_MDC_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include 34 | #include 35 | #include 36 | #include "log4qt/log4qt.h" 37 | 38 | 39 | /****************************************************************************** 40 | * Declarations 41 | ******************************************************************************/ 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | 47 | /*! 48 | * \brief The class MDC implements a mapped diagnostic context. 49 | * 50 | * \note All the functions declared in this class are thread-safe. 51 | */ 52 | class MDC 53 | { 54 | private: 55 | MDC(); 56 | MDC(const MDC &rOther); // Not implemented 57 | // virtual ~MDC(); // Use compiler default 58 | MDC &operator=(const MDC &rOther); // Not implemented 59 | 60 | public: 61 | static QString get(const QString &rKey); 62 | static QHash context(); 63 | 64 | /*! 65 | * Returns the MDC instance. 66 | */ 67 | static MDC *instance(); 68 | 69 | static void put(const QString &rKey, const QString &rValue); 70 | static void remove(const QString &rKey); 71 | 72 | private: 73 | static QHash *localData(); 74 | 75 | private: 76 | QThreadStorage< QHash * > mHash; 77 | }; 78 | 79 | 80 | /************************************************************************** 81 | * Operators, Helper 82 | **************************************************************************/ 83 | 84 | #ifndef QT_NO_DEBUG_STREAM 85 | /*! 86 | * \relates MDC 87 | * 88 | * Writes all object member variables to the given debug stream \a rDebug 89 | * and returns the stream. 90 | * 91 | * 92 | * %MDC(thread:"main" context:QHash(("login", "Peter")("database", "UAT")) ) 93 | * 94 | * \sa QDebug 95 | */ 96 | QDebug operator<<(QDebug debug, 97 | const MDC &rMDC); 98 | #endif // QT_NO_DEBUG_STREAM 99 | 100 | 101 | /************************************************************************** 102 | * Inline 103 | **************************************************************************/ 104 | 105 | inline MDC::MDC() : 106 | mHash() 107 | {} 108 | 109 | inline void MDC::put(const QString &rKey, const QString &rValue) 110 | { localData()->insert(rKey, rValue); } 111 | 112 | inline void MDC::remove(const QString &rKey) 113 | { localData()->remove(rKey); } 114 | 115 | 116 | } // namespace Log4Qt 117 | 118 | 119 | // Q_DECLARE_TYPEINFO(Log4Qt::MDC, Q_COMPLEX_TYPE); // Use default 120 | 121 | 122 | #endif // LOG4QT_MDC_H 123 | -------------------------------------------------------------------------------- /log4qt/ndc.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: ndc.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * changes Feb 2009, Martin Heinrich 10 | * - Fixed VS 2008 unreferenced formal parameter warning by using 11 | * Q_UNUSED in operator<<. 12 | * 13 | * 14 | * Copyright 2007 - 2009 Martin Heinrich 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | *****************************************************************************/ 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Dependencies 34 | ******************************************************************************/ 35 | 36 | 37 | #include "log4qt/ndc.h" 38 | 39 | #include 40 | #include 41 | #include 42 | #include "log4qt/helpers/initialisationhelper.h" 43 | #include "log4qt/logger.h" 44 | 45 | 46 | 47 | namespace Log4Qt 48 | { 49 | 50 | 51 | /************************************************************************** 52 | * Declarations 53 | **************************************************************************/ 54 | 55 | 56 | 57 | /************************************************************************** 58 | * C helper functions 59 | **************************************************************************/ 60 | 61 | 62 | LOG4QT_DECLARE_STATIC_LOGGER(logger, Log4Qt:NDC) 63 | 64 | 65 | 66 | /************************************************************************** 67 | * Class implementation: NDC 68 | **************************************************************************/ 69 | 70 | 71 | void NDC::clear() 72 | { 73 | if (!instance()->mStack.hasLocalData()) 74 | return; 75 | 76 | instance()->mStack.localData()->clear(); 77 | } 78 | 79 | 80 | int NDC::depth() 81 | { 82 | if (!instance()->mStack.hasLocalData()) 83 | return 0; 84 | 85 | return instance()->mStack.localData()->count(); 86 | } 87 | 88 | 89 | LOG4QT_IMPLEMENT_INSTANCE(NDC) 90 | 91 | 92 | QString NDC::pop() 93 | { 94 | if (!instance()->mStack.hasLocalData() || instance()->mStack.localData()->isEmpty()) 95 | { 96 | logger()->warn("Requesting pop from empty NDC stack"); 97 | return QString(); 98 | } 99 | 100 | return instance()->mStack.localData()->pop(); 101 | } 102 | 103 | 104 | void NDC::push(const QString &rMessage) 105 | { 106 | if (!instance()->mStack.hasLocalData()) 107 | instance()->mStack.setLocalData(new QStack); 108 | 109 | instance()->mStack.localData()->push(rMessage); 110 | } 111 | 112 | 113 | void NDC::setMaxDepth(int maxDepth) 114 | { 115 | if (!instance()->mStack.hasLocalData() || 116 | instance()->mStack.localData()->size() <= maxDepth) 117 | return; 118 | 119 | instance()->mStack.localData()->resize(maxDepth); 120 | } 121 | 122 | 123 | QString NDC::peek() 124 | { 125 | if (!instance()->mStack.hasLocalData() || 126 | instance()->mStack.localData()->isEmpty()) 127 | return QString(); 128 | 129 | return instance()->mStack.localData()->top(); 130 | } 131 | 132 | 133 | 134 | /************************************************************************** 135 | * Implementation: Operators, Helper 136 | **************************************************************************/ 137 | 138 | 139 | #ifndef QT_NO_DEBUG_STREAM 140 | QDebug operator<<(QDebug debug, 141 | const NDC &rNDC) 142 | { 143 | Q_UNUSED(rNDC); // To avoid warning C4100 on VS 2008 144 | debug.nospace() << "NDC(" 145 | << "thread:" << QThread::currentThread()->objectName() << " " 146 | << "peek:" << rNDC.peek() << " " 147 | << "depth:" << rNDC.depth() 148 | << ")"; 149 | return debug.space(); 150 | } 151 | #endif // QT_NO_DEBUG_STREAM 152 | 153 | 154 | } // namespace Log4Qt 155 | -------------------------------------------------------------------------------- /log4qt/ndc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: ndc.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_NDC_H 26 | #define LOG4QT_NDC_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include 34 | #include 35 | #include 36 | #include "log4qt/log4qt.h" 37 | 38 | 39 | /****************************************************************************** 40 | * Declarations 41 | ******************************************************************************/ 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | /*! 47 | * \brief The class NDC implements a nested diagnostic context. 48 | * 49 | * The method remove() is not required. QThreadStorage cleans up on thread 50 | * exit. 51 | * 52 | * \note All the functions declared in this class are thread-safe. 53 | */ 54 | class NDC 55 | { 56 | private: 57 | NDC(); 58 | NDC(const NDC &rOther); // Not implemented 59 | // virtual ~NDC(); // Use compiler default 60 | NDC &operator=(const NDC &rOther); // Not implemented 61 | 62 | public: 63 | static void clear(); 64 | // JAVA: static QStack cloneStack(); 65 | // JAVA: static QString get(); 66 | static int depth(); 67 | // JAVA: inherit(Stack stack) 68 | 69 | /*! 70 | * Returns the NDC instance. 71 | */ 72 | static NDC *instance(); 73 | 74 | static QString pop(); 75 | static void push(const QString &rMessage); 76 | // JAVA: static void remove(); // Not required 77 | static void setMaxDepth(int maxDepth); 78 | static QString peek(); 79 | 80 | private: 81 | QThreadStorage< QStack * > mStack; 82 | }; 83 | 84 | 85 | /****************************************************************************** 86 | * Operators, Helper 87 | ******************************************************************************/ 88 | 89 | #ifndef QT_NO_DEBUG_STREAM 90 | /*! 91 | * \relates NDC 92 | * 93 | * Writes all object member variables to the given debug stream \a rDebug and 94 | * returns the stream. 95 | * 96 | * 97 | * %NDC(thread:"main" peek:"i = 3" depth:4) 98 | * 99 | * \sa QDebug 100 | */ 101 | QDebug operator<<(QDebug debug, 102 | const NDC &rNDC); 103 | #endif // QT_NO_DEBUG_STREAM 104 | 105 | 106 | /****************************************************************************** 107 | * Inline 108 | ******************************************************************************/ 109 | 110 | inline NDC::NDC() : 111 | mStack() 112 | {} 113 | 114 | 115 | } // namespace Log4Qt 116 | 117 | 118 | // Q_DECLARE_TYPEINFO(Log4Qt::NDC, Q_COMPLEX_TYPE); // Use default 119 | 120 | 121 | #endif // LOG4QT_NDC_H 122 | -------------------------------------------------------------------------------- /log4qt/patternlayout.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: patternlayout.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/patternlayout.h" 33 | 34 | #include 35 | #include "log4qt/helpers/patternformatter.h" 36 | #include "log4qt/loggingevent.h" 37 | 38 | 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | 44 | /************************************************************************** 45 | * Declarations 46 | **************************************************************************/ 47 | 48 | 49 | 50 | /************************************************************************** 51 | * C helper functions 52 | **************************************************************************/ 53 | 54 | 55 | 56 | /************************************************************************** 57 | * Class implementation: PatternLayout 58 | **************************************************************************/ 59 | 60 | 61 | PatternLayout::PatternLayout(QObject *pParent) : 62 | Layout(pParent), 63 | mPattern(), 64 | mpPatternFormatter(0) 65 | { 66 | setConversionPattern(DEFAULT_CONVERSION_PATTERN); 67 | } 68 | 69 | 70 | PatternLayout::PatternLayout(const QString &rPattern, 71 | QObject *pParent) : 72 | Layout(pParent), 73 | mPattern(), 74 | mpPatternFormatter(0) 75 | { 76 | setConversionPattern(rPattern); 77 | } 78 | 79 | 80 | PatternLayout::PatternLayout(ConversionPattern conversionPattern, 81 | QObject *pParent) : 82 | Layout(pParent), 83 | mPattern(), 84 | mpPatternFormatter(0) 85 | { 86 | setConversionPattern(conversionPattern); 87 | } 88 | 89 | 90 | PatternLayout::~PatternLayout() 91 | { 92 | delete mpPatternFormatter; 93 | } 94 | 95 | 96 | void PatternLayout::setConversionPattern(ConversionPattern conversionPattern) 97 | { 98 | switch (conversionPattern) 99 | { 100 | case DEFAULT_CONVERSION_PATTERN: 101 | setConversionPattern(QLatin1String("%m%n")); 102 | break; 103 | case TTCC_CONVERSION_PATTERN: 104 | setConversionPattern(QLatin1String("%r [%t] %p %c %x - %m%n")); 105 | break; 106 | default: 107 | Q_ASSERT_X(false, "PatternLayout::setConversionFormat", "Unkown ConversionFormat"); 108 | setConversionPattern(QString()); 109 | } 110 | } 111 | 112 | 113 | QString PatternLayout::format(const LoggingEvent &rEvent) 114 | { 115 | Q_ASSERT_X(mpPatternFormatter, "PatternLayout::format()", "mpPatternConverter must not be null"); 116 | 117 | return mpPatternFormatter->format(rEvent); 118 | } 119 | 120 | 121 | void PatternLayout::updatePatternFormatter() 122 | { 123 | delete mpPatternFormatter; 124 | mpPatternFormatter = new PatternFormatter(mPattern); 125 | } 126 | 127 | 128 | #ifndef QT_NO_DEBUG_STREAM 129 | QDebug PatternLayout::debug(QDebug &rDebug) const 130 | { 131 | rDebug.nospace() << "PatternLayout(" 132 | << "name:" << name() << " " 133 | << "pattern:" << conversionPattern() << " " 134 | << "referencecount:" << referenceCount() 135 | << ")"; 136 | return rDebug.space(); 137 | } 138 | #endif // QT_NO_DEBUG_STREAM 139 | 140 | 141 | 142 | /************************************************************************** 143 | * Implementation: Operators, Helper 144 | **************************************************************************/ 145 | 146 | 147 | } // namespace Log4Qt 148 | -------------------------------------------------------------------------------- /log4qt/patternlayout.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: patternlayout.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_PATTERNLAYOUT_H 26 | #define LOG4QT_PATTERNLAYOUT_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/layout.h" 34 | 35 | 36 | /****************************************************************************** 37 | * Declarations 38 | ******************************************************************************/ 39 | 40 | 41 | namespace Log4Qt 42 | { 43 | 44 | class PatternFormatter; 45 | 46 | /*! 47 | * \brief The class PatternLayout outputs a logging event based on a 48 | * pattern string. 49 | * 50 | * \note The ownership and lifetime of objects of this class are managed. 51 | * See \ref Ownership "Object ownership" for more details. 52 | */ 53 | class PatternLayout : public Layout 54 | { 55 | Q_OBJECT 56 | 57 | /*! 58 | * The property holds the conversion pattern used by the appender. 59 | * 60 | * The default is "%m%n". 61 | * 62 | * \sa conversionPattern(), setConversionPattern() 63 | */ 64 | Q_PROPERTY(QString conversionPattern READ conversionPattern WRITE setConversionPattern) 65 | 66 | public: 67 | /*! 68 | * The enum ConversionPattern defines constants for pattern strings. 69 | * 70 | * \sa setConversionPattern(ConversionPattern); 71 | */ 72 | enum ConversionPattern 73 | { 74 | /*! The default conversion pattern string is "%m,%n". */ 75 | DEFAULT_CONVERSION_PATTERN, 76 | /*! 77 | * The ttcc conversion pattern string is 78 | * "%r [%t] %p %c %x - %m%n". 79 | */ 80 | TTCC_CONVERSION_PATTERN, 81 | }; 82 | Q_ENUMS(ConversionPattern) 83 | 84 | PatternLayout(QObject *pParent = 0); 85 | PatternLayout(const QString &rPattern, 86 | QObject *pParent = 0); 87 | 88 | /*! 89 | * Creates a PatternLayout with the conversion pattern value specified 90 | * by the \a conversionPattern constant. 91 | */ 92 | PatternLayout(ConversionPattern conversionPattern, 93 | QObject *pParent = 0); 94 | 95 | virtual ~PatternLayout(); 96 | private: 97 | PatternLayout(const PatternLayout &rOther); // Not implemented 98 | PatternLayout &operator=(const PatternLayout &rOther); // Not implemented 99 | 100 | public: 101 | QString conversionPattern() const; 102 | void setConversionPattern(const QString &rPattern); 103 | 104 | /*! 105 | * Sets the conversion pattern to the value specified by the 106 | * \a conversionPattern constant. 107 | */ 108 | void setConversionPattern(ConversionPattern conversionPattern); 109 | 110 | virtual QString format(const LoggingEvent &rEvent); 111 | 112 | protected: 113 | #ifndef QT_NO_DEBUG_STREAM 114 | /*! 115 | * Writes all object member variables to the given debug stream 116 | * \a rDebug and returns the stream. 117 | * 118 | * 119 | * %PatternLayout(name:"PL" pattern:"%r [%t] %p %c %x - %m%n" 120 | * "referencecount:3") 121 | * 122 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 123 | */ 124 | virtual QDebug debug(QDebug &rDebug) const; 125 | #endif // QT_NO_DEBUG_STREAM 126 | 127 | private: 128 | void updatePatternFormatter(); 129 | 130 | private: 131 | QString mPattern; 132 | PatternFormatter *mpPatternFormatter; 133 | }; 134 | 135 | 136 | /************************************************************************** 137 | * Operators, Helper 138 | **************************************************************************/ 139 | 140 | 141 | /************************************************************************** 142 | * Inline 143 | **************************************************************************/ 144 | 145 | inline QString PatternLayout::conversionPattern() const 146 | { return PatternLayout::mPattern; } 147 | 148 | inline void PatternLayout::setConversionPattern(const QString &rPattern) 149 | { mPattern = rPattern; 150 | updatePatternFormatter(); } 151 | 152 | 153 | } // namespace Log4Qt 154 | 155 | 156 | // Q_DECLARE_TYPEINFO(Log4Qt::PatternLayout, Q_COMPLEX_TYPE); // Use default 157 | 158 | 159 | #endif // LOG4QT_PATTERNLAYOUT_H 160 | -------------------------------------------------------------------------------- /log4qt/simplelayout.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: simplelayout.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/simplelayout.h" 33 | 34 | #include 35 | #include "log4qt/loggingevent.h" 36 | 37 | 38 | 39 | namespace Log4Qt 40 | { 41 | 42 | 43 | /************************************************************************** 44 | * Declarations 45 | **************************************************************************/ 46 | 47 | 48 | 49 | /************************************************************************** 50 | * C helper functions 51 | **************************************************************************/ 52 | 53 | 54 | 55 | /************************************************************************** 56 | * Class implementation: SimpleLayout 57 | **************************************************************************/ 58 | 59 | 60 | QString SimpleLayout::format(const LoggingEvent &rEvent) 61 | { 62 | return rEvent.level().toString() + QLatin1String(" - ") + rEvent.message() + Layout::endOfLine(); 63 | } 64 | 65 | 66 | #ifndef QT_NO_DEBUG_STREAM 67 | QDebug SimpleLayout::debug(QDebug &rDebug) const 68 | { 69 | rDebug.nospace() << "SimpleLayout(" 70 | << "name:" << name() << " " 71 | << "referencecount:" << referenceCount() 72 | << ")"; 73 | return rDebug.space(); 74 | } 75 | #endif // QT_NO_DEBUG_STREAM 76 | 77 | 78 | 79 | /************************************************************************** 80 | * Implementation: Operators, Helper 81 | **************************************************************************/ 82 | 83 | 84 | } // namespace Log4Qt 85 | -------------------------------------------------------------------------------- /log4qt/simplelayout.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: simplelayout.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_SIMPLELAYOUT_H 26 | #define LOG4QT_SIMPLELAYOUT_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/layout.h" 34 | 35 | 36 | /****************************************************************************** 37 | * Declarations 38 | ******************************************************************************/ 39 | 40 | 41 | namespace Log4Qt 42 | { 43 | 44 | /*! 45 | * \brief The class SimpleLayout outputs the level and message of a logging 46 | * event. 47 | * 48 | * \note The ownership and lifetime of objects of this class are managed. 49 | * See \ref Ownership "Object ownership" for more details. 50 | */ 51 | class SimpleLayout : public Layout 52 | { 53 | Q_OBJECT 54 | 55 | public: 56 | SimpleLayout(QObject *pParent = 0); 57 | // virtual ~SimpleLayout(); // Use compiler default 58 | private: 59 | SimpleLayout(const SimpleLayout &rOther); // Not implemented 60 | SimpleLayout &operator=(const SimpleLayout &rOther); // Not implemented 61 | 62 | public: 63 | virtual QString format(const LoggingEvent &rEvent); 64 | 65 | protected: 66 | 67 | #ifndef QT_NO_DEBUG_STREAM 68 | /*! 69 | * Writes all object member variables to the given debug stream 70 | * \a rDebug and returns the stream. 71 | * 72 | * 73 | * %SimpleLayout(name:"SL" referencecount:1) 74 | * 75 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 76 | */ 77 | virtual QDebug debug(QDebug &rDebug) const; 78 | #endif // QT_NO_DEBUG_STREAM 79 | }; 80 | 81 | 82 | /************************************************************************** 83 | * Operators, Helper 84 | **************************************************************************/ 85 | 86 | 87 | /************************************************************************** 88 | * Inline 89 | **************************************************************************/ 90 | 91 | inline SimpleLayout::SimpleLayout(QObject *pParent) : 92 | Layout(pParent) 93 | {} 94 | 95 | 96 | } // namespace Log4Qt 97 | 98 | 99 | // Q_DECLARE_TYPEINFO(Log4Qt::SimpleLayout, Q_COMPLEX_TYPE); // Use default 100 | 101 | 102 | #endif // LOG4QT_SIMPLELAYOUT_H 103 | -------------------------------------------------------------------------------- /log4qt/spi/filter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: filter.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/spi/filter.h" 33 | 34 | #include 35 | 36 | 37 | namespace Log4Qt 38 | { 39 | 40 | 41 | /************************************************************************** 42 | * Declarations 43 | **************************************************************************/ 44 | 45 | 46 | 47 | /************************************************************************** 48 | * C helper functions 49 | **************************************************************************/ 50 | 51 | 52 | 53 | /************************************************************************** 54 | * Class implementation: Filter 55 | **************************************************************************/ 56 | 57 | 58 | void Filter::setNext(Filter *pFilter) 59 | { 60 | mpNext = pFilter; 61 | } 62 | 63 | 64 | 65 | /************************************************************************** 66 | * Implementation: Operators, Helper 67 | **************************************************************************/ 68 | 69 | 70 | } // namespace Log4Qt 71 | -------------------------------------------------------------------------------- /log4qt/spi/filter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: filter.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_FILTER_H 26 | #define LOG4QT_FILTER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/helpers/logobject.h" 34 | 35 | #include "log4qt/helpers/logobjectptr.h" 36 | #include "log4qt/log4qt.h" 37 | 38 | 39 | /****************************************************************************** 40 | * Declarations 41 | ******************************************************************************/ 42 | 43 | namespace Log4Qt 44 | { 45 | 46 | class LoggingEvent; 47 | 48 | /*! 49 | * \brief The class Filter is the base class for all filters. 50 | * 51 | * \note The ownership and lifetime of objects of this class are managed. 52 | * See \ref Ownership "Object ownership" for more details. 53 | */ 54 | class Filter : public LogObject 55 | { 56 | Q_OBJECT 57 | 58 | /*! 59 | * The property holds the next filter of this filter. 60 | * 61 | * The default is 0 for no next filter. 62 | * 63 | * \sa next(), setNext() 64 | */ 65 | Q_PROPERTY(Filter* next READ next WRITE setNext) 66 | 67 | public: 68 | enum Decision 69 | { 70 | ACCEPT, 71 | DENY, 72 | NEUTRAL 73 | }; 74 | Q_ENUMS(Decision); 75 | 76 | public: 77 | Filter(QObject *pObject = 0); 78 | // Filter(const Filter &rOther); // Use compiler default 79 | virtual ~Filter(); 80 | // Filter &operator=(const Filter &rOther); // Use compiler default 81 | 82 | Filter* next() const; 83 | void setNext(Filter *pFilter); 84 | 85 | virtual void activateOptions(); 86 | virtual Decision decide(const LoggingEvent &rEvent) const = 0; 87 | 88 | private: 89 | LogObjectPtr mpNext; 90 | }; 91 | 92 | 93 | /************************************************************************** 94 | * Operators, Helper 95 | **************************************************************************/ 96 | 97 | 98 | /************************************************************************** 99 | * Inline 100 | **************************************************************************/ 101 | 102 | inline Filter::Filter(QObject *pObject) : 103 | LogObject(pObject), 104 | mpNext(0) 105 | {} 106 | 107 | inline Filter::~Filter() 108 | {} 109 | 110 | inline Filter* Filter::next() const 111 | { return mpNext; } 112 | 113 | inline void Filter::activateOptions() 114 | {} 115 | 116 | 117 | } // namespace Log4Qt 118 | 119 | 120 | // Q_DECLARE_TYPEINFO(Log4Qt::Filter, Q_COMPLEX_TYPE); // Use default 121 | Q_DECLARE_TYPEINFO(Log4Qt::LogObjectPtr, Q_MOVABLE_TYPE); 122 | 123 | 124 | #endif // LOG4QT_FILTER_H 125 | -------------------------------------------------------------------------------- /log4qt/varia/debugappender.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: debugappender.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/debugappender.h" 33 | 34 | #include 35 | #include 36 | #include "log4qt/layout.h" 37 | #include "log4qt/loggingevent.h" 38 | 39 | #if defined(Q_WS_WIN) 40 | #include 41 | #endif 42 | 43 | 44 | namespace Log4Qt 45 | { 46 | 47 | 48 | /************************************************************************** 49 | * Declarations 50 | **************************************************************************/ 51 | 52 | 53 | 54 | /************************************************************************** 55 | * C helper functions 56 | **************************************************************************/ 57 | 58 | 59 | 60 | /************************************************************************** 61 | * Class implementation: DebugAppender 62 | **************************************************************************/ 63 | 64 | 65 | DebugAppender::DebugAppender(Layout *pLayout, 66 | QObject *pParent) : 67 | AppenderSkeleton(pParent) 68 | { 69 | setLayout(pLayout); 70 | } 71 | 72 | 73 | bool DebugAppender::requiresLayout() const 74 | { 75 | return true; 76 | } 77 | 78 | 79 | void DebugAppender::append(const LoggingEvent &rEvent) 80 | { 81 | // Q_ASSERT_X(, "DebugAppender::append()", "Lock must be held by caller"); 82 | Q_ASSERT_X(layout(), "DebugAppender::append()", "Layout must not be null"); 83 | 84 | QString message(layout()->format(rEvent)); 85 | #if defined(Q_WS_WIN) 86 | QT_WA({ 87 | OutputDebugStringW(reinterpret_cast(message.utf16())); 88 | }, { 89 | OutputDebugStringA(message.toLocal8Bit().data()); 90 | }); 91 | #else 92 | fprintf(stderr, "%s", message.toLocal8Bit().data()); 93 | fflush(stderr); 94 | #endif 95 | } 96 | 97 | 98 | 99 | /************************************************************************** 100 | * Implementation: Operators, Helper 101 | **************************************************************************/ 102 | 103 | 104 | #ifndef QT_NO_DEBUG_STREAM 105 | QDebug DebugAppender::debug(QDebug &rDebug) const 106 | { 107 | QString layout_name; 108 | if (layout()) 109 | layout_name = layout()->name(); 110 | 111 | rDebug.nospace() << "DebugAppender(" 112 | << "name:" << name() << " " 113 | << "filter:" << firstFilter() << " " 114 | << "isactive:" << isActive() << " " 115 | << "isclosed:" << isClosed() << " " 116 | << "layout:" << layout_name << " " 117 | << "referencecount:" << referenceCount() << " " 118 | << "threshold:" << threshold().toString() 119 | << ")"; 120 | return rDebug.space(); 121 | } 122 | #endif // QT_NO_DEBUG_STREAM 123 | 124 | 125 | } // namspace Log4Qt 126 | -------------------------------------------------------------------------------- /log4qt/varia/debugappender.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: debugappender.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_DEBUGAPPENDER_H 26 | #define LOG4QT_DEBUGAPPENDER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/appenderskeleton.h" 34 | 35 | 36 | /****************************************************************************** 37 | * Declarations 38 | ******************************************************************************/ 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | /*! 44 | * \brief The class DebugAppender appends logging events to the platform 45 | * specific debug output. 46 | * 47 | * A DebugAppender appends to the Debugger on Windows and to stderr on all 48 | * other systems. 49 | * 50 | * \note All the functions declared in this class are thread-safe. 51 | * 52 | * \note The ownership and lifetime of objects of this class are managed. 53 | * See \ref Ownership "Object ownership" for more details. 54 | */ 55 | class DebugAppender : public AppenderSkeleton 56 | { 57 | Q_OBJECT 58 | 59 | public: 60 | /*! 61 | * Creates a DebugAppender. 62 | */ 63 | DebugAppender(QObject *pParent = 0); 64 | 65 | /*! 66 | * Creates a DebugAppender with the specified layout \a pLayout 67 | */ 68 | DebugAppender(Layout *pLayout, 69 | QObject *pParent = 0); 70 | 71 | // virtual ~DebugAppender(); // Use compiler default 72 | private: 73 | DebugAppender(const DebugAppender &rOther); // Not implemented 74 | DebugAppender &operator=(const DebugAppender &rOther); // Not implemented 75 | 76 | public: 77 | /*! 78 | * The DebugAppended requires a layout. The function returns true. 79 | * 80 | * \sa setLayout() 81 | */ 82 | virtual bool requiresLayout() const; 83 | 84 | protected: 85 | /*! 86 | * Appends the specified logging event \a rEvent to the debug output. 87 | * The output is formatted using the appender's layout. 88 | * 89 | * The method is called by the AppenderSkeleton::doAppend() after it 90 | * the entry conditions have been tested and it has been found that the 91 | * logging event needs to be appended. 92 | * 93 | * \sa setLayout(), AppenderSkeleton::doAppend(), checkEntryConditions() 94 | */ 95 | virtual void append(const LoggingEvent &rEvent); 96 | 97 | #ifndef QT_NO_DEBUG_STREAM 98 | /*! 99 | * Writes all object member variables to the given debug stream \a rDebug 100 | * and returns the stream. 101 | * 102 | * 103 | * %DebugAppender(name:"DA" filter:0x3bee6b8 isactive:true isclosed:false 104 | * layout:"SL" referencecount:1 threshold:"NULL") 105 | * 106 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 107 | */ 108 | virtual QDebug debug(QDebug &rDebug) const; 109 | #endif // QT_NO_DEBUG_STREAM 110 | }; 111 | 112 | 113 | /************************************************************************** 114 | * Operators, Helper 115 | **************************************************************************/ 116 | 117 | 118 | /************************************************************************** 119 | * Inline 120 | **************************************************************************/ 121 | 122 | inline DebugAppender::DebugAppender(QObject *pParent) : 123 | AppenderSkeleton(pParent) 124 | {} 125 | 126 | 127 | } // namespace Log4Qt 128 | 129 | 130 | // Q_DECLARE_TYPEINFO(Log4Qt::DebugAppender, Q_COMPLEX_TYPE); // Use default 131 | 132 | 133 | #endif // LOG4QT_DEBUGAPPENDER_H 134 | -------------------------------------------------------------------------------- /log4qt/varia/denyallfilter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: denyallfilter.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/denyallfilter.h" 33 | 34 | #include 35 | 36 | 37 | namespace Log4Qt 38 | { 39 | 40 | 41 | /************************************************************************** 42 | * Declarations 43 | **************************************************************************/ 44 | 45 | 46 | 47 | /************************************************************************** 48 | * C helper functions 49 | **************************************************************************/ 50 | 51 | 52 | 53 | /************************************************************************** 54 | * Class implementation: Filter 55 | **************************************************************************/ 56 | 57 | 58 | #ifndef QT_NO_DEBUG_STREAM 59 | QDebug DenyAllFilter::debug(QDebug &rDebug) const 60 | { 61 | rDebug.nospace() << "DenyAllFilter(" 62 | << "next:" << next() 63 | << "referencecount:" << referenceCount() << " " 64 | << ")"; 65 | return rDebug.space(); 66 | } 67 | #endif // QT_NO_DEBUG_STREAM 68 | 69 | 70 | 71 | /************************************************************************** 72 | * Implementation: Operators, Helper 73 | **************************************************************************/ 74 | 75 | 76 | 77 | } // namespace Log4Qt 78 | -------------------------------------------------------------------------------- /log4qt/varia/denyallfilter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: denyallfilter.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * changes Feb 2009, Martin Heinrich 10 | * - Fixed a compile error on VS 2008 by using Q_UNUSED(&rEvent) 11 | * instead of Q_UNUSED(rEvent) 12 | * 13 | * 14 | * Copyright 2007 - 2009 Martin Heinrich 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | ******************************************************************************/ 29 | 30 | #ifndef LOG4QT_DENYALLFILTER_H 31 | #define LOG4QT_DENYALLFILTER_H 32 | 33 | 34 | /****************************************************************************** 35 | * Dependencies 36 | ******************************************************************************/ 37 | 38 | #include "log4qt/spi/filter.h" 39 | 40 | 41 | /****************************************************************************** 42 | * Declarations 43 | ******************************************************************************/ 44 | 45 | namespace Log4Qt 46 | { 47 | 48 | /*! 49 | * \brief The class DenyAllFilter drops all logging events 50 | * 51 | * \note The ownership and lifetime of objects of this class are managed. 52 | * See \ref Ownership "Object ownership" for more details. 53 | */ 54 | class DenyAllFilter : public Filter 55 | { 56 | Q_OBJECT 57 | 58 | public: 59 | DenyAllFilter(QObject *pParent = 0); 60 | // DenyAllFilter(const DenyAllFilter &rOther); // Use compiler default 61 | // virtual ~DenyAllFilter(); // Use compiler default 62 | // DenyAllFilter &operator=(const DenyAllFilter &rOther); // Use compiler default 63 | 64 | virtual Decision decide(const LoggingEvent &rEvent) const; 65 | 66 | protected: 67 | #ifndef QT_NO_DEBUG_STREAM 68 | /*! 69 | * Writes all object member variables to the given debug stream \a rDebug 70 | * and returns the stream. 71 | * 72 | * 73 | * %DenyAllFilter(next:QObject(0x0) referencecount:1 ) 74 | * 75 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 76 | */ 77 | virtual QDebug debug(QDebug &rDebug) const; 78 | #endif // QT_NO_DEBUG_STREAM 79 | }; 80 | 81 | 82 | /************************************************************************* 83 | * Operators, Helper 84 | *************************************************************************/ 85 | 86 | 87 | /************************************************************************* 88 | * Inline 89 | *************************************************************************/ 90 | 91 | inline DenyAllFilter::DenyAllFilter(QObject *pParent) : 92 | Filter(pParent) 93 | {} 94 | 95 | inline Filter::Decision DenyAllFilter::decide(const LoggingEvent &rEvent) const 96 | { Q_UNUSED(&rEvent); return Filter::DENY; } 97 | 98 | 99 | } // namespace Log4Qt 100 | 101 | 102 | // Q_DECLARE_TYPEINFO(Log4Qt::DenyAllFilter, Q_MOVABLE_TYPE); // Use default 103 | 104 | 105 | #endif // LOG4QT_DENYALLFILTER_H 106 | -------------------------------------------------------------------------------- /log4qt/varia/levelmatchfilter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: levelmatchfilter.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/levelmatchfilter.h" 33 | 34 | #include 35 | #include "log4qt/loggingevent.h" 36 | 37 | 38 | namespace Log4Qt 39 | { 40 | 41 | 42 | /************************************************************************** 43 | * Declarations 44 | **************************************************************************/ 45 | 46 | 47 | 48 | /************************************************************************** 49 | * C helper functions 50 | **************************************************************************/ 51 | 52 | 53 | 54 | /************************************************************************** 55 | * Class implementation: Filter 56 | **************************************************************************/ 57 | 58 | 59 | LevelMatchFilter::LevelMatchFilter(QObject *pParent) : 60 | Filter(pParent), 61 | mAcceptOnMatch(true), 62 | mLevelToMatch(Level::NULL_INT) 63 | {} 64 | 65 | 66 | Filter::Decision LevelMatchFilter::decide(const LoggingEvent &rEvent) const 67 | { 68 | if (mLevelToMatch == Level::NULL_INT || 69 | rEvent.level() != mLevelToMatch) 70 | return Filter::NEUTRAL; 71 | 72 | if (mAcceptOnMatch) 73 | return Filter::ACCEPT; 74 | else 75 | return Filter::DENY; 76 | } 77 | 78 | 79 | #ifndef QT_NO_DEBUG_STREAM 80 | QDebug LevelMatchFilter::debug(QDebug &rDebug) const 81 | { 82 | rDebug.nospace() << "LevelMatchFilter(" 83 | << "acceptonmatch:" << mAcceptOnMatch << " " 84 | << "leveltomatch:" << mLevelToMatch.toString() << " " 85 | << "next:" << next() 86 | << "referencecount:" << referenceCount() << " " 87 | << ")"; 88 | return rDebug.space(); 89 | } 90 | #endif // QT_NO_DEBUG_STREAM 91 | 92 | 93 | 94 | /************************************************************************** 95 | * Implementation: Operators, Helper 96 | **************************************************************************/ 97 | 98 | 99 | 100 | } // namespace Log4Qt 101 | -------------------------------------------------------------------------------- /log4qt/varia/levelmatchfilter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: levelmatchfilter.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_LEVELMATCHFILTER_H 26 | #define LOG4QT_LEVELMATCHFILTER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/spi/filter.h" 34 | 35 | #include "log4qt/level.h" 36 | 37 | 38 | /****************************************************************************** 39 | * Declarations 40 | ******************************************************************************/ 41 | 42 | namespace Log4Qt 43 | { 44 | 45 | /*! 46 | * \brief The class LevelMatchFilter allows logging events with a specified 47 | * level. 48 | * 49 | * \note The ownership and lifetime of objects of this class are managed. 50 | * See \ref Ownership "Object ownership" for more details. 51 | */ 52 | class LevelMatchFilter : public Filter 53 | { 54 | Q_OBJECT 55 | 56 | /*! 57 | * The property holds if an event is accpeted on a match. 58 | * 59 | * The default is true. 60 | * 61 | * \sa acceptOnMatch(), setAcceptOnMatch() 62 | */ 63 | Q_PROPERTY(bool acceptOnMatch READ acceptOnMatch WRITE setAcceptOnMatch) 64 | 65 | /*! 66 | * The property holds the level to match for this filter. 67 | * 68 | * The default is Level::NULL_INT. 69 | * 70 | * \sa levelToMatch(), setLevelToMatch() 71 | */ 72 | Q_PROPERTY(Level levelToMatch READ levelToMatch WRITE setLevelToMatch) 73 | 74 | public: 75 | LevelMatchFilter(QObject *pParent = 0); 76 | // LevelMatchFilter(const LevelMatchFilter &rOther); // Use compiler default 77 | // virtual ~LevelMatchFilter(); // Use compiler default 78 | // LevelMatchFilter &operator=(const LevelMatchFilter &rOther); // Use compiler default 79 | 80 | bool acceptOnMatch() const; 81 | Level levelToMatch() const; 82 | void setAcceptOnMatch(bool accept); 83 | void setLevelToMatch(Level level); 84 | 85 | virtual Decision decide(const LoggingEvent &rEvent) const; 86 | 87 | protected: 88 | #ifndef QT_NO_DEBUG_STREAM 89 | /*! 90 | * Writes all object member variables to the given debug stream \a rDebug 91 | * and returns the stream. 92 | * 93 | * 94 | * %LevelMatchFilter(acceptonmatch:true leveltomatch:"WARN" 95 | * next:Log4Qt::DenyAllFilter(0x3bce3a8) 96 | * referencecount:1 ) 97 | * 98 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 99 | */ 100 | virtual QDebug debug(QDebug &rDebug) const; 101 | #endif // QT_NO_DEBUG_STREAM 102 | 103 | private: 104 | bool mAcceptOnMatch; 105 | Level mLevelToMatch; 106 | }; 107 | 108 | 109 | /************************************************************************** 110 | * Operators, Helper 111 | **************************************************************************/ 112 | 113 | 114 | /************************************************************************** 115 | * Inline 116 | **************************************************************************/ 117 | 118 | inline bool LevelMatchFilter::acceptOnMatch() const 119 | { return mAcceptOnMatch; } 120 | 121 | inline Level LevelMatchFilter::levelToMatch() const 122 | { return mLevelToMatch; } 123 | 124 | inline void LevelMatchFilter::setAcceptOnMatch(bool accept) 125 | { mAcceptOnMatch = accept; } 126 | 127 | inline void LevelMatchFilter::setLevelToMatch(Level level) 128 | { mLevelToMatch = level; } 129 | 130 | 131 | } // namespace Log4Qt 132 | 133 | 134 | // Q_DECLARE_TYPEINFO(Log4Qt::LevelMatchFilter, Q_MOVABLE_TYPE); // Use default 135 | 136 | 137 | #endif // LOG4QT_LEVELMATCHFILTER_H 138 | -------------------------------------------------------------------------------- /log4qt/varia/levelrangefilter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: levelrangefilter.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/levelrangefilter.h" 33 | 34 | #include 35 | #include "log4qt/loggingevent.h" 36 | 37 | 38 | namespace Log4Qt 39 | { 40 | 41 | 42 | /****************************************************************************** 43 | * Declarations 44 | ******************************************************************************/ 45 | 46 | 47 | 48 | /****************************************************************************** 49 | * C helper functions 50 | ******************************************************************************/ 51 | 52 | 53 | 54 | /****************************************************************************** 55 | * Class implementation: Filter 56 | ******************************************************************************/ 57 | 58 | 59 | LevelRangeFilter::LevelRangeFilter(QObject *pParent) : 60 | Filter(pParent), 61 | mAcceptOnMatch(true), 62 | mLevelMin(Level::NULL_INT), 63 | mLevelMax(Level::OFF_INT) 64 | {} 65 | 66 | 67 | Filter::Decision LevelRangeFilter::decide(const LoggingEvent &rEvent) const 68 | { 69 | if (rEvent.level() < mLevelMin) 70 | return Filter::DENY; 71 | 72 | if (rEvent.level() > mLevelMax) 73 | return Filter::DENY; 74 | 75 | if (mAcceptOnMatch) 76 | return Filter::ACCEPT; 77 | else 78 | return Filter::NEUTRAL; 79 | } 80 | 81 | 82 | #ifndef QT_NO_DEBUG_STREAM 83 | QDebug LevelRangeFilter::debug(QDebug &rDebug) const 84 | { 85 | rDebug.nospace() << "LevelRangeFilter(" 86 | << "acceptonmatch:" << mAcceptOnMatch << " " 87 | << "levelmin:" << mLevelMin.toString() << " " 88 | << "levelmax:" << mLevelMax.toString() << " " 89 | << "next:" << next() 90 | << "referencecount:" << referenceCount() << " " 91 | << ")"; 92 | return rDebug.space(); 93 | } 94 | #endif // QT_NO_DEBUG_STREAM 95 | 96 | 97 | 98 | /****************************************************************************** 99 | * Implementation: Operators, Helper 100 | ******************************************************************************/ 101 | 102 | 103 | 104 | } // namespace Log4Qt 105 | -------------------------------------------------------------------------------- /log4qt/varia/levelrangefilter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: levelrangefilter.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_LEVELRANGEFILTER_H 26 | #define LOG4QT_LEVELRANGEFILTER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/spi/filter.h" 34 | 35 | #include "log4qt/level.h" 36 | 37 | 38 | /****************************************************************************** 39 | * Declarations 40 | ******************************************************************************/ 41 | 42 | namespace Log4Qt 43 | { 44 | 45 | /*! 46 | * \brief The class LevelMatchFilter allows logging events with levels in a 47 | * specified range. 48 | * 49 | * \note The ownership and lifetime of objects of this class are managed. 50 | * See \ref Ownership "Object ownership" for more details. 51 | */ 52 | class LevelRangeFilter : public Filter 53 | { 54 | Q_OBJECT 55 | 56 | /*! 57 | * The property holds if an event is accpeted on a match. 58 | * 59 | * The default is true. 60 | * 61 | * \sa acceptOnMatch(), acceptOnMatch() 62 | */ 63 | Q_PROPERTY(bool acceptOnMatch READ acceptOnMatch WRITE setAcceptOnMatch) 64 | 65 | /*! 66 | * The property holds the maximum level of the range for this filter. 67 | * 68 | * The default is Level::OFF_INT. 69 | * 70 | * \sa levelMax(), setLevelMax() 71 | */ 72 | Q_PROPERTY(Level levelMax READ levelMax WRITE setLevelMax) 73 | 74 | /*! 75 | * The property holds the minimum level of the range for this filter. 76 | * 77 | * The default is Level::NULL_INT. 78 | * 79 | * \sa levelMin(), setLevelMin() 80 | */ 81 | Q_PROPERTY(Level levelMin READ levelMin WRITE setLevelMin) 82 | 83 | public: 84 | LevelRangeFilter(QObject *pParent = 0); 85 | // LevelRangeFilter(const LevelRangeFilter &rOther); // Use compiler default 86 | // virtual ~LevelRangeFilter(); // Use compiler default 87 | // LevelRangeFilter &operator=(const LevelRangeFilter &rOther); // Use compiler default 88 | 89 | bool acceptOnMatch() const; 90 | Level levelMax() const; 91 | Level levelMin() const; 92 | void setAcceptOnMatch(bool accept); 93 | void setLevelMax(Level level); 94 | void setLevelMin(Level level); 95 | 96 | virtual Decision decide(const LoggingEvent &rEvent) const; 97 | 98 | protected: 99 | /*! 100 | * Writes all object member variables to the given debug stream \a rDebug 101 | * and returns the stream. 102 | * 103 | * 104 | * %LevelRangeFilter(acceptonmatch:true levelmin:"ERROR" levelmax:"FATAL" 105 | * next:Log4Qt::LevelMatchFilter(0x3bcd960) 106 | * referencecount:1 ) 107 | * 108 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 109 | */ 110 | virtual QDebug debug(QDebug &rDebug) const; 111 | 112 | private: 113 | bool mAcceptOnMatch; 114 | Level mLevelMin; 115 | Level mLevelMax; 116 | }; 117 | 118 | 119 | /************************************************************************** 120 | * Operators, Helper 121 | **************************************************************************/ 122 | 123 | 124 | /************************************************************************** 125 | * Inline 126 | **************************************************************************/ 127 | 128 | inline bool LevelRangeFilter::acceptOnMatch() const 129 | { return mAcceptOnMatch; } 130 | 131 | inline Level LevelRangeFilter::levelMax() const 132 | { return mLevelMax; } 133 | 134 | inline Level LevelRangeFilter::levelMin() const 135 | { return mLevelMin; } 136 | 137 | inline void LevelRangeFilter::setAcceptOnMatch(bool accept) 138 | { mAcceptOnMatch = accept; } 139 | 140 | inline void LevelRangeFilter::setLevelMax(Level level) 141 | { mLevelMax = level; } 142 | 143 | inline void LevelRangeFilter::setLevelMin(Level level) 144 | { mLevelMin = level; } 145 | 146 | 147 | } // namespace Log4Qt 148 | 149 | 150 | // Q_DECLARE_TYPEINFO(Log4Qt::LevelRangeFilter, Q_MOVABLE_TYPE); // Use default 151 | 152 | 153 | #endif // LOG4QT_LEVELRANGEFILTER_H 154 | -------------------------------------------------------------------------------- /log4qt/varia/listappender.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: listappender.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/listappender.h" 33 | 34 | #include 35 | 36 | 37 | 38 | namespace Log4Qt 39 | { 40 | 41 | 42 | /************************************************************************** 43 | * Declarations 44 | **************************************************************************/ 45 | 46 | 47 | 48 | /************************************************************************** 49 | * C helper functions 50 | **************************************************************************/ 51 | 52 | 53 | 54 | /************************************************************************** 55 | * Class implementation: ListAppender 56 | **************************************************************************/ 57 | 58 | 59 | ListAppender::ListAppender(QObject *pParent) : 60 | AppenderSkeleton(pParent), 61 | mConfiguratorList(false), 62 | mList(), 63 | mMaxCount(0) 64 | { 65 | } 66 | 67 | 68 | ListAppender::~ListAppender() 69 | { 70 | } 71 | 72 | 73 | QList ListAppender::list() const 74 | { 75 | QMutexLocker locker(&mObjectGuard); 76 | 77 | return mList; 78 | } 79 | 80 | 81 | void ListAppender::setMaxCount(int n) 82 | { 83 | QMutexLocker locker(&mObjectGuard); 84 | 85 | if (n < 0) 86 | { 87 | logger()->warn("Attempt to set maximum count for appender '%1' to %2. Using zero instead", name(), n); 88 | n = 0; 89 | } 90 | mMaxCount = n; 91 | ensureMaxCount(); 92 | } 93 | 94 | 95 | QList ListAppender::clearList() 96 | { 97 | QMutexLocker locker(&mObjectGuard); 98 | 99 | QList result = mList; 100 | mList.clear(); 101 | return result; 102 | } 103 | 104 | 105 | // bool ListAppender::requiresLayout() const; 106 | 107 | 108 | void ListAppender::append(const LoggingEvent &rEvent) 109 | { 110 | // Q_ASSERT_X(, "ListAppender::append()", "Lock must be held by caller") 111 | 112 | if ((mMaxCount <= 0) || (mList.size() < mMaxCount)) 113 | mList << rEvent; 114 | } 115 | 116 | 117 | #ifndef QT_NO_DEBUG_STREAM 118 | QDebug ListAppender::debug(QDebug &rDebug) const 119 | { 120 | rDebug.nospace() << "ListAppender(" 121 | << "name:" << name() << " " 122 | << "count:" << list().count() << " " 123 | << "filter:" << firstFilter() << " " 124 | << "isactive:" << isActive() << " " 125 | << "isclosed:" << isClosed() << " " 126 | << "maxcount:" << maxCount() << " " 127 | << "referencecount:" << referenceCount() << " " 128 | << "threshold:" << threshold().toString() 129 | << ")"; 130 | return rDebug.space(); 131 | } 132 | #endif // QT_NO_DEBUG_STREAM 133 | 134 | 135 | void ListAppender::ensureMaxCount() 136 | { 137 | // Q_ASSERT_X(, "ListAppender::ensureMaxCount()", "Lock must be held by caller") 138 | 139 | if (mMaxCount <= 0) 140 | return; 141 | 142 | while (mList.size() > mMaxCount) 143 | mList.removeFirst(); 144 | } 145 | 146 | 147 | 148 | /************************************************************************** 149 | * Implementation: Operators, Helper 150 | **************************************************************************/ 151 | 152 | 153 | } // namespace Log4Qt 154 | -------------------------------------------------------------------------------- /log4qt/varia/nullappender.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: nullappender.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/nullappender.h" 33 | 34 | #include 35 | #include "log4qt/layout.h" 36 | #include "log4qt/loggingevent.h" 37 | 38 | 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | 44 | /************************************************************************** 45 | * Declarations 46 | **************************************************************************/ 47 | 48 | 49 | 50 | /************************************************************************** 51 | * C helper functions 52 | **************************************************************************/ 53 | 54 | 55 | 56 | /************************************************************************** 57 | * Class implementation: NullAppender 58 | **************************************************************************/ 59 | 60 | 61 | NullAppender::NullAppender(QObject *pParent) : 62 | AppenderSkeleton(false, pParent) 63 | { 64 | } 65 | 66 | 67 | NullAppender::~NullAppender() 68 | { 69 | close(); 70 | } 71 | 72 | 73 | void NullAppender::append(const LoggingEvent &rEvent) 74 | { 75 | Q_UNUSED(rEvent); 76 | } 77 | 78 | 79 | #ifndef QT_NO_DEBUG_STREAM 80 | QDebug NullAppender::debug(QDebug &rDebug) const 81 | { 82 | QString layout_name; 83 | if (layout()) 84 | layout_name = layout()->name(); 85 | 86 | rDebug.nospace() << "NullAppender(" 87 | << "name:" << name() << " " 88 | << "isactive:" << isActive() << " " 89 | << "isclosed:" << isClosed() << " " 90 | << "layout:" << layout_name << " " 91 | << "threshold:" << threshold().toString() << " " 92 | << ")"; 93 | return rDebug.space(); 94 | } 95 | #endif // QT_NO_DEBUG_STREAM 96 | 97 | 98 | 99 | /************************************************************************** 100 | * Implementation: Operators, Helper 101 | **************************************************************************/ 102 | 103 | 104 | } // namespace Log4Qt 105 | -------------------------------------------------------------------------------- /log4qt/varia/nullappender.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: nullappender.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_NULLAPPENDER_H 26 | #define LOG4QT_NULLAPPENDER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/appenderskeleton.h" 34 | 35 | 36 | /****************************************************************************** 37 | * Declarations 38 | ******************************************************************************/ 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | /*! 44 | * \brief The class NullAppender ignores all requests to append. 45 | * 46 | * \note All the functions declared in this class are thread-safe. 47 | * 48 | * \note The ownership and lifetime of objects of this class are managed. See 49 | * \ref Ownership "Object ownership" for more details. 50 | */ 51 | class NullAppender : public AppenderSkeleton 52 | { 53 | Q_OBJECT 54 | 55 | public: 56 | NullAppender(QObject *pParent = 0); 57 | virtual ~NullAppender(); 58 | private: 59 | NullAppender(const NullAppender &rOther); // Not implemented 60 | NullAppender &operator=(const NullAppender &rOther); // Not implemented 61 | 62 | public: 63 | virtual bool requiresLayout() const; 64 | 65 | protected: 66 | virtual void append(const LoggingEvent &rEvent); 67 | 68 | #ifndef QT_NO_DEBUG_STREAM 69 | /*! 70 | * Writes all object member variables to the given debug stream \a rDebug and 71 | * returns the stream. 72 | * 73 | * 74 | * %NullAppender() 75 | * 76 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 77 | */ 78 | virtual QDebug debug(QDebug &rDebug) const; 79 | #endif // QT_NO_DEBUG_STREAM 80 | }; 81 | 82 | 83 | /****************************************************************************** 84 | * Operators, Helper 85 | ******************************************************************************/ 86 | 87 | 88 | /****************************************************************************** 89 | * Inline 90 | ******************************************************************************/ 91 | 92 | inline bool NullAppender::requiresLayout() const 93 | { return false; } 94 | 95 | 96 | } // namespace Log4Qt 97 | 98 | 99 | // Q_DECLARE_TYPEINFO(Log4Qt::NullAppender, Q_COMPLEX_TYPE); // Use default 100 | 101 | 102 | #endif // LOG4QT_NULLAPPENDER_H 103 | -------------------------------------------------------------------------------- /log4qt/varia/stringmatchfilter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: stringmatchfilter.cpp 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | 27 | /****************************************************************************** 28 | * Dependencies 29 | ******************************************************************************/ 30 | 31 | 32 | #include "log4qt/varia/stringmatchfilter.h" 33 | 34 | #include 35 | #include "log4qt/loggingevent.h" 36 | 37 | 38 | namespace Log4Qt 39 | { 40 | 41 | 42 | /************************************************************************** 43 | * Declarations 44 | **************************************************************************/ 45 | 46 | 47 | 48 | /************************************************************************** 49 | * C helper functions 50 | **************************************************************************/ 51 | 52 | 53 | 54 | /************************************************************************** 55 | * Class implementation: Filter 56 | **************************************************************************/ 57 | 58 | 59 | StringMatchFilter::StringMatchFilter(QObject *pParent) : 60 | Filter(pParent), 61 | mAcceptOnMatch(true), 62 | mStringToMatch() 63 | {} 64 | 65 | 66 | Filter::Decision StringMatchFilter::decide(const LoggingEvent &rEvent) const 67 | { 68 | if (rEvent.message().isEmpty() || 69 | mStringToMatch.isEmpty() || 70 | rEvent.message().indexOf(mStringToMatch) < 0) 71 | return Filter::NEUTRAL; 72 | 73 | if (mAcceptOnMatch) 74 | return Filter::ACCEPT; 75 | else 76 | return Filter::DENY; 77 | } 78 | 79 | 80 | #ifndef QT_NO_DEBUG_STREAM 81 | QDebug StringMatchFilter::debug(QDebug &rDebug) const 82 | { 83 | rDebug.nospace() << "StringMatchFilter(" 84 | << "acceptonmatch:" << mAcceptOnMatch << " " 85 | << "referencecount:" << referenceCount() << " " 86 | << "stringtomatch:" << mStringToMatch << " " 87 | << "next:" << next() 88 | << ")"; 89 | return rDebug.space(); 90 | } 91 | #endif // QT_NO_DEBUG_STREAM 92 | 93 | 94 | 95 | /************************************************************************** 96 | * Implementation: Operators, Helper 97 | **************************************************************************/ 98 | 99 | 100 | 101 | } // namespace Log4Qt 102 | -------------------------------------------------------------------------------- /log4qt/varia/stringmatchfilter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * package: Log4Qt 4 | * file: stringmatchfilter.h 5 | * created: September 2007 6 | * author: Martin Heinrich 7 | * 8 | * 9 | * Copyright 2007 Martin Heinrich 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | ******************************************************************************/ 24 | 25 | #ifndef LOG4QT_STRINGMATCHFILTER_H 26 | #define LOG4QT_STRINGMATCHFILTER_H 27 | 28 | 29 | /****************************************************************************** 30 | * Dependencies 31 | ******************************************************************************/ 32 | 33 | #include "log4qt/spi/filter.h" 34 | 35 | 36 | /****************************************************************************** 37 | * Declarations 38 | ******************************************************************************/ 39 | 40 | namespace Log4Qt 41 | { 42 | 43 | /*! 44 | * \brief The class StringMatchFilter allows logging events with a 45 | * specified level. 46 | * 47 | * \note The ownership and lifetime of objects of this class are managed. 48 | * See \ref Ownership "Object ownership" for more details. 49 | */ 50 | class StringMatchFilter : public Filter 51 | { 52 | Q_OBJECT 53 | 54 | /*! 55 | * The property holds if an event is accpeted on a match. 56 | * 57 | * The default is true. 58 | * 59 | * \sa acceptOnMatch(), acceptOnMatch() 60 | */ 61 | Q_PROPERTY(bool acceptOnMatch READ acceptOnMatch WRITE setAcceptOnMatch) 62 | 63 | /*! 64 | * The property holds the string to match for this filter. 65 | * 66 | * \sa stringToMatch(), setStringToMatch() 67 | */ 68 | Q_PROPERTY(QString stringToMatch READ stringToMatch WRITE setStringToMatch) 69 | 70 | public: 71 | StringMatchFilter(QObject *pParent = 0); 72 | // StringMatchFilter(const StringMatchFilter &rOther); // Use compiler default 73 | // virtual ~StringMatchFilter(); // Use compiler default 74 | // StringMatchFilter &operator=(const StringMatchFilter &rOther); // Use compiler default 75 | 76 | bool acceptOnMatch() const; 77 | QString stringToMatch() const; 78 | void setAcceptOnMatch(bool accept); 79 | void setStringToMatch(const QString &rString); 80 | 81 | virtual Decision decide(const LoggingEvent &rEvent) const; 82 | 83 | protected: 84 | #ifndef QT_NO_DEBUG_STREAM 85 | /*! 86 | * Writes all object member variables to the given debug stream 87 | * \a rDebug and returns the stream. 88 | * 89 | * 90 | * %StringMatchFilter(acceptonmatch:true referencecount:1 91 | * stringtomatch:"LDAP_STRONG_AUTH_REQUIRED" 92 | * next:Log4Qt::LevelMatchFilter(0x3bdd960) ) 93 | * 94 | * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject) 95 | */ 96 | virtual QDebug debug(QDebug &rDebug) const; 97 | #endif // QT_NO_DEBUG_STREAM 98 | 99 | private: 100 | bool mAcceptOnMatch; 101 | QString mStringToMatch; 102 | }; 103 | 104 | 105 | /************************************************************************** 106 | * Operators, Helper 107 | **************************************************************************/ 108 | 109 | 110 | /************************************************************************** 111 | * Inline 112 | **************************************************************************/ 113 | 114 | inline bool StringMatchFilter::acceptOnMatch() const 115 | { return mAcceptOnMatch; } 116 | 117 | inline QString StringMatchFilter::stringToMatch() const 118 | { return mStringToMatch; } 119 | 120 | inline void StringMatchFilter::setAcceptOnMatch(bool accept) 121 | { mAcceptOnMatch = accept; } 122 | 123 | inline void StringMatchFilter::setStringToMatch(const QString &rString) 124 | { mStringToMatch = rString; } 125 | 126 | 127 | } // namespace Log4Qt 128 | 129 | 130 | // Q_DECLARE_TYPEINFO(Log4Qt::StringMatchFilter, Q_MOVABLE_TYPE); // Use default 131 | 132 | 133 | #endif // LOG4QT_STRINGMATCHFILTER_H 134 | -------------------------------------------------------------------------------- /log4qtdef.h: -------------------------------------------------------------------------------- 1 | #ifndef LOG4QTDEF_H 2 | #define LOG4QTDEF_H 3 | 4 | #include "log4qt/consoleappender.h" 5 | #include "log4qt/fileappender.h" 6 | #include "log4qt/logger.h" 7 | #include "log4qt/ttcclayout.h" 8 | #include "log4qt/patternlayout.h" 9 | #include "log4qt/logmanager.h" 10 | 11 | #endif // LOG4QTDEF_H 12 | -------------------------------------------------------------------------------- /options.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * options.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef OPTIONS_H 11 | #define OPTIONS_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "definitions.h" 20 | 21 | #define SETTINGS_INVERSE_FOURTH "inverse.c"// leave as 'c' for backwards compat 22 | #define SETTINGS_INVERSE_X "inverse.x" 23 | #define SETTINGS_INVERSE_Y "inverse.y" 24 | #define SETTINGS_INVERSE_Z "inverse.z" 25 | #define SETTINGS_RESPONSE_WAIT_TIME "responseWaitTime" 26 | #define SETTINGS_Z_JOG_RATE "zJogRate" 27 | #define SETTINGS_ENABLE_DEBUG_LOG "debugLog" 28 | #define SETTINGS_USE_AGGRESSIVE_PRELOAD "aggressivePreload" 29 | #define SETTINGS_WAIT_FOR_JOG_TO_COMPLETE "waitForJogToComplete" 30 | #define SETTINGS_USE_MM_FOR_MANUAL_CMDS "useMMForManualCommands" 31 | #define SETTINGS_ABSOLUTE_AFTER_AXIS_ADJ "absCoordForManualAfterAxisAdj" 32 | #define SETTINGS_Z_RATE_LIMIT "zRateLimit" 33 | #define SETTINGS_Z_RATE_LIMIT_AMOUNT "zRateLimitAmount" 34 | #define SETTINGS_XY_RATE_AMOUNT "xyRateAmount" 35 | #define SETTINGS_FOUR_AXIS_USE "fourAxis" 36 | #define SETTINGS_FOUR_AXIS_TYPE "fourAxisType" 37 | 38 | #define SETTINGS_FILE_OPEN_DIALOG_STATE "fileopendialogstate" 39 | #define SETTINGS_NAME_FILTER "namefilter" 40 | #define SETTINGS_DIRECTORY "directory" 41 | #define SETTINGS_PORT "port" 42 | #define SETTINGS_BAUD "baud" 43 | 44 | #define SETTINGS_PROMPTED_AGGR_PRELOAD "promptedAggrPreload" 45 | 46 | #define SETTINGS_FILTER_FILE_COMMANDS "filterFileCommands" 47 | #define SETTINGS_REDUCE_PREC_FOR_LONG_LINES "reducePrecisionForLongLines" 48 | #define SETTINGS_GRBL_LINE_BUFFER_LEN "grblLineBufferLen" 49 | #define SETTINGS_CHAR_SEND_DELAY_MS "charSendDelayMs" 50 | #define SETTINGS_JOG_STEP "jogStep" 51 | 52 | #define SETTINGS_ENABLE_POS_REQ "positionRequest" 53 | #define SETTINGS_TYPE_POS_REQ "posRequestType" 54 | #define SETTINGS_POS_REQ_FREQ_SEC "posReqFreqSec" 55 | 56 | 57 | namespace Ui { 58 | class Options; 59 | } 60 | 61 | class Options : public QDialog 62 | { 63 | Q_OBJECT 64 | 65 | public: 66 | explicit Options(QWidget *parent = 0); 67 | ~Options(); 68 | void accept(); 69 | 70 | signals: 71 | void setSettings(); 72 | 73 | private slots: 74 | void toggleUseMm(bool useMm); 75 | void toggleLimitZRate(bool limitZ); 76 | void toggleFourAxis(bool four); 77 | void togglePosReporting(bool usePosReporting); 78 | 79 | private: 80 | char getFourthAxisType(); 81 | QString getPosReqType(); 82 | private: 83 | Ui::Options *ui; 84 | //variables 85 | int settings; 86 | 87 | }; 88 | 89 | #endif // OPTIONS_H 90 | -------------------------------------------------------------------------------- /pointitem.cpp: -------------------------------------------------------------------------------- 1 | #include "pointitem.h" 2 | 3 | PointItem::PointItem(double x1, double y1) 4 | : ItemToBase(0), x(x1), y(y1) 5 | { 6 | } 7 | 8 | void PointItem::moveToFirst(QPainterPath& path) 9 | { 10 | Q_UNUSED(path); 11 | } 12 | 13 | void PointItem::addToPath(QPainterPath& path) 14 | { 15 | Q_UNUSED(path); 16 | } 17 | 18 | PosItem PointItem::computeExtents() 19 | { 20 | return PosItem(); 21 | } 22 | 23 | double PointItem::getXScr() 24 | { 25 | return screenX(x); 26 | } 27 | 28 | double PointItem::getYScr() 29 | { 30 | return screenY(y); 31 | } 32 | 33 | double PointItem::getXRaw() 34 | { 35 | return x; 36 | } 37 | 38 | double PointItem::getYRaw() 39 | { 40 | return y; 41 | } 42 | -------------------------------------------------------------------------------- /pointitem.h: -------------------------------------------------------------------------------- 1 | #ifndef POINTITEM_H 2 | #define POINTITEM_H 3 | #include "itemtobase.h" 4 | 5 | class PointItem : public ItemToBase 6 | { 7 | public: 8 | PointItem(double x, double y); 9 | 10 | void moveToFirst(QPainterPath& path); 11 | void addToPath(QPainterPath& path); 12 | PosItem computeExtents(); 13 | double getXScr(); 14 | double getYScr(); 15 | double getXRaw(); 16 | double getYRaw(); 17 | 18 | private: 19 | double x; 20 | double y; 21 | }; 22 | 23 | #endif // POINTITEM_H 24 | -------------------------------------------------------------------------------- /positem.cpp: -------------------------------------------------------------------------------- 1 | #include "positem.h" 2 | 3 | void PosItem::setCoords(double x1, double y1, double i1, double j1) 4 | { 5 | x = x1; 6 | y = y1; 7 | i = i1; 8 | j = j1; 9 | } 10 | 11 | void PosItem::setCoords(double x1, double y1, bool mm1) 12 | { 13 | x = x1; 14 | y = y1; 15 | i = x1; 16 | j = y1; 17 | mm = mm1; 18 | } 19 | 20 | void PosItem::expand(const PosItem& item) 21 | { 22 | if (item.x < x) 23 | x = item.x; 24 | if (item.y < y) 25 | y = item.y; 26 | if (item.i > i) 27 | i = item.i; 28 | if (item.j > j) 29 | j = item.j; 30 | } 31 | 32 | void PosItem::toMm() 33 | { 34 | x *= MM_IN_AN_INCH; 35 | y *= MM_IN_AN_INCH; 36 | i *= MM_IN_AN_INCH; 37 | j *= MM_IN_AN_INCH; 38 | mm = true; 39 | } 40 | 41 | void PosItem::toInches() 42 | { 43 | x /= MM_IN_AN_INCH; 44 | y /= MM_IN_AN_INCH; 45 | i /= MM_IN_AN_INCH; 46 | j /= MM_IN_AN_INCH; 47 | mm = false; 48 | } 49 | -------------------------------------------------------------------------------- /positem.h: -------------------------------------------------------------------------------- 1 | #ifndef POSITEM_H 2 | #define POSITEM_H 3 | #include 4 | //#include "stdio.h" 5 | #include "definitions.h" 6 | 7 | class PosItem 8 | { 9 | public: 10 | PosItem() 11 | : x(0), y(0), i(0), j(0), 12 | arc(false), cw(false), mm(true), index(0) {} 13 | PosItem(double x1, double y1) 14 | : x(x1), y(y1), i(0), j(0), 15 | arc(false), cw(false), mm(true), index(0) {} 16 | PosItem(double x1, double y1, double i1, double j1) 17 | : x(x1), y(y1), i(i1), j(j1), 18 | arc(false), cw(false), mm(true), index(0) {} 19 | PosItem(double x1, double y1, double i1, double j1, bool arc1, bool cw1, bool mm1, int index1) 20 | : x(x1), y(y1), i(i1), j(j1), 21 | arc(arc1), cw(cw1), mm(mm1), index(index1) {} 22 | 23 | void setCoords(double x1, double y1, double i1, double j1); 24 | void setCoords(double x1, double y1, bool mm); 25 | void expand(const PosItem& item); 26 | double width() { return qAbs(i - x); } 27 | double height() { return qAbs(j - y); } 28 | bool isNull() { return x == 0 && y == 0 && i == 0 && j == 0 && arc == false && cw == false && index == 0; } 29 | void toMm(); 30 | void toInches(); 31 | 32 | public: 33 | double x; 34 | double y; 35 | double i; 36 | double j; 37 | bool arc; 38 | bool cw; 39 | bool mm; 40 | int index; 41 | }; 42 | 43 | Q_DECLARE_METATYPE ( PosItem ) 44 | 45 | #endif // POSITEM_H 46 | -------------------------------------------------------------------------------- /renderarea.cpp: -------------------------------------------------------------------------------- 1 | #include "renderarea.h" 2 | 3 | RenderArea::RenderArea(QWidget *parent) 4 | : QWidget(parent), 5 | penProposedPath(QPen(Qt::blue)), penAxes(QPen(QColor(193,97,0))), 6 | penCoveredPath(QPen(QColor(60,196,70), 2)), 7 | penCurrPosActive(QPen(Qt::red, 6)), penCurrPosInactive(QPen(QColor(60,196,70), 6)), 8 | penMeasure(QPen(QColor(151,111,26))), isLiveCurrPos(false) 9 | { 10 | penCurrPosActive.setCapStyle(Qt::RoundCap); 11 | penCurrPosInactive.setCapStyle(Qt::RoundCap); 12 | } 13 | 14 | void RenderArea::setItems(QList itemsRcvd) 15 | { 16 | items = itemsRcvd; 17 | 18 | listToRender.setCurrFileLine(0); 19 | listToRender.convertList(items); 20 | listToRender.updateLivePoint(); 21 | update(); 22 | } 23 | 24 | void RenderArea::setLivePoint(double x, double y, bool mm, bool isLiveCP) 25 | { 26 | isLiveCurrPos = isLiveCP; 27 | livePoint.setCoords(x, y, mm); 28 | listToRender.setLivePoint(livePoint); 29 | update(); 30 | 31 | } 32 | 33 | void RenderArea::setVisualLivenessCurrPos(bool isLiveCP) 34 | { 35 | isLiveCurrPos = isLiveCP; 36 | } 37 | 38 | void RenderArea::setVisCurrLine(int currLine) 39 | { 40 | if (listToRender.setCurrFileLine(currLine)) 41 | update(); 42 | } 43 | 44 | void RenderArea::paintEvent(QPaintEvent * /* event */) 45 | { 46 | if (!items.size()) 47 | return; 48 | 49 | QSize size = this->size(); 50 | 51 | listToRender.rescale(size); 52 | 53 | QPainter painter(this); 54 | 55 | painter.setPen(penProposedPath); 56 | listToRender.writePath(painter, false); 57 | 58 | painter.setPen(penAxes); 59 | listToRender.drawAxes(painter); 60 | 61 | painter.setPen(penMeasure); 62 | listToRender.drawMeasurements(painter); 63 | 64 | painter.setPen(penCoveredPath); 65 | listToRender.writePath(painter, true); 66 | 67 | //if (!livePoint.isNull()) FIX isNull 68 | { 69 | if (isLiveCurrPos) 70 | painter.setPen(penCurrPosActive); 71 | else 72 | painter.setPen(penCurrPosInactive); 73 | listToRender.drawPoint(painter, livePoint); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /renderarea.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERAREA_H 2 | #define RENDERAREA_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "positem.h" 9 | #include "renderitemlist.h" 10 | #include "arcitem.h" 11 | #include "lineitem.h" 12 | 13 | class RenderArea : public QWidget 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit RenderArea(QWidget *parent = 0); 18 | 19 | signals: 20 | 21 | public slots: 22 | void setItems(QList); 23 | void setLivePoint(double x, double y, bool isMM, bool isLiveCP); 24 | void setVisualLivenessCurrPos(bool isLiveCP); 25 | void setVisCurrLine(int currLine); 26 | 27 | protected: 28 | void paintEvent(QPaintEvent *event); 29 | 30 | private: 31 | QList items; 32 | RenderItemList listToRender; 33 | QPen penProposedPath, penAxes, penCoveredPath, penCurrPosActive, penCurrPosInactive, penMeasure; 34 | PosItem livePoint; 35 | bool isLiveCurrPos; 36 | }; 37 | 38 | #endif // RENDERAREA_H 39 | -------------------------------------------------------------------------------- /renderitemlist.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERITEMLIST_H 2 | #define RENDERITEMLIST_H 3 | #include "arcitem.h" 4 | #include "lineitem.h" 5 | #include "pointitem.h" 6 | 7 | #define SCREEN_SCALE_FILE 0.85 8 | 9 | class RenderItemList 10 | { 11 | public: 12 | RenderItemList(); 13 | virtual ~RenderItemList(); 14 | 15 | void convertList(const QList& items); 16 | void rescale(const QSize& size); 17 | void writePath(QPainter& painter, bool updatedFromFile); 18 | void drawAxes(QPainter& painter); 19 | void drawMeasurements(QPainter& painter); 20 | void drawPoint(QPainter& painter, const PosItem& point); 21 | bool setCurrFileLine(const int currLine); 22 | void setLivePoint(const PosItem& livePoint); 23 | void updateLivePoint(); 24 | 25 | private: 26 | void clearList(); 27 | void writeText(QPainter& painter, QString text, double x, double y, int avgCharWd); 28 | 29 | private: 30 | QList list; 31 | double scale; 32 | double offsetx; 33 | double offsety; 34 | PosItem extents; 35 | QSize windowSize; 36 | bool mm; 37 | int currFileLine; 38 | PosItem livePoint; 39 | QFont font; 40 | }; 41 | 42 | #endif // RENDERITEMLIST_H 43 | -------------------------------------------------------------------------------- /rs232.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * rs232.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef RS232_H 11 | #define RS232_H 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_ANDROID) 19 | #include 20 | #include "../termiosext.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #else 28 | #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) 29 | #include 30 | #else 31 | // TODO - R - if I leave out Windows.h then Sleep is not found??? 32 | #include 33 | #include 34 | #endif 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | #include "definitions.h" 41 | 42 | 43 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_ANDROID) 44 | #define SLEEP(x) usleep(1000 * x); 45 | #else 46 | #define SLEEP(x) Sleep(x); 47 | #endif 48 | 49 | 50 | class RS232 51 | { 52 | public: 53 | RS232(); 54 | //methods 55 | bool OpenComport(QString commPortStr, QString baudRate); 56 | int PollComport(char *buf, int size); 57 | int PollComportLine(char *buf, int size); 58 | int SendBuf(const char *buf, int size); 59 | void CloseComport(); 60 | void Reset(); 61 | void flush(); 62 | bool isPortOpen(); 63 | QString getDetectedLineFeed(); 64 | int bytesAvailable(); 65 | void setCharSendDelayMs(int charSendDelayMs); 66 | 67 | private: 68 | QextSerialPort *port; 69 | char detectedEOL; 70 | QString detectedLineFeed; 71 | int charSendDelayMs; 72 | 73 | }; 74 | 75 | 76 | #endif // RS232_H 77 | -------------------------------------------------------------------------------- /termiosext.h: -------------------------------------------------------------------------------- 1 | #ifndef TERMIOSEXT_H 2 | #define TERMIOSEXT_H 3 | 4 | #ifdef Q_OS_ANDROID 5 | static __inline__ int tcdrain(int fd) 6 | { 7 | return ioctl(fd, TCSBRK, (void *)(intptr_t)1); 8 | } 9 | #endif 10 | 11 | #endif // TERMIOSEXT_H 12 | -------------------------------------------------------------------------------- /timer.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * timer.cpp 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | #include "timer.h" 10 | Timer::Timer(QObject *parent) : 11 | QObject(parent), timing(false) 12 | { 13 | startTimer(500); 14 | } 15 | 16 | void Timer::resetTimer(bool timeIt) 17 | { 18 | timing = timeIt; 19 | if (timeIt) 20 | timer.start(); 21 | } 22 | 23 | void Timer::timerEvent(QTimerEvent *event) 24 | { 25 | Q_UNUSED(event); 26 | 27 | if (timing) 28 | { 29 | int secs = timer.elapsed() / 1000; 30 | int mins = (secs / 60) % 60; 31 | int hours = (secs / 3600); 32 | secs = secs % 60; 33 | emit setRuntime(QString("%1:%2:%3").arg(hours, 2, 10, QLatin1Char('0')).arg(mins, 2, 10, QLatin1Char('0')).arg(secs, 2, 10, QLatin1Char('0'))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * timer.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 15 Nov 2012 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | 10 | #ifndef TIMER_H 11 | #define TIMER_H 12 | 13 | #include 14 | 15 | class Timer : public QObject 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit Timer(QObject *parent = 0); 21 | 22 | signals: 23 | void setRuntime(QString timestr); 24 | 25 | public slots: 26 | void resetTimer(bool timeIt); 27 | 28 | protected: 29 | void timerEvent(QTimerEvent *event); 30 | 31 | private: 32 | QTime timer; 33 | bool timing; 34 | }; 35 | 36 | #endif // TIMER_H 37 | -------------------------------------------------------------------------------- /trlocale/GrblController_fr.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/trlocale/GrblController_fr.qm -------------------------------------------------------------------------------- /trlocale/GrblController_xx.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zapmaker/GrblHoming/178bcddb7311074fc8093ab23ab68c409b38fb49/trlocale/GrblController_xx.qm -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * version.h 3 | * GrblHoming - zapmaker fork on github 4 | * 5 | * 14 July 2013 6 | * GPL License (see LICENSE file) 7 | * Software is provided AS-IS 8 | ****************************************************************/ 9 | #ifndef VERSION_H 10 | #define VERSION_H 11 | #define GRBL_CONTROLLER_NAME_AND_VERSION "Grbl Controller 3.6.1" 12 | #endif // VERSION_H 13 | -------------------------------------------------------------------------------- /wininfoafter.txt: -------------------------------------------------------------------------------- 1 | Thanks! Please visit www.zapmaker.org to give feedback. -------------------------------------------------------------------------------- /wininfobefore.txt: -------------------------------------------------------------------------------- 1 | GrblController 3 - Control your Grbl Arduino and other basic CNC 3-axis systems. 2 | 3 | Installs a EXE file and support DLLs that communicate via COM port to Grbl Arduino using GCode. 4 | 5 | by Zapmaker 6 | 7 | Released under GPL 3.0 -------------------------------------------------------------------------------- /winlicense.txt: -------------------------------------------------------------------------------- 1 | GrblController 2 | 3 | The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. --------------------------------------------------------------------------------