]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
CCAR: First part of a development to add GUI (python only for now) and DOC generation.
authorcaremoli <caremoli>
Thu, 23 Sep 2010 13:48:32 +0000 (13:48 +0000)
committercaremoli <caremoli>
Thu, 23 Sep 2010 13:48:32 +0000 (13:48 +0000)
See example in Examples/pygui1

13 files changed:
Examples/context.py
Examples/pygui1/README.txt [new file with mode: 0644]
Examples/pygui1/components.py [new file with mode: 0644]
Examples/pygui1/demo.ui [new file with mode: 0644]
Examples/pygui1/exec.png [new file with mode: 0644]
Examples/pygui1/index.rst [new file with mode: 0644]
Examples/pygui1/pycompos.png [new file with mode: 0644]
Examples/pygui1/pycomposGUI.py [new file with mode: 0644]
Examples/pygui1/using.rst [new file with mode: 0644]
module_generator/doc_tmpl.py [new file with mode: 0644]
module_generator/gener.py
module_generator/gui_tmpl.py [new file with mode: 0644]
module_generator/mod_tmpl.py

index 37abe847ee0d30061ae93478127f7dbf7cc6485d..0d6ab8e92e3a8eb4a61ca1d803075f4c41b876ad 100644 (file)
@@ -28,6 +28,7 @@ context={'update':1,
          "makeflags":"",
          "prerequisites":"/local/cchris/.packages.d/envSalome51main",
          "kernel":KERNEL_ROOT_DIR,
+         "gui":GUI_ROOT_DIR,
         }
 
 
