Salome HOME
Merge from V6_main 28/02/2013
[modules/gui.git] / tools / dlgfactory / dlgfactory.sh
1 #!/bin/sh
2 # Copyright (C) 2010-2012  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.
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 #_debut_usage
23 #
24 # USAGE:
25 #
26 #      dlgfactory.sh -n className [-t classType]
27 #
28 #
29 # DESCRIPTION:
30 #
31 # This script generates a set of files to initiate a dialog qt window
32 # (i.e. MyDialog.ui, MyDialog.h and MyDialog.cxx files).
33 #
34 # The dialog window can be a self-consistent class (i.e. depends only
35 # on Qt classes) or a classe that inherits from the class
36 # GenericDialog whose implementation is provided in this package and
37 # whose design is defined by the GenericDialog.ui file (editable using
38 # the qt designer).
39 #
40 # The -t option let you choose between the two possibilities (specify
41 # "-t qdialog" for the first case, "-t gdialog" otherwise).
42 #
43 # OPTION:
44 #          -n : specify the name of the class (default is TestDialog)
45 #
46 #          -t : specify the type of the class (default is qdialog)
47 #
48 #_fin_usage
49 # ==================================================================
50 #
51
52 thisScript=$(which $0)
53 TOOLDIRNAME=$(dirname $0)
54
55 displayUsage()
56 {
57   cat $thisScript | sed -e '/^#_debut_usage/,/^#_fin_usage/!d' \
58    -e '/^#_debut_usage/d' \
59    -e '/^#_fin_usage/d' \
60    -e 's/^#//g'
61 }
62
63 #
64 # Read the options on the command line
65 #
66 className=TestDialog
67 classType=dialog
68 if [ $# -eq 0 ]; then
69     displayUsage
70     exit 1
71 else
72     while [ $# -ne 0 ]; do
73         case $1 in
74             -n)
75                 shift; className=$1; shift ;;
76             -t)
77                 shift; classType=$1; shift ;;
78             *)
79                 displayUsage;;
80         esac
81     done
82 fi
83
84 if [ "$classType" = "qdialog" ]; then
85     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.ui > $className.ui
86     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.h > $className.h
87     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.cxx > $className.cxx
88 else
89     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.ui > $className.ui
90     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.h > $className.h
91     sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.cxx > $className.cxx    
92 fi
93
94 displayMessage()
95 {
96   cat $thisScript | sed -e '/^#_debut_message/,/^#_fin_message/!d' \
97    -e '/^#_debut_message/d' \
98    -e '/^#_fin_message/d' \
99    -e 's/^#//g' \
100    -e "s/__CLASSNAME__/$className/g"
101 }
102
103 #_debut_message
104 ##
105 ## ---------------------------------------------------------
106 ## Generation rules to create moc files from QObject headers
107 ## and form source files from ui files
108 ## ---------------------------------------------------------
109 ##
110 #%_moc.cxx: %.h
111 #       $(MOC) $< -o $@
112 #
113 #ui_%.h: %.ui
114 #       $(UIC) -o $@ $<
115 #
116 ##
117 ## ---------------------------------------------------------
118 ## Declaration of form files generated by UIC and MOC files
119 ## as BUILT_SOURCES to be used in the building process.
120 ## ---------------------------------------------------------
121 ##
122 #UIC_FILES = \
123 #       ui___CLASSNAME__.h
124 ##
125 #MOC_FILES = \
126 #       __CLASSNAME___moc.cxx
127 #
128 #BUILT_SOURCES = $(UIC_FILES)
129 #
130 ##
131 ## ---------------------------------------------------------
132 ## Declaration of sources files to the building process
133 ## ---------------------------------------------------------
134 ## MOC files and UIC files should be added to the list of undistributed
135 ## source files with something like (where <MyLibrary> should be
136 ## replaced by the name of the product declared by the directive
137 ## lib_LTLIBRARIES):
138 ##
139 #nodist_<MyLibrary>_la_SOURCES += $(MOC_FILES) $(UIC_FILES)
140 #
141 #dist_<MyLibrary>_la_SOURCES += __CLASSNAME__.cxx
142 #salomeinclude_HEADERS       += __CLASSNAME__.h
143 #
144 #<MyLibrary>_la_CPPFLAGS = \
145 #       $(QT_CXXFLAGS)
146 #
147 #<MyLibrary>_la_LDFLAGS = \
148 #        $(QT_LIBS)
149
150 #_fin_message
151
152 echo "Note that the following directives should be present in your Makefile.am (or something like that):"
153 echo ""
154 displayMessage
155