Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/tools/yacsgen
[tools/yacsgen.git] / module_generator / gui_tmpl.py
1 # Copyright (C) 2009-2014  EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 try:
21   from string import Template
22 except:
23   from compat import Template,set
24
25 pysalomeapp="""
26 <document>
27   <section name="${module}">
28     <parameter name="name" value="${module}"/>
29     <parameter name="icon" value="${module}.png"/>
30     <parameter name="library" value="SalomePyQtGUI"/>
31     <parameter name="documentation" value="${lmodule}_help"/>
32   </section>
33   <section name="resources">
34     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
35   </section>
36   <section name="${lmodule}_help" >
37     <parameter name="sub_menu"          value="%1 module"/>
38     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
39   </section>
40 </document>
41 """
42 pysalomeapp=Template(pysalomeapp)
43
44 cppsalomeapp="""
45 <document>
46   <section name="${module}">
47     <parameter name="name" value="${module}"/>
48     <parameter name="icon" value="${module}.png"/>
49     <parameter name="documentation" value="${lmodule}_help"/>
50   </section>
51   <section name="resources">
52     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
53   </section>
54   <section name="${lmodule}_help" >
55     <parameter name="sub_menu"          value="%1 module"/>
56     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
57   </section>
58 </document>
59 """
60 cppsalomeapp=Template(cppsalomeapp)
61
62 # CMakeLists.txt for a c++ GUI of the module (src/{module}GUI/CMakeLists.txt)
63 # template parameters:
64 #   module : module name
65 #   include_dirs : additional include directories
66 #   libs : libraries to link to
67 #   uic_files : .ui files
68 #   moc_headers : header files - to be processed by moc
69 #   sources : .cxx
70 #   resources : resource files
71 #   ts_resources : .ts files - to be processed by lrelease
72 cmake_cpp_gui = """
73 INCLUDE(UseQt4Ext)
74
75 # --- options ---
76 # additional include directories
77 INCLUDE_DIRECTORIES(
78   $${QT_INCLUDES}
79   $${OMNIORB_INCLUDE_DIR}
80   $${KERNEL_INCLUDE_DIRS}
81   $${GUI_INCLUDE_DIRS}
82   $${PROJECT_BINARY_DIR}/idl
83   ${include_dirs}
84 )
85
86 # additional preprocessor / compiler flags
87 ADD_DEFINITIONS(
88   $${QT_DEFINITIONS}
89   $${OMNIORB_DEFINITIONS}
90   $${KERNEL_DEFINITIONS}
91   $${GUI_DEFINITIONS}
92 )
93
94 # libraries to link to
95 SET(_link_LIBRARIES
96   $${QT_LIBRARIES}
97   SalomeIDL${module}
98   ${libs}
99 )
100
101 # --- resources ---
102
103 # resource files / to be processed by uic
104 SET(_uic_files
105   ${uic_files}
106 )
107
108 # --- headers ---
109
110 # header files / to be processed by moc
111 SET(_moc_HEADERS
112   ${moc_headers}
113 )
114
115 # header files / uic wrappings
116 QT4_WRAP_UI(_uic_HEADERS $${_uic_files})
117
118 # --- sources ---
119
120 # sources / moc wrappings
121 QT4_WRAP_CPP(_moc_SOURCES $${_moc_HEADERS})
122
123
124 # sources / static
125 SET(_other_SOURCES
126   ${sources}
127 )
128
129 # sources / to compile
130 SET(${module}GUI_SOURCES 
131   $${_other_SOURCES}
132   $${_moc_SOURCES}
133   $${_uic_files}
134 )
135
136 # --- resources ---
137
138 # resource files / to be processed by lrelease
139 SET(_ts_files
140   ${ts_resources}
141
142
143 SET(_res_files
144   SalomeApp.xml
145   ${resources}
146
147
148 # --- rules ---
149
150 ADD_LIBRARY(${module} $${${module}GUI_SOURCES})
151 TARGET_LINK_LIBRARIES(${module} $${_link_LIBRARIES} )
152 INSTALL(TARGETS ${module} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS})
153
154 INSTALL(FILES $${_moc_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS})
155 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
156 QT4_INSTALL_TS_RESOURCES("$${_ts_files}" "$${SALOME_${module}_INSTALL_RES_DATA}")
157 """
158 cmake_cpp_gui = Template(cmake_cpp_gui)
159
160 # CMakeLists.txt for a python GUI (src/{module}GUI/CMakeLists.txt)
161 # template parameters:
162 #   module : module name
163 #   scripts : .py files
164 #   ts_resources : .ts files - to be processed by lrelease
165 #   resources : other resource files
166 cmake_py_gui = """
167 INCLUDE(UseQt4Ext)
168
169 # additional include directories
170 INCLUDE_DIRECTORIES(
171   $${QT_INCLUDES}
172 )
173
174 # --- scripts ---
175
176 # scripts / static
177 SET(_bin_SCRIPTS
178   ${scripts}
179 )
180
181 # --- resources ---
182
183 # resource files / to be processed by lrelease
184 SET(_ts_RESOURCES
185   ${ts_resources}
186 )
187
188 SET(_res_files
189   SalomeApp.xml
190   ${resources}
191 )
192
193 # --- rules ---
194
195 SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON})
196 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
197 QT4_INSTALL_TS_RESOURCES("$${_ts_RESOURCES}" "$${SALOME_${module}_INSTALL_RES_DATA}")
198 """
199 cmake_py_gui = Template(cmake_py_gui)