diff --git a/Examples/pygui1/README.txt b/Examples/pygui1/README.txt
new file mode 100644 (file)
index 0000000..fb47288
--- /dev/null
@@ -0,0 +1,19 @@
+A Python component dynamically loadable
+===============================================
+
+To build this example, modify the ../context.py file
+to take into account your configuration.
+
+1- your prerequisite file 
+2- your KERNEL_ROOT_DIR
+
+Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py ::
+
+  source <your prerequisite file>
+  python components.py
+
+You should get a SALOME module in source form (pycompos_SRC), its installation (install) and
+a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module pycompos.
+
+Launch SALOME : ./appli/runAppli -k
+activate the pycompos module, look at the doc, activate commands, ...
diff --git a/Examples/pygui1/components.py b/Examples/pygui1/components.py
new file mode 100644 (file)
index 0000000..f10274b
--- /dev/null
@@ -0,0 +1,55 @@
+#  Copyright (C) 2009-2010  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.
+#
+#  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 os
+
+#import context from ..
+execfile("../context.py")
+
+from module_generator import Generator,Module,Service,PYComponent
+
+defs="""
+"""
+
+body="""
+      c=a+b
+      d=a-b
+"""
+c1=PYComponent("compo2",services=[
+          Service("s1",inport=[("a","double"),("b","double")],
+                       outport=[("c","double"),("d","double")],
+                       defs=defs,body=body,
+                 ),
+         ],
+         )
+
+modul=Module("pycompos",components=[c1],prefix="./install",
+              doc=["*.rst",],
+              gui=["pycomposGUI.py","demo.ui","*.png"],
+            )
+
+g=Generator(modul,context)
+g.generate()
+g.bootstrap()
+g.configure()
+g.make()
+g.install()
+g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR})
+
+
diff --git a/Examples/pygui1/demo.ui b/Examples/pygui1/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/pygui1/exec.png b/Examples/pygui1/exec.png
new file mode 100644 (file)
index 0000000..16a20c1
Binary files /dev/null and b/Examples/pygui1/exec.png differ
diff --git a/Examples/pygui1/index.rst b/Examples/pygui1/index.rst
new file mode 100644 (file)
index 0000000..ff84846
--- /dev/null
@@ -0,0 +1,23 @@
+.. pycompos 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 pycompos's documentation!
+=======================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   using.rst
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/Examples/pygui1/pycompos.png b/Examples/pygui1/pycompos.png
new file mode 100644 (file)
index 0000000..16a20c1
Binary files /dev/null and b/Examples/pygui1/pycompos.png differ
diff --git a/Examples/pygui1/pycomposGUI.py b/Examples/pygui1/pycomposGUI.py
new file mode 100644 (file)
index 0000000..933665f
--- /dev/null
@@ -0,0 +1,73 @@
+import os
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+from PyQt4.QtWebKit import *
+from PyQt4 import QtCore, QtGui, uic
+
+# Get SALOME PyQt interface
+import SalomePyQt
+sgPyQt = SalomePyQt.SalomePyQt()
+
+# called when module is initialized
+# return map of popup windows to be used by the module
+def windows():
+  wm = {}
+  wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea
+  wm[SalomePyQt.WT_PyConsole]     = Qt.BottomDockWidgetArea
+  return wm
+
+# called when module is initialized
+# return list of 2d/3d views to be used ny the module
+def views():
+  return []
+
+# called when module is activated
+# returns True if activating is successfull and False otherwise
+def activate():
+  # create top-level menu
+  mid = sgPyQt.createMenu( "pycompos", -1, 90, sgPyQt.defaultMenuGroup() )
+  # create toolbar
+  tid = sgPyQt.createTool( "pycompos" )
+  # create actions and fill menu and toolbar with actions
+  a = sgPyQt.createAction( 941, "Hello", "Hello", "Show hello dialog box" ,"exec.png")
+  sgPyQt.createMenu( a, mid )
+  sgPyQt.createTool( a, tid )
+  a = sgPyQt.createAction( 942, "Hello2", "Hello2", "Show hello2 dialog box" ,"exec.png")
+  sgPyQt.createMenu( a, mid )
+  sgPyQt.createTool( a, tid )
+  return True
+
+# called when module is deactivated
+def deactivate():
+  pass
+
+class DemoImpl(QtGui.QDialog):
+    def __init__(self, *args):
+        super(DemoImpl, self).__init__(*args)
+
+        uic.loadUi(os.path.join(os.environ["pycompos_ROOT_DIR"],"share","salome","resources","pycompos","demo.ui"), self)
+
+    @QtCore.pyqtSlot()
+    def on_button1_clicked(self):
+        for s in "This is a demo".split(" "):
+            self.list.addItem(s)
+
+# called when GUI action is activated
+# action ID is passed as parameter
+def OnGUIEvent( commandID ):
+  print "pycompos.OnGUIEvent(): command = %d" % commandID
+  if commandID==941:
+    widget=QMainWindow(sgPyQt.getDesktop())
+    web = QWebView(widget)
+    page=os.path.join(os.environ["pycompos_ROOT_DIR"],"share","doc","salome","gui","pycompos","index.html")
+    web.load(QUrl(page))
+    widget.setCentralWidget(web)
+    widget.show()
+
+  elif commandID==942:
+    widget = DemoImpl(sgPyQt.getDesktop())
+    widget.show()
+
+
+
diff --git a/Examples/pygui1/using.rst b/Examples/pygui1/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
+----------
diff --git a/module_generator/doc_tmpl.py b/module_generator/doc_tmpl.py
new file mode 100644 (file)
index 0000000..e778e0f
--- /dev/null
@@ -0,0 +1,259 @@
+
+try:
+  from string import Template
+except:
+  from compat import Template,set
+
+docmakefile="""
+include $(top_srcdir)/adm_local/make_common_starter.am
+
+salomedoc_DATA=html/index.html
+
+html/index.html:
+       make htm
+
+SPHINXOPTS      =
+SOURCEDIR       = $(srcdir)
+SPHINXBUILD     = sphinx-build
+PAPEROPT_a4     = -D latex_paper_size=a4
+ALLSPHINXOPTS   = -d doctrees $(PAPEROPT_a4) $(SPHINXOPTS) $(SOURCEDIR)
+
+htm:
+       mkdir -p html doctrees
+       $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) html
+       @echo
+       @echo "Build finished. The HTML pages are in html."
+
+install-data-local:
+       $(INSTALL) -d $(DESTDIR)$(salomedocdir)
+       cp -rf html/* $(DESTDIR)$(salomedocdir) ;
+
+uninstall-local:
+       chmod -R +w $(DESTDIR)$(salomedocdir)
+       rm -rf $(DESTDIR)$(salomedocdir)/*
+
+clean-local:
+       -rm -rf html latex doctrees
+       if test -d "html"; then rm -rf html ; fi
+
+"""
+
+docconf="""# -*- coding: utf-8 -*-
+#
+# ${module} documentation build configuration file, created by
+# sphinx-quickstart on Sun Sep 19 16:20:14 2010.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'${module}'
+copyright = u'2010'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1'
+# The full version, including alpha/beta/rc tags.
+release = '1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = '${module}doc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', '${module}.tex', u'${module} Documentation',
+   u'cc', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', '${module}', u'${module} Documentation',
+     [u'cc'], 1)
+]
+"""
+
+docconf=Template(docconf)
index 704f2f0a9233b78c16b8e9212f5648061908c942..53038cbb27655c89d7ba2faaf9e71dfa2c46f5e1 100644 (file)
@@ -19,6 +19,7 @@
 
 import os, shutil, glob, socket
 import traceback
