summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/CMakeLists.txt10
-rw-r--r--ldmicro/circuit.cpp46
-rw-r--r--ldmicro/draw.cpp8
-rw-r--r--ldmicro/icons/toolbox/Add.pngbin0 -> 1794 bytes
-rw-r--r--ldmicro/icons/toolbox/CountDown.pngbin0 -> 2621 bytes
-rw-r--r--ldmicro/icons/toolbox/CountUp.pngbin0 -> 2403 bytes
-rw-r--r--ldmicro/icons/toolbox/Div.pngbin0 -> 1854 bytes
-rw-r--r--ldmicro/icons/toolbox/Mul.pngbin0 -> 2015 bytes
-rw-r--r--ldmicro/icons/toolbox/Multiply.pngbin0 -> 2059 bytes
-rw-r--r--ldmicro/icons/toolbox/NegatedCoil.pngbin0 -> 2209 bytes
-rw-r--r--ldmicro/icons/toolbox/NegatedContact.pngbin0 -> 1211 bytes
-rw-r--r--ldmicro/icons/toolbox/NormalCoil.pngbin0 -> 1587 bytes
-rw-r--r--ldmicro/icons/toolbox/NormalContact.pngbin0 -> 549 bytes
-rw-r--r--ldmicro/icons/toolbox/OffTimer.pngbin0 -> 1688 bytes
-rw-r--r--ldmicro/icons/toolbox/OnTimer.pngbin0 -> 1992 bytes
-rw-r--r--ldmicro/icons/toolbox/Reset.pngbin0 -> 2141 bytes
-rw-r--r--ldmicro/icons/toolbox/ResetOnlyCoil.pngbin0 -> 2489 bytes
-rw-r--r--ldmicro/icons/toolbox/SetOnlyCoil.pngbin0 -> 2617 bytes
-rw-r--r--ldmicro/icons/toolbox/Sub.pngbin0 -> 1713 bytes
-rw-r--r--ldmicro/includes/ldmicro.h20
-rw-r--r--ldmicro/includes/ldmicroVC.h1
-rw-r--r--ldmicro/includes/toolbar.h42
-rw-r--r--ldmicro/iolist.cpp18
-rw-r--r--ldmicro/ldmicro.cpp16
-rw-r--r--ldmicro/ldmicro.qrc15
-rw-r--r--ldmicro/lib/linuxUI/linuxLD.h5
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h16
-rw-r--r--ldmicro/maincontrols.cpp91
-rw-r--r--ldmicro/toolbar.cpp129
29 files changed, 372 insertions, 45 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index adb0c0f..8f5a5e8 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -2,10 +2,11 @@ cmake_minimum_required(VERSION 2.6)
project(LDMicro)
-## Version control
- set (LDMicro_VERSION_MAJOR 2)
- set (LDMicro_VERSION_MINOR 2)
- set (LDMicro_VERSION_PATCH 0)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/includes/ldmicroVC.h" VersionRead)
+
+string(REGEX MATCH "LDMicro_VERSION_MAJOR ([0-9]*)" LDMicro_VERSION_MAJOR ${VersionRead})
+string(REGEX MATCH "LDMicro_VERSION_MINOR ([0-9]*)" LDMicro_VERSION_MINOR ${VersionRead})
+string(REGEX MATCH "LDMicro_VERSION_PATCH ([0-9]*)" LDMicro_VERSION_PATCH ${VersionRead})
macro(use_cxx14)
@@ -157,6 +158,7 @@ endif()
draw.cpp
schematic.cpp
helpdialog.cpp
+ toolbar.cpp
${OBJDIR}/helptext.cpp
maincontrols.cpp
ldmicro.cpp)
diff --git a/ldmicro/circuit.cpp b/ldmicro/circuit.cpp
index 2868fe2..ebf80ba 100644
--- a/ldmicro/circuit.cpp
+++ b/ldmicro/circuit.cpp
@@ -245,6 +245,16 @@ void AddContact(void)
AddLeaf(ELEM_CONTACTS, c);
}
+void AddContactNeg(void)
+{
+ if(!CanInsertOther) return;
+
+ ElemLeaf *c = AllocLeaf();
+ strcpy(c->d.contacts.name, "Xnew");
+ c->d.contacts.negated = TRUE;
+
+ AddLeaf(ELEM_CONTACTS, c);
+}
void AddCoil(void)
{
if(!CanInsertEnd) return;
@@ -257,6 +267,42 @@ void AddCoil(void)
AddLeaf(ELEM_COIL, c);
}
+void AddCoilNeg(void)
+{
+ if(!CanInsertEnd) return;
+
+ ElemLeaf *c = AllocLeaf();
+ strcpy(c->d.coil.name, "Ynew");
+ c->d.coil.negated = TRUE;
+ c->d.coil.setOnly = FALSE;
+ c->d.coil.resetOnly = FALSE;
+
+ AddLeaf(ELEM_COIL, c);
+}
+void AddCoilSet(void)
+{
+ if(!CanInsertEnd) return;
+
+ ElemLeaf *c = AllocLeaf();
+ strcpy(c->d.coil.name, "Ynew");
+ c->d.coil.negated = FALSE;
+ c->d.coil.setOnly = TRUE;
+ c->d.coil.resetOnly = FALSE;
+
+ AddLeaf(ELEM_COIL, c);
+}
+void AddCoilRes(void)
+{
+ if(!CanInsertEnd) return;
+
+ ElemLeaf *c = AllocLeaf();
+ strcpy(c->d.coil.name, "Ynew");
+ c->d.coil.negated = FALSE;
+ c->d.coil.setOnly = FALSE;
+ c->d.coil.resetOnly = TRUE;
+
+ AddLeaf(ELEM_COIL, c);
+}
void AddTimer(int which)
{
if(!CanInsertOther) return;
diff --git a/ldmicro/draw.cpp b/ldmicro/draw.cpp
index 0adba74..cb5764a 100644
--- a/ldmicro/draw.cpp
+++ b/ldmicro/draw.cpp
@@ -891,21 +891,21 @@ cmp:
switch(leaf->selectedState) {
case SELECTED_LEFT:
Cursor.setLeft(x0 + FONT_WIDTH - 4 - xadj);
- Cursor.setTop(y0 - FONT_HEIGHT/2);
+ Cursor.setTop(y0 - FONT_HEIGHT/2 - 10);
Cursor.setWidth(2);
Cursor.setHeight(POS_HEIGHT*FONT_HEIGHT);
break;
case SELECTED_RIGHT:
Cursor.setLeft(x0 + (POS_WIDTH-1)*FONT_WIDTH - 5);
- Cursor.setTop(y0 - FONT_HEIGHT/2);
+ Cursor.setTop(y0 - FONT_HEIGHT/2 - 10);
Cursor.setWidth(2);
Cursor.setHeight(POS_HEIGHT*FONT_HEIGHT);
break;
case SELECTED_ABOVE:
Cursor.setLeft(x0 + FONT_WIDTH/2 - xadj);
- Cursor.setTop(y0 - 2);
+ Cursor.setTop(y0 - 10);
Cursor.setWidth((POS_WIDTH-2)*FONT_WIDTH + xadj);
Cursor.setHeight(2);
break;
@@ -913,7 +913,7 @@ cmp:
case SELECTED_BELOW:
Cursor.setLeft(x0 + FONT_WIDTH/2 - xadj);
Cursor.setTop(y0 + (POS_HEIGHT-1)*FONT_HEIGHT +
- FONT_HEIGHT/2 - 2);
+ FONT_HEIGHT/2 - 10);
Cursor.setWidth((POS_WIDTH-2)*(FONT_WIDTH) + xadj);
Cursor.setHeight(2);
break;
diff --git a/ldmicro/icons/toolbox/Add.png b/ldmicro/icons/toolbox/Add.png
new file mode 100644
index 0000000..ea353e6
--- /dev/null
+++ b/ldmicro/icons/toolbox/Add.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/CountDown.png b/ldmicro/icons/toolbox/CountDown.png
new file mode 100644
index 0000000..7824999
--- /dev/null
+++ b/ldmicro/icons/toolbox/CountDown.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/CountUp.png b/ldmicro/icons/toolbox/CountUp.png
new file mode 100644
index 0000000..e7913ba
--- /dev/null
+++ b/ldmicro/icons/toolbox/CountUp.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/Div.png b/ldmicro/icons/toolbox/Div.png
new file mode 100644
index 0000000..eaf3653
--- /dev/null
+++ b/ldmicro/icons/toolbox/Div.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/Mul.png b/ldmicro/icons/toolbox/Mul.png
new file mode 100644
index 0000000..20f44af
--- /dev/null
+++ b/ldmicro/icons/toolbox/Mul.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/Multiply.png b/ldmicro/icons/toolbox/Multiply.png
new file mode 100644
index 0000000..6eeb6b2
--- /dev/null
+++ b/ldmicro/icons/toolbox/Multiply.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/NegatedCoil.png b/ldmicro/icons/toolbox/NegatedCoil.png
new file mode 100644
index 0000000..60cbac8
--- /dev/null
+++ b/ldmicro/icons/toolbox/NegatedCoil.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/NegatedContact.png b/ldmicro/icons/toolbox/NegatedContact.png
new file mode 100644
index 0000000..553a2a0
--- /dev/null
+++ b/ldmicro/icons/toolbox/NegatedContact.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/NormalCoil.png b/ldmicro/icons/toolbox/NormalCoil.png
new file mode 100644
index 0000000..a9808cd
--- /dev/null
+++ b/ldmicro/icons/toolbox/NormalCoil.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/NormalContact.png b/ldmicro/icons/toolbox/NormalContact.png
new file mode 100644
index 0000000..b8e54e3
--- /dev/null
+++ b/ldmicro/icons/toolbox/NormalContact.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/OffTimer.png b/ldmicro/icons/toolbox/OffTimer.png
new file mode 100644
index 0000000..cf5747a
--- /dev/null
+++ b/ldmicro/icons/toolbox/OffTimer.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/OnTimer.png b/ldmicro/icons/toolbox/OnTimer.png
new file mode 100644
index 0000000..f11d9a1
--- /dev/null
+++ b/ldmicro/icons/toolbox/OnTimer.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/Reset.png b/ldmicro/icons/toolbox/Reset.png
new file mode 100644
index 0000000..f109734
--- /dev/null
+++ b/ldmicro/icons/toolbox/Reset.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/ResetOnlyCoil.png b/ldmicro/icons/toolbox/ResetOnlyCoil.png
new file mode 100644
index 0000000..37d1e08
--- /dev/null
+++ b/ldmicro/icons/toolbox/ResetOnlyCoil.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/SetOnlyCoil.png b/ldmicro/icons/toolbox/SetOnlyCoil.png
new file mode 100644
index 0000000..9f2280d
--- /dev/null
+++ b/ldmicro/icons/toolbox/SetOnlyCoil.png
Binary files differ
diff --git a/ldmicro/icons/toolbox/Sub.png b/ldmicro/icons/toolbox/Sub.png
new file mode 100644
index 0000000..5853a14
--- /dev/null
+++ b/ldmicro/icons/toolbox/Sub.png
Binary files differ
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 788c580..34b9520 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -103,6 +103,11 @@ typedef signed long SDWORD;
#define MNU_MAKE_SET_ONLY 0x44
#define MNU_MAKE_RESET_ONLY 0x45
#define MNU_INSERT_PWL 0x46
+#define MNU_INSERT_CONTACTS_N 0x47
+#define MNU_INSERT_COIL_N 0x48
+#define MNU_INSERT_COIL_S 0x49
+#define MNU_INSERT_COIL_R 0x4a
+
#define MNU_MCU_SETTINGS 0x50
#define MNU_PROCESSOR_0 0xa0
@@ -179,7 +184,9 @@ extern QAction* InsertPwlMenu;
extern QAction* McuSettingsMenu;
extern QAction* ProcessorMenuItems[NUM_SUPPORTED_MCUS+1];
-extern HMENU MicroControllerMenu;
+extern HMENU MicroControllerMenu;
+extern HMENU ArithmeticMenu;
+extern HMENU AnalogMenu;
extern QAction* SimulationModeMenu;
extern QAction* StartSimulationMenu;
@@ -489,7 +496,7 @@ typedef struct PlcProgramTag {
// offset from the top left of the window at which we start drawing, in pixels
#define X_PADDING 35
-#define Y_PADDING 14
+#define Y_PADDING 24
typedef class PlcCursorTag{
int left;
@@ -498,6 +505,8 @@ typedef class PlcCursorTag{
int height;
} PlcCursor;
+extern QToolBar* EasyAccessTool;
+
//-----------------------------------------------
// The syntax highlighting style colours; a structure for the palette.
@@ -632,6 +641,9 @@ extern int IoListTop;
extern UINT IoListHeight;
extern HMENU ScrollWindow;
+// toolbar.cpp
+void CreateToolBar(void);
+
// draw.cpp
int ProgCountWidestRow(void);
int CountHeightOfElement(int which, void *elem);
@@ -695,7 +707,11 @@ extern BOOL CanInsertComment;
// circuit.cpp
void AddTimer(int which);
void AddCoil(void);
+void AddCoilNeg(void);
+void AddCoilRes(void);
+void AddCoilSet(void);
void AddContact(void);
+void AddContactNeg(void);
void AddEmpty(int which);
void AddMove(void);
void AddMath(int which);
diff --git a/ldmicro/includes/ldmicroVC.h b/ldmicro/includes/ldmicroVC.h
index 67e0d9c..151beb9 100644
--- a/ldmicro/includes/ldmicroVC.h
+++ b/ldmicro/includes/ldmicroVC.h
@@ -1,3 +1,4 @@
/// version control
#define LDMicro_VERSION_MAJOR 2
#define LDMicro_VERSION_MINOR 2
+#define LDMicro_VERSION_PATCH 1
diff --git a/ldmicro/includes/toolbar.h b/ldmicro/includes/toolbar.h
new file mode 100644
index 0000000..2ff7397
--- /dev/null
+++ b/ldmicro/includes/toolbar.h
@@ -0,0 +1,42 @@
+#ifndef __TOOLBAR_H
+#define __TOOLBAR_H
+
+#include <QToolBar>
+#include <QIcon>
+
+extern QIcon* ContactIco;
+extern QIcon* NegContactIco;
+extern QIcon* CoilIco;
+extern QIcon* NegCoilIco;
+extern QIcon* SetCoilIco;
+extern QIcon* ResetCoilIco;
+extern QIcon* ResetTimerIco;
+extern QIcon* TonIco;
+extern QIcon* TofIco;
+extern QIcon* RtoIco;
+extern QIcon* AddIco;
+extern QIcon* SubIco;
+extern QIcon* MulIco;
+extern QIcon* DivIco;
+extern QIcon* CtuIco;
+extern QIcon* CtdIco;
+extern QAction* ContactBtn;
+extern QAction* NegContactBtn;
+extern QAction* CoilBtn;
+extern QAction* NegCoilBtn;
+extern QAction* SetCoilBtn;
+extern QAction* ResetCoilBtn;
+extern QAction* ResetTimerBtn;
+extern QAction* TonBtn;
+extern QAction* TofBtn;
+extern QAction* RtoBtn;
+extern QAction* AddBtn;
+extern QAction* SubBtn;
+extern QAction* MulBtn;
+extern QAction* DivBtn;
+extern QAction* CtuBtn;
+extern QAction* CtdBtn;
+
+// Functions
+void ToolBarHandler();
+#endif
diff --git a/ldmicro/iolist.cpp b/ldmicro/iolist.cpp
index 5d2f2d5..cd5bb22 100644
--- a/ldmicro/iolist.cpp
+++ b/ldmicro/iolist.cpp
@@ -60,7 +60,7 @@ static BOOL AnalogSliderCancel;
//Slider procedures to display slider values at realtime
// and to close slider window on release
-void AnalogSliderProc(int Value);
+void AnalogSliderProc(int Value, char* name);
void AnalogSliderRelProc(char* name);
void ListView_RedrawItems(HLIST list, int min, int max);
@@ -449,13 +449,14 @@ void ShowAnalogSliderPopup(char *name)
AnalogSliderLabel = new QLabel();
char str[5];
- sprintf(str, "%d",currentVal);
+ sprintf(str, "%d",currentVal);
AnalogSliderLabel->setText(str);
- // AnalogSliderTrackbar->setTracking(FALSE);
AnalogSliderLayout->addWidget(AnalogSliderTrackbar);
AnalogSliderLayout->addWidget(AnalogSliderLabel);
QObject::connect(AnalogSliderTrackbar,
- &QSlider::valueChanged,AnalogSliderProc);
+ &QSlider::valueChanged,
+ std::bind(AnalogSliderProc, std::placeholders::_1, name)
+ );
QObject::connect(AnalogSliderTrackbar,
&QSlider::sliderReleased,
std::bind(AnalogSliderRelProc, name)
@@ -469,10 +470,7 @@ void ShowAnalogSliderPopup(char *name)
void AnalogSliderRelProc(char* name)
{
- SWORD v = AnalogSliderTrackbar->value();
AnalogSliderMain->hide();
- SetAdcShadow(name, v);
- SimulateOneCycle(TRUE);
}
void ListView_RedrawItems(HLIST list, int min, int max)
@@ -498,11 +496,15 @@ void ListView_RedrawItems(HLIST list, int min, int max)
}
}
-void AnalogSliderProc(int Value)
+void AnalogSliderProc(int Value, char* name)
{
char str[5];
sprintf(str, "%d", Value);
AnalogSliderLabel->setText(str);
+ SWORD v = AnalogSliderTrackbar->value();
+ // AnalogSliderMain->hide();
+ SetAdcShadow(name, v);
+ SimulateOneCycle(TRUE);
}
static void MakeControls()
diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp
index 8181c4a..8e5d758 100644
--- a/ldmicro/ldmicro.cpp
+++ b/ldmicro/ldmicro.cpp
@@ -362,10 +362,25 @@ static void ProcessMenu(int code)
CHANGING_PROGRAM(AddContact());
break;
+ case MNU_INSERT_CONTACTS_N:
+ CHANGING_PROGRAM(AddContactNeg());
+ break;
+
case MNU_INSERT_COIL:
CHANGING_PROGRAM(AddCoil());
break;
+ case MNU_INSERT_COIL_N:
+ CHANGING_PROGRAM(AddCoilNeg());
+ break;
+
+ case MNU_INSERT_COIL_S:
+ CHANGING_PROGRAM(AddCoilSet());
+ break;
+
+ case MNU_INSERT_COIL_R:
+ CHANGING_PROGRAM(AddCoilRes());
+ break;
case MNU_INSERT_TON:
CHANGING_PROGRAM(AddTimer(ELEM_TON));
break;
@@ -1022,6 +1037,7 @@ int main(int argc, char** argv)
app.setWindowIcon(*MWIcon);
//Icon for main window
MainWindow->setWindowIcon(*MWIcon);
+ CreateToolBar();
MakeMainWindowMenus();
MakeDialogBoxClass();
InitForDrawing();
diff --git a/ldmicro/ldmicro.qrc b/ldmicro/ldmicro.qrc
index a68b238..c44dccb 100644
--- a/ldmicro/ldmicro.qrc
+++ b/ldmicro/ldmicro.qrc
@@ -1,5 +1,20 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file alias="ldmicro.ico">ldmicro.ico</file>
+ <file alias="AddIcon">icons/toolbox/Add.png</file>
+ <file alias="SubIcon">icons/toolbox/Sub.png</file>
+ <file alias="MulIcon">icons/toolbox/Multiply.png</file>
+ <file alias="DivIcon">icons/toolbox/Div.png</file>
+ <file alias="CTUIcon">icons/toolbox/CountUp.png</file>
+ <file alias="CTDIcon">icons/toolbox/CountDown.png</file>
+ <file alias="TONIcon">icons/toolbox/OnTimer.png</file>
+ <file alias="TOFIcon">icons/toolbox/OffTimer.png</file>
+ <file alias="ResIcon">icons/toolbox/Reset.png</file>
+ <file alias="Contact">icons/toolbox/NormalContact.png</file>
+ <file alias="NegContact">icons/toolbox/NegatedContact.png</file>
+ <file alias="Coil">icons/toolbox/NormalCoil.png</file>
+ <file alias="NegCoil">icons/toolbox/NegatedCoil.png</file>
+ <file alias="SetCoil">icons/toolbox/SetOnlyCoil.png</file>
+ <file alias="ResetCoil">icons/toolbox/ResetOnlyCoil.png</file>
</qresource>
</RCC>
diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h
index 1b2117d..1254387 100644
--- a/ldmicro/lib/linuxUI/linuxLD.h
+++ b/ldmicro/lib/linuxUI/linuxLD.h
@@ -7,6 +7,7 @@
#include <math.h>
#include <algorithm>
#include <QAction>
+#include <QToolBar>
#include <QTreeWidget>
#include <QSplitter>
#include <Qt>
@@ -25,8 +26,8 @@
#define HEAP_ZERO_MEMORY 0x00000008
/// Image loading flags
-#define IMAGE_ICON 1
-#define LDMICRO_ICON ":/ldmicro.ico"
+#define IMAGE_ICON 1
+#define LDMICRO_ICON ":/ldmicro.ico"
/// Typedefs
//typedef int64_t __int64;
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 5459920..631e11d 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -130,6 +130,22 @@
#define LTGRAY_BRUSH 0x00000020L
#define DKGRAY_BRUSH 0x00000040L
+#define ADD_ICON ":/AddIcon"
+#define SUB_ICON ":/SubIcon"
+#define MUL_ICON ":/MulIcon"
+#define DIV_ICON ":/DivIcon"
+#define CTU_ICON ":/CTUIcon"
+#define CTD_ICON ":/CTDIcon"
+#define TON_ICON ":/TONIcon"
+#define TOF_ICON ":/TOFIcon"
+#define RES_ICON ":/ResIcon"
+#define CONT_ICON ":/Contact"
+#define NEG_CONT_ICON ":/NegContact"
+#define COIL_ICON ":/Coil"
+#define NEG_COIL_ICON ":/NegCoil"
+#define SET_COIL_ICON ":/SetCoil"
+#define RESET_COIL_ICON ":/ResetCoil"
+
extern const COLORREF BLACK_BR;
extern const COLORREF WHITE_BR;
extern const COLORREF GRAY_BR;
diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp
index c290953..b0e1db1 100644
--- a/ldmicro/maincontrols.cpp
+++ b/ldmicro/maincontrols.cpp
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <QKeySequence>
#include <QStatusBar>
+#include "toolbar.h"
#include "ldmicro.h"
// status bar at the bottom of the screen, to display settings
@@ -106,6 +107,8 @@ QAction* InsertPwlMenu;
QAction* McuSettingsMenu;
QAction* ProcessorMenuItems[NUM_SUPPORTED_MCUS+1];
+HMENU ArithmeticMenu;
+HMENU AnalogMenu;
HMENU MicroControllerMenu;
QAction* SimulationModeMenu;
@@ -206,6 +209,15 @@ HMENU MakeMainWindowMenus(void)
HMENU InstructionMenuSeparator;
HMENU SimulateMenuSeparator;
+ HMENU TimersMenu = new QMenu("&Timers",NULL);
+ HMENU CountersMenu = new QMenu("C&ounters",NULL);
+ HMENU ComparisonMenu = new QMenu("Com&parison Operators",NULL);
+ HMENU UARTMenu = new QMenu("&UART Operations",NULL);
+
+ ArithmeticMenu = new QMenu("A&rithmetic Operators",NULL);
+ AnalogMenu = new QMenu("A&nalog Operations",NULL);
+
+
int i;
// Create new menu bar to hold menu and add it to window
@@ -377,47 +389,54 @@ HMENU MakeMainWindowMenus(void)
InstructionMenu->addAction(InsertCommentMenu);
InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertContactsMenu);
+ InstructionMenu->addAction(InsertCoilMenu);
InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertOsrMenu);
- InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertOsfMenu);
- InstructionMenu->addAction(InsertTonMenu);
- InstructionMenu->addAction(InsertTofMenu);
- InstructionMenu->addAction(InsertRtoMenu);
InstructionMenu->addSeparator();
- InstructionMenu->addAction(InsertCtuMenu);
- InstructionMenu->addAction(InsertCtdMenu);
- InstructionMenu->addAction(InsertCtcMenu);
+
+ TimersMenu->addAction(InsertTonMenu);
+ TimersMenu->addAction(InsertTofMenu);
+ TimersMenu->addAction(InsertRtoMenu);
+ InstructionMenu->addMenu(TimersMenu);
+ InstructionMenu->addAction(InsertResMenu);
+ InstructionMenu->addSeparator();
+
+ CountersMenu->addAction(InsertCtuMenu);
+ CountersMenu->addAction(InsertCtdMenu);
+ CountersMenu->addAction(InsertCtcMenu);
+ InstructionMenu->addMenu(CountersMenu);
InstructionMenu->addSeparator();
- InstructionMenu->addAction(InsertEquMenu);
- InstructionMenu->addAction(InsertNeqMenu);
- InstructionMenu->addAction(InsertGrtMenu);
- InstructionMenu->addAction(InsertGeqMenu);
- InstructionMenu->addAction(InsertLesMenu);
- InstructionMenu->addAction(InsertLeqMenu);
+ ComparisonMenu->addAction(InsertEquMenu);
+ ComparisonMenu->addAction(InsertNeqMenu);
+ ComparisonMenu->addAction(InsertGrtMenu);
+ ComparisonMenu->addAction(InsertGeqMenu);
+ ComparisonMenu->addAction(InsertLesMenu);
+ ComparisonMenu->addAction(InsertLeqMenu);
+ InstructionMenu->addMenu(ComparisonMenu);
InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertOpenMenu);
InstructionMenu->addAction(InsertShortMenu);
InstructionMenu->addAction(InsertMasterRlyMenu);
InstructionMenu->addSeparator();
- InstructionMenu->addAction(InsertCoilMenu);
- InstructionMenu->addAction(InsertResMenu);
- InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertMovMenu);
- InstructionMenu->addAction(InsertAddMenu);
- InstructionMenu->addAction(InsertSubMenu);
- InstructionMenu->addAction(InsertMulMenu);
- InstructionMenu->addAction(InsertDivMenu);
+ ArithmeticMenu->addAction(InsertAddMenu);
+ ArithmeticMenu->addAction(InsertSubMenu);
+ ArithmeticMenu->addAction(InsertMulMenu);
+ ArithmeticMenu->addAction(InsertDivMenu);
+ InstructionMenu->addMenu(ArithmeticMenu);
InstructionMenu->addSeparator();
InstructionMenu->addAction(InsertShiftRegMenu);
InstructionMenu->addAction(InsertLutMenu);
InstructionMenu->addAction(InsertPwlMenu);
- InstructionMenu->addAction(InsertFmtdStrMenu);
InstructionMenu->addSeparator();
- InstructionMenu->addAction(InsertUartSendMenu);
- InstructionMenu->addAction(InsertUartRecvMenu);
- InstructionMenu->addAction(InsertSetPwmMenu);
- InstructionMenu->addAction(InsertReadAdcMenu);
+ UARTMenu->addAction(InsertUartSendMenu);
+ UARTMenu->addAction(InsertUartRecvMenu);
+ UARTMenu->addAction(InsertFmtdStrMenu);
+ InstructionMenu->addMenu(UARTMenu);
+ AnalogMenu->addAction(InsertSetPwmMenu);
+ AnalogMenu->addAction(InsertReadAdcMenu);
+ InstructionMenu->addMenu(AnalogMenu);
InstructionMenu->addAction(InsertPersistMenu);
InstructionMenu->addSeparator();
InstructionMenu->addAction(MakeNormalMenu);
@@ -484,6 +503,7 @@ void MakeMainWindowControls(void)
QSplitter *splitter = new QSplitter(Qt::Orientation::Vertical);
MainWindow->setLayout(PackBoxMenu);
PackBoxMenu->setMenuBar(MainMenu);
+ // MainWindow->addToolBar(*EasyAccessTool);
IoList = new QTreeWidget();
IoList->setColumnCount(IO_COLUMN_COUNT);
IoList->setSelectionMode(QAbstractItemView::SingleSelection);
@@ -504,6 +524,9 @@ void MakeMainWindowControls(void)
DrawWindow->setMinimumHeight(100);
scrollbar->resize(DWSize);
scrollbar->setWidget(DrawWindow);
+ PackBoxMenu->setSpacing(3);
+ PackBoxMenu->setContentsMargins(10,0,10,0);
+ PackBoxMenu->addWidget(EasyAccessTool);
splitter->addWidget(scrollbar);
DWSize.setWidth(MainWindow->width() -
(scrollbar->sizeHint().width()+ MainWindow->sizeHint().width()));
@@ -592,12 +615,14 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
EnableMenuItem(InstructionMenu, InsertCoilMenu, t);
EnableMenuItem(InstructionMenu, InsertResMenu, t);
EnableMenuItem(InstructionMenu, InsertMovMenu, t);
+ EnableMenuItem(InstructionMenu, ArithmeticMenu, t);
EnableMenuItem(InstructionMenu, InsertAddMenu, t);
EnableMenuItem(InstructionMenu, InsertSubMenu, t);
EnableMenuItem(InstructionMenu, InsertMulMenu, t);
EnableMenuItem(InstructionMenu, InsertDivMenu, t);
EnableMenuItem(InstructionMenu, InsertCtcMenu, t);
EnableMenuItem(InstructionMenu, InsertPersistMenu, t);
+ EnableMenuItem(InstructionMenu, AnalogMenu, t);
EnableMenuItem(InstructionMenu, InsertReadAdcMenu, t);
EnableMenuItem(InstructionMenu, InsertSetPwmMenu, t);
EnableMenuItem(InstructionMenu, InsertMasterRlyMenu, t);
@@ -605,6 +630,16 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
EnableMenuItem(InstructionMenu, InsertLutMenu, t);
EnableMenuItem(InstructionMenu, InsertPwlMenu, t);
+ // Disable tool buttons along with menus
+ EnableMenuItem(NULL, CoilBtn, t);
+ EnableMenuItem(NULL, NegCoilBtn, t);
+ EnableMenuItem(NULL, SetCoilBtn, t);
+ EnableMenuItem(NULL, ResetCoilBtn, t);
+ EnableMenuItem(NULL, AddBtn, t);
+ EnableMenuItem(NULL, SubBtn, t);
+ EnableMenuItem(NULL, MulBtn, t);
+ EnableMenuItem(NULL, DivBtn, t);
+
t = canInsertOther ? MF_ENABLED : MF_GRAYED;
EnableMenuItem(InstructionMenu, InsertTonMenu, t);
EnableMenuItem(InstructionMenu, InsertTofMenu, t);
@@ -625,6 +660,12 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
EnableMenuItem(InstructionMenu, InsertUartSendMenu, t);
EnableMenuItem(InstructionMenu, InsertUartRecvMenu, t);
EnableMenuItem(InstructionMenu, InsertFmtdStrMenu, t);
+
+ //Disable respective tool items
+ EnableMenuItem(NULL, TonBtn, t);
+ EnableMenuItem(NULL, TofBtn, t);
+ EnableMenuItem(NULL, CtuBtn, t);
+ EnableMenuItem(NULL, CtdBtn, t);
}
//-----------------------------------------------------------------------------
diff --git a/ldmicro/toolbar.cpp b/ldmicro/toolbar.cpp
new file mode 100644
index 0000000..99bba4b
--- /dev/null
+++ b/ldmicro/toolbar.cpp
@@ -0,0 +1,129 @@
+#include "toolbar.h"
+#include <linuxUI.h>
+#include "ldmicro.h"
+
+QIcon* ContactIco;
+QIcon* NegContactIco;
+QIcon* CoilIco;
+QIcon* NegCoilIco;
+QIcon* SetCoilIco;
+QIcon* ResetCoilIco;
+QIcon* ResetTimerIco;
+QIcon* TonIco;
+QIcon* TofIco;
+// QIcon* RtoIco;
+QIcon* AddIco;
+QIcon* SubIco;
+QIcon* MulIco;
+QIcon* DivIco;
+QIcon* CtuIco;
+QIcon* CtdIco;
+QAction* ContactBtn;
+QAction* NegContactBtn;
+QAction* CoilBtn;
+QAction* NegCoilBtn;
+QAction* SetCoilBtn;
+QAction* ResetCoilBtn;
+QAction* ResetTimerBtn;
+QAction* TonBtn;
+QAction* TofBtn;
+QAction* RtoBtn;
+QAction* AddBtn;
+QAction* SubBtn;
+QAction* MulBtn;
+QAction* DivBtn;
+QAction* CtuBtn;
+QAction* CtdBtn;
+QToolBar* EasyAccessTool;
+
+void CreateToolBar()
+{
+ ContactIco = new QIcon(CONT_ICON);
+ NegContactIco = new QIcon(NEG_CONT_ICON);
+ CoilIco = new QIcon(COIL_ICON);
+ NegCoilIco = new QIcon(NEG_COIL_ICON);
+ SetCoilIco = new QIcon(SET_COIL_ICON);
+ ResetCoilIco = new QIcon(RESET_COIL_ICON);
+ TonIco = new QIcon(TON_ICON);
+ TofIco = new QIcon(TOF_ICON);
+ // RtoIco = new QIcon(RTO_ICON);
+ AddIco = new QIcon(ADD_ICON);
+ SubIco = new QIcon(SUB_ICON);
+ MulIco = new QIcon(MUL_ICON);
+ DivIco = new QIcon(DIV_ICON);
+ CtuIco = new QIcon(CTU_ICON);
+ CtdIco = new QIcon(CTD_ICON);
+ /*ContactBtn = new QAction(*ContactIco, "C-NO");
+ NegContactBtn = new QAction(*NegContactIco, "C-NC");
+ CoilBtn = new QAction(*CoilIco, "L-NO");
+ NegCoilBtn = new QAction(*NegCoilIco, "L-NC");
+ SetCoilBtn = new QAction(*SetCoilIco, "L-SO");
+ ResetCoilBtn = new QAction(*ResetCoilIco, "L-RO");
+ TonBtn = new QAction(*TonIco, "TON");
+ TofBtn = new QAction(*TofIco, "TOF");
+ RtoBtn = new QAction(*RtoIco, "RTO");
+ AddBtn = new QAction(*AddIco, "Add");
+ SubBtn = new QAction(*SubIco, "Sub");
+ MulBtn = new QAction(*MulIco, "Mul");
+ DivBtn = new QAction(*DivIco, "Div");
+ CtuBtn = new QAction(*CtuIco, "CTU");
+ CtdBtn = new QAction(*CtdIco, "CTD");*/
+ EasyAccessTool = new QToolBar();
+ EasyAccessTool->addSeparator();
+ ContactBtn = EasyAccessTool->addAction(*ContactIco, "Normal Contact");
+ NegContactBtn = EasyAccessTool->addAction(*NegContactIco, "Negated Contact");
+ EasyAccessTool->addSeparator();
+ CoilBtn = EasyAccessTool->addAction(*CoilIco, "Normal Coil");
+ NegCoilBtn = EasyAccessTool->addAction(*NegCoilIco, "Negated Coil");
+ SetCoilBtn = EasyAccessTool->addAction(*SetCoilIco, "Set Only Coil");
+ ResetCoilBtn = EasyAccessTool->addAction(*ResetCoilIco, "Reset Only Coil");
+ EasyAccessTool->addSeparator();
+ TonBtn = EasyAccessTool->addAction(*TonIco, "On Timer");
+ TofBtn = EasyAccessTool->addAction(*TofIco, "Off Timer");
+ EasyAccessTool->addSeparator();
+ CtuBtn = EasyAccessTool->addAction(*CtuIco, "Up Counter");
+ CtdBtn = EasyAccessTool->addAction(*CtdIco, "Down Counter");
+ EasyAccessTool->addSeparator();
+ AddBtn = EasyAccessTool->addAction(*AddIco, "Add");
+ SubBtn = EasyAccessTool->addAction(*SubIco, "Substract");
+ MulBtn = EasyAccessTool->addAction(*MulIco, "Multiply");
+ DivBtn = EasyAccessTool->addAction(*DivIco, "Divide");
+ EasyAccessTool->addSeparator();
+ EasyAccessTool->adjustSize();
+ ToolBarHandler();
+}
+
+void ToolBarHandler()
+{
+ QSignalMapper* CommandMapper = new QSignalMapper (&MenuHandle);
+ CommandMapper->setMapping(ContactBtn, MNU_INSERT_CONTACTS);
+ CommandMapper->setMapping(NegContactBtn, MNU_INSERT_CONTACTS_N);
+ CommandMapper->setMapping(CoilBtn, MNU_INSERT_COIL);
+ CommandMapper->setMapping(NegCoilBtn, MNU_INSERT_COIL_N);
+ CommandMapper->setMapping(SetCoilBtn, MNU_INSERT_COIL_S);
+ CommandMapper->setMapping(ResetCoilBtn, MNU_INSERT_COIL_R);
+ CommandMapper->setMapping(TonBtn, MNU_INSERT_TON);
+ CommandMapper->setMapping(TofBtn, MNU_INSERT_TOF);
+ CommandMapper->setMapping(CtuBtn, MNU_INSERT_CTU);
+ CommandMapper->setMapping(CtdBtn, MNU_INSERT_CTD);
+ CommandMapper->setMapping(AddBtn, MNU_INSERT_ADD);
+ CommandMapper->setMapping(SubBtn, MNU_INSERT_SUB);
+ CommandMapper->setMapping(MulBtn, MNU_INSERT_MUL);
+ CommandMapper->setMapping(DivBtn, MNU_INSERT_DIV);
+ QObject::connect(ContactBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(NegContactBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(CoilBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(NegCoilBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(SetCoilBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(ResetCoilBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(TonBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(TofBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(CtuBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(CtdBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(AddBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(SubBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(MulBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect(DivBtn, SIGNAL(triggered()), CommandMapper, SLOT(map()));
+ QObject::connect (CommandMapper, SIGNAL(mapped(int)),
+ &MenuHandle, SLOT(LD_WM_Command_call(int))) ;
+} \ No newline at end of file