Salome HOME
4fef5c42af2d7957df94ae137d366be7ad0f3516
[tools/yacsgen.git] / module_generator / gui_tmpl.py
1 # Copyright (C) 2009-2016  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 # SalomeApp.xml file for a python gui.
26 # template parameters:
27 #   module : module name
28 #   lmodule : module name in lower case
29 #   version : version number of the module
30 pysalomeapp="""
31 <document>
32   <section name="${module}">
33     <parameter name="name" value="${module}"/>
34     <parameter name="icon" value="${module}.png"/>
35     <parameter name="library" value="SalomePyQtGUI"/>
36     <parameter name="documentation" value="${lmodule}_help"/>
37     <parameter name="version" value="${version}"/>
38   </section>
39   <section name="resources">
40     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
41   </section>
42   <section name="${lmodule}_help" >
43     <parameter name="sub_menu"          value="%1 module"/>
44     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
45   </section>
46 </document>
47 """
48 pysalomeapp=Template(pysalomeapp)
49
50 # SalomeApp.xml file for a cpp gui.
51 # template parameters:
52 #   module : module name
53 #   lmodule : module name in lower case
54 #   version : version number of the module
55 cppsalomeapp="""
56 <document>
57   <section name="${module}">
58     <parameter name="name" value="${module}"/>
59     <parameter name="icon" value="${module}.png"/>
60     <parameter name="documentation" value="${lmodule}_help"/>
61     <parameter name="version" value="${version}"/>
62   </section>
63   <section name="resources">
64     <parameter name="${module}" value="$${${module}_ROOT_DIR}/share/salome/resources/${lmodule}"/>
65   </section>
66   <section name="${lmodule}_help" >
67     <parameter name="sub_menu"          value="%1 module"/>
68     <parameter name="User's Guide"      value="%${module}_ROOT_DIR%/share/doc/salome/gui/${lmodule}/index.html"/>
69   </section>
70 </document>
71 """
72 cppsalomeapp=Template(cppsalomeapp)
73
74 # CMakeLists.txt for a c++ GUI of the module (src/{module}GUI/CMakeLists.txt)
75 # template parameters:
76 #   module : module name
77 #   include_dirs : additional include directories
78 #   libs : libraries to link to
79 #   uic_files : .ui files
80 #   moc_headers : header files - to be processed by moc
81 #   sources : .cxx
82 #   resources : resource files
83 #   ts_resources : .ts files - to be processed by lrelease
84 cmake_cpp_gui = """
85 INCLUDE(UseQt4Ext)
86
87 # --- options ---
88 # additional include directories
89 INCLUDE_DIRECTORIES(
90   $${QT_INCLUDES}
91   $${OMNIORB_INCLUDE_DIR}
92   $${KERNEL_INCLUDE_DIRS}
93   $${GUI_INCLUDE_DIRS}
94   $${PROJECT_BINARY_DIR}/idl
95   ${include_dirs}
96 )
97
98 # additional preprocessor / compiler flags
99 ADD_DEFINITIONS(
100   $${QT_DEFINITIONS}
101   $${OMNIORB_DEFINITIONS}
102   $${KERNEL_DEFINITIONS}
103   $${GUI_DEFINITIONS}
104 )
105
106 # libraries to link to
107 SET(_link_LIBRARIES
108   $${QT_LIBRARIES}
109   SalomeIDL${module}
110   ${libs}
111 )
112
113 # --- resources ---
114
115 # resource files / to be processed by uic
116 SET(_uic_files
117   ${uic_files}
118 )
119
120 # --- headers ---
121
122 # header files / to be processed by moc
123 SET(_moc_HEADERS
124   ${moc_headers}
125 )
126
127 # header files / uic wrappings
128 QT4_WRAP_UI(_uic_HEADERS $${_uic_files})
129
130 # --- sources ---
131
132 # sources / moc wrappings
133 QT4_WRAP_CPP(_moc_SOURCES $${_moc_HEADERS})
134
135
136 # sources / static
137 SET(_other_SOURCES
138   ${sources}
139 )
140
141 # sources / to compile
142 SET(${module}GUI_SOURCES 
143   $${_other_SOURCES}
144   $${_moc_SOURCES}
145   $${_uic_files}
146 )
147
148 # --- resources ---
149
150 # resource files / to be processed by lrelease
151 SET(_ts_files
152   ${ts_resources}
153
154
155 SET(_res_files
156   SalomeApp.xml
157   ${resources}
158
159
160 # --- rules ---
161
162 ADD_LIBRARY(${module} $${${module}GUI_SOURCES})
163 TARGET_LINK_LIBRARIES(${module} $${_link_LIBRARIES} )
164 INSTALL(TARGETS ${module} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS})
165
166 INSTALL(FILES $${_moc_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS})
167 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
168 QT4_INSTALL_TS_RESOURCES("$${_ts_files}" "$${SALOME_${module}_INSTALL_RES_DATA}")
169 """
170 cmake_cpp_gui = Template(cmake_cpp_gui)
171
172 # CMakeLists.txt for a python GUI (src/{module}GUI/CMakeLists.txt)
173 # template parameters:
174 #   module : module name
175 #   scripts : .py files
176 #   ts_resources : .ts files - to be processed by lrelease
177 #   resources : other resource files
178 cmake_py_gui = """
179 INCLUDE(UseQt4Ext)
180
181 # additional include directories
182 INCLUDE_DIRECTORIES(
183   $${QT_INCLUDES}
184 )
185
186 # --- scripts ---
187
188 # scripts / static
189 SET(_bin_SCRIPTS
190   ${scripts}
191 )
192
193 # --- resources ---
194
195 # resource files / to be processed by lrelease
196 SET(_ts_RESOURCES
197   ${ts_resources}
198 )
199
200 SET(_res_files
201   SalomeApp.xml
202   ${resources}
203 )
204
205 # --- rules ---
206
207 SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON})
208 INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}")
209 QT4_INSTALL_TS_RESOURCES("$${_ts_RESOURCES}" "$${SALOME_${module}_INSTALL_RES_DATA}")
210 """
211 cmake_py_gui = Template(cmake_py_gui)