+import warnings
 
 try:
   from string import Template
@@ -32,6 +33,7 @@ debug=0
 
 from mod_tmpl import resMakefile, makecommon, configure, paco_configure
 from mod_tmpl import mainMakefile, autogen, application
+from mod_tmpl import check_sphinx
 from cata_tmpl import catalog, interface, idl, idlMakefile, parallel_interface
 from cata_tmpl import xml, xml_interface, xml_service
 from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS
@@ -45,6 +47,8 @@ from salomemodules import salome_modules
 from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type
 from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes
 from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies
+from gui_tmpl import pyguimakefile, pysalomeapp, cppguimakefile, cppsalomeapp
+from doc_tmpl import docmakefile, docconf
 
 def makedirs(namedir):
   """Create a new directory named namedir. If a directory already exists copy it to namedir.bak"""
@@ -57,11 +61,13 @@ def makedirs(namedir):
   os.makedirs(namedir)
 
 class Module(object):
-  def __init__(self, name, components=None, prefix="",layout="multidir"):
+  def __init__(self, name, components=None, prefix="",layout="multidir", doc=None, gui=None):
     self.name = name
     self.components = components or []
     self.prefix = prefix or "%s_INSTALL" % name
     self.layout=layout
+    self.doc = doc
+    self.gui = gui
     try:
       self.validate()
     except Invalid,e:
@@ -80,6 +86,10 @@ class Module(object):
         raise Invalid("%s is already defined as a component of the module" % compo.name)
       lcompo.add(compo.name)
       compo.validate()
