diff Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp @ 527:b1377625e4ba bgo-commands-codegen

Removed ICommand and friends + fixed warnings + added missing header files in solution (in CMakeLists.txt file)
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 17 Mar 2019 20:14:20 +0100
parents b70e9be013e4
children 2d8ab34c8c91
line wrap: on
line diff
--- a/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp	Tue Mar 12 15:01:36 2019 +0100
+++ b/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp	Sun Mar 17 20:14:20 2019 +0100
@@ -27,8 +27,15 @@
 #include <ui_SimpleViewerMainWindow.h>
 #include "../SimpleViewerApplication.h"
 
+
 namespace SimpleViewer
 {
+  template<typename T, typename U>
+  bool ExecuteCommand(U* handler, const T& command)
+  {
+    std::string serializedCommand = StoneSerialize(command);
+    StoneDispatchToHandler(serializedCommand, handler);
+  }
 
   SimpleViewerMainWindow::SimpleViewerMainWindow(
     OrthancStone::NativeStoneApplicationContext& context,
@@ -67,43 +74,36 @@
 
   void SimpleViewerMainWindow::cropClicked()
   {
-    GenericNoArgCommand command("selectTool:crop");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(SelectTool(Tool_Crop));
   }
 
   void SimpleViewerMainWindow::undoCropClicked()
   {
-    GenericNoArgCommand command("action:undo-crop");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(Action(ActionType_UndoCrop));
   }
 
   void SimpleViewerMainWindow::lineClicked()
   {
-    GenericNoArgCommand command("selectTool:line-measure");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(SelectTool(Tool_LineMeasure));
   }
 
   void SimpleViewerMainWindow::circleClicked()
   {
-    GenericNoArgCommand command("selectTool:circle-measure");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(SelectTool(Tool_CircleMeasure));
   }
 
   void SimpleViewerMainWindow::windowingClicked()
   {
-    GenericNoArgCommand command("selectTool:windowing");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(SelectTool(Tool_Windowing));
   }
 
   void SimpleViewerMainWindow::rotateClicked()
   {
-    GenericNoArgCommand command("action:rotate");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(Action(ActionType_Rotate));
   }
 
   void SimpleViewerMainWindow::invertClicked()
   {
-    GenericNoArgCommand command("action:invert");
-    stoneApplication_.ExecuteCommand(command);
+    stoneApplication_.ExecuteCommand(Action(ActionType_Invert));
   }
 }