From ab58fcfd12be3e60a9dfaac757a3b8c663c2fc4b Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski Date: Tue, 30 Aug 2016 09:49:58 +0200 Subject: [PATCH 13/22] grc: replace templated xml files with search and replace for qt4 --- grc/blocks/CMakeLists.txt | 23 +++++++++++++++++++---- grc/blocks/{options.xml.cmakein => options.xml} | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) rename grc/blocks/{options.xml.cmakein => options.xml} (99%) --- a/grc/blocks/CMakeLists.txt +++ b/grc/blocks/CMakeLists.txt @@ -22,7 +22,18 @@ file(GLOB xml_files "*.xml") -configure_file(options.xml.cmakein "${CMAKE_CURRENT_BINARY_DIR}/options.xml" @ONLY) +macro(REPLACE_IN_FILE _xml_block match replace) + set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}") + set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}") + + list(REMOVE_ITEM xml_files "${xml_block_src}") + file(READ "${xml_block_src}" xml_block_src_text) + string(REPLACE "${match}" "${replace}" + xml_block_text "${xml_block_src_text}") + file(WRITE "${xml_block}" "${xml_block_text}") + + list(APPEND generated_xml_files "${xml_block}") +endmacro() macro(GEN_BLOCK_XML _generator _xml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) @@ -32,14 +43,18 @@ DEPENDS ${generator} OUTPUT ${xml_block} COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} ) -endmacro(GEN_BLOCK_XML) +endmacro() + +GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) -GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) +if(DESIRED_QT_VERSION EQUAL 4) + REPLACE_IN_FILE(options.xml PyQt5 PyQt4) +endif() add_custom_target(grc_generated_xml ALL DEPENDS ${generated_xml_files}) install( - FILES ${xml_files} "${CMAKE_CURRENT_BINARY_DIR}/options.xml" ${generated_xml_files} + FILES ${xml_files} ${generated_xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "grc" ) --- a/grc/blocks/options.xml.cmakein +++ /dev/null @@ -1,294 +0,0 @@ - - - - Options - options - from gnuradio import gr - from gnuradio.filter import firdes - #if $generate_options() == 'wx_gui' -from grc_gnuradio import wxgui as grc_wxgui -import wx -#end if -#if $generate_options() == 'qt_gui' -from PyQt@DESIRED_QT_VERSION@ import Qt -import sys -#end if -#if $generate_options() == 'bokeh_gui' -import time -import signal -import functools -from bokeh.client import push_session -from bokeh.plotting import curdoc -#end if -#if not $generate_options().startswith('hb') -from optparse import OptionParser -from gnuradio.eng_option import eng_option -from gnuradio import eng_notation -#end if - - if $run: self.start() -else: self.stop(); self.wait() - - Title - title - - string - #if $title() then 'none' else 'part'# - - - Author - author - - string - #if $author() then 'none' else 'part'# - - - Description - description - - string - #if $description() then 'none' else 'part'# - - - Canvas Size - window_size - - int_vector - part - - - Generate Options - generate_options - qt_gui - enum - - - - - - - - - Category - category - [GRC Hier Blocks] - string - #if $generate_options().startswith('hb') then 'none' else 'all'# - - - Run Options - run_options - prompt - enum - #if $generate_options() == 'no_gui' then 'none' else 'all'# - - - - - Widget Placement - placement - (0,0) - int_vector - #if $generate_options() == 'bokeh_gui' then 'part' else 'all'# - - - Sizing Mode - sizing_mode - fixed - enum - #if $generate_options() == 'bokeh_gui' then 'part' else 'all'# - - - - - - - - Run - run - True - bool - -#if $generate_options() in ('qt_gui', 'wx_gui', 'bokeh_gui') - #if $run() - part - #else - none - #end if -#else - all -#end if - - - - - - Max Number of Output - max_nouts - 0 - int - #if $generate_options().startswith('hb') -all#slurp -#elif $max_nouts() -none#slurp -#else -part#slurp -#end if - - - Realtime Scheduling - realtime_scheduling - - enum - #if $generate_options().startswith('hb') -all#slurp -#elif $realtime_scheduling() -none#slurp -#else -part#slurp -#end if - - - - - QSS Theme - qt_qss_theme - - file_open - -#if $generate_options() in ('qt_gui',) - #if $qt_qss_theme() - none - #else - part - #end if -#else - all -#end if - - - - Thread-safe setters - thread_safe_setters - - enum - part - - - Advanced - - - Run Command - run_command - {python} -u {filename} - string - #if $generate_options().startswith('hb') -all#slurp -#else -part#slurp -#end if - Advanced - - - Hier Block Source Path - hier_block_src_path - .: - string - part - Advanced - - not $window_size or len($window_size) == 2 - not $window_size or 300 <= $(window_size)[0] <= 4096 - not $window_size or 300 <= $(window_size)[1] <= 4096 - len($placement) == 4 or len($placement) == 2 - all(i >= 0 for i in $(placement)) - -The options block sets special parameters for the flow graph. \ -Only one option block is allowed per flow graph. - -Title, author, and description parameters are for identification purposes. - -The window size controls the dimensions of the flow graph editor. \ -The window size (width, height) must be between (300, 300) and (4096, 4096). - -The generate options controls the type of code generated. \ -Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. - -In a graphical application, \ -run can be controlled by a variable to start and stop the flowgraph at runtime. - -The id of this block determines the name of the generated file and the name of the class. \ -For example, an id of my_block will generate the file my_block.py and class my_block(gr.... - -The category parameter determines the placement of the block in the block selection window. \ -The category only applies when creating hier blocks. \ -To put hier blocks into the root category, enter / for the category. - -The Max Number of Output is the maximum number of output items allowed for any block \ -in the flowgraph; to disable this set the max_nouts equal to 0.\ -Use this to adjust the maximum latency a flowgraph can exhibit. - - --- /dev/null +++ b/grc/blocks/options.xml @@ -0,0 +1,294 @@ + + + + Options + options + from gnuradio import gr + from gnuradio.filter import firdes + #if $generate_options() == 'wx_gui' +from grc_gnuradio import wxgui as grc_wxgui +import wx +#end if +#if $generate_options() == 'qt_gui' +from PyQt5 import Qt +import sys +#end if +#if $generate_options() == 'bokeh_gui' +import time +import signal +import functools +from bokeh.client import push_session +from bokeh.plotting import curdoc +#end if +#if not $generate_options().startswith('hb') +from optparse import OptionParser +from gnuradio.eng_option import eng_option +from gnuradio import eng_notation +#end if + + if $run: self.start() +else: self.stop(); self.wait() + + Title + title + + string + #if $title() then 'none' else 'part'# + + + Author + author + + string + #if $author() then 'none' else 'part'# + + + Description + description + + string + #if $description() then 'none' else 'part'# + + + Canvas Size + window_size + + int_vector + part + + + Generate Options + generate_options + qt_gui + enum + + + + + + + + + Category + category + [GRC Hier Blocks] + string + #if $generate_options().startswith('hb') then 'none' else 'all'# + + + Run Options + run_options + prompt + enum + #if $generate_options() == 'no_gui' then 'none' else 'all'# + + + + + Widget Placement + placement + (0,0) + int_vector + #if $generate_options() == 'bokeh_gui' then 'part' else 'all'# + + + Sizing Mode + sizing_mode + fixed + enum + #if $generate_options() == 'bokeh_gui' then 'part' else 'all'# + + + + + + + + Run + run + True + bool + +#if $generate_options() in ('qt_gui', 'wx_gui', 'bokeh_gui') + #if $run() + part + #else + none + #end if +#else + all +#end if + + + + + + Max Number of Output + max_nouts + 0 + int + #if $generate_options().startswith('hb') +all#slurp +#elif $max_nouts() +none#slurp +#else +part#slurp +#end if + + + Realtime Scheduling + realtime_scheduling + + enum + #if $generate_options().startswith('hb') +all#slurp +#elif $realtime_scheduling() +none#slurp +#else +part#slurp +#end if + + + + + QSS Theme + qt_qss_theme + + file_open + +#if $generate_options() in ('qt_gui',) + #if $qt_qss_theme() + none + #else + part + #end if +#else + all +#end if + + + + Thread-safe setters + thread_safe_setters + + enum + part + + + Advanced + + + Run Command + run_command + {python} -u {filename} + string + #if $generate_options().startswith('hb') +all#slurp +#else +part#slurp +#end if + Advanced + + + Hier Block Source Path + hier_block_src_path + .: + string + part + Advanced + + not $window_size or len($window_size) == 2 + not $window_size or 300 <= $(window_size)[0] <= 4096 + not $window_size or 300 <= $(window_size)[1] <= 4096 + len($placement) == 4 or len($placement) == 2 + all(i >= 0 for i in $(placement)) + +The options block sets special parameters for the flow graph. \ +Only one option block is allowed per flow graph. + +Title, author, and description parameters are for identification purposes. + +The window size controls the dimensions of the flow graph editor. \ +The window size (width, height) must be between (300, 300) and (4096, 4096). + +The generate options controls the type of code generated. \ +Non-graphical flow graphs should avoid using graphical sinks or graphical variable controls. + +In a graphical application, \ +run can be controlled by a variable to start and stop the flowgraph at runtime. + +The id of this block determines the name of the generated file and the name of the class. \ +For example, an id of my_block will generate the file my_block.py and class my_block(gr.... + +The category parameter determines the placement of the block in the block selection window. \ +The category only applies when creating hier blocks. \ +To put hier blocks into the root category, enter / for the category. + +The Max Number of Output is the maximum number of output items allowed for any block \ +in the flowgraph; to disable this set the max_nouts equal to 0.\ +Use this to adjust the maximum latency a flowgraph can exhibit. + +