+    if self.gui and self.layout != "multidir":
+      raise Invalid("A module with GUI can not be generated if layout is not multidir")
+    if self.doc and not self.gui:
+      warnings.warn("You can't have an help doc without a GUI. doc parameter will be ignored")
 
 class Component(object):
   def __init__(self, name, services=None, impl="PY", libs="", rlibs="",
@@ -218,8 +228,11 @@ class Generator(object):
     self.module = module
     self.context = context or {}
     self.kernel = self.context["kernel"]
+    self.gui = self.context.get("gui")
     self.makeflags = self.context.get("makeflags")
     self.aster = ""
+    if self.module.gui and not self.gui:
+      raise Invalid("To generate a module with GUI, you need to set the 'gui' parameter in the context dictionnary")
 
   def generate(self):
     """generate SALOME module as described by module attribute"""
@@ -242,7 +255,7 @@ class Generator(object):
     makefile = "SUBDIRS="
     makefileItems={"header":"""
 include $(top_srcdir)/adm_local/make_common_starter.am
-AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
+AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions
 """,
                    "salomepython_PYTHON":[],
                    "dist_salomescript_SCRIPTS":[],
@@ -288,11 +301,22 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
         makefileItems["salomeinclude_HEADERS"]=makefileItems["salomeinclude_HEADERS"]+mdict.get("salomeinclude_HEADERS",[])
         makefileItems["body"]=makefileItems["body"]+mdict.get("body","")+'\n'
 
+    if module.gui:
+      GUIname=module.name+"GUI"
+      fdict=self.makeGui(namedir)
+      srcs[GUIname] = fdict
+      #for src/Makefile.am
+      makefile = makefile + " " + GUIname
+
     if self.module.layout == "multidir":
       srcs["Makefile.am"] = makefile+'\n'
     else:
       srcs["Makefile.am"] = self.makeMakefile(makefileItems)
 
+    docsubdir=""
+    if module.gui and module.doc:
+      docsubdir="doc"
+
     #for catalog files
     catalogfile = "%sCatalog.xml" % module.name
 
@@ -301,12 +325,16 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
     for mod in self.used_modules:
       common_starter = common_starter + salome_modules[mod]["makefiledefs"] + '\n'
 
+    adm_local={"make_common_starter.am": common_starter, "check_aster.m4":check_aster}
+    if module.gui and module.doc:
+      adm_local["check_sphinx.m4"]=check_sphinx
+
     self.makeFiles({"autogen.sh":autogen,
-                    "Makefile.am":mainMakefile,
+                    "Makefile.am":mainMakefile.substitute(docsubdir=docsubdir),
                     "README":"", "NEWS":"", "AUTHORS":"", "ChangeLog":"",
                     "src":srcs,
                     "resources":{"Makefile.am":resMakefile.substitute(module=module.name), catalogfile:self.makeCatalog()},
-                    "adm_local":{"make_common_starter.am": common_starter, "check_aster.m4":check_aster},
+                    "adm_local":adm_local,
                     }, namedir)
 
     #add checks for modules in configure.ac
@@ -319,43 +347,81 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
     if self.module.layout=="multidir":
       for compo in module.components:
         configure_makefiles.append("     src/"+compo.name+"/Makefile")
+
+    if module.gui:
+      configure_makefiles.append("     src/%sGUI/Makefile" % module.name)
+      if module.doc:
+        configure_makefiles.append("     doc/Makefile")
+
+    other_check=""
+    other_summary=""
+    other_require=""
+
+    if module.gui:
+      other_check=other_check + """CHECK_SALOME_GUI
+CHECK_QT
+"""
+      other_summary=other_summary+'''echo "  SALOME GUI ............. : $SalomeGUI_ok"
+echo "  Qt ..................... : $qt_ok"
+'''
+      other_require=other_require + """
+      if test "x$SalomeGUI_ok" = "xno"; then
+        AC_MSG_ERROR([SALOME GUI is required],1)
+      fi
+      if test "x$qt_ok" = "xno"; then
+        AC_MSG_ERROR([Qt library is required],1)
+      fi
+"""
+      if module.doc:
+        other_check=other_check+"CHECK_SPHINX\n"
+        other_summary=other_summary+'''echo "  Sphinx ................. : $sphinx_ok"\n'''
+        other_require=other_require + """
+      if test "x$sphinx_ok" = "xno"; then
+        AC_MSG_ERROR([Sphinx documentation generator is required],1)
+      fi
+"""
+
+    files={}
     #for idl files
     idlfile = "%s.idl" % module.name
+    paco_config=""
+    PACO_BUILT_SOURCES=""
+    PACO_SALOMEINCLUDE_HEADERS=""
+    PACO_INCLUDES=""
+    PACO_salomepython_DATA=""
+    PACO_salomeidl_DATA=""
 
     if paco:
-      xmlfile = "%s.xml" % module.name
       PACO_BUILT_SOURCES = idlMakefilePaCO_BUILT_SOURCES.substitute(module=module.name)
       PACO_SALOMEINCLUDE_HEADERS = idlMakefilePaCO_nodist_salomeinclude_HEADERS.substitute(module=module.name)
       PACO_salomepython_DATA = idlMakefilePACO_salomepython_DATA.substitute(module=module.name)
       PACO_salomeidl_DATA = idlMakefilePACO_salomeidl_DATA.substitute(module=module.name)
       PACO_INCLUDES = idlMakefilePACO_INCLUDES
+      paco_config=paco_configure
+
+    files["configure.ac"]=configure.substitute(module=module.name.lower(),
+                                               makefiles='\n'.join(configure_makefiles),
+                                               paco_configure=paco_config,
+                                               modules=configure_modules,
+                                               other_check=other_check,
+                                               other_summary=other_summary,
+                                               other_require=other_require,
+                                              )
+
+    idlfiles={"Makefile.am":    idlMakefile.substitute(module=module.name,
+                                                       PACO_BUILT_SOURCES=PACO_BUILT_SOURCES,
+                                                       PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS,
+                                                       PACO_INCLUDES=PACO_INCLUDES,
+                                                       PACO_salomepython_DATA=PACO_salomepython_DATA,
+                                                       PACO_salomeidl_DATA=PACO_salomeidl_DATA),
+              idlfile : self.makeidl(),
+             }
+    if paco:
+      idlfiles["%s.xml" % module.name]=self.makexml()
+
+    files["idl"]=idlfiles
 
-      self.makeFiles({"configure.ac":configure.substitute(module=module.name.lower(),
-                                                          makefiles='\n'.join(configure_makefiles),
-                                                          paco_configure=paco_configure,
-                                                          modules=configure_modules),
-                      "idl":{"Makefile.am":idlMakefile.substitute(module=module.name,
-                                                                  PACO_BUILT_SOURCES=PACO_BUILT_SOURCES,
-                                                                  PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS,
-                                                                  PACO_INCLUDES=PACO_INCLUDES,
-                                                                  PACO_salomepython_DATA=PACO_salomepython_DATA,
-                                                                  PACO_salomeidl_DATA=PACO_salomeidl_DATA),
-                      idlfile:self.makeidl(),
-                      xmlfile:self.makexml()},
-                      }, namedir)
-    else :
-      self.makeFiles({"configure.ac":configure.substitute(module=module.name.lower(),
-                                                          makefiles='\n'.join(configure_makefiles),
-                                                          paco_configure="",
-                                                          modules=configure_modules),
-                      "idl":{"Makefile.am":idlMakefile.substitute(module=module.name,
-                                                                  PACO_BUILT_SOURCES="",
-                                                                  PACO_SALOMEINCLUDE_HEADERS="",
-                                                                  PACO_INCLUDES="",
-                                                                  PACO_salomepython_DATA="",
-                                                                  PACO_salomeidl_DATA=""), 
-                             idlfile:self.makeidl()},
-                      }, namedir)
+    self.makeFiles(files,namedir)
 
     os.chmod(os.path.join(namedir, "autogen.sh"), 0777)
     #copy source files if any in created tree
@@ -366,16 +432,85 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
         else:
           shutil.copyfile(src, os.path.join(namedir, "src", os.path.basename(src)))
 
-    for m4file in ("check_Kernel.m4", "check_omniorb.m4", 
+    for m4file in ("check_Kernel.m4", "check_omniorb.m4",
                    "ac_linker_options.m4", "ac_cxx_option.m4",
-                   "python.m4", "enable_pthreads.m4", "check_f77.m4", 
+                   "python.m4", "enable_pthreads.m4", "check_f77.m4",
                    "acx_pthread.m4", "check_boost.m4", "check_paco++.m4",
                    "check_mpi.m4", "check_lam.m4", "check_openmpi.m4", "check_mpich.m4"):
-      shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), 
+      shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file),
                       os.path.join(namedir, "adm_local", m4file))
