Salome HOME
eb45b16afb7e851fc0896b77f664886cb208b272
[modules/gui.git] / tools / dlgfactory / dlgfactory.sh
1 #!/bin/sh
2 # Copyright (C) 2010-2022  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 #
22 # ==================================================================
23 #_debut_usage
24 #
25 # USAGE:
26 #
27 #      dlgfactory.sh -n className [-t classType]
28 #
29 #
30 # DESCRIPTION:
31 #
32 # This script generates a set of files to initiate a dialog qt window
33 # (i.e. MyDialog.ui, MyDialog.h and MyDialog.cxx files).
34 #
35 # The dialog window can be a self-consistent class (i.e. depends only
36 # on Qt classes) or a classe that inherits from the class
37 # GenericDialog whose implementation is provided in this package and
38 # whose design is defined by the GenericDialog.ui file (editable using
39 # the qt designer).
40 #
41 # The -t option let you choose between the two possibilities (specify
42 # "-t qdialog" for the first case, "-t gdialog" otherwise).
43 #
44 # OPTION:
45 #          -n : specify the name of the class (default is TestDialog)
46 #
47 #          -t : specify the type of the class (default is qdialog)
48 #
49 #_fin_usage
50 # ==================================================================
51 #
52
53 thisScript=$(which $0)
54 TOOLDIRNAME=$(dirname $0)
55
56 displayUsage()
57 {
58   cat $thisScript | sed -e '/^#_debut_usage/,/^#_fin_usage/!d' \
59    -e '/^#_debut_usage/d' \
60    -e '/^#_fin_usage/d' \
61    -e 's/^#//g'
62 }
63
64 #
65 # Read the options on the command line
66 #
67 className=TestDialog
68 classType=dialog
69 if [ $# -eq 0 ]; then
70     displayUsage
71     exit 1
72 else
73     while [ $# -ne 0 ]; do
74         case $1 in
75             -n)
76                 shift; className=$1; shift ;;
77             -t)
78                 shift; classType=$1; shift ;;
79             *)
80                 displayUsage;;
81         esac
82     done
83 fi
84
85 if [ "$classType" = "qdialog" ]; then
86     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.ui > $className.ui
87     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.h > $className.h
88     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.cxx > $className.cxx
89 else
90     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.ui > $className.ui
91     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.h > $className.h
92     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.cxx > $className.cxx    
93 fi
94
95 displayMessage()
96 {
97   cat $thisScript | sed -e '/^#_debut_message/,/^#_fin_message/!d' \
98    -e '/^#_debut_message/d' \
99    -e '/^#_fin_message/d' \
100    -e 's/^#//g' \
101    -e "s/__CLASSNAME__/$className/g"
102 }
103
104 #_debut_message
105 ##
106 ## ---------------------------------------------------------
107 ## Generation rules to create moc files from QObject headers
108 ## and form source files from ui files
109 ## ---------------------------------------------------------
110 ##
111 #%_moc.cxx: %.h
112 #       $(MOC) $< -o $@
113 #
114 #ui_%.h: %.ui
115 #       $(UIC) -o $@ $<
116 #
117 ##
118 ## ---------------------------------------------------------
119 ## Declaration of form files generated by UIC and MOC files
120 ## as BUILT_SOURCES to be used in the building process.
121 ## ---------------------------------------------------------
122 ##
123 #UIC_FILES = \
124 #       ui___CLASSNAME__.h
125 ##
126 #MOC_FILES = \
127 #       __CLASSNAME___moc.cxx
128 #
129 #BUILT_SOURCES = $(UIC_FILES)
130 #
131 ##
132 ## ---------------------------------------------------------
133 ## Declaration of sources files to the building process
134 ## ---------------------------------------------------------
135 ## MOC files and UIC files should be added to the list of undistributed
136 ## source files with something like (where <MyLibrary> should be
137 ## replaced by the name of the product declared by the directive
138 ## lib_LTLIBRARIES):
139 ##
140 #nodist_<MyLibrary>_la_SOURCES += $(MOC_FILES) $(UIC_FILES)
141 #
142 #dist_<MyLibrary>_la_SOURCES += __CLASSNAME__.cxx
143 #salomeinclude_HEADERS       += __CLASSNAME__.h
144 #
145 #<MyLibrary>_la_CPPFLAGS = \
146 #       $(QT_CXXFLAGS)
147 #
148 #<MyLibrary>_la_LDFLAGS = \
149 #        $(QT_LIBS)
150
151 #_fin_message
152
153 echo "Note that the following directives should be present in your CMakeLists.txt (or something like that):"
154 echo ""
155 displayMessage
156