]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
Light GUI module example.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 21 Jul 2021 15:01:35 +0000 (17:01 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 21 Jul 2021 15:01:35 +0000 (17:01 +0200)
Examples/cppgui2/Makefile [new file with mode: 0644]
Examples/cppgui2/build.sh [new file with mode: 0755]
Examples/cppgui2/components.py [new file with mode: 0644]
Examples/cppgui2/cppcompos.png [new file with mode: 0644]
Examples/cppgui2/cppcomposGUI.cxx [new file with mode: 0644]
Examples/cppgui2/cppcomposGUI.h [new file with mode: 0644]
Examples/cppgui2/demo.ui [new file with mode: 0644]
Examples/cppgui2/exec.png [new file with mode: 0644]
Examples/cppgui2/index.rst [new file with mode: 0644]
Examples/cppgui2/using.rst [new file with mode: 0644]

diff --git a/Examples/cppgui2/Makefile b/Examples/cppgui2/Makefile
new file mode 100644 (file)
index 0000000..8ca1e93
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (C) 2009-2021  EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+clean:
+       rm -rf *.o *.so cppcompos_* appli install *.bak traceExec_proc *.err *.log
diff --git a/Examples/cppgui2/build.sh b/Examples/cppgui2/build.sh
new file mode 100755 (executable)
index 0000000..8430376
--- /dev/null
@@ -0,0 +1 @@
+../exec.sh python components.py
diff --git a/Examples/cppgui2/components.py b/Examples/cppgui2/components.py
new file mode 100644 (file)
index 0000000..eb18cad
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2009-2021  EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+#import context from ..
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
+
+import os
+from module_generator import *
+
+
+modul=Module("cppcompos",components=[],prefix="./install",
+             doc=["*.rst",],
+             gui=["cppcomposGUI.cxx","cppcomposGUI.h","demo.ui","*.png"],
+            )
+
+g=Generator(modul,context)
+g.generate()
+g.configure()
+g.make()
+g.install()
+g.make_appli("appli", restrict=["KERNEL","GUI","YACS"], sys_modules=SYS_MODULES)
+
diff --git a/Examples/cppgui2/cppcompos.png b/Examples/cppgui2/cppcompos.png
new file mode 100644 (file)
index 0000000..16a20c1
Binary files /dev/null and b/Examples/cppgui2/cppcompos.png differ
diff --git a/Examples/cppgui2/cppcomposGUI.cxx b/Examples/cppgui2/cppcomposGUI.cxx
new file mode 100644 (file)
index 0000000..ba6a593
--- /dev/null
@@ -0,0 +1,159 @@
+// Copyright (C) 2009-2021  EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "cppcomposGUI.h"
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Study.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <SalomeApp_Application.h>
+
+#include <SALOMEconfig.h>
+
+// QT Includes
+#include <QInputDialog>
+#include <QIcon>
+#include <QLabel>
+
+// Export the module
+extern "C" {
+  CAM_Module* createModule()
+  {
+    return new cppcomposGUI();
+  }
+}
+
+// Constructor
+cppcomposGUI::cppcomposGUI() :
+  SalomeApp_Module( "cppcompos" ) // default name
+{
+}
+
+//static cppcompos_ORB::cppcompos_var engine;
+
+// Module's initialization
+void cppcomposGUI::initialize( CAM_Application* app )
+{
+
+  SalomeApp_Module::initialize( app );
+
+  QWidget* aParent = application()->desktop();
+  SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
+
+  // create actions
+  QPixmap aPixmap = aResourceMgr->loadPixmap( "cppcompos","exec.png" );
+  createAction( 901, "Banner", QIcon( aPixmap ), "Banner", "Banner", 0, aParent, false, this, SLOT( OnGetBanner() ) );
+  createAction( 902, "Designer", QIcon( aPixmap ), "Designer", "Designer", 0, aParent, false, this, SLOT( OnDesigner() ) );
+
+  // create menus
+  int aMenuId;
+  aMenuId = createMenu( "cppcompos", -1, -1, 30 );
+  createMenu( 901, aMenuId, 10 );
+
+  // create toolbars
+  int aToolId = createTool ( "cppcompos" );
+  createTool( 901, aToolId );
+  createTool( 902, aToolId );
+  
+  _myWidget = new QLabel("My module!", aParent);
+  _myViewManager = getApp()->createViewManager("cppcompos", _myWidget);
+  _myViewManager->getActiveView()->setClosable( false );
+  if(app->desktop() )
+     connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+              this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
+    
+}
+
+// Get compatible dockable windows.
+void cppcomposGUI::windows( QMap<int, int>& theMap ) const
+{
+  theMap.clear();
+//  theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+//  theMap.insert( SalomeApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
+}
+
+// Module's engine IOR
+QString cppcomposGUI::engineIOR() const
+{
+  return "Fake";
+}
+
+// Module's activation
+bool cppcomposGUI::activateModule( SUIT_Study* theStudy )
+{
+  bool bOk = SalomeApp_Module::activateModule( theStudy );
+
+  if(bOk)
+  {
+    setMenuShown( true );
+    setToolShown( true );
+    _myViewManager->setShown(true);
+    _myWidget->setVisible(true);
+    _myViewManager->getActiveView()->setFocus();
+  }
+  return bOk;
+}
+
+// Module's deactivation
+bool cppcomposGUI::deactivateModule( SUIT_Study* theStudy )
+{
+  setMenuShown( false );
+  setToolShown( false );
+  _myWidget->setVisible(false);
+  _myViewManager->setShown(false);
+
+  return SalomeApp_Module::deactivateModule( theStudy );
+}
+
+void cppcomposGUI::onWindowActivated( SUIT_ViewWindow* svw)
+{
+  if(_myViewManager->getActiveView()->getId() == svw->getId())
+    if (!getApp()->activeModule() ||
+        getApp()->activeModule()->moduleName() != "cppcompos")
+      getApp()->activateModule("cppcompos");
+}
+
+// Action slot
+void cppcomposGUI::OnGetBanner()
+{
+  // Dialog to get the Name
+  bool ok = false;
+  QString myName = QInputDialog::getText( getApp()->desktop(), "label", "name", QLineEdit::Normal, QString::null, &ok );
+
+  if ( ok && !myName.isEmpty()) 
+  {
+    QString banner = "Hello " + myName;
+    SUIT_MessageBox::information( getApp()->desktop(), "info", banner, "OK" );
+  }
+}
+
+// Action slot
+void cppcomposGUI::OnDesigner()
+{
+  QWidget* wid= new MyDemo(getApp()->desktop());
+  wid->show();
+}
+
+MyDemo::MyDemo(QWidget *parent)
+        :QDialog(parent)
+{
+  ui.setupUi(this);
+}
diff --git a/Examples/cppgui2/cppcomposGUI.h b/Examples/cppgui2/cppcomposGUI.h
new file mode 100644 (file)
index 0000000..b4f26c0
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2009-2021  EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _cppcomposGUI_H_
+#define _cppcomposGUI_H_
+
+#include <SalomeApp_Module.h>
+#include "ui_demo.h"
+
+class SUIT_ViewManager;
+class SUIT_ViewWindow;
+
+class cppcomposGUI: public SalomeApp_Module
+{
+  Q_OBJECT
+
+public:
+  cppcomposGUI();
+  void    initialize( CAM_Application* );
+  QString engineIOR() const;
+  virtual void  windows( QMap<int, int>& theMap ) const;
+
+public slots:
+  bool    deactivateModule( SUIT_Study* );
+  bool    activateModule( SUIT_Study* );
+
+protected slots:
+  void OnGetBanner();
+  void OnDesigner();
+  void onWindowActivated( SUIT_ViewWindow* svw);
+
+private:
+  QWidget* _myWidget;
+  SUIT_ViewManager* _myViewManager;
+};
+
+class MyDemo: public QDialog
+{
+  Q_OBJECT
+
+public:
+  MyDemo(QWidget *parent = 0);
+
+private:
+  Ui::DemoDialog ui;
+
+};
+
+#endif
diff --git a/Examples/cppgui2/demo.ui b/Examples/cppgui2/demo.ui
new file mode 100644 (file)
index 0000000..69e4ac0
--- /dev/null
@@ -0,0 +1,146 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>DemoDialog</class>
+ <widget class="QDialog" name="DemoDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>PyUIC4 Demo Dialog</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="2" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="0" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item rowspan="3" row="0" column="1" >
+    <widget class="QListWidget" name="list" />
+   </item>
+   <item row="1" column="0" >
+    <layout class="QVBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <widget class="QPushButton" name="button1" >
+       <property name="text" >
+        <string>Add items</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="button2" >
+       <property name="text" >
+        <string>Clear list</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="3" column="0" colspan="2" >
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>131</width>
+         <height>31</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="okButton" >
+       <property name="text" >
+        <string>OK</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>okButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DemoDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>369</x>
+     <y>256</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>96</x>
+     <y>254</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>button2</sender>
+   <signal>clicked()</signal>
+   <receiver>list</receiver>
+   <slot>clear()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>92</x>
+     <y>112</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>279</x>
+     <y>123</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Examples/cppgui2/exec.png b/Examples/cppgui2/exec.png
new file mode 100644 (file)
index 0000000..16a20c1
Binary files /dev/null and b/Examples/cppgui2/exec.png differ
diff --git a/Examples/cppgui2/index.rst b/Examples/cppgui2/index.rst
new file mode 100644 (file)
index 0000000..e5ebde0
--- /dev/null
@@ -0,0 +1,23 @@
+.. cppcompos documentation master file, created by
+   sphinx-quickstart on Sun Sep 19 16:20:14 2010.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to cppcompos's documentation!
+=======================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   using.rst
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/Examples/cppgui2/using.rst b/Examples/cppgui2/using.rst
new file mode 100644 (file)
index 0000000..f28347d
--- /dev/null
@@ -0,0 +1,17 @@
+
+GUI components
+===================
+
+Object Browser
+--------------
+The Object Browser is a reusable GUI component.
+
+The Object Browser is only used to publish the run of the schema as a whole.
+
+
+.. centered:: **Object Browser tab**
+
+The Object Browser is in a tab, with tree_view
+
+Other
+----------