+    if self.module.gui:
+      for m4file in ("check_GUI.m4", "check_qt.m4", "check_opengl.m4"):
+        shutil.copyfile(os.path.join(self.gui, "adm_local", "unix", "config_files", m4file),
+                        os.path.join(namedir, "adm_local", m4file))
 
+    self.makeDoc(namedir)
     return
 
+  def makeDoc(self,namedir):
+    if not self.module.gui:
+      return
+    if not self.module.doc:
+      return
+    rep=os.path.join(namedir,"doc")
+    os.makedirs(rep)
+    for docs in self.module.doc:
+      for doc in glob.glob(docs):
+        name = os.path.basename(doc)
+        shutil.copyfile(doc, os.path.join(rep, name))
+    d={}
+    if not os.path.exists(os.path.join(namedir, "doc", "Makefile.am")):
+      #create a minimal makefile.am
+      d["Makefile.am"]=docmakefile
+    if not os.path.exists(os.path.join(namedir, "doc", "conf.py")):
+      #create a minimal conf.py
+      d["conf.py"]=docconf.substitute(module=self.module.name)
+    self.makeFiles(d,os.path.join(namedir,"doc"))
+
+  def makeGui(self,namedir):
+    if not self.module.gui:
+      return
+    ispython=False
+    iscpp=False
+    #Force creation of intermediate directories
+    os.makedirs(os.path.join(namedir, "src", self.module.name+"GUI"))
+
+    for srcs in self.module.gui:
+      for src in glob.glob(srcs):
+        shutil.copyfile(src, os.path.join(namedir, "src", self.module.name+"GUI", os.path.basename(src)))
+        if src[-3:]==".py":ispython=True
+        if src[-4:]==".cxx":iscpp=True
+    if ispython and iscpp:
+      raise Invalid("Module GUI must be pure python or pure C++ but not mixed")
+    if ispython:
+      return self.makePyGUI(namedir)
+    if iscpp:
+      return self.makeCPPGUI(namedir)
+
+  def makePyGUI(self,namedir):
+    d={}
+    if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")):
+      #create a minimal makefile.am
+      sources=[]
+      other=[]
+      for srcs in self.module.gui:
+        for src in glob.glob(srcs):
+          if src[-3:]==".py":
+            sources.append(os.path.basename(src))
+          else:
+            other.append(os.path.basename(src))
+      makefile=pyguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other))
+      d["Makefile.am"]=makefile
+
+    if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")):
+      #create a minimal SalomeApp.xml
+      salomeapp=pysalomeapp.substitute(module=self.module.name)
+      d["SalomeApp.xml"]=salomeapp
+    return d
+
+  def makeCPPGUI(self,namedir):
+    return {}
+
   def makeMakefile(self,makefileItems):
     makefile=""
     if makefileItems.has_key("header"):
@@ -526,29 +661,19 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions
     prefix = self.module.prefix
     paco = self.context.get("paco")
     mpi = self.context.get("mpi")
+    args = (self.module.name, self.kernel, self.aster)
+    cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" % args
+    if self.gui:
+      cmd = cmd + " --with-gui=%s" % self.gui
     if prefix:
       prefix = os.path.abspath(prefix)
-      cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s --prefix=%s"
-      if paco:
-        cmd += " --with-paco=%s"
-        if mpi:
-          cmd += " --with-mpi=%s"
-          ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix, paco, mpi))
-        else :  
-          ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix, paco))
-      else :  
-        ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix))
-    else:
-      cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s"
-      if paco:
-        cmd += " --with-paco=%s"
-        if mpi:
-          cmd += " --with-mpi=%s"
-          ier = os.system(cmd % (self.module.name, self.kernel, self.aster, paco, mpi))
-        else:  
-          ier = os.system(cmd % (self.module.name, self.kernel, self.aster, paco))
-      else:  
-        ier = os.system(cmd % (self.module.name, self.kernel, self.aster))
+      cmd = cmd + " --prefix=%s" % prefix
+    if paco:
+      cmd += " --with-paco=%s" % paco
+    if mpi:
+      cmd += " --with-mpi=%s" % mpi
+
+    ier = os.system(cmd)
     if ier != 0:
       raise Invalid("configure has ended in error")
 
diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py
new file mode 100644 (file)
index 0000000..0e798a4
--- /dev/null
@@ -0,0 +1,45 @@
+try:
+  from string import Template
+except:
+  from compat import Template,set
+
+pyguimakefile="""
+include $$(top_srcdir)/adm_local/make_common_starter.am
+
+# Scripts to be installed
+salomepython_PYTHON= ${sources}
+
+salomeres_DATA =SalomeApp.xml ${other_sources}
+"""
+pyguimakefile=Template(pyguimakefile)
+
+
+pysalomeapp="""
+<document>
+  <section name="${module}">
+    <parameter name="name" value="${module}"/>
+    <parameter name="icon" value="${module}.png"/>
+    <parameter name="library" value="SalomePyQtGUI"/>
+  </section>
+  <section name="resources">
+    <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${module}"/>
+  </section>
+</document>
+"""
+pysalomeapp=Template(pysalomeapp)
+
+cppguimakefile="""
+include $$(top_srcdir)/adm_local/make_common_starter.am
+
+salomeres_DATA =SalomeApp.xml
+"""
+cppguimakefile=Template(cppguimakefile)
+
+cppsalomeapp="""
+<document>
+  <section name="${module}">
+    <parameter name="name" value="${module}"/>
+  </section>
+</document>
+"""
+cppsalomeapp=Template(cppsalomeapp)
index 61f41e3432bf53c4dbb55fe93dae7976fb359d4a..59bddf2f03c1909c900e9aa65c1c1825cd45fcc7 100644 (file)
@@ -46,10 +46,11 @@ echo "Running libtoolize..." ; libtoolize --copy --force           || exit 1
 echo "Running automake..."   ; automake --add-missing --copy       || exit 1
 """
 
-mainMakefile="""include $(top_srcdir)/adm_local/make_common_starter.am
-SUBDIRS = idl resources src
+mainMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am
+SUBDIRS = idl resources src ${docsubdir}
 ACLOCAL_AMFLAGS = -I adm_local
 """
+mainMakefile=Template(mainMakefile)
 
 configure="""
 AC_INIT(${module}, 1.0)
@@ -80,6 +81,8 @@ AC_SUBST(MODULE_NAME)
 
 AC_CHECK_ASTER
 
+${other_check}
+
 echo
 echo
 echo
@@ -89,7 +92,6 @@ echo "------------------------------------------------------------------------"
 echo
 echo "Configuration Options Summary:"
 echo
-echo "Mandatory products:"
 echo "  Threads ................ : $$threads_ok"
 echo "  OmniOrb (CORBA) ........ : $$omniORB_ok"
 echo "  OmniOrbpy (CORBA) ...... : $$omniORBpy_ok"
@@ -99,6 +101,7 @@ echo "  SALOME KERNEL .......... : $$Kernel_ok"
 echo "  PaCO++ ................. : $$PaCO_ok"
 echo "  MPI .................... : $$mpi_ok"
 echo "  Code Aster ............. : $$Aster_ok"
+${other_summary}
 echo
 echo "------------------------------------------------------------------------"
 echo
@@ -118,6 +121,8 @@ fi
 if test "x$$Kernel_ok" = "xno"; then
   AC_MSG_ERROR([SALOME KERNEL is required],1)
 fi
+${other_require}
+
 ${paco_configure}
 
 AC_CONFIG_FILES([
@@ -160,7 +165,7 @@ admlocalm4dir        = $(admlocaldir)/unix/config_files
 sharedpkgpythondir =$(pkgpythondir)/shared_modules
 
 # Documentation directory
-docdir             = $(datadir)/doc/salome
+salomedocdir             = $(prefix)/share/doc/salome/gui/${MODULE_NAME}
 
 IDL_INCLUDES = -I$(KERNEL_ROOT_DIR)/idl/salome
 KERNEL_LIBS= -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC
@@ -179,3 +184,42 @@ salomeres_DATA = $${DATA_INST}
 EXTRA_DIST = $${DATA_INST}
 """
 resMakefile=Template(resMakefile)
+
+check_sphinx="""
+AC_DEFUN([CHECK_SPHINX],[
+
+AC_CHECKING(for sphinx doc generator)
+
+sphinx_ok=yes
+dnl where is sphinx ?
+AC_PATH_PROG(SPHINX,sphinx-build)
+if test "x$SPHINX" = "x"
+then
+  AC_MSG_WARN(sphinx not found)
+  sphinx_ok=no
+fi
+
+dnl Can I load ths sphinx module ?
+dnl This code comes from the ax_python_module macro.
+if test -z $PYTHON;
+then
+   PYTHON="python"
+fi
+PYTHON_NAME=`basename $PYTHON`
+AC_MSG_CHECKING($PYTHON_NAME module: sphinx)
+   $PYTHON -c "import sphinx" 2>/dev/null
+   if test $? -eq 0;
+   then
+     AC_MSG_RESULT(yes)
+     eval AS_TR_CPP(HAVE_PYMOD_sphinx)=yes
+   else
+     AC_MSG_RESULT(no)
+     eval AS_TR_CPP(HAVE_PYMOD_sphinx)=no
+     sphinx_ok=no
+   fi
+
+AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes])
+
+])
+"""
+