From: Takashi Iwai Date: Fri, 18 Mar 2005 16:42:48 +0000 (+0000) Subject: Add qlo10k1 X-Git-Tag: v1.0.9rc2~1 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=ab3e05d1da00274a1142028522093efedbe67e9a;p=alsa-tools.git Add qlo10k1 Added qlo10k1 by Peter Zubaj. --- diff --git a/Makefile b/Makefile index f18a269..97babb5 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION = 1.0.9rc1 TOP = . SUBDIRS = ac3dec as10k1 envy24control hdsploader hdspconf hdspmixer \ mixartloader pcxhrloader rmedigicontrol sb16_csp seq sscape_ctl us428control \ - usx2yloader vxloader echomixer ld10k1 + usx2yloader vxloader echomixer ld10k1 qlo10k1 all: @for i in $(SUBDIRS); do cd $(TOP)/$$i; ./cvscompile $(CVSCOMPILE_ARGS); cd ..; make -C $$i; done diff --git a/qlo10k1/AUTHORS b/qlo10k1/AUTHORS new file mode 100644 index 0000000..a568df6 --- /dev/null +++ b/qlo10k1/AUTHORS @@ -0,0 +1,4 @@ +Peter Zubaj + +Contributors: +Eduardo García-Mádico Portabella diff --git a/qlo10k1/COPYING b/qlo10k1/COPYING new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/qlo10k1/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/qlo10k1/ChangeLog b/qlo10k1/ChangeLog new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/qlo10k1/ChangeLog @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/qlo10k1/INSTALL b/qlo10k1/INSTALL new file mode 100644 index 0000000..56b077d --- /dev/null +++ b/qlo10k1/INSTALL @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PREFIX', the package will +use PREFIX as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/qlo10k1/Makefile.am b/qlo10k1/Makefile.am new file mode 100644 index 0000000..a88b2a7 --- /dev/null +++ b/qlo10k1/Makefile.am @@ -0,0 +1,9 @@ +SUBDIRS = src + +EXTRA_DIST = COPYING configure.in README NEWS AUTHORS TODO INSTALL ChangeLog + +alsa-dist: distdir + @rm -rf ../distdir/ld10k1 + @mkdir -p ../distdir/ld10k1 + @cp -RLpv $(distdir)/* ../distdir/ld10k1 + @rm -rf $(distdir) diff --git a/qlo10k1/NEWS b/qlo10k1/NEWS new file mode 100644 index 0000000..f751581 --- /dev/null +++ b/qlo10k1/NEWS @@ -0,0 +1,14 @@ +0.1.2 + - ld10k1 0.1.8 required + - Colors and better object positioning - Eduardo García-Mádico Portabella +0.1.1test3 + - Warning cleaning +0.1.1test2 + - Fixed build + - Fixed "make dist" - not include moc generated sources +0.1.1test1 + - No more needs for kde - only qt is needed + - Sync with lo10k1 - save dsp config, load dsp config, save patch + - Source cleanup +0.1.0 + - First version \ No newline at end of file diff --git a/qlo10k1/README b/qlo10k1/README new file mode 100644 index 0000000..1d5c2c3 --- /dev/null +++ b/qlo10k1/README @@ -0,0 +1,6 @@ +Some sort of GUI for ld10k1. +Still early stage of development. +Source is ugly (better not to read). +Don't expeect everything will work. +To compile needs QT instaled. +First install ld10k1. diff --git a/qlo10k1/TODO b/qlo10k1/TODO new file mode 100644 index 0000000..9b8776d --- /dev/null +++ b/qlo10k1/TODO @@ -0,0 +1,6 @@ +- nefunguje dobre disconnect na inpute +- source cleanup (warnings, ...) +- rename +- patch info +- dsp ussage info +- optimalization - is getting slow \ No newline at end of file diff --git a/qlo10k1/acinclude.m4 b/qlo10k1/acinclude.m4 new file mode 100644 index 0000000..3a38ac5 --- /dev/null +++ b/qlo10k1/acinclude.m4 @@ -0,0 +1,217 @@ +# Check for Qt compiler flags, linker flags, and binary packages +AC_DEFUN([gw_CHECK_QT], +[ +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PATH_X]) + +AC_MSG_CHECKING([QTDIR]) +AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=$QTDIR]], QTDIR=$withval) +# Check that QTDIR is defined or that --with-qtdir given +if test x"$QTDIR" = x ; then + QT_SEARCH="/usr/lib/qt31 /usr/local/qt31 /usr/lib/qt3 /usr/local/qt3 /usr/lib/qt2 /usr/local/qt2 /usr/lib/qt /usr/local/qt" + for i in $QT_SEARCH; do + if test -f $i/include/qglobal.h -a x$QTDIR = x; then QTDIR=$i; fi + done +fi +if test x"$QTDIR" = x ; then + AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given]) +fi +AC_MSG_RESULT([$QTDIR]) + +# Change backslashes in QTDIR to forward slashes to prevent escaping +# problems later on in the build process, mainly for Cygwin build +# environment using MSVC as the compiler +# TODO: Use sed instead of perl +QTDIR=`echo $QTDIR | perl -p -e 's/\\\\/\\//g'` + +# Figure out which version of Qt we are using +AC_MSG_CHECKING([Qt version]) +QT_VER=`grep 'define.*QT_VERSION_STR\W' $QTDIR/include/qglobal.h | perl -p -e 's/\D//g'` +case "${QT_VER}" in + 2*) + QT_MAJOR="2" + ;; + 3*) + QT_MAJOR="3" + ;; + *) + AC_MSG_ERROR([*** Don't know how to handle this Qt major version]) + ;; +esac +AC_MSG_RESULT([$QT_VER ($QT_MAJOR)]) + +# Check that moc is in path +AC_PATH_PROG([MOC], [moc], [$QTDIR/bin/moc], [$PATH:$QTDIR/bin]) +if test x$MOC = x ; then + AC_MSG_ERROR([*** moc must be in path]) +fi + +# uic is the Qt user interface compiler +AC_PATH_PROG([UIC], [uic], [$QTDIR/bin/uic], [$PATH:$QTDIR/bin]) +if test x$UIC = x ; then + AC_MSG_ERROR([*** uic must be in path]) +fi + +# qembed is the Qt data embedding utility. +# It is located in $QTDIR/tools/qembed, and must be compiled and installed +# manually, we'll let it slide if it isn't present +AC_PATH_PROG([QEMBED], [qembed], [$QTDIR/bin/qembed], [$PATH:$QTDIR/bin]) + + +# Calculate Qt include path +QT_CXXFLAGS="-I$QTDIR/include" + +QT_IS_EMBEDDED="no" +# On unix, figure out if we're doing a static or dynamic link +case "${host}" in + *-cygwin) + AC_DEFINE_UNQUOTED(WIN32, "", Defined if on Win32 platform) + if test -f "$QTDIR/lib/qt.lib" ; then + QT_LIB="qt.lib" + QT_IS_STATIC="yes" + QT_IS_MT="no" + elif test -f "$QTDIR/lib/qt-mt.lib" ; then + QT_LIB="qt-mt.lib" + QT_IS_STATIC="yes" + QT_IS_MT="yes" + elif test -f "$QTDIR/lib/qt$QT_VER.lib" ; then + QT_LIB="qt$QT_VER.lib" + QT_IS_STATIC="no" + QT_IS_MT="no" + elif test -f "$QTDIR/lib/qt-mt$QT_VER.lib" ; then + QT_LIB="qt-mt$QT_VER.lib" + QT_IS_STATIC="no" + QT_IS_MT="yes" + fi + ;; + + *) + QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null` + if test "x$QT_IS_STATIC" = x; then + QT_IS_STATIC="no" + else + QT_IS_STATIC="yes" + fi + if test x$QT_IS_STATIC = xno ; then + QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null` + if test "x$QT_IS_DYNAMIC" = x; then + AC_MSG_ERROR([*** Couldn't find any Qt libraries]) + fi + fi + + if test "x`ls $QTDIR/lib/libqt.* 2> /dev/null`" != x ; then + QT_LIB="-lqt" + QT_IS_MT="no" + elif test "x`ls $QTDIR/lib/libqt-mt.* 2> /dev/null`" != x ; then + QT_LIB="-lqt-mt" + QT_IS_MT="yes" + elif test "x`ls $QTDIR/lib/libqte.* 2> /dev/null`" != x ; then + QT_LIB="-lqte" + QT_IS_MT="no" + QT_IS_EMBEDDED="yes" + elif test "x`ls $QTDIR/lib/libqte-mt.* 2> /dev/null`" != x ; then + QT_LIB="-lqte-mt" + QT_IS_MT="yes" + QT_IS_EMBEDDED="yes" + fi + ;; +esac +AC_MSG_CHECKING([if Qt is static]) +AC_MSG_RESULT([$QT_IS_STATIC]) +AC_MSG_CHECKING([if Qt is multithreaded]) +AC_MSG_RESULT([$QT_IS_MT]) +AC_MSG_CHECKING([if Qt is embedded]) +AC_MSG_RESULT([$QT_IS_EMBEDDED]) + +QT_GUILINK="" +QASSISTANTCLIENT_LDADD="-lqassistantclient" +case "${host}" in + *irix*) + QT_LIBS="$QT_LIB" + if test $QT_IS_STATIC = yes ; then + QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" + fi + ;; + + *linux*) + QT_LIBS="$QT_LIB" + if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then + QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg" + fi + ;; + + + *osf*) + # Digital Unix (aka DGUX aka Tru64) + QT_LIBS="$QT_LIB" + if test $QT_IS_STATIC = yes ; then + QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" + fi + ;; + + *solaris*) + QT_LIBS="$QT_LIB" + if test $QT_IS_STATIC = yes ; then + QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl" + fi + ;; + + + *win*) + # linker flag to suppress console when linking a GUI app on Win32 + QT_GUILINK="/subsystem:windows" + + if test $QT_MAJOR = "3" ; then + if test $QT_IS_MT = yes ; then + QT_LIBS="/nodefaultlib:libcmt" + else + QT_LIBS="/nodefaultlib:libc" + fi + fi + + if test $QT_IS_STATIC = yes ; then + QT_LIBS="$QT_LIBS $QT_LIB kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib shell32.lib imm32.lib advapi32.lib wsock32.lib winspool.lib winmm.lib netapi32.lib" + if test $QT_MAJOR = "3" ; then + QT_LIBS="$QT_LIBS qtmain.lib" + fi + else + QT_LIBS="$QT_LIBS $QT_LIB" + if test $QT_MAJOR = "3" ; then + QT_CXXFLAGS="$QT_CXXFLAGS -DQT_DLL" + QT_LIBS="$QT_LIBS qtmain.lib qui.lib user32.lib netapi32.lib" + fi + fi + QASSISTANTCLIENT_LDADD="qassistantclient.lib" + ;; + +esac + + +if test x"$QT_IS_EMBEDDED" = "xyes" ; then + QT_CXXFLAGS="-DQWS $QT_CXXFLAGS" +fi + +if test x"$QT_IS_MT" = "xyes" ; then + QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_THREAD_SUPPORT" +fi + +QT_LDADD="-L$QTDIR/lib $QT_LIBS" + +if test x$QT_IS_STATIC = xyes ; then + OLDLIBS="$LIBS" + LIBS="$QT_LDADD" + AC_CHECK_LIB(Xft, XftFontOpen, QT_LDADD="$QT_LDADD -lXft") + LIBS="$LIBS" +fi + +AC_MSG_CHECKING([QT_CXXFLAGS]) +AC_MSG_RESULT([$QT_CXXFLAGS]) +AC_MSG_CHECKING([QT_LDADD]) +AC_MSG_RESULT([$QT_LDADD]) + +AC_SUBST(QT_CXXFLAGS) +AC_SUBST(QT_LDADD) +AC_SUBST(QT_GUILINK) +AC_SUBST(QASSISTANTCLIENT_LDADD) + +]) diff --git a/qlo10k1/config.h.in b/qlo10k1/config.h.in new file mode 100644 index 0000000..215c9bd --- /dev/null +++ b/qlo10k1/config.h.in @@ -0,0 +1,65 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `lo10k1' library (-llo10k1). */ +#undef HAVE_LIBLO10K1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Defined if on Win32 platform */ +#undef WIN32 + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN diff --git a/qlo10k1/configure.in b/qlo10k1/configure.in new file mode 100644 index 0000000..1e91a56 --- /dev/null +++ b/qlo10k1/configure.in @@ -0,0 +1,15 @@ +AC_INIT(src/main.cpp) +AM_INIT_AUTOMAKE(qlo10k1, 0.1.2) +AC_CONFIG_HEADERS(config.h) +AC_PROG_CXX +AC_PROG_LD +AC_PROG_INSTALL +AC_PROG_LIBTOOL + +AC_C_BIGENDIAN +gw_CHECK_QT +CXXFLAGS="$CXXFLAGS $QT_CXXFLAGS -Wall" +AM_PATH_LD10K1(0.1.8) + +AC_OUTPUT(Makefile + src/Makefile) \ No newline at end of file diff --git a/qlo10k1/cvscompile b/qlo10k1/cvscompile new file mode 100644 index 0000000..5ddd1ec --- /dev/null +++ b/qlo10k1/cvscompile @@ -0,0 +1,9 @@ +#!/bin/bash + +autoreconf -fi +export CFLAGS='-O2 -Wall -pipe -g' +echo "CFLAGS=$CFLAGS" +echo "./configure $@" +./configure $@ +unset CFLAGS +make diff --git a/qlo10k1/src/Makefile.am b/qlo10k1/src/Makefile.am new file mode 100644 index 0000000..64e3500 --- /dev/null +++ b/qlo10k1/src/Makefile.am @@ -0,0 +1,137 @@ +#SUBDIRS = dlgs icons + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = qlo10k1 + +# the libraries to link against. +qlo10k1_LDADD = $(LDADD) $(QT_LDADD) + +EXTRA_DIST = dlgs/connectionwizardbase.ui dlgs/filecontroldialogbase.ui dlgs/filecontrolsdialogbase.ui \ + dlgs/loadpatchdialogbase.ui dlgs/mainwndbase.ui dlgs/patchdialogbase.ui dlgs/preferencesbase.ui \ + dlgs/newiodialogbase.ui dlgs/aboutdialogbase.ui dlgs/transformpatchbase.ui\ + icons/routing_fx.xpm \ + icons/routing_in.xpm \ + icons/routing_out.xpm \ + icons/routing_route.xpm \ + icons/routing_effect.xpm \ + icons/routing_effect_stack.xpm \ + icons/routing_zoom_plus.xpm \ + icons/routing_zoom_minus.xpm \ + icons/routing_normal.xpm + +# these are the headers for your project +noinst_HEADERS = + +%.moc.cpp: %.h + $(MOC) -o $@ $< + +%.h: %.ui + $(UIC) -o $@ $< + +%.cpp: %.ui + $(UIC) -o $@ -impl $*.h $< + +qlo10k1_UI = dlgs/connectionwizardbase.h \ + dlgs/connectionwizardbase.cpp \ + \ + dlgs/filecontroldialogbase.h \ + dlgs/filecontroldialogbase.cpp \ + \ + dlgs/filecontrolsdialogbase.h \ + dlgs/filecontrolsdialogbase.cpp \ + \ + dlgs/loadpatchdialogbase.h \ + dlgs/loadpatchdialogbase.cpp \ + \ + dlgs/transformpatchbase.h \ + dlgs/transformpatchbase.cpp \ + \ + dlgs/mainwndbase.h \ + dlgs/mainwndbase.cpp \ + \ + dlgs/patchdialogbase.h \ + dlgs/patchdialogbase.cpp \ + \ + dlgs/preferencesbase.h \ + dlgs/preferencesbase.cpp \ + \ + dlgs/newiodialogbase.h \ + dlgs/newiodialogbase.cpp \ + \ + dlgs/aboutdialogbase.h \ + dlgs/aboutdialogbase.cpp + +qlo10k1_MOC = dlgs/connectionwizardbase.moc.cpp \ + dlgs/filecontroldialogbase.moc.cpp \ + dlgs/filecontrolsdialogbase.moc.cpp \ + dlgs/loadpatchdialogbase.moc.cpp \ + dlgs/mainwndbase.moc.cpp \ + dlgs/patchdialogbase.moc.cpp \ + dlgs/preferencesbase.moc.cpp \ + dlgs/newiodialogbase.moc.cpp \ + dlgs/aboutdialogbase.moc.cpp \ + dlgs/transformpatchbase.moc.cpp \ + \ + connectionwizard.moc.cpp \ + filecontroldialog.moc.cpp \ + loadpatchdialog.moc.cpp \ + mainwnd.moc.cpp \ + patchdialog.moc.cpp \ + preferences.moc.cpp \ + routingwidget.moc.cpp \ + newiodialog.moc.cpp \ + aboutdialog.moc.cpp \ + transformpatchdialog.moc.cpp + +BUILT_SOURCES = $(qlo10k1_MOC) $(qlo10k1_UI) +CLEANFILES = $(BUILT_SOURCES) + +# which sources should be compiled for qlo10k1 +# emu10k1file.cpp emu10k1file.h +qlo10k1_SOURCES = app_global.h connectionwizard.cpp connectionwizard.h \ + filecontroldialog.cpp filecontroldialog.h ld10k1file.cpp ld10k1file.h \ + loadpatchdialog.cpp loadpatchdialog.h main.cpp \ + mainwnd.cpp mainwnd.h patchdialog.cpp patchdialog.h preferences.cpp preferences.h \ + routingwidget.h routingwidget.cpp structure.cpp structure.h structure_patch.cpp structure_patch.h \ + structure_io.cpp structure_io.h structure_link.cpp structure_link.h\ + structure_aa.cpp strglobal.h strglobal.cpp routingwidget_new.cpp routingwidget_menu.cpp \ + newiodialog.h newiodialog.cpp strparam.h strparam.cpp \ + aboutdialog.h aboutdialog.cpp transformpatchdialog.h transformpatchdialog.cpp \ + custom_colors.h +# \ +# $(qlo10k1_UI) \ +# $(qlo10k1_MOC) + +nodist_qlo10k1_SOURCES = $(qlo10k1_UI) \ + $(qlo10k1_MOC) + +dlgs/connectionwizardbase.h : dlgs/connectionwizardbase.ui +dlgs/connectionwizardbase.cpp : dlgs/connectionwizardbase.h dlgs/connectionwizardbase.ui + +dlgs/filecontroldialogbase.h : dlgs/filecontroldialogbase.ui +dlgs/filecontroldialogbase.cpp : dlgs/filecontroldialogbase.h dlgs/filecontroldialogbase.ui + +dlgs/filecontrolsdialogbase.h : dlgs/filecontrolsdialogbase.ui +dlgs/filecontrolsdialogbase.cpp : dlgs/filecontrolsdialogbase.h dlgs/filecontrolsdialogbase.ui + +dlgs/loadpatchdialogbase.h : dlgs/loadpatchdialogbase.ui +dlgs/loadpatchdialogbase.cpp : dlgs/loadpatchdialogbase.h dlgs/loadpatchdialogbase.ui + +dlgs/transformpatchbase.h : dlgs/transformpatchbase.ui +dlgs/transformpatchbase.cpp : dlgs/transformpatchbase.h dlgs/transformpatchbase.ui + +dlgs/mainwndbase.h : dlgs/mainwndbase.ui +dlgs/mainwndbase.cpp : dlgs/mainwndbase.h dlgs/mainwndbase.ui + +dlgs/patchdialogbase.h : dlgs/patchdialogbase.ui +dlgs/patchdialogbase.cpp : dlgs/patchdialogbase.h dlgs/patchdialogbase.ui + +dlgs/preferencesbase.h : dlgs/preferencesbase.ui +dlgs/preferencesbase.cpp : dlgs/preferencesbase.h dlgs/preferencesbase.ui + +dlgs/newiodialogbase.h : dlgs/newiodialogbase.ui +dlgs/newiodialogbase.cpp : dlgs/newiodialogbase.h dlgs/newiodialogbase.ui + +dlgs/aboutdialogbase.h : dlgs/aboutdialogbase.ui +dlgs/aboutdialogbase.cpp : dlgs/aboutdialogbase.h dlgs/aboutdialogbase.ui \ No newline at end of file diff --git a/qlo10k1/src/aboutdialog.cpp b/qlo10k1/src/aboutdialog.cpp new file mode 100644 index 0000000..ab34666 --- /dev/null +++ b/qlo10k1/src/aboutdialog.cpp @@ -0,0 +1,34 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "aboutdialog.h" + +AboutDlg::AboutDlg() +{ + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); +} + +void AboutDlg::okClicked() +{ + done(Accepted); +} diff --git a/qlo10k1/src/aboutdialog.h b/qlo10k1/src/aboutdialog.h new file mode 100644 index 0000000..b72ca18 --- /dev/null +++ b/qlo10k1/src/aboutdialog.h @@ -0,0 +1,36 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include "dlgs/aboutdialogbase.h" + +class AboutDlg : public AboutDialogBase +{ + Q_OBJECT +public: + AboutDlg(); +public slots: + void okClicked(); +}; + +#endif // ABOUTDIALOG_H diff --git a/qlo10k1/src/app_global.h b/qlo10k1/src/app_global.h new file mode 100644 index 0000000..b6f5ef0 --- /dev/null +++ b/qlo10k1/src/app_global.h @@ -0,0 +1,6 @@ +#ifndef __APP_GLOBAL_H +#define __APP_GLOBAL_H + +#define APP_NAME "qlo10k1 - emu10k1 patch loader" + +#endif /* __APP_GLOBAL_H */ diff --git a/qlo10k1/src/connectionwizard.cpp b/qlo10k1/src/connectionwizard.cpp new file mode 100644 index 0000000..25aef79 --- /dev/null +++ b/qlo10k1/src/connectionwizard.cpp @@ -0,0 +1,324 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include + +#include "structure_patch.h" +#include "structure_io.h" +#include "connectionwizard.h" + +ConnectionWizard::ConnectionWizard(bool o, StrGlobal *g, RouteInfo *r) + : ConnectionWizardBase() +{ + out = o; + global = g; + route = *r; + rptr = r; + + rtype = None; + pto = NULL; + + RSItemIO *io = r->getToIO(); + + if (io) + { + RSItemBaseWithType *owner = (RSItemBaseWithType *)io->getOwner(); + switch (owner->type()) + { + case RSItemBaseWithType::In: + rtype = In; + break; + case RSItemBaseWithType::Out: + rtype = Out; + break; + case RSItemBaseWithType::FX: + rtype = FX; + break; + case RSItemBaseWithType::Patch: + if (io->isOutput()) + rtype = POut; + else + rtype = PIn; + pto = (StrPatch *)owner; + break; + default: + break; + } + } + + if (!out) + { + rbOutput->hide(); + } + else + { + rbFX->hide(); + rbInput->hide(); + } + + StrPatch *patch; + + lbPatch->clear(); + for(patch = global->Patches.first(); patch; patch = global->Patches.next() ) + { + lbPatch->insertItem(patch->name()); + patchList.append(patch); + } + + connect(rbNone, SIGNAL(clicked()), this, SLOT(noneClicked())); + connect(rbFX, SIGNAL(clicked()), this, SLOT(fxClicked())); + connect(rbInput, SIGNAL(clicked()), this, SLOT(inClicked())); + connect(rbOutput, SIGNAL(clicked()), this, SLOT(outClicked())); + connect(rbPatch, SIGNAL(clicked()), this, SLOT(patchClicked())); + + connect(lbPatch, SIGNAL(clicked(QListBoxItem *)), this, SLOT(patchListClicked(QListBoxItem *))); + connect(lbEnd, SIGNAL(clicked(QListBoxItem *)), this, SLOT(endListClicked(QListBoxItem *))); + + connect(finishButton(), SIGNAL(clicked()), this, SLOT(finishClicked())); + + connect(this, SIGNAL(selected(const QString &)), this, SLOT(selected(const QString &))); + helpButton()->hide(); + + setFinishEnabled(pageType, true); + setNextEnabled(pageType, true); + setFinishEnabled(pagePatch, true); + setNextEnabled(pagePatch, true); + setFinishEnabled(pageEnd, true); + setNextEnabled(pageEnd, true); +} + +void ConnectionWizard::setState(bool patch, bool end, bool back, bool next, bool finish) +{ + setAppropriate(pagePatch, patch ? true : false); + setAppropriate(pageEnd, end ? true : false); + + backButton()->setEnabled(back ? true : false); + nextButton()->setEnabled(next ? true : false); + finishButton()->setEnabled(finish ? true : false); +} + +void ConnectionWizard::loadEnd(IOType iotype) +{ + lbEnd->clear(); + ios.clear(); + + if (iotype == In) + { + for (int i = 0; i < (int)global->Inputs.count(); i++) + { + StrInput *io = global->Inputs.at(i); + ios.append(io->getIO(false, 0)); + lbEnd->insertItem(io->name()); + } + } + else if (iotype == Out) + { + for (int i = 0; i < (int)global->Outputs.count(); i++) + { + StrOutput *io = global->Outputs.at(i); + ios.append(io->getIO(true, 0)); + lbEnd->insertItem(io->name()); + } + } + else if (iotype == FX) + { + for (int i = 0; i < (int)global->FXs.count(); i++) + { + StrFX *io = global->FXs.at(i); + ios.append(io->getIO(false, 0)); + lbEnd->insertItem(io->name()); + } + } +} + +void ConnectionWizard::noneClicked() +{ + setState(false, false, false, false, true); + if (rtype != ConnectionWizard::None) + { + rtype = ConnectionWizard::None; + pto = NULL; + } +} + + +void ConnectionWizard::fxClicked() +{ + setState(false, true, false, true, false); + if (rtype != ConnectionWizard::FX) + { + rtype = ConnectionWizard::FX; + pto = NULL; + } +} + +void ConnectionWizard::inClicked() +{ + setState(false, true, false, true, false); + if (rtype != ConnectionWizard::In) + { + rtype = ConnectionWizard::In; + pto = NULL; + } +} + +void ConnectionWizard::outClicked() +{ + setState(false, true, false, true, false); + if (rtype != ConnectionWizard::Out) + { + rtype = ConnectionWizard::Out; + pto = NULL; + } +} + +void ConnectionWizard::patchClicked() +{ + setState(true, true, false, true, false); + if (rtype != ConnectionWizard::PIn && rtype != ConnectionWizard::POut) + { + if (out) + rtype = ConnectionWizard::PIn; + else + rtype = ConnectionWizard::POut; + pto = NULL; + } +} + +void ConnectionWizard::selected(const QString &page) +{ + if (page == "Connection target") + { + switch (rtype) + { + case None: + rbNone->setChecked(true); + setState(false, false, false, false, true); + break; + case FX: + rbFX->setChecked(true); + setState(false, true, false, true, false); + break; + case In: + rbInput->setChecked(true); + setState(false, true, false, true, false); + break; + case Out: + rbOutput->setChecked(true); + setState(false, true, false, true, false); + break; + case PIn: + case POut: + rbPatch->setChecked(true); + setState(true, true, false, true, false); + break; + } + } + else if (page == "Patch") + { + finishButton()->setEnabled(false); + if (pto) + { + // find patch + lbPatch->setCurrentItem(patchList.find(pto)); + nextButton()->setEnabled(true); + } + else + { + QListBoxItem *si = lbPatch->selectedItem(); + if (si) + lbPatch->setSelected(si, false); + lbPatch->setCurrentItem(-1); + nextButton()->setEnabled(false); + } + + cbMulti->setChecked(route.getMulti()); + cbSimple->setChecked(route.getSimple()); + } + else if (page == "End") + { + nextButton()->setEnabled(false); + switch (rtype) + { + case None: + break; + case FX: + case In: + case Out: + loadEnd(rtype); + break; + case PIn: + case POut: + // load patch in or out + ios.clear(); + lbEnd->clear(); + + for (int i = 0; i < (int)pto->getMaxIOIdx(out); i++) + { + RSItemIO *io = pto->getIO(out, i); + if (io) + { + ios.append(io); + lbEnd->insertItem(io->getDesc()); + } + } + + route.setMulti(cbMulti->isChecked()); + route.setSimple(cbSimple->isChecked()); + break; + } + + if (route.getToIO()) + { + lbEnd->setCurrentItem(ios.find(route.getToIO())); + finishButton()->setEnabled(true); + } + else + { + QListBoxItem *si = lbEnd->selectedItem(); + if (si) + lbEnd->setSelected(si, false); + lbEnd->setCurrentItem(-1); + finishButton()->setEnabled(false); + } + } +} + +void ConnectionWizard::patchListClicked(QListBoxItem *item) +{ + pto = patchList.at(lbPatch->index(item)); + route.setToIO(NULL); + nextButton()->setEnabled(true); +} + +void ConnectionWizard::endListClicked(QListBoxItem *item) +{ + route.setToIO(ios.at(lbEnd->index(item))); + finishButton()->setEnabled(true); +} + +void ConnectionWizard::finishClicked() +{ + *rptr = route; +} diff --git a/qlo10k1/src/connectionwizard.h b/qlo10k1/src/connectionwizard.h new file mode 100644 index 0000000..0db31ec --- /dev/null +++ b/qlo10k1/src/connectionwizard.h @@ -0,0 +1,128 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef CONNECTIONWIZARD_H +#define CONNECTIONWIZARD_H + +#include + +#include "strglobal.h" +#include "structure.h" +#include "dlgs/connectionwizardbase.h" + +class RouteInfo +{ +private: + RSItemIO *toIO; + + bool Multi; + bool Simple; + +public: + RouteInfo(bool multi, bool simple, RSItemIO *t) + { + toIO = t; + Multi = multi; + Simple = simple; + } + + RouteInfo(const RouteInfo &from) + { + toIO = from.toIO; + Multi = from.Multi; + Simple = from.Simple; + } + + RouteInfo() + { + toIO = NULL; + Multi = false; + Simple = false; + } + + RSItemIO *getToIO() + { + return toIO; + } + + void setToIO(RSItemIO *tio) + { + toIO = tio; + } + + bool getMulti() + { + return Multi; + } + + bool getSimple() + { + return Simple; + } + + void setMulti(bool multi) + { + Multi = multi; + } + + void setSimple(bool simple) + { + Simple = simple; + } + + bool isValid() + { + return toIO != NULL; + } +}; + +class ConnectionWizard : public ConnectionWizardBase +{ + Q_OBJECT + + enum IOType {None, In, Out, FX, PIn, POut} rtype; + RouteInfo route; + StrPatch *pto; + RouteInfo *rptr; + StrGlobal *global; + bool out; + QPtrList ios; + QPtrList patchList; + StrPatch *selPatch; +public: + ConnectionWizard(bool o, StrGlobal *g, RouteInfo *r); + void loadEnd(IOType iotype); + void setState(bool patch, bool end, bool back, bool next, bool finish); +public slots: + void noneClicked(); + void fxClicked(); + void inClicked(); + void outClicked(); + void patchClicked(); + + void finishClicked(); + + void selected(const QString &page); + void patchListClicked(QListBoxItem *item); + void endListClicked(QListBoxItem *item); +}; + +#endif // CONNECTIONWIZARD_H diff --git a/qlo10k1/src/custom_colors.h b/qlo10k1/src/custom_colors.h new file mode 100644 index 0000000..6acef2f --- /dev/null +++ b/qlo10k1/src/custom_colors.h @@ -0,0 +1,39 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Eduardo García-Mádico Portabella + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +// Common colors +#define DEF_PAINTING_COLOR QColor(0,0,0) +#define LINE_COLOR QColor(125,125,125) +#define BOX_COLOR QColor(0,0,255) +#define BOX_SELECTED_COLOR QColor(255,0,0) +#define POINT_COLOR QColor(0,255,0) +#define TEXT_COLOR QColor(0,0,0) + +// IO colors +#define IO_BOX_COLOR QColor(0,255,0) +#define IO_TEXT_PEN QColor(0,0,0) + +// Pens +#define DEF_PAINTING_PEN QPen(DEF_PAINTING_COLOR) +#define LINE_PEN QPen(LINE_COLOR) +#define BOX_PEN QPen(BOX_COLOR) +#define POINT_PEN QPen(POINT_COLOR) +#define TEXT_PEN QPen(TEXT_COLOR) diff --git a/qlo10k1/src/dlgs/aboutdialogbase.ui b/qlo10k1/src/dlgs/aboutdialogbase.ui new file mode 100644 index 0000000..4489562 --- /dev/null +++ b/qlo10k1/src/dlgs/aboutdialogbase.ui @@ -0,0 +1,53 @@ + +AboutDialogBase + + + AboutDialogBase + + + + 0 + 0 + 450 + 359 + + + + About + + + + unnamed + + + + textEdit1 + + + <html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans"> +<p align="center"><span style="font-size:12pt;font-weight:600">qlo10k1 - GUI for ld10k1</span></p> +<p align="center"><span style="font-size:12pt;font-weight:600">Copyright (C) 2004 by Peter Zubaj</span></p> +<p><br /><span style="font-weight:600">This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</span> <br /><br /><span style="font-weight:600">This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</span></p> +</body></html> + + + + WidgetWidth + + + + + pbOK + + + &Close + + + Alt+C + + + + + + + diff --git a/qlo10k1/src/dlgs/connectionwizardbase.ui b/qlo10k1/src/dlgs/connectionwizardbase.ui new file mode 100644 index 0000000..b29b862 --- /dev/null +++ b/qlo10k1/src/dlgs/connectionwizardbase.ui @@ -0,0 +1,181 @@ + +ConnectionWizardBase + + + ConnectionWizardBase + + + + 0 + 0 + 282 + 229 + + + + Connection + + + + pageType + + + Connection target + + + + unnamed + + + + buttonGroup1 + + + NoFrame + + + Plain + + + + + + + unnamed + + + 1 + + + 0 + + + + layout17 + + + + unnamed + + + + rbNone + + + None + + + + + rbFX + + + FX + + + + + rbInput + + + Input + + + + + rbOutput + + + Output + + + + + rbPatch + + + Patch + + + + + + + + + + + pagePatch + + + Patch + + + + unnamed + + + + layout5 + + + + unnamed + + + + lbPatch + + + + + layout4 + + + + unnamed + + + + cbMulti + + + Multi + + + + + cbSimple + + + Simple + + + + + + + + + + + pageEnd + + + End + + + + unnamed + + + + lbEnd + + + + + + + + diff --git a/qlo10k1/src/dlgs/filecontroldialogbase.ui b/qlo10k1/src/dlgs/filecontroldialogbase.ui new file mode 100644 index 0000000..8f3c585 --- /dev/null +++ b/qlo10k1/src/dlgs/filecontroldialogbase.ui @@ -0,0 +1,252 @@ + +FileControlDialogBase + + + FileControlDialogBase + + + + 0 + 0 + 566 + 363 + + + + File control + + + + unnamed + + + + lbControls + + + + + layout14 + + + + unnamed + + + + spacer7 + + + Horizontal + + + Expanding + + + + 211 + 21 + + + + + + pbUp + + + &Up + + + + + pbDown + + + &Down + + + + + + + layout34 + + + + unnamed + + + + spacer12 + + + Horizontal + + + Expanding + + + + 141 + 31 + + + + + + pbOK + + + &OK + + + true + + + false + + + + + pbCancel + + + &Cancel + + + + + + + layout39 + + + + unnamed + + + + textLabel3 + + + + 0 + 5 + 0 + 0 + + + + Index: + + + + + textLabel10 + + + Loaded name: + + + + + spacer11 + + + Horizontal + + + Expanding + + + + 346 + 21 + + + + + + sbIndex + + + + 0 + 0 + 0 + 0 + + + + 100000000 + + + -1 + + + -1 + + + + + leLoadedName + + + + + sbVisible + + + + + textLabel12 + + + Visible: + + + + + textLabel11 + + + Translation: + + + + + + None + + + + + Table100 + + + + + Bass + + + + + Treble + + + + + On/Off + + + + cbTranslation + + + + + + + + + diff --git a/qlo10k1/src/dlgs/filecontrolsdialogbase.ui b/qlo10k1/src/dlgs/filecontrolsdialogbase.ui new file mode 100644 index 0000000..656f0b1 --- /dev/null +++ b/qlo10k1/src/dlgs/filecontrolsdialogbase.ui @@ -0,0 +1,21 @@ + +FileControlsDialogBase + + + FileControlsDialogBase + + + + 0 + 0 + 492 + 314 + + + + File controls + + + + + diff --git a/qlo10k1/src/dlgs/loadpatchdialogbase.ui b/qlo10k1/src/dlgs/loadpatchdialogbase.ui new file mode 100644 index 0000000..cac8886 --- /dev/null +++ b/qlo10k1/src/dlgs/loadpatchdialogbase.ui @@ -0,0 +1,375 @@ + +LoadPatchDialogBase + + + LoadPatchDialogBase + + + + 0 + 0 + 608 + 454 + + + + Load patch + + + + unnamed + + + + layout26 + + + + unnamed + + + + lePatchName + + + + + leFileName + + + false + + + + + textLabel6 + + + Patch name: + + + + + textLabel3 + + + File: + + + + + + + tabOptions + + + true + + + + tabControls + + + Con&trols + + + + unnamed + + + + lbFileCtrl + + + Single + + + + + textLabel4 + + + File controls: + + + + + layout11 + + + + unnamed + + + + layout10 + + + + unnamed + + + + tlMax + + + Max: + + + + + leMax + + + false + + + true + + + + + tlTransl + + + Transl: + + + + + leTranslation + + + false + + + true + + + + + tlMin + + + Min: + + + + + leMin + + + false + + + true + + + + + + + layout9 + + + + unnamed + + + + tlVal + + + Values: + + + + + lbValues + + + + + + + + + + + tabNames + + + &Names + + + + unnamed + + + + layout10 + + + + unnamed + + + + textLabel2 + + + Inputs: + + + + + lbInputs + + + + + textLabel1 + + + Outputs: + + + + + lbOutputs + + + + + + + + + + layout17 + + + + unnamed + + + + spacer7 + + + Horizontal + + + Expanding + + + + 211 + 31 + + + + + + pbOK + + + &OK + + + true + + + + + pbCancel + + + &Cancel + + + + + + + layout16 + + + + unnamed + + + + textLabel7 + + + + 0 + 5 + 0 + 0 + + + + Insert: + + + + + + Before + + + + + After + + + + cbBefAfter + + + + 0 + 0 + 0 + 0 + + + + + + textLabel8 + + + + 0 + 5 + 0 + 0 + + + + Patch: + + + + + cbWhere + + + + 1 + 5 + 0 + 0 + + + + + + + + + + diff --git a/qlo10k1/src/dlgs/mainwndbase.ui b/qlo10k1/src/dlgs/mainwndbase.ui new file mode 100644 index 0000000..f1a1ad7 --- /dev/null +++ b/qlo10k1/src/dlgs/mainwndbase.ui @@ -0,0 +1,179 @@ + +MainWndBase + + + MainWndBase + + + + 0 + 0 + 494 + 360 + + + + qlo10k1 - emu10k1 patch loader + + + + unnamed + + + + tabMain + + + + tabLoad + + + &Load + + + + unnamed + + + + layout11 + + + + unnamed + + + + + Order + + + true + + + true + + + + + Num + + + true + + + true + + + + + Patch name + + + true + + + true + + + + lvPatches + + + true + + + + + layout3 + + + + unnamed + + + + pbLoad + + + Load + + + + + cbFromFile + + + false + + + From file + + + true + + + + + pbUnload + + + Unload + + + + + spacer2 + + + Vertical + + + Expanding + + + + 31 + 71 + + + + + + + + tlPatches + + + Patches: + + + + + + + + + tabRouting + + + &Routing + + + + unnamed + + + + + + + + + menubar + + + + + + diff --git a/qlo10k1/src/dlgs/newiodialogbase.ui b/qlo10k1/src/dlgs/newiodialogbase.ui new file mode 100644 index 0000000..29b2c90 --- /dev/null +++ b/qlo10k1/src/dlgs/newiodialogbase.ui @@ -0,0 +1,105 @@ + +NewIODialogBase + + + NewIODialogBase + + + + 0 + 0 + 297 + 284 + + + + Form2 + + + + unnamed + + + + + Num + + + true + + + true + + + + + New Column + + + true + + + true + + + + lvIOs + + + + + layout1 + + + + unnamed + + + + pbOK + + + false + + + &OK + + + Alt+O + + + + + pbCancel + + + &Cancel + + + Alt+C + + + + + spacer1 + + + Vertical + + + Expanding + + + + 41 + 171 + + + + + + + + + + diff --git a/qlo10k1/src/dlgs/patchdialogbase.ui b/qlo10k1/src/dlgs/patchdialogbase.ui new file mode 100644 index 0000000..cbe60ed --- /dev/null +++ b/qlo10k1/src/dlgs/patchdialogbase.ui @@ -0,0 +1,247 @@ + +PatchDialogBase + + + PatchDialogBase + + + + 0 + 0 + 600 + 480 + + + + Patch info + + + + unnamed + + + + layout35 + + + + unnamed + + + + tabOptions + + + true + + + + tabControls + + + Con&trols + + + + unnamed + + + + layout33 + + + + unnamed + + + + textLabel5 + + + Loaded controls: + + + + + lbLoadedCtrl + + + + + + + + + tabNames + + + &Names + + + + unnamed + + + + layout10 + + + + unnamed + + + + textLabel2 + + + Inputs: + + + + + lbInputs + + + + + textLabel1 + + + Outputs: + + + + + lbOutputs + + + + + + + + + tabConnection + + + Co&nnection + + + + unnamed + + + + layout11 + + + + unnamed + + + + lbInputs_2 + + + Inputs: + + + + + lbConnInputs + + + + + lbInputs_2_2 + + + Outputs: + + + + + lbConnOutputs + + + + + + + + + + layout34 + + + + unnamed + + + + textLabel6 + + + Patch name: + + + + + lePatchName + + + + + + + layout17_2 + + + + unnamed + + + + spacer7 + + + Horizontal + + + Expanding + + + + 211 + 31 + + + + + + pbOK + + + &OK + + + true + + + + + pbCancel + + + &Cancel + + + + + + + + + + + diff --git a/qlo10k1/src/dlgs/preferencesbase.ui b/qlo10k1/src/dlgs/preferencesbase.ui new file mode 100644 index 0000000..053dd2b --- /dev/null +++ b/qlo10k1/src/dlgs/preferencesbase.ui @@ -0,0 +1,394 @@ + +PreferencesBase + + + PreferencesBase + + + + 0 + 0 + 540 + 329 + + + + Settings + + + + unnamed + + + + layout10 + + + + unnamed + + + + tabSet + + + + tabCard + + + &Card + + + + unnamed + + + + layout8 + + + + unnamed + + + + layout7 + + + + unnamed + + + + layout6 + + + + unnamed + + + + textLabel1 + + + Cards: + + + + + spacer4_2 + + + Vertical + + + Expanding + + + + 20 + 51 + + + + + + + + lbCards + + + + + + + layout4 + + + + unnamed + + + + spacer2 + + + Horizontal + + + Expanding + + + + 251 + 20 + + + + + + pbCardAdd + + + &Add + + + + + pbCardDel + + + false + + + &Delete + + + + + + + gbCard + + + false + + + Card info + + + + unnamed + + + + layout3 + + + + unnamed + + + + leCardSocket + + + + + leCardName + + + + + tlCardSocket + + + Socket: + + + + + tlCardName + + + Name: + + + + + + + + + layout7 + + + + unnamed + + + + spacer4_3 + + + Horizontal + + + Expanding + + + + 381 + 20 + + + + + + pbUpdate + + + &Update + + + + + + + + + + + tabRepository + + + Repository + + + + unnamed + + + + layout15 + + + + unnamed + + + + layout14 + + + + unnamed + + + + pbSelUser + + + + 30 + 32767 + + + + ... + + + + + pbSelSystem + + + + 30 + 32767 + + + + ... + + + + + tlRepUserDir + + + User dir: + + + + + tlRepSysDir + + + System dir: + + + + + leRepUser + + + + + leRepSystem + + + + + + + spacer6 + + + Vertical + + + Expanding + + + + 20 + 169 + + + + + + + + + + + layout9 + + + + unnamed + + + + spacer4 + + + Horizontal + + + Expanding + + + + 16 + 21 + + + + + + pbOK + + + &OK + + + + + pbCancel + + + &Cancel + + + + + + + + + + + diff --git a/qlo10k1/src/dlgs/transformpatchbase.ui b/qlo10k1/src/dlgs/transformpatchbase.ui new file mode 100644 index 0000000..b37a7f8 --- /dev/null +++ b/qlo10k1/src/dlgs/transformpatchbase.ui @@ -0,0 +1,306 @@ + +TransformPatchBase + + + TransformPatchBase + + + + 0 + 0 + 655 + 496 + + + + Transform patch + + + + unnamed + + + + layout26 + + + + unnamed + + + + lePatchName + + + + + leFileName + + + false + + + + + textLabel6 + + + Patch name: + + + + + textLabel3 + + + File: + + + + + + + tabOptions + + + true + + + + tabControls + + + Con&trols + + + + unnamed + + + + layout24 + + + + unnamed + + + + layout21 + + + + unnamed + + + + textLabel4 + + + File controls: + + + + + lbFileCtrl + + + Extended + + + + + + + layout23 + + + + unnamed + + + + spacer9 + + + Vertical + + + Expanding + + + + 20 + 41 + + + + + + pbCtrlAdd + + + >> + + + + + pbCtrlDel + + + << + + + + + spacer8 + + + Vertical + + + Expanding + + + + 21 + 30 + + + + + + + + layout22 + + + + unnamed + + + + textLabel5 + + + Transformed controls: + + + + + lbLoadedCtrl + + + + + + + + + + + tabNames + + + &Names + + + + unnamed + + + + layout10 + + + + unnamed + + + + textLabel2 + + + Inputs: + + + + + lbInputs + + + + + textLabel1 + + + Outputs: + + + + + lbOutputs + + + + + + + + + + layout17 + + + + unnamed + + + + spacer7 + + + Horizontal + + + Expanding + + + + 211 + 31 + + + + + + pbOK + + + &OK + + + Alt+O + + + true + + + + + pbCancel + + + &Cancel + + + Alt+C + + + + + + + + + diff --git a/qlo10k1/src/filecontroldialog.cpp b/qlo10k1/src/filecontroldialog.cpp new file mode 100644 index 0000000..3776f6d --- /dev/null +++ b/qlo10k1/src/filecontroldialog.cpp @@ -0,0 +1,199 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include "filecontroldialog.h" + +FileControlDlg::FileControlDlg(QValueList *eselected, EMU10k1File *efile, TranslatedCtrl *etranslated) +{ + file = efile; + translated = etranslated; + + int ctrlIdx; + unsigned int i; + + if (eselected) + { + selected = *eselected; + // insert file controls to listbox + for (i = 0; i < selected.count(); i++) + { + ctrlIdx = selected[i]; + lbControls->insertItem(getName(ctrlIdx)); + } + + sbIndex->setValue(-1); + + sbVisible->setMinValue(1); + sbVisible->setMaxValue(selected.count()); + sbVisible->setValue(selected.count()); + + // set min, max + EMU10k1Ctrl ctrl; + file->getCtrl(selected[0], &ctrl); + min = ctrl.min; + max = ctrl.max; + values.append(ctrl.value); + for (i = 1; i < selected.count(); i++) + { + file->getCtrl(selected[i], &ctrl); + values.append(ctrl.value); + if (ctrl.max > max) + max = ctrl.max; + if (ctrl.min < min) + min = ctrl.min; + } + + if (min == 0 && max == 100) + cbTranslation->setCurrentItem(1); + } + else + { + selected = translated->fileCtrlIdx; + for (i = 0; i < translated->fileCtrlIdx.count(); i++) + { + lbControls->insertItem(getName(translated->fileCtrlIdx[i])); + } + + sbVisible->setMinValue(1); + sbVisible->setMaxValue(translated->fileCtrlIdx.count()); + sbVisible->setValue(translated->visible); + + leLoadedName->setText(translated->name); + sbIndex->setValue(translated->index); + + switch(translated->translation) + { + case TranslatedCtrl::None: + cbTranslation->setCurrentItem(0); + break; + case TranslatedCtrl::Table100: + cbTranslation->setCurrentItem(1); + break; + case TranslatedCtrl::Bass: + cbTranslation->setCurrentItem(2); + break; + case TranslatedCtrl::Treble: + cbTranslation->setCurrentItem(3); + break; + case TranslatedCtrl::OnOff: + cbTranslation->setCurrentItem(4); + break; + } + + for (unsigned int i = 0; i < translated->values.count(); i++) + values.append(translated->values[i]); + min = translated->min; + max = translated->max; + } + + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + connect(pbUp, SIGNAL(clicked()), this, SLOT(upClicked())); + connect(pbDown, SIGNAL(clicked()), this, SLOT(downClicked())); +} + +QString FileControlDlg::getName(int i) +{ + EMU10k1Ctrl ctrl; + + file->getCtrl(i, &ctrl); + QString name = QString(ctrl.name) + " - " + QString().setNum(ctrl.value) + + " (" + QString().setNum(ctrl.min) + "," + + QString().setNum(ctrl.max) + ")"; + return name; +} + +void FileControlDlg::okClicked() +{ + translated->name = leLoadedName->text(); + translated->index = sbIndex->value(); + + switch(cbTranslation->currentItem()) + { + case 0: + translated->translation = TranslatedCtrl::None; + break; + case 1: + translated->translation = TranslatedCtrl::Table100; + break; + case 2: + translated->translation = TranslatedCtrl::Bass; + break; + case 3: + translated->translation = TranslatedCtrl::Treble; + break; + case 4: + translated->translation = TranslatedCtrl::OnOff; + break; + } + + translated->fileCtrlIdx = selected; + translated->visible = sbVisible->value(); + translated->values.clear(); + for (unsigned int i = 0; i < values.count(); i++) + translated->values.append(values[i]); + + translated->min = min; + translated->max = max; + done(Accepted); +} + +void FileControlDlg::cancelClicked() +{ + done(Rejected); +} + +void FileControlDlg::upClicked() +{ + int idx = lbControls->currentItem(); + if (idx > 0) + { + int tmp = selected[idx - 1]; + selected[idx - 1] = selected[idx]; + selected[idx] = tmp; + + // update labels + lbControls->changeItem(getName(selected[idx - 1]), idx - 1); + lbControls->changeItem(getName(selected[idx]), idx); + lbControls->setCurrentItem(idx - 1); + } +} + +void FileControlDlg::downClicked() +{ + int idx = lbControls->currentItem(); + if (idx >= 0 && idx < (int)lbControls->count() - 1) + { + int tmp = selected[idx + 1]; + selected[idx + 1] = selected[idx]; + selected[idx] = tmp; + + // update labels + lbControls->changeItem(getName(selected[idx]), idx); + lbControls->changeItem(getName(selected[idx + 1]), idx + 1); + lbControls->setCurrentItem(idx + 1); + } +} diff --git a/qlo10k1/src/filecontroldialog.h b/qlo10k1/src/filecontroldialog.h new file mode 100644 index 0000000..7a69230 --- /dev/null +++ b/qlo10k1/src/filecontroldialog.h @@ -0,0 +1,66 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef FILECONTROLDIALOG_H +#define FILECONTROLDIALOG_H + +#include +#include "dlgs/filecontroldialogbase.h" +#include "ld10k1file.h" + +class TranslatedCtrl +{ +public: + QString name; + int index; + + enum TranslationType {None, Table100, Bass, Treble, OnOff }; + TranslationType translation; + int visible; + int min; + int max; + QValueList fileCtrlIdx; + QValueList values; +}; + +class FileControlDlg : public FileControlDialogBase +{ + Q_OBJECT + + QValueList selected; + EMU10k1File *file; + TranslatedCtrl *translated; + unsigned int min; + unsigned int max; + QValueList values; +public: + FileControlDlg(QValueList *eselected, EMU10k1File *efile, TranslatedCtrl *etranslated); + + QString getName(int i); +public slots: + void okClicked(); + void cancelClicked(); + + void upClicked(); + void downClicked(); +}; + +#endif // FILECONTROLDIALOG_H diff --git a/qlo10k1/src/icons/routing_effect.xpm b/qlo10k1/src/icons/routing_effect.xpm new file mode 100644 index 0000000..a83c5f1 --- /dev/null +++ b/qlo10k1/src/icons/routing_effect.xpm @@ -0,0 +1,50 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_effect[]={ +"22 22 4 1", +". c None", +"# c #000000", +"b c #303030", +"a c #ffffff", +"......................", +"......................", +"......................", +"....##############....", +"....#aaaaaaaaaaaa#....", +"....#aaaaaaaaaaaa#....", +"....#aaabb####aaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabbb#baaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaabaaaaaaaa#....", +"....#aaa######aaa#....", +"....#aaaaaaaaaaaa#....", +"....#aaaaaaaaaaaa#....", +"....##############....", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_effect_stack.xpm b/qlo10k1/src/icons/routing_effect_stack.xpm new file mode 100644 index 0000000..0a1ed97 --- /dev/null +++ b/qlo10k1/src/icons/routing_effect_stack.xpm @@ -0,0 +1,50 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_effect_stack[]={ +"22 22 4 1", +"b c None", +". c None", +"# c #000000", +"a c #ffffff", +"......................", +".##############.......", +".#aaaaaaaaaaaa#bb.....", +".#aaaaaaaaaaaa###bb...", +".#aaa######aaa#a#bb...", +".#aaa#aaaaaaaa#a###...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa#####aaaa#a#a#...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa#aaaaaaaa#a#a#...", +".#aaa######aaa#a#a#...", +".#aaaaaaaaaaaa#a#a#...", +".#aaaaaaaaaaaa#a#a#...", +".##############a#a#...", +"..b#aaaaaaaaaaaa#a#...", +"..b##############a#...", +"...bb#aaaaaaaaaaaa#...", +"...bb##############...", +"......................"}; diff --git a/qlo10k1/src/icons/routing_fx.xpm b/qlo10k1/src/icons/routing_fx.xpm new file mode 100644 index 0000000..a8becfa --- /dev/null +++ b/qlo10k1/src/icons/routing_fx.xpm @@ -0,0 +1,50 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_fx[]={ +"22 22 4 1", +". c None", +"# c #000000", +"b c #303030", +"a c #ffffff", +"......................", +"......................", +"........#####.........", +"......##aaaaa##.......", +".....#aaaaaaaaa#......", +"....#aaaaaaaaaaa#.....", +"...#aa####a#aa#aa#....", +"...#aa#aaaa#aa#aa#....", +"..#aaa#aaaa#aa#aaa#...", +"..#aaa#aaaaa##aaaa#...", +"..#aaa###.aabbaaaa#...", +"..#aaa#aaaaa##aaaa#...", +"..#aaa#aaaa#aa#aaa#...", +"...#aa#aaaa#aa#aa#....", +"...#aa#aaaa#aa#aa#....", +"....#aaaaaaaaaaa#.....", +".....#aaaaaaaaa#......", +"......##aaaaa##.......", +"........#####.........", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_in.xpm b/qlo10k1/src/icons/routing_in.xpm new file mode 100644 index 0000000..7f0858a --- /dev/null +++ b/qlo10k1/src/icons/routing_in.xpm @@ -0,0 +1,50 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_in[]={ +"22 22 4 1", +". c None", +"# c #000000", +"b c #303030", +"a c #ffffff", +"......................", +"......................", +"........#####.........", +"......##aaaaa##.......", +".....#aaaaaaaaa#......", +"....#aaaaaaaaaaa#.....", +"...#aabaabaaaabaa#....", +"...#aabaabbaaabaa#....", +"..#aaabaababaabaaa#...", +"..#aaabaababaabaaa#...", +"..#aaabaababbabaaa#...", +"..#aaabaabaababaaa#...", +"..#aaabaabaababaaa#...", +"...#aabaabaaabbaa#....", +"...#aabaabaaaabaa#....", +"....#aaaaaaaaaaa#.....", +".....#aaaaaaaaa#......", +"......##aaaaa##.......", +"........#####.........", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_normal.xpm b/qlo10k1/src/icons/routing_normal.xpm new file mode 100644 index 0000000..2eaf424 --- /dev/null +++ b/qlo10k1/src/icons/routing_normal.xpm @@ -0,0 +1,51 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_normal[]={ +"22 22 5 1", +"# c None", +". c None", +"a c #000000", +"b c #303030", +"c c #ffffff", +"......................", +"......................", +"...#..................", +"...###a#########......", +"...###ab########......", +"...###acb#######......", +"...###accb######......", +"...###acccb#####......", +"...###accccb####......", +"...###acccccb###......", +"...###accccccb##......", +"..####acccccabb#......", +"..####accccb#####.....", +"..####acbbccb###......", +"..###.bb#bccb###......", +"...#..b###bccb##......", +"......####bccb##......", +"......#####bccb#......", +"......#####bccb#......", +"......######bb##......", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_out.xpm b/qlo10k1/src/icons/routing_out.xpm new file mode 100644 index 0000000..8a9fb22 --- /dev/null +++ b/qlo10k1/src/icons/routing_out.xpm @@ -0,0 +1,50 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_out[]={ +"22 22 4 1", +". c None", +"# c #000000", +"b c #303030", +"a c #ffffff", +"......................", +"......................", +"........#####.........", +"......##aaaaa##.......", +".....#aaaaaaaaa#......", +"....#aaaaaaaaaaa#.....", +"...#aaaaaaaaaaaaa#....", +"...#aabaabababbba#....", +"..#aababababaabaaa#...", +"..#aababababaabaaa#...", +"..#aababababaabaaa#...", +"..#aababababaabaaa#...", +"..#aababababaabaaa#...", +"...#aabaaabaaabaa#....", +"...#aaaaaaaaaaaaa#....", +"....#aaaaaaaaaaa#.....", +".....#aaaaaaaaa#......", +"......##aaaaa##.......", +"........#####.........", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_route.xpm b/qlo10k1/src/icons/routing_route.xpm new file mode 100644 index 0000000..a771bbe --- /dev/null +++ b/qlo10k1/src/icons/routing_route.xpm @@ -0,0 +1,56 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_route[]={ +"22 22 10 1", +"# c None", +". c None", +"e c #000000", +"g c #303030", +"a c #000000", +"h c #191919", +"d c #1a1a1a", +"b c #333333", +"f c #fefefe", +"c c #ffffff", +"......................", +"......................", +"......................", +"......................", +"......................", +"......................", +"............#.........", +"............a##.......", +"...........#abb##.....", +"...#########accdd##...", +"...eeeeeeeeeaccffeg...", +"............accaa##...", +"............ahh##.....", +"............a##.......", +"............##........", +"......................", +"......................", +"......................", +"......................", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_zoom_minus.xpm b/qlo10k1/src/icons/routing_zoom_minus.xpm new file mode 100644 index 0000000..0fc331b --- /dev/null +++ b/qlo10k1/src/icons/routing_zoom_minus.xpm @@ -0,0 +1,52 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_zoom_minus[]={ +"22 22 6 1", +". c None", +"b c #000000", +"d c #303030", +"# c #a0a0a0", +"c c #a8dcff", +"a c #dcdcdc", +"......................", +".....#####............", +"....abbbbb#...........", +"...abcccccb#..........", +"..abcccccccb#.........", +".abcccccccccb#........", +".abcccccccccb#........", +".abccbbbbbccb#........", +".abcccccccccb#........", +".abcccccccccb#........", +"..abcccccccb#.........", +"...abcccccbbd#........", +"....abbbbbabbb#.......", +".....aaaaa.abbb#......", +"............abbb#.....", +".............abbb#....", +"..............abbb#...", +"...............add#...", +"................aa....", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/icons/routing_zoom_plus.xpm b/qlo10k1/src/icons/routing_zoom_plus.xpm new file mode 100644 index 0000000..a694cde --- /dev/null +++ b/qlo10k1/src/icons/routing_zoom_plus.xpm @@ -0,0 +1,53 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* XPM */ +static const char *routing_zoom_plus[]={ +"22 22 7 1", +"d c None", +". c None", +"b c #000000", +"e c #303030", +"# c #a0a0a0", +"c c #a8dcff", +"a c #dcdcdc", +"......................", +".....#####............", +"....abbbbb#...........", +"...abcccccb#..........", +".dabcccccccb#.........", +".abccccbccccb#........", +".abccccbccccb#........", +".abccbbbbbccb#........", +".abccccbccccb#........", +".abccccbccccb#........", +"..abcccccccb#d........", +"...abcccccbbe#dd......", +"....abbbbbabbb#dd.....", +".....aaaaa.abbb#dd....", +"............abbb#dd...", +".............abbb#d...", +".............dabbb#...", +"...............aee#...", +"................aa....", +"......................", +"......................", +"......................"}; diff --git a/qlo10k1/src/ld10k1file.cpp b/qlo10k1/src/ld10k1file.cpp new file mode 100644 index 0000000..5742d61 --- /dev/null +++ b/qlo10k1/src/ld10k1file.cpp @@ -0,0 +1,573 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "ld10k1file.h" + +class EMU10k1FilePrivate +{ + liblo10k1_emu_patch_t *ep; +public: + EMU10k1FilePrivate() + { + ep = liblo10k1_emu_new_patch(); + } + + ~EMU10k1FilePrivate() + { + if (ep) + liblo10k1_emu_free_patch(ep); + } + + void setNativeStruct(liblo10k1_emu_patch_t *ns) + { + if (ep) + liblo10k1_emu_free_patch(ep); + ep = ns; + } + + liblo10k1_emu_patch_t *getNativeStruct() + { + return ep; + } +}; + +EMU10k1File::EMU10k1File() +{ + privData = new EMU10k1FilePrivate(); +} + +EMU10k1File::~EMU10k1File() +{ + if (privData) + delete (privData); +} + +int EMU10k1File::LoadFromFile(QString file, EMU10k1File **ef) +{ + liblo10k1_emu_patch_t *nf; + char fn[1000]; // FIXME file name length + int err; + + strncpy(fn, file.local8Bit(), 999); + fn[999] = '\0'; + if ((err = liblo10k1_emu_load_patch(fn, &nf)) < 0) + return err; + + EMU10k1File *efi = new EMU10k1File(); + efi->privData->setNativeStruct(nf); + *ef = efi; + return 0; +} + +void EMU10k1File::getCtrl(unsigned int i, EMU10k1Ctrl *ctrl) +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + liblo10k1_emu_ctl_t *ctl; + + if (i >= nf->ctl_count) + return; + + ctl = &(nf->ctls[i]); + + ctrl->value = ctl->ctl_val; + ctrl->min = ctl->ctl_val_min; + ctrl->max = ctl->ctl_val_max; + ctrl->name = ctl->ctl_name; +} + +void EMU10k1File::setCtrl(unsigned int i, EMU10k1Ctrl *ctrl) +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + liblo10k1_emu_ctl_t *ctl; + + if (i >= nf->ctl_count) + return; + + ctl = &(nf->ctls[i]); + + ctl->ctl_val = ctrl->value; + ctl->ctl_val_min = ctrl->min; + ctl->ctl_val_max = ctrl->max; + strcpy(ctl->ctl_name, ctrl->name.local8Bit()); +} + +QString EMU10k1File::getPatchName() +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + return QString(nf->patch_name); +} + +int EMU10k1File::getCtrlCount() +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + return nf->ctl_count; +} + +int EMU10k1File::getInCount() +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + return nf->in_count; +} + +int EMU10k1File::getOutCount() +{ + liblo10k1_emu_patch_t *nf = privData->getNativeStruct(); + return nf->out_count; +} + +class LD10k1FilePrivate +{ + liblo10k1_dsp_patch_t *lp; +public: + LD10k1FilePrivate() + { + lp = liblo10k1_patch_alloc(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + ~LD10k1FilePrivate() + { + if (lp) + liblo10k1_patch_free(lp); + } + + void setNativeStruct(liblo10k1_dsp_patch_t *ns) + { + if (lp) + liblo10k1_patch_free(lp); + lp = ns; + } + + liblo10k1_dsp_patch_t *getNativeStruct() + { + return lp; + } +}; + +LD10k1File::LD10k1File() +{ + privData = new LD10k1FilePrivate(); +} + +LD10k1File::~LD10k1File() +{ + if (privData) + delete (privData); +} + +liblo10k1_dsp_patch_t *LD10k1File::getLD10k1Format() +{ + return privData->getNativeStruct(); +} + +void LD10k1File::setLD10k1Format(liblo10k1_dsp_patch_t *patch) +{ + privData->setNativeStruct(patch); +} + +int LD10k1File::transformFromEmuFile(EMU10k1File *ef, LD10k1FileTransfCtl *tc, int tc_count, LD10k1File **lf) +{ + liblo10k1_ctl_transform_t *ntc = (liblo10k1_ctl_transform_t *)malloc(sizeof(liblo10k1_ctl_transform_t) * tc_count); + if (!ntc) + return LD10K1_ERR_NO_MEM; + + // copy tc to ntc + int i, j, err; + liblo10k1_dsp_patch_t *np = NULL; + + for (i = 0; i < tc_count; i++) + { + for (j = 0; j < tc[i].emu_ctl_count; j++) + ntc[i].emu_ctls[j] = tc[i].emu_ctls[j]; + + ntc[i].emu_ctl_count = tc[i].emu_ctl_count; + strncpy(ntc[i].ctl_name, tc[i].ctl_name.local8Bit(), 43); + ntc[i].ctl_name[43] = '\0'; + } + + if ((err = liblo10k1_emu_transform_patch(ef->privData->getNativeStruct(), ntc, tc_count, &np)) < 0) + { + free(ntc); + return err; + } + + free(ntc); + + LD10k1File *nlf = new LD10k1File(); + + nlf->privData->setNativeStruct(np); + *lf = nlf; + return 0; +} + +int LD10k1File::getIOCount(bool out) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (out) + return nf->out_count; + else + return nf->in_count; +} + +QString LD10k1File::getIOName(bool out, unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (out) + { + if (i >= nf->out_count) + return ""; + return QString(nf->outs[i].name); + } + else + { + if (i >= nf->in_count) + return ""; + return QString(nf->ins[i].name); + } +} + +void LD10k1File::setIOName(bool out, unsigned int i, QString name) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (out) + { + if (i >= nf->out_count) + return; + strncpy(nf->outs[i].name, name.local8Bit(), MAX_NAME_LEN - 1); + nf->outs[i].name[MAX_NAME_LEN - 1] = '\0'; + } + else + { + if (i >= nf->in_count) + return; + strncpy(nf->ins[i].name, name.local8Bit(), MAX_NAME_LEN - 1); + nf->ins[i].name[MAX_NAME_LEN - 1] = '\0'; + } +} + +int LD10k1File::getCtlCount() +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + return nf->ctl_count; +} + +QString LD10k1File::getCtlName(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return ""; + return QString(nf->ctl[i].name); +} + +void LD10k1File::setCtlName(unsigned int i, QString name) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return; + strncpy(nf->ctl[i].name, name.local8Bit(), 43); + nf->ctl[i].name[43] = '\0'; +} + +LD10k1File::TranslationType LD10k1File::getCtlTranslation(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return None; + switch (nf->ctl[i].translation) + { + case EMU10K1_GPR_TRANSLATION_NONE: + return LD10k1File::None; + case EMU10K1_GPR_TRANSLATION_TABLE100: + return LD10k1File::Table100; + case EMU10K1_GPR_TRANSLATION_BASS: + return LD10k1File::Bass; + case EMU10K1_GPR_TRANSLATION_TREBLE: + return LD10k1File::Treble; + case EMU10K1_GPR_TRANSLATION_ONOFF: + return LD10k1File::OnOff; + default: + return LD10k1File::None; + } +} + +void LD10k1File::setCtlTranslation(unsigned int i, LD10k1File::TranslationType t) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return; + switch (t) + { + case LD10k1File::None: + nf->ctl[i].translation = EMU10K1_GPR_TRANSLATION_NONE; + break; + case LD10k1File::Table100: + nf->ctl[i].translation = EMU10K1_GPR_TRANSLATION_TABLE100; + break; + case LD10k1File::Bass: + nf->ctl[i].translation = EMU10K1_GPR_TRANSLATION_BASS; + break; + case LD10k1File::Treble: + nf->ctl[i].translation = EMU10K1_GPR_TRANSLATION_TREBLE; + break; + case LD10k1File::OnOff: + nf->ctl[i].translation = EMU10K1_GPR_TRANSLATION_ONOFF; + break; + default: + break; + } +} + +int LD10k1File::getCtlValCount(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return 0; + return nf->ctl[i].count; +} + +int LD10k1File::getCtlValVCount(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return 0; + return nf->ctl[i].vcount; +} + +void LD10k1File::setCtlValVCount(unsigned int i, unsigned int cnt) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return; + nf->ctl[i].vcount = cnt; +} + +unsigned int LD10k1File::getCtlVal(unsigned int i, unsigned int vi) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return 0; + + if (vi >= nf->ctl[i].vcount) + return 0; + return nf->ctl[i].value[vi]; +} + +void LD10k1File::setCtlVal(unsigned int i, unsigned int vi, unsigned int val) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return; + + if (vi >= nf->ctl[i].vcount) + return; + nf->ctl[i].value[vi] = val; +} + +QString LD10k1File::getPatchName() +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + return nf->patch_name; +} + +void LD10k1File::setPatchName(QString name) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + strncpy(nf->patch_name, name.local8Bit(), MAX_NAME_LEN - 1); + nf->patch_name[MAX_NAME_LEN - 1] = '\0'; +} + +int LD10k1File::LoadFromFile(QString file, LD10k1File **lf) +{ + liblo10k1_dsp_patch_t *nf = NULL; + liblo10k1_file_info_t *fi = NULL; + char fn[1000]; // FIXME file name length + int err; + + strncpy(fn, file.local8Bit(), 999); + fn[999] = '\0'; + if ((err = liblo10k1lf_load_dsp_patch(&nf, fn, &fi)) < 0) + return err; + + LD10k1File *lfi = new LD10k1File(); + lfi->privData->setNativeStruct(nf); + *lf = lfi; + + lfi->fileName = fi->name; + lfi->fileDesc = fi->desc; + lfi->fileCreater = fi->creater; + lfi->fileAuthor = fi->author; + lfi->fileCopyright = fi->copyright; + lfi->fileLicense = fi->license; + + liblo10k1lf_file_info_free(fi); + return 0; +} + +int LD10k1File::SaveToFile(QString file) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + + liblo10k1_file_info_t *fi = liblo10k1lf_file_info_alloc(); + char fn[1000]; // FIXME file name length + int err; + + strncpy(fn, file.local8Bit(), 999); + fn[999] = '\0'; + + fi->name = strdup(fileName.local8Bit()); + fi->desc = strdup(fileDesc.local8Bit()); + fi->creater = strdup(fileCreater.local8Bit()); + fi->author = strdup(fileAuthor.local8Bit()); + fi->copyright = strdup(fileCopyright.local8Bit()); + fi->license = strdup(fileLicense.local8Bit()); + + if ((err = liblo10k1lf_save_dsp_patch(nf, fn, fi)) < 0) + { + liblo10k1lf_file_info_free(fi); + return err; + } + + liblo10k1lf_file_info_free(fi); + return 0; +} + +unsigned int LD10k1File::getCtlMin(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return 0; + + return nf->ctl[i].min; +} + +unsigned int LD10k1File::getCtlMax(unsigned int i) +{ + liblo10k1_dsp_patch_t *nf = privData->getNativeStruct(); + if (i >= nf->ctl_count) + return 0; + + return nf->ctl[i].max; +} + + +class LD10k1DspFilePrivate +{ + liblo10k1_file_dsp_setup_t *ls; +public: + LD10k1DspFilePrivate() + { + ls = liblo10k1lf_dsp_config_alloc(); + } + + ~LD10k1DspFilePrivate() + { + if (ls) + liblo10k1lf_dsp_config_free(ls); + } + + void setNativeStruct(liblo10k1_file_dsp_setup_t *ns) + { + if (ls) + liblo10k1lf_dsp_config_free(ls); + ls = ns; + } + + liblo10k1_file_dsp_setup_t *getNativeStruct() + { + return ls; + } +}; + +LD10k1DspFile::LD10k1DspFile() +{ + privData = new LD10k1DspFilePrivate(); +} + +LD10k1DspFile::~LD10k1DspFile() +{ + if (privData) + delete (privData); +} + +liblo10k1_file_dsp_setup_t *LD10k1DspFile::getLD10k1DspFormat() +{ + return privData->getNativeStruct(); +} + +void LD10k1DspFile::setLD10k1DspFormat(liblo10k1_file_dsp_setup_t *setup) +{ + privData->setNativeStruct(setup); +} + +int LD10k1DspFile::LoadFromFile(QString file, LD10k1DspFile **lf) +{ + liblo10k1_file_dsp_setup_t *nf = NULL; + liblo10k1_file_info_t *fi = NULL; + char fn[1000]; // FIXME file name length + int err; + + strncpy(fn, file.local8Bit(), 999); + fn[999] = '\0'; + if ((err = liblo10k1lf_load_dsp_config(&nf, fn, &fi)) < 0) + return err; + + LD10k1DspFile *lfi = new LD10k1DspFile(); + lfi->privData->setNativeStruct(nf); + *lf = lfi; + + lfi->fileName = fi->name; + lfi->fileDesc = fi->desc; + lfi->fileCreater = fi->creater; + lfi->fileAuthor = fi->author; + lfi->fileCopyright = fi->copyright; + lfi->fileLicense = fi->license; + + liblo10k1lf_file_info_free(fi); + return 0; +} + +int LD10k1DspFile::SaveToFile(QString file) +{ + liblo10k1_file_dsp_setup_t *nf = privData->getNativeStruct(); + + liblo10k1_file_info_t *fi = liblo10k1lf_file_info_alloc(); + char fn[1000]; // FIXME file name length + int err; + + strncpy(fn, file.local8Bit(), 999); + fn[999] = '\0'; + + fi->name = strdup(fileName.local8Bit()); + fi->desc = strdup(fileDesc.local8Bit()); + fi->creater = strdup(fileCreater.local8Bit()); + fi->author = strdup(fileAuthor.local8Bit()); + fi->copyright = strdup(fileCopyright.local8Bit()); + fi->license = strdup(fileLicense.local8Bit()); + + if ((err = liblo10k1lf_save_dsp_config(nf, fn, fi)) < 0) + { + liblo10k1lf_file_info_free(fi); + return err; + } + + liblo10k1lf_file_info_free(fi); + return 0; +} + diff --git a/qlo10k1/src/ld10k1file.h b/qlo10k1/src/ld10k1file.h new file mode 100644 index 0000000..c22f0bd --- /dev/null +++ b/qlo10k1/src/ld10k1file.h @@ -0,0 +1,145 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef LD10K1FILE_H +#define LD10K1FILE_H + +#include +#include +#include +#include "structure.h" + +class EMU10k1FilePrivate; +class LD10k1File; + +struct EMU10k1Ctrl +{ + unsigned int value; + unsigned int min; + unsigned int max; + QString name; +}; + +class EMU10k1File +{ + EMU10k1FilePrivate *privData; +public: + EMU10k1File(); + ~EMU10k1File(); + + static int LoadFromFile(QString file, EMU10k1File **ef); + + int getInCount(); + int getOutCount(); + + int getCtrlCount(); + void getCtrl(unsigned int i, EMU10k1Ctrl *ctrl); + void setCtrl(unsigned int i, EMU10k1Ctrl *ctrl); + QString getPatchName(); + + friend class LD10k1File; +}; + + +class LD10k1FilePrivate; + +class LD10k1FileTransfCtl +{ +public: + int emu_ctls[32]; + int emu_ctl_count; + QString ctl_name; +}; + +class LD10k1File +{ + LD10k1FilePrivate *privData; + QString fileName; + QString fileDesc; + QString fileCreater; + QString fileAuthor; + QString fileCopyright; + QString fileLicense; +public: + enum TranslationType {None, Table100, Bass, Treble, OnOff}; + + LD10k1File(); + ~LD10k1File(); + + QString getPatchName(); + void setPatchName(QString name); + + int getIOCount(bool out); + QString getIOName(bool out, unsigned int i); + void setIOName(bool out, unsigned int i, QString name); + + int getCtlCount(); + QString getCtlName(unsigned int i); + void setCtlName(unsigned int i, QString name); + + TranslationType getCtlTranslation(unsigned int i); + void setCtlTranslation(unsigned int i, TranslationType t); + + int getCtlValCount(unsigned int i); + + unsigned int getCtlMin(unsigned int i); + unsigned int getCtlMax(unsigned int i); + + int getCtlValVCount(unsigned int i); + void setCtlValVCount(unsigned int i, unsigned int cnt); + + unsigned int getCtlVal(unsigned int i, unsigned int vi); + void setCtlVal(unsigned int i, unsigned int vi, unsigned int val); + + static int transformFromEmuFile(EMU10k1File *ef, LD10k1FileTransfCtl *tc, int tc_count, LD10k1File **lf); + liblo10k1_dsp_patch_t *getLD10k1Format(); + void setLD10k1Format(liblo10k1_dsp_patch_t *patch); + + static int LoadFromFile(QString file, LD10k1File **lf); + int SaveToFile(QString file); +}; + +class LD10k1DspFilePrivate; +class CardParam; + +class LD10k1DspFile +{ + LD10k1DspFilePrivate *privData; + QString fileName; + QString fileDesc; + QString fileCreater; + QString fileAuthor; + QString fileCopyright; + QString fileLicense; +public: + LD10k1DspFile(); + ~LD10k1DspFile(); + + liblo10k1_file_dsp_setup_t *getLD10k1DspFormat(); + void setLD10k1DspFormat(liblo10k1_file_dsp_setup_t *setup); + + static int LoadFromFile(QString file, LD10k1DspFile **lf); + int SaveToFile(QString file); + + friend class CardParam; +}; + +#endif // LD10K1FILE_H diff --git a/qlo10k1/src/loadpatchdialog.cpp b/qlo10k1/src/loadpatchdialog.cpp new file mode 100644 index 0000000..5cf6721 --- /dev/null +++ b/qlo10k1/src/loadpatchdialog.cpp @@ -0,0 +1,235 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "app_global.h" +#include "loadpatchdialog.h" +#include "structure_patch.h" +#include "structure_io.h" + +LoadPatchDlg::LoadPatchDlg(StrGlobal *glob, QString efileName, LD10k1File *efile) + : LoadPatchDialogBase() +{ + global = glob; + fileName = efileName; + file = efile; + + leFileName->setText(fileName); + lePatchName->setText(file->getPatchName()); + + // load controls list + int i; + for (i = 0; i < file->getCtlCount(); i++) + { + QString text = getName(i); + lbFileCtrl->insertItem(text); + ctrlFileList.append(i); + } + + for (i = 0; i < file->getIOCount(false); i++) + inputNames.append(file->getIOName(false, i)); + for (i = 0; i < file->getIOCount(true); i++) + outputNames.append(file->getIOName(true, i)); + + for (i = 0; i < file->getIOCount(false); i++) + lbInputs->insertItem(inputNames[i]); + + for (i = 0; i < file->getIOCount(true); i++) + lbOutputs->insertItem(outputNames[i]); + + // create sorted patch list + sortedPatches.clear(); + + for (StrPatch *onePatch = global->Patches.first(); onePatch; onePatch = global->Patches.next()) + { + i = 0; + bool found = false; + for (StrPatch *secondPatch = sortedPatches.first(); secondPatch; secondPatch = sortedPatches.next()) + { + if (onePatch->order() < secondPatch->order()) + { + sortedPatches.insert(i, onePatch); + found = true; + break; + } + i++; + } + + if (!found) + sortedPatches.append(onePatch); + } + + // fill combobox + cbWhere->clear(); + + for (StrPatch *p = sortedPatches.first(); p; p = sortedPatches.next()) + cbWhere->insertItem(QString().sprintf("%03d %03d ", p->order(), p->num()) + p->name()); + + cbWhere->setCurrentItem(sortedPatches.count() - 1); + cbBefAfter->setCurrentItem(1); + + setBefore(1, sortedPatches.count() - 1); + + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + connect(lbInputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(inputsDoubleClicked(QListBoxItem *))); + connect(lbOutputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(outputsDoubleClicked(QListBoxItem *))); + + connect(lbFileCtrl, SIGNAL(selectionChanged()), this, SLOT(fileSelectionChanged())); + + connect(cbBefAfter, SIGNAL(activated(int)), this, SLOT(befAfterActivated(int))); + connect(cbWhere, SIGNAL(activated(int)), this, SLOT(whereActivated(int))); +} + +QString LoadPatchDlg::getName(int i) +{ + return file->getCtlName(i); +} + +void LoadPatchDlg::okClicked() +{ + // load patch + done(Accepted); +} + +void LoadPatchDlg::cancelClicked() +{ + done(Rejected); +} + +void LoadPatchDlg::inputsDoubleClicked(QListBoxItem *item) +{ + bool ok; + int idx = lbInputs->index(item); + QString text = inputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Input name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + inputNames[idx] = text; + lbInputs->changeItem(text, idx); + } +} + +void LoadPatchDlg::outputsDoubleClicked(QListBoxItem *item) +{ + bool ok; + int idx = lbOutputs->index(item); + QString text = outputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Output name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + outputNames[idx] = text; + lbOutputs->changeItem(text, idx); + } +} + +void LoadPatchDlg::fileSelectionChanged() +{ + QListBoxItem *item = lbFileCtrl->selectedItem(); + if (!item) + { + leTranslation->setText(""); + leMin->setText(""); + leMax->setText(""); + lbValues->clear(); + lbValues->setEnabled(false); + } + else + { + int iidx = lbFileCtrl->index(item); + int i; + QString transl; + + switch (file->getCtlTranslation(iidx)) + { + case LD10k1File::None: + transl = "None"; + break; + case LD10k1File::Table100: + transl = "Table100"; + break; + case LD10k1File::Bass: + transl = "Bass"; + break; + case LD10k1File::Treble: + transl = "Treble"; + break; + case LD10k1File::OnOff: + transl = "On/Off"; + break; + } + + leTranslation->setText(transl); + leMin->setText(QString().setNum(file->getCtlMin(iidx))); + leMax->setText(QString().setNum(file->getCtlMax(iidx))); + lbValues->clear(); + + for (i = 0; i < file->getCtlValVCount(iidx); i++) + lbValues->insertItem(QString("%1 : %2").arg(i).arg(file->getCtlVal(iidx, i))); + + lbValues->setEnabled(false); + } +} + +StrPatch *LoadPatchDlg::whereLoad() +{ + return before; +} + +void LoadPatchDlg::setBefore(int i1, int i2) +{ + if (i1) + { + if (i2 < (int)sortedPatches.count() - 1) + before = sortedPatches.at(i2 + 1); + else + before = NULL; + } + else + before = sortedPatches.at(i2); +} + +void LoadPatchDlg::whereActivated(int index) +{ + setBefore(cbBefAfter->currentItem(), index); +} + +void LoadPatchDlg::befAfterActivated(int index) +{ + setBefore(index, cbWhere->currentItem()); +} diff --git a/qlo10k1/src/loadpatchdialog.h b/qlo10k1/src/loadpatchdialog.h new file mode 100644 index 0000000..832a029 --- /dev/null +++ b/qlo10k1/src/loadpatchdialog.h @@ -0,0 +1,71 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef LOADPATCHDIALOG_H +#define LOADPATCHDIALOG_H + +#include +#include +#include +#include "dlgs/loadpatchdialogbase.h" +#include "filecontroldialog.h" +#include "connectionwizard.h" +#include "structure.h" +#include "structure_patch.h" +#include "ld10k1file.h" + +class LoadPatchDlg : public LoadPatchDialogBase +{ + Q_OBJECT + StrGlobal *global; + LD10k1File *file; + QString fileName; + QStringList inputNames; + QStringList outputNames; + + QValueList ctrlFileList; + QValueList translatedList; + + QPtrList sortedPatches; + + StrPatch *before; + + void setBefore(int i1, int i2); +public: + + LoadPatchDlg(StrGlobal *glob, QString efileName, LD10k1File *efile); + + QString getName(int i); + StrPatch *whereLoad(); +public slots: + void okClicked(); + void cancelClicked(); + + void inputsDoubleClicked(QListBoxItem *item); + void outputsDoubleClicked(QListBoxItem *item); + + void fileSelectionChanged(); + + void whereActivated(int index); + void befAfterActivated(int index); +}; + +#endif // LOADPATCHDIALOG_H diff --git a/qlo10k1/src/main.cpp b/qlo10k1/src/main.cpp new file mode 100644 index 0000000..b156d57 --- /dev/null +++ b/qlo10k1/src/main.cpp @@ -0,0 +1,32 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include "mainwnd.h" + +int main( int argc, char ** argv ) +{ + QApplication a( argc, argv ); + MainWnd w; + w.show(); + a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); + return a.exec(); +} diff --git a/qlo10k1/src/mainwnd.cpp b/qlo10k1/src/mainwnd.cpp new file mode 100644 index 0000000..96ea316 --- /dev/null +++ b/qlo10k1/src/mainwnd.cpp @@ -0,0 +1,550 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "app_global.h" +#include "mainwnd.h" +#include "preferences.h" +#include "loadpatchdialog.h" +#include "transformpatchdialog.h" +#include "aboutdialog.h" +#include "routingwidget.h" +#include "structure_patch.h" +#include "strparam.h" + +class PatchesListViewItem : public QListViewItem +{ +public: + StrPatch *patch; + + PatchesListViewItem(StrPatch *p, QListView *parent) : QListViewItem(parent) + { + patch = p; + updateText(); + } + + PatchesListViewItem(StrPatch *p, QListView *parent, PatchesListViewItem *after) : QListViewItem(parent, after) + { + patch = p; + updateText(); + } + + void updateText() + { + setText(0,QString().sprintf("%03d", patch->order())); + setText(1,QString().sprintf("%03d", patch->num())); + setText(2,patch->name()); + } +}; + +MainWnd::MainWnd() : MainWndBase() +{ + cardGlobal = new StrCardGlobal(); + CurrentCard = NULL; + + // try to load settings + loadSettings(); + + // main menu + QPopupMenu *fileMenu = new QPopupMenu(); + fileMenu->insertItem(tr("&Load DSP config"), this, SLOT(menuLoadDSPConfigActivated(int))); + fileMenu->insertItem(tr("&Save DSP config"), this, SLOT(menuSaveDSPConfigActivated(int))); + fileMenu->insertSeparator(); + fileMenu->insertItem(tr("&Quit"), this, SLOT(menuQuitActivated(int))); + + menubar->insertItem(tr("&File"), fileMenu); + + cardMenu = new QPopupMenu(); + menubar->insertItem(tr("&Card"), cardMenu); + cardMenu->setCheckable(true); + + QPopupMenu *settingMenu = new QPopupMenu(); + settingMenu->insertItem(tr("&Main settings"), this, SLOT(menuSettingsActivated(int))); + menubar->insertItem(tr("&Settings"), settingMenu); + + QPopupMenu *helpMenu = new QPopupMenu(); + helpMenu->insertItem(tr("&About"), this, SLOT(menuHelpAboutActivated(int))); + menubar->insertItem(tr("&Help"), helpMenu); + + // connect signals + connect((QObject *)tabMain, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabMainCurrentChanged(QWidget *))); + + createCardMenu(); + enableTabs(false); + + setCaption(tr(APP_NAME)); + + connect(pbLoad, SIGNAL(clicked()), this, SLOT(loadClicked())); + connect(pbUnload, SIGNAL(clicked()), this, SLOT(unloadClicked())); + + connect(lvPatches, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(patchDoubleClicked(QListViewItem *))); + + routing = new RoutingWidget(tabRouting); + + tabRoutingLayout->addWidget(routing, 0, 0); + routing->show(); +} + +MainWnd::~MainWnd() +{ + CurrentCard = NULL; + delete cardGlobal; +} + +void MainWnd::tabMainCurrentChanged(QWidget *tab) +{ + if (!CurrentCard) + return; + if (tab == tabLoad) + { + loadPatchesList(lvPatches); + } + else if (tab == tabRouting) + { + routing->refreshDrawing(CurrentCard); + } +} + +void MainWnd::loadPatchesList(QListView *lv) +{ + StrPatch *patch; + + lv->clear(); + PatchesListViewItem *after = NULL; + for(patch = CurrentCard->Patches.first(); patch; patch = CurrentCard->Patches.next() ) + { + if (after) + after = new PatchesListViewItem(patch, lv, after); + else + after = new PatchesListViewItem(patch, lv); + } +} + +void MainWnd::patchesUpdateText() +{ + QListViewItemIterator it(lvPatches); + while (it.current()) + { + PatchesListViewItem *i = (PatchesListViewItem *)it.current(); + i->updateText(); + ++it; + } +} + +void MainWnd::menuQuitActivated(int /*id*/) +{ + qApp->quit(); +} + +void MainWnd::menuLoadDSPConfigActivated(int id) +{ + if (!CurrentCard) + return; + QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setMode(QFileDialog::ExistingFile); + fd->setFilter("DSP config (*.ld10k1)"); + fd->setCaption("Save DSP config"); + int err = 0; + + QString fileName; + if (fd->exec() == QDialog::Accepted) + { + fileName = fd->selectedFile(); + delete fd; + + LD10k1DspFile *dc = NULL; + if ((err = dc->LoadFromFile(fileName, &dc)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load DSP config\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + return; + } + + if ((err = CurrentCard->putDspConfig(dc)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't put DSP config\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + delete dc; + CurrentCard->clear(); + CurrentCard->loadFromLD(); + refreshState(); + } + else + delete fd; +} + +void MainWnd::menuSaveDSPConfigActivated(int id) +{ + if (!CurrentCard) + return; + QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setMode(QFileDialog::AnyFile); + fd->setFilter("DSP config (*.ld10k1)"); + fd->setCaption("Save DSP config"); + int err = 0; + + QString fileName; + if (fd->exec() == QDialog::Accepted) + { + fileName = fd->selectedFile(); + delete fd; + + if (!fileName.endsWith(".ld10k1")) + fileName += ".ld10k1"; + if (QFile::exists(fileName)) + { + if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exist. Overwite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) + return; + } + + LD10k1DspFile *dc = NULL; + if ((err = CurrentCard->getDspConfig(&dc)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't get DSP config\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + return; + } + + if ((err = dc->SaveToFile(fileName)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't save DSP config\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + delete dc; + } + else + delete fd; +} + +void MainWnd::refreshState() +{ + tabMainCurrentChanged(tabMain->currentPage()); +} + +void MainWnd::menuCardActivated(int id) +{ + CardParam *card; + CardParam *old_card, *new_card; + int item_id = 0, old_item_id = 0; + + new_card = NULL; + if (CurrentCard && CurrentCard->Card->isConnected()) + old_card = CurrentCard->Card; + else + old_card = NULL; + + for (unsigned int i = 0; i < cardMenuItems.count(); i++) + { + item_id = cardMenuItems[i]; + card = cardGlobal->Cards.at(i); + if (cardMenu->isItemChecked(item_id)) + old_item_id = item_id; + + if (id == item_id) + new_card = card; + } + + if (new_card && new_card != old_card) + { + if (!new_card->connect()) + { + cardMenu->setItemChecked(id, true); + enableTabs(true); + CurrentCard = new_card->getStructure(); + // FIXME - refresh data + CurrentCard->loadFromLD(); + refreshState(); + + if (old_card) + { + old_card->disconnect(); + cardMenu->setItemChecked(old_item_id, false); + } + } + } +} + +void MainWnd::menuSettingsActivated(int /*id*/) +{ + PreferencesDlg d(cardGlobal); + int item_id; + + if (CurrentCard && CurrentCard->Card->isConnected()) + { + CurrentCard->Card->disconnect(); + CurrentCard = NULL; + enableTabs(false); + + for (unsigned int i = 0; i < cardMenuItems.count(); i++) + { + item_id = cardMenuItems[i]; + cardMenu->setItemChecked(item_id, false); + } + } + + if (d.exec() == QDialog::Accepted) + { + saveSettings(); + createCardMenu(); + } +} + +void MainWnd::menuHelpAboutActivated(int /* id */) +{ + AboutDlg d; + d.exec(); +} + +void MainWnd::menuCardClearDSPActivated(int /* id */) +{ + if (CurrentCard) + { + CurrentCard->clearDSP(); + refreshState(); + } +} + +void MainWnd::menuCardRefreshActivated(int /* id */) +{ + if (CurrentCard) + CurrentCard->loadFromLD(); + + refreshState(); +} + +void MainWnd::enableTabs(bool en) +{ + if (en) + { + tabLoad->setEnabled(true); + tabRouting->setEnabled(true); + } + else + { + tabLoad->setEnabled(false); + tabRouting->setEnabled(false); + } +} + +void MainWnd::createCardMenu(void) +{ + CardParam *card; + int id; + + for (unsigned int i = 0; i < cardMenuItems.count() ;i++) + { + cardMenu->disconnectItem(cardMenuItems[i], this, SLOT(menuCardActivated(int))); + } + + cardMenuItems.clear(); + cardMenu->clear(); + for (unsigned int i = 0; i < cardGlobal->Cards.count() ;i++) + { + card = cardGlobal->Cards.at(i); + id = cardMenu->insertItem(card->CardName); + cardMenuItems.append(id); + cardMenu->connectItem(id, this, SLOT(menuCardActivated(int))); + } + + // special items + cardMenu->insertSeparator(); + cardMenu->insertItem(tr("&Refresh"), this, SLOT(menuCardRefreshActivated(int))); + cardMenu->insertItem(tr("&Clear DSP"), this, SLOT(menuCardClearDSPActivated(int))); +} + +void MainWnd::loadClicked() +{ + QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setMode(QFileDialog::ExistingFile); + fd->setFilter("Patches (*.emu10k1 *.ld10k1)"); + fd->setCaption("Load patch"); + int err = 0; + + QString fileName; + if ( fd->exec() == QDialog::Accepted ) + { + fileName = fd->selectedFile(); + delete fd; + LD10k1File *ldfile = NULL; + if (fileName.endsWith(".emu10k1")) + { + EMU10k1File *emufile = NULL; + if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + return; + } + else + { + TransformPatchDlg d(fileName, emufile); + if (d.exec() == QDialog::Accepted) + { + if ((err = d.transformFile(&ldfile)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't transform patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + delete emufile; + return; + } + delete emufile; + } + else + { + delete emufile; + return; + } + } + } + else + { + if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + return; + } + } + + LoadPatchDlg d(CurrentCard, fileName, ldfile); + + if (d.exec() == QDialog::Accepted) + { + // and now convert to loader + StrPatch *loaded = NULL; + if ((err = CurrentCard->load(ldfile, d.whereLoad(), &loaded)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + else + refreshState(); + } + delete ldfile; + } + else + delete fd; +} + +void MainWnd::unloadClicked() +{ + PatchesListViewItem *current = (PatchesListViewItem *)lvPatches->currentItem(); + int err; + + if (current) + { + // find patch index + StrPatch *p = current->patch; + if ((err = CurrentCard->unload(p))) + QMessageBox::critical(0, APP_NAME, QString("Couldn't unload patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); + else + refreshState(); + } +} + +void MainWnd::patchDoubleClicked(QListViewItem *item) +{ + /*int patch_num = item->text(0).toInt(); + int err; + + liblo10k1_dsp_patch_t *patch = NULL; + if ((err = global->CurrentCard->get(patch_num, &patch))) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't get patch\n(ld10k1 error:%1)").arg(global->CurrentCard->error_str(err))); + return; + }*/ +} + +void MainWnd::saveSettings() +{ + QSettings settings(QSettings::Ini); + settings.setPath("pzad", "qlo10k1", QSettings::User); + + settings.beginGroup("/qlo10k1"); + settings.writeEntry("/Version", "0.0.1"); + settings.writeEntry("/RepDirSystem", cardGlobal->RepDirSystem); + settings.writeEntry("/RepDirUser", cardGlobal->RepDirUser); + + // first save cards + settings.beginGroup("/Cards"); + settings.writeEntry("/CardCount", (int)cardGlobal->Cards.count()); + for (unsigned int i = 0; i < cardGlobal->Cards.count(); i++) + { + settings.beginGroup(QString("/Card_%1").arg(i)); + CardParam *card = cardGlobal->Cards.at(i); + + settings.writeEntry("/Name", card->CardName); + settings.writeEntry("/Socket", card->CardSocket); + + settings.endGroup(); + } + // write current card + settings.endGroup(); +} + +void MainWnd::loadSettings() +{ + QSettings settings(QSettings::Ini); + settings.setPath("pzad", "qlo10k1", QSettings::User); + settings.beginGroup("/qlo10k1"); + + QString version = settings.readEntry("/Version", ""); + if (version == "") + { + // settings doesn't exists + cardGlobal->RepDirSystem = ""; + cardGlobal->RepDirUser = ""; + + CardParam *card = new CardParam(); + card->CardName = "Default card"; + card->CardSocket = "/tmp/.ld10k1_port"; + + if (!card->testConnection()) + { + cardGlobal->Cards.append(card); + } + } + else + { + cardGlobal->RepDirSystem = settings.readEntry("/RepDirSystem", ""); + cardGlobal->RepDirUser = settings.readEntry("/RepDirUser", ""); + + settings.beginGroup("/Cards"); + + unsigned int cardCount = settings.readNumEntry("/CardCount", 0); + for (unsigned int i = 0; i < cardCount; i++) + { + settings.beginGroup(QString("/Card_%1").arg(i)); + + CardParam *card = new CardParam(); + card->CardName = settings.readEntry("/Name", ""); + card->CardSocket = settings.readEntry("/Socket", ""); + + if (!card->testConnection()) + { + cardGlobal->Cards.append(card); + } + + settings.endGroup(); + } + + + settings.endGroup(); + } +} diff --git a/qlo10k1/src/mainwnd.h b/qlo10k1/src/mainwnd.h new file mode 100644 index 0000000..89a06b9 --- /dev/null +++ b/qlo10k1/src/mainwnd.h @@ -0,0 +1,77 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef MAINWND_H +#define MAINWND_H + +#include "dlgs/mainwndbase.h" +#include "structure.h" +#include "strglobal.h" + +class QPopupMenu; +class RoutingWidget; + +class MainWnd : public MainWndBase +{ + Q_OBJECT + StrCardGlobal *cardGlobal; + StrGlobal *CurrentCard; + + QPopupMenu *cardMenu; + QValueList cardMenuItems; + RoutingWidget *routing; +public: + MainWnd(void); + ~MainWnd(void); + + void enableTabs(bool en); + + void createCardMenu(void); + void loadPatchesList(QListView *lv); + void refreshState(); + + void saveSettings(); + void loadSettings(); + + void patchesUpdateText(); +public slots: + // menu + void menuLoadDSPConfigActivated(int id); + void menuSaveDSPConfigActivated(int id); + void menuQuitActivated(int id); + + + void menuCardActivated(int id); + void menuSettingsActivated(int id); + void menuHelpAboutActivated(int id); + + void menuCardClearDSPActivated(int id); + void menuCardRefreshActivated(int id); + + void tabMainCurrentChanged(QWidget *tab); + + void loadClicked(); + void unloadClicked(); + + void patchDoubleClicked(QListViewItem *item); +}; + +#endif // MAINWND_H diff --git a/qlo10k1/src/newiodialog.cpp b/qlo10k1/src/newiodialog.cpp new file mode 100644 index 0000000..fb1ef4d --- /dev/null +++ b/qlo10k1/src/newiodialog.cpp @@ -0,0 +1,160 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include + +#include "newiodialog.h" +#include "routingwidget.h" +#include "structure_io.h" +#include "strparam.h" + +class IOListViewItem : public QListViewItem +{ +public: + int num; + QString name; + + IOListViewItem(int n, QString na, QListView *parent) : QListViewItem(parent) + { + num = n; + name = na; + updateText(); + } + + IOListViewItem(int n, QString na, QListView *parent, IOListViewItem *after) : QListViewItem(parent, after) + { + num = n; + name = na; + updateText(); + } + + void updateText() + { + setText(0, QString().sprintf("%03d", num)); + setText(1, name); + } +}; + +NewIODlg::NewIODlg(StrGlobal *glob, DlgType t) + : NewIODialogBase() +{ + global = glob; + dt = t; + + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + QString title; + QString columnTitle; + + switch (dt) + { + case In: + title = "New input"; + columnTitle = "Input"; + break; + case Out: + title = "New output"; + columnTitle = "Output"; + break; + case FX: + title = "New FX bus"; + columnTitle = "FX bus"; + break; + } + + IOListViewItem *after = NULL; + int cnt; + + lvIOs->clear(); + + if (dt == In) + global->Card->getInputCount(&cnt); + else if (dt == Out) + global->Card->getOutputCount(&cnt); + else + global->Card->getFXCount(&cnt); + + for (int i = 0; i < cnt; i++) + { + QString ioname; + bool used = false; + + if (dt == In) + used = global->findInputByNum(i) != NULL; + else if (dt == Out) + used = global->findOutputByNum(i) != NULL; + else + used = global->findFXByNum(i) != NULL; + + if (!used) + { + if (dt == In) + global->Card->getInput(i, ioname); + else if (dt == Out) + global->Card->getOutput(i, ioname); + else + global->Card->getFX(i, ioname); + + + if (after) + after = new IOListViewItem(i, ioname, lvIOs, after); + else + after = new IOListViewItem(i, ioname, lvIOs); + } + } + + setCaption(title); + lvIOs->setColumnText(1, columnTitle); + + connect(lvIOs, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(ioSelectionChanged(QListViewItem *))); +} + + +void NewIODlg::okClicked() +{ + done(Accepted); +} + +void NewIODlg::cancelClicked() +{ + done(Rejected); +} + +void NewIODlg::ioSelectionChanged(QListViewItem *item) +{ + IOListViewItem *ioitem = (IOListViewItem *)item; + + num = ioitem->num; + name = ioitem->name; + pbOK->setEnabled(true); +} + +StrIOBase *NewIODlg::getNewIO() +{ + if (dt == In) + return new StrInput(num, name); + else if (dt == Out) + return new StrOutput(num, name); + else + return new StrFX(num, name); +} diff --git a/qlo10k1/src/newiodialog.h b/qlo10k1/src/newiodialog.h new file mode 100644 index 0000000..b5ff392 --- /dev/null +++ b/qlo10k1/src/newiodialog.h @@ -0,0 +1,53 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef NEWIODIALOG_H +#define NEWIODIALOG_H + +#include "dlgs/newiodialogbase.h" +#include "strglobal.h" + +class StrIOBase; + +class NewIODlg : public NewIODialogBase +{ + Q_OBJECT +public: + enum DlgType {In, Out, FX}; +private: + StrGlobal *global; + DlgType dt; + + int num; + QString name; +public: + NewIODlg(StrGlobal *glob, DlgType t); + + StrIOBase *getNewIO(); +public slots: + void okClicked(); + void cancelClicked(); + + void ioSelectionChanged(QListViewItem *item); +}; + +#endif // NEWIODIALOG_H + diff --git a/qlo10k1/src/patchdialog.cpp b/qlo10k1/src/patchdialog.cpp new file mode 100644 index 0000000..035c763 --- /dev/null +++ b/qlo10k1/src/patchdialog.cpp @@ -0,0 +1,312 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include + +#include "patchdialog.h" +#include "structure_patch.h" + +PatchDlg::PatchDlg(StrGlobal *glob, StrPatch *p) + : PatchDialogBase() +{ + global = glob; + patch = p; + + lePatchName->setText(p->name()); + + // load controls list + /* + FIXME + int i; + for (i = 0; i < file->ctrl_count; i++) + { + QString text = getName(i); + lbFileCtrl->insertItem(text); + ctrlFileList.append(i); + }*/ + + // set default in names + /* FIXME + switch (file->in_count) + { + case 1: + inputNames.append("I"); + break; + case 2: + inputNames.append("IL"); + inputNames.append("IR"); + break; + case 4: + inputNames.append("IL"); + inputNames.append("IR"); + inputNames.append("IRL"); + inputNames.append("IRR"); + break; + case 6: + inputNames.append("IL"); + inputNames.append("IR"); + inputNames.append("IRL"); + inputNames.append("IRR"); + inputNames.append("IC"); + inputNames.append("ILFE"); + break; + default: + for (i = 0; i < file->in_count; i++) + inputNames.append(""); + break; + } + + // set default out names + switch (file->out_count) + { + case 1: + outputNames.append("O"); + break; + case 2: + outputNames.append("OL"); + outputNames.append("OR"); + break; + case 4: + outputNames.append("OL"); + outputNames.append("OR"); + outputNames.append("ORL"); + outputNames.append("ORR"); + break; + case 6: + outputNames.append("OL"); + outputNames.append("OR"); + outputNames.append("ORL"); + outputNames.append("ORR"); + outputNames.append("OC"); + outputNames.append("OLFE"); + break; + default: + for (i = 0; i < file->out_count; i++) + outputNames.append(""); + break; + } + + for (i = 0; i < file->in_count; i++) + { + lbInputs->insertItem(inputNames[i]); + + RouteInfo r; + inRoutes.append(r); + + lbConnInputs->insertItem(getRouteName(false, i)); + } + + for (i = 0; i < file->out_count; i++) + { + lbOutputs->insertItem(outputNames[i]); + + RouteInfo r; + outRoutes.append(r); + + lbConnOutputs->insertItem(getRouteName(true, i)); + } + */ + + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + connect(lbInputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(inputsDoubleClicked(QListBoxItem *))); + connect(lbOutputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(outputsDoubleClicked(QListBoxItem *))); + + /*connect(pbCtrlAdd, SIGNAL(clicked()), this, SLOT(ctrlAddClicked())); + connect(pbCtrlDel, SIGNAL(clicked()), this, SLOT(ctrlDelClicked())); + + connect(lbLoadedCtrl, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(loadedDoubleClicked(QListBoxItem *))); + connect(lbFileCtrl, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(fileDoubleClicked(QListBoxItem *))); +*/ + connect(lbConnInputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(connInputsDoubleClicked(QListBoxItem *))); + connect(lbConnOutputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(connOutputsDoubleClicked(QListBoxItem *))); +/* + connect(cbInsertInRep, SIGNAL(stateChanged(int)), this, SLOT(insertInRepStateChanged(int))); + + connect(rbArchBoth, SIGNAL(clicked()), this, SLOT(archBothClicked())); + connect(rbArchEmu10k1, SIGNAL(clicked()), this, SLOT(archEmu10k1Clicked())); + connect(rbArchEmu10k2, SIGNAL(clicked()), this, SLOT(archEmu10k2Clicked())); + + tabRepository2->setEnabled(false);*/ +} + +/*QString LoadPatchDlg::getName(int i) +{ + EMU10k1CtrlReg *ctrl; + + ctrl = &(file->ctrls[i]); + QString name = QString(ctrl->name) + " - " + QString().setNum(ctrl->value) + + " (" + QString().setNum(ctrl->min) + "," + + QString().setNum(ctrl->max) + ")"; + return name; +}*/ + +/*QString LoadPatchDlg::getRouteName(bool output, int i) +{ + QString name; + RouteInfo ri; + + if (output) + { + name = outputNames[i]; + ri = outRoutes[i]; + } + else + { + name = inputNames[i]; + ri = inRoutes[i]; + } + + switch (ri.io) + { + case RouteInfo::None: + break; + case RouteInfo::FX: + name += QString(" -> FX:") + global->Registers.at(ri.reg)->name(); + break; + case RouteInfo::In: + name += QString(" -> In:") + global->Registers.at(ri.reg)->name(); + break; + case RouteInfo::Out: + name += QString(" -> Out:") + global->Registers.at(ri.reg)->name(); + break; + case RouteInfo::PatchIn: + case RouteInfo::PatchOut: + StrPatch *patch = global->Patches.at(ri.patch); + if (ri.io == RouteInfo::PatchIn) + name += QString(" -> In:") + patch->name() + "-" + patch->Registers.at(ri.reg)->name(); + else + name += QString(" -> Out:") + patch->name() + "-" + patch->Registers.at(ri.reg)->name(); + break; + } + + return name; +}*/ + +void PatchDlg::okClicked() +{ + // update routing and rename patch + done(Accepted); +} + +void PatchDlg::cancelClicked() +{ + done(Rejected); +} + +void PatchDlg::inputsDoubleClicked(QListBoxItem *item) +{ + /*bool ok; + int idx = lbInputs->index(item); + QString text = inputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Input name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + inputNames[idx] = text; + lbInputs->changeItem(text, idx); + lbConnInputs->changeItem(getRouteName(false, idx), idx); + }*/ +} + +void PatchDlg::outputsDoubleClicked(QListBoxItem *item) +{ + /*bool ok; + int idx = lbOutputs->index(item); + QString text = outputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Output name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + outputNames[idx] = text; + lbOutputs->changeItem(text, idx); + lbConnOutputs->changeItem(getRouteName(false, idx), idx); + }*/ +} + + +void PatchDlg::connInputsDoubleClicked(QListBoxItem *item) +{ + /*int idx = lbConnInputs->index(item); + RouteInfo ri = inRoutes[idx]; + + ConnectionWizard d(false, global, &ri); + + if (d.exec() == QDialog::Accepted) + { + inRoutes[idx] = ri; + lbConnInputs->changeItem(getRouteName(false, idx), idx); + } + */ +} + +void PatchDlg::connOutputsDoubleClicked(QListBoxItem *item) +{ + /*int idx = lbConnOutputs->index(item); + RouteInfo ri = outRoutes[idx]; + + ConnectionWizard d(true, global, &ri); + + if (d.exec() == QDialog::Accepted) + { + outRoutes[idx] = ri; + lbConnOutputs->changeItem(getRouteName(true, idx), idx); + }*/ +} + + +/*LD10k1Route LoadPatchDlg::getRoute(bool out, int idx) +{ + RouteInfo *route; + if (out) + route = &(outRoutes[idx]); + else + route = &(inRoutes[idx]); + + LD10k1Route nroute; + + nroute.PatchTo = route->patch; + nroute.Multi = route->multi; + + if (route->patch >= 0 && route->reg >= 0) + { + StrPatch *patch = global->Patches.at(route->patch); + StrRegister *reg = patch->Registers.at(route->reg); + nroute.RegTo = reg->idx(); + } + else if (route->reg >= 0) + { + StrRegister *reg = global->Registers.at(route->reg); + nroute.RegTo = reg->phIdx(); + } + else + { + nroute.RegTo = -1; + } + + return nroute; +} +*/ diff --git a/qlo10k1/src/patchdialog.h b/qlo10k1/src/patchdialog.h new file mode 100644 index 0000000..adbf891 --- /dev/null +++ b/qlo10k1/src/patchdialog.h @@ -0,0 +1,79 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef PATCHDIALOG_H +#define PATCHDIALOG_H + +#include "dlgs/patchdialogbase.h" +#include "strglobal.h" + +class PatchDlg : public PatchDialogBase +{ + Q_OBJECT + StrGlobal *global; + /*EMU10k1File *file; + QString fileName;*/ + QStringList inputNames; + QStringList outputNames; + + /*QValueList ctrlFileList; + QValueList translatedList; + QValueList inRoutes; + QValueList outRoutes;*/ + + //LD10k1Route getRoute(bool out, int idx); + StrPatch *patch; +public: + + PatchDlg(StrGlobal *glob, StrPatch *p); + + QString getName(int i); + QString getRouteName(bool output, int i); + + /*void enableSBLive(bool en); + void enableAudigy(bool en); + + void transformFile(LD10k1File **outFile, QValueList *routes);*/ +public slots: + void okClicked(); + void cancelClicked(); + + void inputsDoubleClicked(QListBoxItem *item); + void outputsDoubleClicked(QListBoxItem *item); + + /*void ctrlAddClicked(); + void ctrlDelClicked(); + + void loadedDoubleClicked(QListBoxItem *item); + void fileDoubleClicked(QListBoxItem *item);*/ + + void connInputsDoubleClicked(QListBoxItem *item); + void connOutputsDoubleClicked(QListBoxItem *item); + + /*void insertInRepStateChanged(int state); + + void archBothClicked(); + void archEmu10k1Clicked(); + void archEmu10k2Clicked();*/ +}; + +#endif // PATCHDIALOG_H + diff --git a/qlo10k1/src/preferences.cpp b/qlo10k1/src/preferences.cpp new file mode 100644 index 0000000..72811d0 --- /dev/null +++ b/qlo10k1/src/preferences.cpp @@ -0,0 +1,175 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "preferences.h" +#include "app_global.h" +#include "strparam.h" + +PreferencesDlg::PreferencesDlg(StrCardGlobal *glob) +{ + global = glob; + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + connect(lbCards, SIGNAL(highlighted(int)), this, SLOT(cardHighlighted(int))); + + connect(pbUpdate, SIGNAL(clicked()), this, SLOT(updateClicked())); + connect(pbCardAdd, SIGNAL(clicked()), this, SLOT(cardAddClicked())); + connect(pbCardDel, SIGNAL(clicked()), this, SLOT(cardDelClicked())); + + // copy card list + for (unsigned int i = 0; i < global->Cards.count(); i++) + cards.append(new CardParam(global->Cards.at(i))); + + refreshListBox(); + + if (cards.count() > 1) + pbCardDel->setEnabled(true); + repDirSystem = global->RepDirSystem; + repDirUser = global->RepDirUser; + + leRepSystem->setText(repDirSystem); + leRepUser->setText(repDirUser); +} + +void PreferencesDlg::okClicked() +{ + unsigned int i; + CardParam *card; + for (i = 0; i < cards.count(); i++) + { + // test connection + card = cards.at(i); + if (card->testConnection()) + { + // error + QMessageBox::critical( 0, APP_NAME, + QString("Couldn't connect to socket %1 for card %2").arg(card->CardSocket).arg(card->CardName)); + return; + } + } + + // copy values to global + global->Cards.clear(); + for (i = 0; i < cards.count(); i++) + global->Cards.append(new CardParam(cards.at(i))); + + global->RepDirSystem = repDirSystem; + global->RepDirUser = repDirUser; + + done(Accepted); +} + +void PreferencesDlg::cancelClicked() +{ + done(Rejected); +} + +void PreferencesDlg::refreshListBox(void) +{ + lbCards->clear(); + + CardParam *card; + QString desc; + + for (unsigned int i = 0; i < cards.count() ;i++) + { + card = cards.at(i); + desc = card->CardName + " - " + card->CardSocket; + lbCards->insertItem(desc); + } +} + +void PreferencesDlg::refreshListBox(int idx) +{ + CardParam *card; + QString desc; + + card = cards.at(idx); + desc = card->CardName + " - " + card->CardSocket; + lbCards->changeItem(desc, idx); +} + + +void PreferencesDlg::cardHighlighted(int index) +{ + CardParam *card; + + if (index >= 0 && (unsigned int)index < cards.count()) + { + card = cards.at(index); + leCardName->setText(card->CardName); + leCardSocket->setText(card->CardSocket); + gbCard->setEnabled(true); + } + else + { + leCardName->setText(""); + leCardSocket->setText(""); + gbCard->setEnabled(false); + } +} + +void PreferencesDlg::updateClicked() +{ + int idx = lbCards->currentItem(); + + if (idx >=0 && (unsigned int)idx < cards.count()) + { + CardParam *card; + + card = cards.at(idx); + + card->CardName = leCardName->text(); + card->CardSocket = leCardSocket->text(); + refreshListBox(idx); + } +} + +void PreferencesDlg::cardAddClicked() +{ + CardParam *card = new CardParam(); + card->CardName = "Default card"; + card->CardSocket = "/tmp/.ld10k1_port"; + cards.append(card); + refreshListBox(); +} + +void PreferencesDlg::cardDelClicked() +{ + int idx = lbCards->currentItem(); + + if (idx >= 0) + { + cards.remove(idx); + + if (cards.count() <= 1) + pbCardDel->setEnabled(false); + refreshListBox(); + } +} diff --git a/qlo10k1/src/preferences.h b/qlo10k1/src/preferences.h new file mode 100644 index 0000000..640672d --- /dev/null +++ b/qlo10k1/src/preferences.h @@ -0,0 +1,56 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef PREFERENCES_H +#define PREFERENCES_H + +#include + +#include "dlgs/preferencesbase.h" +#include "strglobal.h" + +class PreferencesDlg : public PreferencesBase +{ + Q_OBJECT + StrCardGlobal *global; + QPtrList cards; + QString repDirSystem; + QString repDirUser; +public: + PreferencesDlg(StrCardGlobal *glob); + void refreshListBox(void); + void refreshListBox(int idx); + + void refreshRepListBox(void); + void refreshRepListBox(int idx); +public slots: + + void cardHighlighted(int index); + + void okClicked(); + void cancelClicked(); + + void updateClicked(); + void cardAddClicked(); + void cardDelClicked(); +}; + +#endif // PREFERENCES_H diff --git a/qlo10k1/src/routingwidget.cpp b/qlo10k1/src/routingwidget.cpp new file mode 100644 index 0000000..adcc041 --- /dev/null +++ b/qlo10k1/src/routingwidget.cpp @@ -0,0 +1,1029 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "routingwidget.h" +#include "structure.h" +#include "strglobal.h" +#include "structure_io.h" +#include "structure_patch.h" + +//icons +#include "icons/routing_fx.xpm" +#include "icons/routing_in.xpm" +#include "icons/routing_out.xpm" +#include "icons/routing_route.xpm" +#include "icons/routing_effect.xpm" +#include "icons/routing_effect_stack.xpm" +#include "icons/routing_zoom_plus.xpm" +#include "icons/routing_zoom_minus.xpm" +#include "icons/routing_normal.xpm" + +class RoutingToolTip : public QToolTip +{ +protected: + virtual void maybeTip(const QPoint &p); +public: + RoutingToolTip(QWidget *widget, QToolTipGroup *group = 0); +}; + +RoutingDrawWidget::RoutingDrawWidget(RoutingWidget *parent, const char *name, WFlags f) + : QScrollView(parent, name, f) +{ + setFocusPolicy(QWidget::StrongFocus); + resizeContents(4000,3000); + this->viewport()->setEraseColor(QColor(255,255,255)); + resizeItem = NULL; + + mode = None; + + //enable tooltips + new RoutingToolTip(this); +} + +RoutingDrawWidget::~RoutingDrawWidget() +{ +} + +void RoutingDrawWidget::drawContents(QPainter* p, int cx, int cy, int cw, int ch) +{ + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + RSItemBaseWithType *item; + DrawingParams dp(parent->getZoomLevel(), this->viewport(), NULL, p); + + p->setFont(createFont(parent->getZoomLevel())); + + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next() ) + { + if (item->flagNew() || item->flagChanged()) + { + item->calcSize(); + item->setFlagNew(false); + item->setFlagChanged(false); + } + + item->draw(&dp); + } + + // if in link mode + if (mode == DragLink) + { + QPainter p(this->viewport()); + int piox, pioy; + int ex = selectEndPoint.x(); + int ey = selectEndPoint.y(); + + ((StrPatch *)linkStart->getOwner())->getIOPoint(linkStart, &piox, &pioy); + contentsToViewport(parent->zoomVal(piox), parent->zoomVal(pioy), piox, pioy); + contentsToViewport(parent->zoomVal(ex), parent->zoomVal(ey), ex, ey); + + p.setPen(LINE_PEN); + p.drawLine(QPoint(piox, pioy), QPoint(ex, ey)); + p.setPen(DEF_PAINTING_PEN); + } +} + +void RoutingDrawWidget::mousePressEvent(QMouseEvent *e) +{ + QScrollView::mousePressEvent(e); + setFocus(); + + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + //treba prepocet na zoom a ofset qscrollview - a niekde to pada + int xp = e->x(); + int yp = e->y(); + + viewportToContents(xp, yp, xp, yp); + + xp = parent->deZoomVal(xp); + yp = parent->deZoomVal(yp); + + RSItemBaseWithType *item; + + QPtrList toClear; + + if (e->button() == MidButton) + return; + + if (mode == DragLink) + { + QPoint tmpp = mapToGlobal(QPoint(e->x(), e->y())); + connectLinkDrag(xp, yp, tmpp.x(), tmpp.y()); + return; + } + + // get mode + if (parent->getWidgetMode() != RoutingWidget::Normal && + e->button() == LeftButton) + { + parent->putNewObjectAt(xp, yp); + return; + } + + + // find item under this point + bool oneSelected = false; + bool clearOthers = false; + + RSItemBase::RSItemHandle resHandle = RSItemBase::None; + RSItemBaseWithType *itemToResize = NULL; + RSItemBaseWithType *itemOn = NULL; + linkHandle = -1; + + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next()) + { + bool redraw = false; + + if (!oneSelected && item->containsPoint(xp, yp)) + { + if (!item->flagSelected()) + { + item->setFlagSelected(true); + redraw = true; + clearOthers = true; + } + else if (e->state() & Qt::ControlButton) + { + item->setFlagSelected(false); + redraw = true; + } + oneSelected = true; + + itemOn = item; + + // check resize point + resHandle = item->getHandlePoint(xp, yp); + if (resHandle == RSItemBase::Other) + { + itemToResize = item; + linkHandle = item->getHandlePointNum(xp, yp); + } + else + { + linkHandle = -1; + if (resHandle != RSItemBase::None) + itemToResize = item; + } + } + else + { + if (item->flagSelected()) + toClear.append(item); + } + + if (redraw) + { + this->updateContents(parent->zoomVal(item->x()), + parent->zoomVal(item->y()), + parent->zoomVal(item->width()), + parent->zoomVal(item->height())); + } + } + + EditMode newMode = None; + RoutingWidget::MenuMode newMenuMode = RoutingWidget::MenuNone; + + parent->itemOn = NULL; + + bool doClearOthers = false; + + if (e->button() == LeftButton) + { + if (!oneSelected) + { + // set select mode + newMode = Select; + } + else + { + if (e->state() & Qt::ControlButton) + { + newMode = None; + } + else + { + if (clearOthers) + doClearOthers = true; + if (itemToResize) + { + resizeItem = itemToResize; + + if (linkHandle < 0) + { + switch (resHandle) + { + case RSItemBase::TopLeft: + newMode = ResizeTopLeft; + break; + case RSItemBase::TopRight: + newMode = ResizeTopRight; + break; + case RSItemBase::BottomLeft: + newMode = ResizeBottomLeft; + break; + case RSItemBase::BottomRight: + newMode = ResizeBottomRight; + break; + default: + break; + } + } + else + newMode = HandleMove; + } + else if(itemOn->type() != RSItemBaseWithType::Link) + newMode = Move; + else + newMode = None; + } + } + } + else + { + if (!oneSelected) + { + newMenuMode = RoutingWidget::MenuNone; + doClearOthers = true; + } + else + { + if (clearOthers) + { + doClearOthers = true; + } + + if (!doClearOthers && toClear.count() > 0) + newMenuMode = RoutingWidget::MenuObjects; + else + { + switch (itemOn->type()) + { + case RSItemBaseWithType::In: + case RSItemBaseWithType::Out: + case RSItemBaseWithType::FX: + newMenuMode = RoutingWidget::MenuIO; + break; + case RSItemBaseWithType::Link: + newMenuMode = RoutingWidget::MenuLink; + break; + case RSItemBaseWithType::Patch: + newMenuMode = RoutingWidget::MenuPatch; + break; + default: + break; + } + } + } + + parent->itemOn = itemOn; + parent->posXOn = xp; + parent->posYOn = yp; + } + + if (doClearOthers) + { + for(item = toClear.first(); item; item = toClear.next()) + { + item->setFlagSelected(false); + + this->updateContents(parent->zoomVal(item->x()), + parent->zoomVal(item->y()), + parent->zoomVal(item->width()), + parent->zoomVal(item->height())); + } + } + + if (e->button() == LeftButton) + mode = newMode; + else + { + QPoint p = mapToGlobal(QPoint(e->x(), e->y())); + parent->openObjectMenuAt(itemOn, newMenuMode, xp, yp, p.x(), p.y()); + } + + selectStartPoint.setX(e->x()); + selectStartPoint.setY(e->y()); + selectEndPoint = selectStartPoint; + +} + +void RoutingDrawWidget::mouseMoveEvent(QMouseEvent *e) +{ + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + if (mode == Select && + (e->x() != selectStartPoint.x() || e->y() != selectStartPoint.y())) + { + QPainter p(this->viewport()); + + p.drawWinFocusRect(selectStartPoint.x(), + selectStartPoint.y(), + selectEndPoint.x() - selectStartPoint.x(), + selectEndPoint.y() - selectStartPoint.y()); + + selectEndPoint.setX(e->x()); + selectEndPoint.setY(e->y()); + + p.drawWinFocusRect(selectStartPoint.x(), + selectStartPoint.y(), + selectEndPoint.x() - selectStartPoint.x(), + selectEndPoint.y() - selectStartPoint.y()); + } + else + { + int dx = parent->deZoomVal((selectEndPoint.x() - selectStartPoint.x())); + int dy = parent->deZoomVal((selectEndPoint.y() - selectStartPoint.y())); + + if (mode == Move) + { + RSItemBaseWithType *item; + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next() ) + { + if (item->flagSelected()) + { + // update old + item->updateContents(this, parent->getZoomLevel()); + + item->moveRel(dx, dy); + // update new + item->updateContents(this, parent->getZoomLevel()); + } + } + } + else if (mode == HandleMove) + { + // update old + resizeItem->updateContents(this, parent->getZoomLevel()); + + resizeItem->moveHandleRel(linkHandle, dx, dy); + // update new + resizeItem->updateContents(this, parent->getZoomLevel()); + } + else if (mode == ResizeTopLeft || + mode == ResizeTopRight || + mode == ResizeBottomLeft || + mode == ResizeBottomRight) + { + int nx = resizeItem->x(); + int ny = resizeItem->y(); + int nw = resizeItem->width(); + int nh = resizeItem->height(); + + switch (mode) + { + case ResizeTopLeft: + nx = nx + dx; + ny = ny + dy; + nw = nw - dx; + nh = nh - dy; + break; + case ResizeTopRight: + ny = ny + dy; + nw = nw + dx; + nh = nh - dy; + break; + case ResizeBottomLeft: + nx = nx + dx; + nw = nw - dx; + nh = nh + dy; + break; + case ResizeBottomRight: + nw = nw + dx; + nh = nh + dy; + break; + default: + break; + } + + if (nx < 0) + nx = 0; + if (ny < 0) + ny = 0; + + if (nw < resizeItem->minWidth()) + nw = resizeItem->minWidth(); + if (nh < resizeItem->minHeight()) + nh = resizeItem->minHeight(); + + resizeItem->updateContents(this, parent->getZoomLevel()); + + resizeItem->setPosition(nx, ny); + resizeItem->setSize(nw, nh); + // update new + resizeItem->updateContents(this, parent->getZoomLevel()); + } + else if (mode == DragLink) + { + updateDragLink(); + } + + selectStartPoint = selectEndPoint; + + selectEndPoint.setX(e->x()); + selectEndPoint.setY(e->y()); + + if (mode == DragLink) + { + int ex = selectEndPoint.x(); + int ey = selectEndPoint.y(); + + viewportToContents(parent->deZoomVal(ex), parent->deZoomVal(ey), ex, ey); + + selectEndPoint.setX(ex); + selectEndPoint.setY(ey); + } + } +} + +void RoutingDrawWidget::updateDragLink() +{ + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + + int piox, pioy; + + int ex = selectEndPoint.x(); + int ey = selectEndPoint.y(); + + ((StrPatch *)linkStart->getOwner())->getIOPoint(linkStart, &piox, &pioy); + + QRect rect(QPoint(piox, pioy), QPoint(ex, ey)); + rect = rect.normalize(); + rect.setX(rect.x() - 1); + rect.setY(rect.y() - 1); + rect.setWidth(rect.width() + 2 * 1); + rect.setHeight(rect.height() + 2 * 1); + this->updateContents(parent->zoomVal(rect.x()), + parent->zoomVal(rect.y()), + parent->zoomVal(rect.width()), + parent->zoomVal(rect.height())); +} + +void RoutingDrawWidget::mouseReleaseEvent(QMouseEvent *e) +{ + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + if (mode == Select) + { + selectEndPoint.setX(e->x()); + selectEndPoint.setY(e->y()); + + QRect selArea(selectStartPoint, selectEndPoint); + selArea = selArea.normalize(); + + // transform + int xt1; + int yt1; + + int xt2; + int yt2; + + viewportToContents(selArea.x(), selArea.y(), xt1, yt1); + xt1 = parent->deZoomVal(xt1); + yt1 = parent->deZoomVal(yt1); + + viewportToContents(selArea.right(), selArea.bottom(), xt2, yt2); + xt2 = parent->deZoomVal(xt2); + yt2 = parent->deZoomVal(yt2); + + // set flag for selected + QRect selAreaTrans(QPoint(xt1, yt1), QPoint(xt2, yt2)); + + RSItemBaseWithType *item; + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next() ) + { + if (selAreaTrans.contains(item->x(), item->y()) && + selAreaTrans.contains(item->x() + item->width(), item->y() + item->height())) + { + if (!item->flagSelected()) + item->setFlagSelected(true); + } + else + { + if (!(e->state() & Qt::ControlButton) && item->flagSelected()) + { + item->setFlagSelected(false); + + this->updateContents(parent->zoomVal(item->x()), + parent->zoomVal(item->y()), + parent->zoomVal(item->width()), + parent->zoomVal(item->height())); + } + } + + + } + + //this->updateContents(selArea); + this->viewport()->update(selArea); + } + + if (mode != DragLink) + mode = None; +} + +void RoutingDrawWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Key_Escape && isDragLink()) + stopLinkDrag(); + + if (e->key() == Key_Delete && !isDragLink()) + { + deleteAllSelected(); + } +} + +void RoutingDrawWidget::startLinkDrag(RSItemIO *si, int xp, int yp) +{ + mode = DragLink; + linkStart = si; + + selectStartPoint.setX(xp); + selectStartPoint.setY(yp); + selectEndPoint = selectStartPoint; + + setMouseTracking(true); + viewport()->setMouseTracking(true); +} + +void RoutingDrawWidget::stopLinkDrag() +{ + mode = None; + updateDragLink(); +} + +QFont &RoutingDrawWidget::createFont(float zoom) +{ + //QFont f("Helvetica", 10 * zoom); + titleFont.setStyleHint(QFont::Helvetica); + titleFont.setPointSize((int)(10 * zoom)); + return titleFont; +} + + +RoutingWidget::RoutingWidget(QWidget *parent, const char *name, WFlags f) + : QWidget(parent, name, f) +{ + structure = NULL; + setFocusPolicy(QWidget::StrongFocus); + + RoutingWidgetLayout = new QVBoxLayout(this); + + createButtons(); + + drawing = new RoutingDrawWidget(this); + + RoutingWidgetLayout->addWidget(drawing/*, 1, 1*/); + drawing->setUpdatesEnabled(TRUE); + + widgetMode = Normal; + toggleMode(widgetMode); + + setZoomLevel(1.00); + updateZoomLevelCtrl(100); +} + +void RoutingWidget::createButtons() +{ + QHBoxLayout *hbox = new QHBoxLayout(RoutingWidgetLayout); + + + pbRoutingNormal = new QPushButton(this); + pbRoutingNormal->setIconSet(QIconSet(QPixmap((const char**)routing_normal))); + hbox->addWidget(pbRoutingNormal); + pbRoutingNormal->setToggleButton(true); + + pbRoutingFX = new QPushButton(this); + pbRoutingFX->setIconSet(QIconSet(QPixmap((const char**)routing_fx))); + hbox->addWidget(pbRoutingFX); + pbRoutingFX->setToggleButton(true); + + pbRoutingIn = new QPushButton(this); + pbRoutingIn->setIconSet(QIconSet(QPixmap((const char**)routing_in))); + hbox->addWidget(pbRoutingIn); + pbRoutingIn->setToggleButton(true); + + pbRoutingOut = new QPushButton(this); + pbRoutingOut->setIconSet(QIconSet(QPixmap((const char**)routing_out))); + hbox->addWidget(pbRoutingOut); + pbRoutingOut->setToggleButton(true); + + pbRoutingRoute = new QPushButton(this); + pbRoutingRoute->setIconSet(QIconSet(QPixmap((const char**)routing_route))); + hbox->addWidget(pbRoutingRoute); + pbRoutingRoute->setToggleButton(true); + + pbRoutingEffect = new QPushButton(this); + pbRoutingEffect->setIconSet(QIconSet(QPixmap((const char**)routing_effect))); + hbox->addWidget(pbRoutingEffect); + pbRoutingEffect->setToggleButton(true); + + pbRoutingEffectStack = new QPushButton(this); + pbRoutingEffectStack->setIconSet(QIconSet(QPixmap((const char**)routing_effect_stack))); + hbox->addWidget(pbRoutingEffectStack); + pbRoutingEffectStack->setToggleButton(true); + + pbRoutingEffectStack->hide(); + + QSpacerItem *spacer1 = new QSpacerItem(10, 0, QSizePolicy::Minimum, QSizePolicy::Minimum); + hbox->addItem(spacer1); + + QPushButton *pbRoutingZoomPlus = new QPushButton(this); + pbRoutingZoomPlus->setIconSet(QIconSet(QPixmap((const char**)routing_zoom_plus))); + hbox->addWidget(pbRoutingZoomPlus); + + sbRoutingZoom = new QSpinBox(this); + hbox->addWidget(sbRoutingZoom); + sbRoutingZoom->setMinValue(10); + sbRoutingZoom->setMaxValue(500); + + QPushButton *pbRoutingZoomMinus = new QPushButton(this); + pbRoutingZoomMinus->setIconSet(QIconSet(QPixmap((const char**)routing_zoom_minus))); + hbox->addWidget(pbRoutingZoomMinus); + + + QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + hbox->addItem(spacer); + + connect(pbRoutingNormal, SIGNAL(clicked()), this, SLOT(modeNormalClicked())); + connect(pbRoutingFX, SIGNAL(clicked()), this, SLOT(modeFxClicked())); + connect(pbRoutingIn, SIGNAL(clicked()), this, SLOT(modeInClicked())); + connect(pbRoutingOut, SIGNAL(clicked()), this, SLOT(modeOutClicked())); + connect(pbRoutingRoute, SIGNAL(clicked()), this, SLOT(modeRouteClicked())); + connect(pbRoutingEffect, SIGNAL(clicked()), this, SLOT(modeEffectClicked())); + connect(pbRoutingEffectStack, SIGNAL(clicked()), this, SLOT(modeEffectStackClicked())); + + connect(sbRoutingZoom, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int))); + + connect(pbRoutingZoomMinus, SIGNAL(clicked()), this, SLOT(zoomOutClicked())); + connect(pbRoutingZoomPlus, SIGNAL(clicked()), this, SLOT(zoomInClicked())); +} + +RoutingWidget::~RoutingWidget() +{ +} + +void RoutingWidget::untoggleMode(EditMode m) +{ + if (m != Normal) + pbRoutingNormal->setOn(false); + if (m != FX) + pbRoutingFX->setOn(false); + if (m != In) + pbRoutingIn->setOn(false); + if (m != Out) + pbRoutingOut->setOn(false); + if (m != Route) + pbRoutingRoute->setOn(false); + if (m != Effect) + pbRoutingEffect->setOn(false); + if (m != EffectStack) + pbRoutingEffectStack->setOn(false); +} + +void RoutingWidget::toggleMode(EditMode m) +{ + switch (m) + { + case Normal: + pbRoutingNormal->setOn(true); + break; + case FX: + pbRoutingFX->setOn(true); + break; + case In: + pbRoutingIn->setOn(true); + break; + case Out: + pbRoutingOut->setOn(true); + break; + case Route: + pbRoutingRoute->setOn(true); + break; + case Effect: + pbRoutingEffect->setOn(true); + break; + case EffectStack: + pbRoutingEffectStack->setOn(true); + break; + } +} + +void RoutingWidget::modeNormalClicked() +{ + widgetMode = Normal; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeFxClicked() +{ + widgetMode = FX; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeInClicked() +{ + widgetMode = In; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeOutClicked() +{ + widgetMode = Out; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeRouteClicked() +{ + widgetMode = Route; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeEffectClicked() +{ + widgetMode = Effect; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::modeEffectStackClicked() +{ + widgetMode = EffectStack; + toggleMode(widgetMode); + untoggleMode(widgetMode); +} + +void RoutingWidget::setZoomLevel(float level) +{ + if (level < 0.10) + level = 0.10; + if (level > 5.00) + level = 5.00; + + zoomLevel = level; + drawing->viewport()->update(); + drawing->resizeContents((int)(4000 * zoomLevel), (int)(3000 * zoomLevel)); +} + +void RoutingWidget::updateZoomLevelCtrl(int level) +{ + sbRoutingZoom->setValue(level); +} + +float RoutingWidget::getZoomLevel() +{ + return zoomLevel; +} + +void RoutingWidget::zoomValueChanged(int value) +{ + setZoomLevel(value / 100.0); +} + +void RoutingWidget::zoomInClicked() +{ + setZoomLevel(zoomLevel + 0.10); + updateZoomLevelCtrl((int)(zoomLevel * 100)); +} + +void RoutingWidget::zoomOutClicked() +{ + setZoomLevel(zoomLevel - 0.10); + updateZoomLevelCtrl((int)(zoomLevel * 100)); +} + +void RoutingWidget::refreshDrawing(StrGlobal *str) +{ + structure = str; + + drawing->updateContents(); +} + +RoutingWidget::EditMode RoutingWidget::getWidgetMode() +{ + return widgetMode; +} + +void RoutingWidget::putNewObjectAt(int xp, int yp) +{ + RSItemBaseWithType *newItem = NULL; + + switch (widgetMode) + { + case FX: + case In: + case Out: + newItem = createNewIO(widgetMode); + if (widgetMode == FX) + structure->FXs.append((StrFX *)newItem); + else if (widgetMode == In) + structure->Inputs.append((StrInput *)newItem); + else + structure->Outputs.append((StrOutput *)newItem); + break; + case Effect: + newItem = createNewPatch(); + structure->updatePatchesOrder(); + break; + case Route: + if (!drawing->isDragLink()) + startLinkDrag(xp, yp); + return; + default: + break; + } + + if (newItem) + { + if (newItem->type() != RSItemBaseWithType::Patch) + structure->UsedItems.append(newItem); + newItem->setPosition(xp, yp); + + drawing->updateContents(); + + modeNormalClicked(); + } +} + + + + +RoutingToolTip::RoutingToolTip(QWidget *widget, QToolTipGroup *group) : QToolTip(widget, group) +{ +} + +void RoutingToolTip::maybeTip(const QPoint &p) +{ + RoutingDrawWidget *drawWidget = (RoutingDrawWidget *)parentWidget(); + RoutingWidget *parent = (RoutingWidget *)drawWidget->parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + int i, j; + // find object under cursor + int xp = p.x(); + int yp = p.y(); + + drawWidget->viewportToContents(xp, yp, xp, yp); + + xp = parent->deZoomVal(xp); + yp = parent->deZoomVal(yp); + + RSItemBaseWithType *item; + + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next()) + { + if (item->containsPoint(xp, yp)) + { + int ix; + int iy; + int iw; + int ih; + + QString tipText = ""; + + StrInput *in = NULL; + StrOutput *out = NULL; + StrFX *fx = NULL; + StrPatch *patch = NULL; + + ix = item->x(); + iy = item->y(); + iw = item->width(); + ih = item->height(); + + RSItemIO *pio = NULL; + + switch(item->type()) + { + case RSItemBaseWithType::In: + in = (StrInput *)item; + tipText = QString("Input: %1\nName: %2").arg(in->num()).arg(in->name()); + break; + case RSItemBaseWithType::Out: + out = (StrOutput *)item; + tipText = QString("Output: %1\nName: %2").arg(out->num()).arg(out->name()); + break; + case RSItemBaseWithType::FX: + fx = (StrFX *)item; + tipText = QString("FX: %1\nName: %2").arg(fx->num()).arg(fx->name()); + break; + case RSItemBaseWithType::Patch: + patch = (StrPatch *)item; + + pio = patch->getIOAtPoint(xp, yp); + if (pio) + { + if (pio->isOutput()) + tipText = QString("Patch output: %1\nOutput name: %2\n\n").arg(pio->getIdx()).arg(pio->getDesc()); + else + tipText = QString("Patch input: %1\nInput name: %2\n\n").arg(pio->getIdx()).arg(pio->getDesc()); + + QRect r; + patch->getIORect(pio->isOutput(), pio->getIdx(), r); + + ix = r.x(); + iy = r.y(); + iw = r.width(); + ih = r.height(); + } + else + { + // create region without ios + QRegion reg(ix, iy, iw, ih); + QRect ior; + + for (j = 0; j < 2; j++) + { + for (i = 0; i < patch->getMaxIOIdx(j); i++) + { + patch->getIORect(j, i, ior); + reg = reg.subtract(QRegion(ior)); + } + } + + // find rect with point + QMemArray rects = reg.rects(); + + for (i = 0; i < (int)rects.count(); i++) + { + if (rects[i].contains(xp, yp)) + { + ix = rects[i].x(); + iy = rects[i].y(); + iw = rects[i].width(); + ih = rects[i].height(); + break; + } + } + } + + tipText = tipText + QString("Patch: %1\nOrder: %2\nName: %3").arg(patch->num()).arg(patch->order()).arg(patch->name()); + break; + default: + break; + } + + if (tipText != "") + { + ix = parent->zoomVal(ix); + iy = parent->zoomVal(iy); + iw = parent->zoomVal(iw); + ih = parent->zoomVal(ih); + + drawWidget->contentsToViewport(ix, iy, ix, iy); + + tip(QRect(ix, iy, iw, ih), tipText); + } + } + } +} diff --git a/qlo10k1/src/routingwidget.h b/qlo10k1/src/routingwidget.h new file mode 100644 index 0000000..9e4b6a8 --- /dev/null +++ b/qlo10k1/src/routingwidget.h @@ -0,0 +1,170 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ROUTINGWIDGET_H +#define ROUTINGWIDGET_H + +#include +#include +#include + +#include "custom_colors.h" + +class RoutingWidget; +class QPushButton; +class QSpinBox; +class StrGlobal; +class RSItemBaseWithType; +class RSItemIO; + +class RoutingDrawWidget : public QScrollView +{ + Q_OBJECT + + enum EditMode {None, Select, ResizeTopLeft, ResizeTopRight, ResizeBottomLeft, ResizeBottomRight, HandleMove, Move, DragLink}; + + EditMode mode; + + // for select + QPoint selectStartPoint; + QPoint selectEndPoint; + + RSItemBaseWithType *resizeItem; + int linkHandle; + + RSItemIO *linkStart; + + QFont titleFont; +public: + RoutingDrawWidget(RoutingWidget *parent = 0, const char *name = 0, WFlags f = 0); + ~RoutingDrawWidget(); + + void startLinkDrag(RSItemIO *si, int xp, int yp); + void updateDragLink(); + void stopLinkDrag(); + void connectLinkDrag(int xp, int yp, int mxp, int myp); + bool isDragLink() + { + return mode == DragLink; + } + + void deleteAllSelected(); + void deleteOneSelected(RSItemBaseWithType *item); + + QFont &createFont(float zoom); + +protected: + void drawContents(QPainter* p, int cx, int cy, int cw, int ch); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseMoveEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e); + virtual void keyPressEvent(QKeyEvent *e); +}; + +class RoutingWidget : public QWidget +{ + Q_OBJECT + +public: + enum EditMode {Normal, FX, In, Out, Route, Effect, EffectStack}; + enum MenuMode {MenuNone, MenuObjects, MenuIO, MenuPatch, MenuLink}; +private: + RoutingDrawWidget *drawing; + QVBoxLayout *RoutingWidgetLayout; + + EditMode widgetMode; + + void untoggleMode(EditMode m); + void toggleMode(EditMode m); + + QPushButton *pbRoutingNormal; + QPushButton *pbRoutingFX; + QPushButton *pbRoutingIn; + QPushButton *pbRoutingOut; + QPushButton *pbRoutingRoute; + QPushButton *pbRoutingEffect; + QPushButton *pbRoutingEffectStack; + + QSpinBox *sbRoutingZoom; + float zoomLevel; + StrGlobal *structure; + + RSItemBaseWithType *itemOn; + int posXOn; + int posYOn; +public: + RoutingWidget(QWidget *parent = 0, const char *name = 0, WFlags f = 0); + ~RoutingWidget(); + + void createButtons(); + StrGlobal *getStructure() + { + return structure; + } + + RoutingDrawWidget *getDrawing() + { + return drawing; + } + + void refreshDrawing(StrGlobal *str); + void setZoomLevel(float level); + float getZoomLevel(); + int zoomVal(int val) + { + return (int)(getZoomLevel() * (float)val); + }; + + int deZoomVal(int val) + { + return (int)((float)val / getZoomLevel()); + }; + + void updateZoomLevelCtrl(int level); + + EditMode getWidgetMode(); + + void putNewObjectAt(int xp, int yp); + RSItemBaseWithType *createNewIO(EditMode em); + RSItemBaseWithType *createNewPatch(); + + void startLinkDrag(int xp, int yp); + + void openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int xp, int yp, int mxp, int myp); + + friend class RoutingDrawWidget; +public slots: + void modeNormalClicked(); + void modeFxClicked(); + void modeInClicked(); + void modeOutClicked(); + void modeRouteClicked(); + void modeEffectClicked(); + void modeEffectStackClicked(); + + + void zoomValueChanged(int value); + void zoomInClicked(); + void zoomOutClicked(); +}; + +#endif // ROUTINGWIDGET_H + diff --git a/qlo10k1/src/routingwidget_menu.cpp b/qlo10k1/src/routingwidget_menu.cpp new file mode 100644 index 0000000..84986ee --- /dev/null +++ b/qlo10k1/src/routingwidget_menu.cpp @@ -0,0 +1,226 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +#include "app_global.h" +#include "routingwidget.h" +#include "structure.h" +#include "structure_io.h" +#include "structure_link.h" +#include "structure_patch.h" +#include "strglobal.h" +#include "ld10k1file.h" + +void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int xp, int yp, int mxp, int myp) +{ + QPopupMenu *contextMenu = new QPopupMenu(); + + enum Action {Refresh, ClearDSP, Delete, Rename, Disconnect, DelPoint, AddPoint, Connect, Save}; + + if (mm == MenuNone) + { + contextMenu->insertItem(tr("&Refresh"), Refresh); + //contextMenu->insertItem(tr("&AutoArange")/*, this, SLOT(menuQuitActivated(int))*/); + contextMenu->insertItem(tr("&Clear DSP"), ClearDSP); + } + else if (mm == MenuObjects) + { + contextMenu->insertItem(tr("&Delete (Unload)"), Delete); + } + else if (mm == MenuIO) + { + //contextMenu->insertItem(tr("&Rename"), Rename); + + bool isConnected = false; + + if (item->type() == RSItemBaseWithType::Out) + isConnected = item->getIO(false, 0)->getConnectedTo() != NULL; + else + isConnected = item->getIO(true, 0)->getConnectedTo() != NULL; + + if (isConnected) + contextMenu->insertItem(tr("D&isconnect"), Disconnect); + + contextMenu->insertSeparator(); + contextMenu->insertItem(tr("&Delete"), Delete); + } + else if (mm == MenuLink) + { + int pn = item->getHandlePointNum(xp, yp); + if (pn > 0) + contextMenu->insertItem(tr("D&elete point"), DelPoint); + else if (pn < 0) + contextMenu->insertItem(tr("A&dd point"), AddPoint); + + contextMenu->insertItem(tr("D&isconnect"), Disconnect); + + contextMenu->insertSeparator(); + contextMenu->insertItem(tr("&Delete"), Delete); + } + else if (mm == MenuPatch) + { + //contextMenu->insertItem(tr("&Rename"), Rename); + + RSItemIO *io = item->getIOAtPoint(xp, yp); + + if (io) + { + //contextMenu->insertItem(tr("&IO Rename"), Rename); + + if (io->getConnectedTo()) + contextMenu->insertItem(tr("D&isconnect"), Disconnect); + else + contextMenu->insertItem(tr("&Connect"), Connect); + } + else + contextMenu->insertItem(tr("&Save"), Save); + + contextMenu->insertSeparator(); + contextMenu->insertItem(tr("&Unload"), Delete); + } + + + + int id = contextMenu->exec(QPoint(mxp, myp)); + + delete contextMenu; + + if (id < 0) + return; + + if (id == AddPoint) + { + StrLink *l = (StrLink *)item; + if (l->addSegmentPoint(xp, yp)) + { + l->updateContents(drawing, getZoomLevel()); + } + } + else if (id == DelPoint) + { + StrLink *l = (StrLink *)item; + // FIXME - update before del + l->updateContents(drawing, getZoomLevel()); + l->delSegmentPoint(l->getHandlePointNum(xp, yp)); + l->calcSize(); + } + else if (id == Delete) + { + drawing->deleteAllSelected(); + } + else if (id == Connect) + { + StrPatch *p = (StrPatch *)item; + RSItemIO *pio = p->getIOAtPoint(xp, yp); + if (pio) + drawing->startLinkDrag(pio, xp, yp); + } + else if (id == Disconnect) + { + RSItemIO *io = NULL; + if (item->type() == RSItemBaseWithType::Patch) + { + int err; + StrPatch *p = (StrPatch *)item; + io = p->getIOAtPoint(xp, yp); + + StrLink *l = io->getConnectedTo(); + // FIXME - update before disconnect + l->updateContents(drawing, getZoomLevel()); + + if ((err = structure->disconnectFromLink(io)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + } + else + { + if (item->type() == RSItemBaseWithType::In) + { + StrInput *in = (StrInput *)item; + io = in->getIO(true, 0); + } + else if (item->type() == RSItemBaseWithType::Out) + { + StrOutput *out = (StrOutput *)item; + io = out->getIO(false, 0); + } + if (item->type() == RSItemBaseWithType::FX) + { + StrFX *fx = (StrFX *)item; + io = fx->getIO(true, 0); + } + + StrLink *l = io->getConnectedTo(); + structure->deleteOneLink(l); + drawing->updateContents(); + } + } + else if (id == ClearDSP) + { + structure->clearDSP(); + drawing->updateContents(); + } + else if (id == Refresh) + { + structure->loadFromLD(); + drawing->updateContents(); + } + else if (id == Save) + { + StrPatch *p = (StrPatch *)item; + int err; + + QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setMode(QFileDialog::AnyFile); + fd->setFilter("Patch (*.ld10k1)"); + fd->setCaption("Save patch"); + + QString fileName; + if (fd->exec() == QDialog::Accepted) + { + fileName = fd->selectedFile(); + delete fd; + + if (!fileName.endsWith(".ld10k1")) + fileName += ".ld10k1"; + if (QFile::exists(fileName)) + { + if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exist. Overwite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) + return; + } + + LD10k1File *pf = NULL; + if ((err = structure->get(p->num(), &pf)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't get patch !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + return; + } + + if ((err = pf->SaveToFile(fileName)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't save patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + delete pf; + } + else + delete fd; + } +} diff --git a/qlo10k1/src/routingwidget_new.cpp b/qlo10k1/src/routingwidget_new.cpp new file mode 100644 index 0000000..ddfd0e2 --- /dev/null +++ b/qlo10k1/src/routingwidget_new.cpp @@ -0,0 +1,293 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +#include "app_global.h" +#include "routingwidget.h" +#include "structure_io.h" +#include "structure_link.h" +#include "newiodialog.h" +#include "loadpatchdialog.h" +#include "transformpatchdialog.h" + + +RSItemBaseWithType *RoutingWidget::createNewIO(EditMode em) +{ + // show io dialog + NewIODlg::DlgType t = NewIODlg::FX; + + switch (em) + { + case FX: + t = NewIODlg::FX; + break; + case In: + t = NewIODlg::In; + break; + case Out: + t = NewIODlg::Out; + break; + default: + break; + } + + NewIODlg d(structure, t); + + if (d.exec() == QDialog::Accepted) + return d.getNewIO(); + else + return NULL; +} + +RSItemBaseWithType *RoutingWidget::createNewPatch() +{ + QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setMode(QFileDialog::ExistingFile); + fd->setFilter("Patches (*.emu10k1 *.ld10k1)"); + fd->setCaption("Load patch"); + + StrPatch *loaded = NULL; + int err; + + QString fileName; + if ( fd->exec() == QDialog::Accepted ) + { + fileName = fd->selectedFile(); + delete fd; + LD10k1File *ldfile = NULL; + if (fileName.endsWith(".emu10k1")) + { + EMU10k1File *emufile = NULL; + if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + return NULL; + } + else + { + TransformPatchDlg d(fileName, emufile); + if (d.exec() == QDialog::Accepted) + { + if ((err = d.transformFile(&ldfile)) < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Couldn't transform patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + delete emufile; + return NULL; + } + delete emufile; + } + else + { + delete emufile; + return NULL; + } + } + } + else + { + if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + return NULL; + } + } + + LoadPatchDlg d(structure, fileName, ldfile); + + if (d.exec() == QDialog::Accepted) + { + // and now convert to loader + StrPatch *loaded = NULL; + if ((err = structure->load(ldfile, d.whereLoad(), &loaded)) < 0) { + QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + delete ldfile; + return NULL; + } + else + { + loaded->calcSize(); + loaded->updateContents(this->drawing, getZoomLevel()); + } + } + delete ldfile; + } + return loaded; +} + +void RoutingWidget::startLinkDrag(int xp, int yp) +{ + // find patch under - only on patch can start drag + + RSItemBaseWithType *item = NULL; + + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next()) + { + if (item->containsPoint(xp, yp) && item->type() == RSItemBaseWithType::Patch) + { + // I have patch - find io + RSItemIO *pio = ((StrPatch *)item)->getIOAtPoint(xp, yp); + if (pio) + { + drawing->startLinkDrag(pio, xp, yp); + return; + } + } + } +} + +void RoutingDrawWidget::connectLinkDrag(int xp, int yp, int mxp, int myp) +{ + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + if (!structure) + return; + + RSItemBaseWithType *item = NULL; + + for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next()) + { + if (item->containsPoint(xp, yp)) + { + // I have patch - find io + RSItemIO *pio = NULL; + if (item->type() == RSItemBaseWithType::Patch) + pio = ((StrPatch *)item)->getIOAtPoint(xp, yp); + else if (item->type() == RSItemBaseWithType::In) + pio = ((StrInput *)item)->getIO(true, 0); + else if (item->type() == RSItemBaseWithType::Out) + pio = ((StrInput *)item)->getIO(false, 0); + else if (item->type() == RSItemBaseWithType::FX) + pio = ((StrFX *)item)->getIO(true, 0); + + + if (pio) + { + // check if connecting in to out or out to in + if (pio->isOutput() != linkStart->isOutput()) + { + if (pio->getConnectedTo() == linkStart->getConnectedTo() && pio->getConnectedTo() && linkStart->getConnectedTo()) + return; + + if (pio->getOwner() == linkStart->getOwner()) + return; + + QPopupMenu *contextMenu = new QPopupMenu(); + enum Action {Normal, SimpleMulti, Simple, Multi}; + + contextMenu->insertItem(tr("&Normal"), Normal); + contextMenu->insertItem(tr("&Multi"), Multi); + if (((RSItemBaseWithType *)pio->getOwner())->type() == RSItemBaseWithType::Patch) + contextMenu->insertItem(tr("S&imple"), Simple); + contextMenu->insertItem(tr("&Simple + Multi"), SimpleMulti); + + + int id = contextMenu->exec(QPoint(mxp, myp)); + if (id < 0) + return; + + int conn_id; + int err; + + QValueList actIds; + + actIds.clear(); + + StrLink *linkTo = pio->getConnectedTo(); + if (linkTo && actIds.findIndex(linkTo->id()) < 0) + actIds.append(linkTo->id()); + + StrLink *linkFrom = linkStart->getConnectedTo(); + if (linkFrom && actIds.findIndex(linkFrom->id()) < 0) + actIds.append(linkFrom->id()); + + if (id == Normal && linkTo && ((RSItemBaseWithType *)pio->getOwner())->type() != RSItemBaseWithType::Patch) + { + if ((err = structure->deleteOneLink(linkTo)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + } + + if ((err = structure->conAdd(id != Simple && id != Normal, + id != Multi && id != Normal, + linkStart, pio, &conn_id)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't connect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + else + { + if (actIds.findIndex(conn_id) < 0) + actIds.append(conn_id); + + if (linkFrom) + linkFrom->updateContents(this, parent->getZoomLevel()); + if (linkTo) + linkTo->updateContents(this, parent->getZoomLevel()); + + for (unsigned int i = 0; i < actIds.count(); i++) + { + StrLink *link = NULL; + int aid = actIds[i]; + if ((err = structure->actualizeLink(aid, &link)) < 0 && aid == conn_id) + QMessageBox::critical(0, APP_NAME, QString("Couldn't actualize link !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + + if (link) + { + if (!link->isValid()) + structure->destroyLink(link); + else + { + //wasn't error + link->calcSize(); + link->updateContents(this, parent->getZoomLevel()); + } + } + } + + stopLinkDrag(); + parent->modeNormalClicked(); + } + + delete contextMenu; + + return; + } + return; + } + } + } +} + +void RoutingDrawWidget::deleteAllSelected() +{ + // through all selected + RoutingWidget *parent = (RoutingWidget *)parentWidget(); + StrGlobal *structure = parent->getStructure(); + + int err; + + if (!structure) + return; + + if ((err = structure->deleteAllSelected()) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't delete selected items !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + + this->updateContents(); +} diff --git a/qlo10k1/src/strglobal.cpp b/qlo10k1/src/strglobal.cpp new file mode 100644 index 0000000..20d6113 --- /dev/null +++ b/qlo10k1/src/strglobal.cpp @@ -0,0 +1,1038 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "strglobal.h" +#include "strparam.h" +#include "structure.h" +#include "structure_io.h" +#include "structure_link.h" +#include "structure_patch.h" + +#include "ld10k1file.h" + +StrGlobal::StrGlobal(CardParam *card) +{ + Card = card; + Card->Structure = this; + + // registers + Inputs.setAutoDelete(TRUE); // the list owns the objects + Outputs.setAutoDelete(TRUE); + FXs.setAutoDelete(TRUE); + Links.setAutoDelete(TRUE); + + // patches + Patches.setAutoDelete(TRUE); // the list owns the objects +} + +StrGlobal::~StrGlobal(void) +{ + Card = NULL; +} + +void StrGlobal::clear(void) +{ + Links.clear(); + Inputs.clear(); + Outputs.clear(); + FXs.clear(); + Patches.clear(); + UsedItems.clear(); +} + +void StrGlobal::clearFlags(void) +{ + StrFX *fx = NULL; + for(fx = FXs.first(); fx; fx = FXs.next()) + { + fx->setFlagUsed(false); + fx->setFlagNew(false); + fx->setFlagChanged(false); + } + + StrInput *in = NULL; + for(in = Inputs.first(); in; in = Inputs.next()) + { + in->setFlagUsed(false); + in->setFlagNew(false); + in->setFlagChanged(false); + } + + StrOutput *out = NULL; + for(out = Outputs.first(); out; out = Outputs.next()) + { + out->setFlagUsed(false); + out->setFlagNew(false); + out->setFlagChanged(false); + } + + StrPatch *p = NULL; + for(p = Patches.first(); p; p = Patches.next()) + { + p->setFlagUsed(false); + p->setFlagNew(false); + p->setFlagChanged(false); + } + + StrLink *l = NULL; + for(l = Links.first(); l; l = Links.next()) + { + l->setFlagUsed(false); + l->setFlagNew(false); + l->setFlagChanged(false); + } +} + +int StrGlobal::loadFromLD(void) +{ + clearFlags(); + + // load registers + int cnt; + int err = 0; + int i; + + QString ioname; + + // FXs + if ((err = Card->getFXCount(&cnt)) < 0) + return err; + + for (i = 0; i < cnt; i++) + { + if ((err = Card->getFX(i, ioname)) < 0) + return err; + + StrFX *fx = findFXByNum(i); + if (fx) + { + if (fx->name() != ioname) + { + fx->setName(ioname); + fx->setFlagChanged(true); + } + } + else + { + fx = new StrFX(i, ioname); + fx->setFlagNew(true); + FXs.append(fx); + } + } + + if ((err = Card->getInputCount(&cnt)) < 0) + return err; + + for (i = 0; i < cnt; i++) + { + if ((err = Card->getInput(i, ioname)) < 0) + return err; + + StrInput *in = findInputByNum(i); + if (in) + { + if (in->name() != ioname) + { + in->setName(ioname); + in->setFlagChanged(true); + } + } + else + { + in = new StrInput(i, ioname); + in->setFlagNew(true); + Inputs.append(in); + } + } + + if ((err = Card->getOutputCount(&cnt)) < 0) + return err; + + for (i = 0; i < cnt; i++) + { + if ((err = Card->getOutput(i, ioname)) < 0) + return err; + + StrOutput *out = findOutputByNum(i); + if (out) + { + if (out->name() != ioname) + { + out->setName(ioname); + out->setFlagChanged(true); + } + } + else + { + out = new StrOutput(i, ioname); + out->setFlagNew(true); + Outputs.append(out); + } + } + + // load patches and patch registers + CardParamPatchInfo **pi; + + + if ((err = Card->getPatchesInfo(&pi, &cnt)) < 0) + return err; + // copy registers to internal structure + for (i = 0; i < cnt; i++) + { + StrPatch *patch = NULL; + + if ((err = actualizePatch(pi[i]->id, pi[i]->patch_num, pi[i]->patch_name, &patch)) < 0) + { + for (i = 0; i < cnt; i++) + delete pi[i]; + delete pi; + return err; + } + patch->setOrder(i); + } + + for (i = 0; i < cnt; i++) + delete pi[i]; + delete pi; + + int *ld_tmplids = NULL; + if ((err = Card->getPointsInfo(&ld_tmplids, &cnt)) < 0) + return err; + + for (i = 0; i < cnt; i++) + { + StrLink *link = NULL; + + if ((err = actualizeLink(ld_tmplids[i], &link)) < 0) + { + free(ld_tmplids); + return err; + } + } + + free(ld_tmplids); + + // copy used items + StrPatch *patch; + + UsedItems.clear(); + + for(patch = Patches.first(); patch; patch = Patches.next() ) + { + if (patch->flagUsed()) + UsedItems.append(patch); + } + + // remove unused + for(patch = Patches.last(); patch; patch = Patches.prev() ) + { + if (!patch->flagUsed()) + Patches.remove(patch); + } + + QPtrListIterator itin(Inputs); + StrInput *in; + while ((in = itin.current()) != 0 ) { + ++itin; + if (in->flagUsed()) + UsedItems.append(in); + else + Inputs.remove(in); + } + + QPtrListIterator itout(Outputs); + StrOutput *out; + while ((out = itout.current()) != 0 ) { + ++itout; + if (out->flagUsed()) + UsedItems.append(out); + else + Outputs.remove(out); + } + + QPtrListIterator itfx(FXs); + StrFX *fx; + while ((fx = itfx.current()) != 0 ) { + ++itfx; + if (fx->flagUsed()) + UsedItems.append(fx); + else + FXs.remove(fx); + } + + QPtrListIterator itlnk(Links); + StrLink *lnk; + while ((lnk = itlnk.current()) != 0 ) { + ++itlnk; + if (lnk->flagUsed()) + UsedItems.append(lnk); + else + Links.remove(lnk); + } + + updatePatchesOrder(); + + AutoArange(&UsedItems); + + QPtrListIterator itlnk1(Links); + while ((lnk = itlnk1.current()) != 0 ) { + ++itlnk1; + lnk->calcSize(); + } + return 0; +} + +int StrGlobal::getPio(int pnum, bool out, int idx, QString &name) +{ + int err; + + if (out) + err = Card->getPOutput(pnum, idx, name); + else + err = Card->getPInput(pnum, idx, name); + return err; +} + +int StrGlobal::actualizePatch(int pid, int pnum, QString pname, StrPatch **out) +{ + QString ioname; + int z, j; + int err; + + int cnt1[2]; + + if ((err = Card->getPInputCount(pnum, &(cnt1[0]))) < 0) + return err; + if ((err = Card->getPOutputCount(pnum, &(cnt1[1]))) < 0) + return err; + + StrPatch *patch = findPatchById(pid); + + if (patch) + { + // check changes + if (patch->name() != pname) + { + patch->setName(pname); + patch->setFlagChanged(true); + } + + for (z = 0; z < 2; z++) + { + for (j = 0; j < cnt1[z]; j++) + { + if ((err = getPio(pnum, z, j, ioname)) < 0) + return err; + + RSItemIO *io = patch->getIO(z, j); + if (io->getDesc() != ioname) + { + io->setDesc(ioname); + patch->setFlagChanged(true); + } + } + } + } + else + { + patch = new StrPatch(pnum, pid, pname); + Patches.append(patch); + + for (z = 0; z < 2; z++) + { + for (j = 0; j < cnt1[z]; j++) + { + if ((err = getPio(pnum, z, j, ioname)) < 0) + return err; + + RSItemIO *io = new RSItemIO(patch, z, j, ioname); + patch->setIO(z, j, io); + } + } + + patch->setFlagNew(true); + } + + patch->setFlagUsed(true); + + *out = patch; + return 0; +} + +StrPatch *StrGlobal::findPatchByNum(int num) +{ + StrPatch *patch; + + for(patch = Patches.first(); patch; patch = Patches.next() ) + { + if (patch->num() == num) + return patch; + } + + return NULL; +} + +StrPatch *StrGlobal::findPatchById(int id) +{ + StrPatch *patch; + + for(patch = Patches.first(); patch; patch = Patches.next() ) + { + if (patch->id() == id) + return patch; + } + + return NULL; +} + +StrFX *StrGlobal::findFXByNum(int num) +{ + StrFX *fx; + + for(fx = FXs.first(); fx; fx = FXs.next() ) + { + if (fx->num() == num) + return fx; + } + + return NULL; +} + +StrInput *StrGlobal::findInputByNum(int num) +{ + StrInput *in; + + for(in = Inputs.first(); in; in = Inputs.next() ) + { + if (in->num() == num) + return in; + } + + return NULL; +} + +StrOutput *StrGlobal::findOutputByNum(int num) +{ + StrOutput *out; + + for(out = Outputs.first(); out; out = Outputs.next() ) + { + if (out->num() == num) + return out; + } + + return NULL; +} + +StrLink *StrGlobal::findLinkById(int id) +{ + StrLink *l; + + for(l = Links.first(); l; l = Links.next() ) + { + if (l->id() == id) + return l; + } + + return NULL; +} + +int StrGlobal::conAdd(bool multi, bool simple, RSItemIO *from_io, RSItemIO *to_io, int *id) +{ + int ftype = 0; + int ttype = 0; + int type = 0; + int fp = 0; + int tp = 0; + int p = 0; + int fio = 0; + int tio = 0; + int io = 0; + + RSItemIO *tmp; + + RSItemBaseWithType *owner; + + for (int i = 0; i < 2; i++) + { + if (!i) + tmp = from_io; + else + tmp = to_io; + + owner = (RSItemBaseWithType *)tmp->getOwner(); + + p = -1; + io = -1; + + switch (owner->type()) + { + case RSItemBaseWithType::In: + type = CON_IO_IN; + io = ((StrInput *)owner)->num(); + break; + case RSItemBaseWithType::Out: + type = CON_IO_OUT; + io = ((StrOutput *)owner)->num(); + break; + case RSItemBaseWithType::FX: + type = CON_IO_FX; + io = ((StrFX *)owner)->num(); + break; + case RSItemBaseWithType::Patch: + if (!tmp->isOutput()) + type = CON_IO_PIN; + else + type = CON_IO_POUT; + io = tmp->getIdx(); + + p = ((StrPatch *)owner)->num(); + break; + default: + break; + } + + if (!i) + { + ftype = type; + fio = io; + fp = p; + } + else + { + ttype = type; + tio = io; + tp = p; + } + } + + return Card->conAdd(multi, simple, ftype, fp, fio, ttype, tp, tio, id); + // FIXME - uprava strglobal - urobene inde +} + +int StrGlobal::conDel(RSItemIO *from_io, int *id) +{ + int io, p; + int type = 0; + + RSItemBaseWithType *owner; + + owner = (RSItemBaseWithType *)from_io->getOwner(); + + p = -1; + io = -1; + + switch (owner->type()) + { + // only patch valid + case RSItemBaseWithType::Patch: + if (!from_io->isOutput()) + type = CON_IO_PIN; + else + type = CON_IO_POUT; + io = from_io->getIdx(); + + p = ((StrPatch *)owner)->num(); + break; + default: + break; + } + + return Card->conDel(type, p, io, id); +} + +int StrGlobal::load(LD10k1File *ld10k1file, StrPatch *before, StrPatch **loaded) +{ + int bef = -1; + int loade, loade_id; + int retval; + + if (before) + bef = before->num(); + if ((retval = Card->load(ld10k1file, bef, &loade, &loade_id)) < 0) + return retval; + + StrPatch *p = NULL; + + if ((retval = actualizePatch(loade_id, loade, ld10k1file->getPatchName(), &p)) < 0) + return retval; + + UsedItems.append(p); + updatePatchesOrder(); + AutoArange(&UsedItems); + *loaded = p; + return retval; +} + +int StrGlobal::unload(StrPatch *p) +{ + int retval; + if ((retval = Card->unload(p->num())) < 0) + return retval; + + // FIXME - odmaz aj prepojenia + UsedItems.remove(p); + Patches.remove(p); + updatePatchesOrder(); + return retval; +} + +int StrGlobal::clearDSP(void) +{ + int retval; + + if ((retval = Card->clearDSP()) < 0) + return retval; + + clear(); + return 0; +} + +void StrGlobal::destroyLink(StrLink *l) +{ + UsedItems.remove(l); + l->disconnectAll(); + + // delete not needed - autodelete + Links.remove(l); +} + +int StrGlobal::disconnectFromLink(RSItemIO *io) +{ + StrLink *link = io->getConnectedTo(); + if (link) + { + int idx = link->findRoute(io); + int conn_id; + int err; + if((err = conDel(io, &conn_id)) < 0) + return err; + link->setRoutePoint(idx, NULL); + if (conn_id < 0 || !link->isValid()) + { + destroyLink(link); + return 0; + } + link->calcSize(); + } + return 0; +} + +int StrGlobal::actualizeLink(int id, StrLink **out) +{ + int err; + CardParamPointInfo point; + + err = Card->getPointInfo(id, &point); + if (err == LD10K1_ERR_UNKNOWN_POINT) + { + // FIXME - probably not exists - remove + StrLink *delLink = findLinkById(id); + if (delLink) + destroyLink(delLink); + + *out = NULL; + return 0; + } + if (err < 0) + return err; + + RSItemIO *firstItem = NULL; + StrLink::LinkType newType = StrLink::LinkFX; + switch(point.type) + { + case CON_IO_FX: + newType = StrLink::LinkFX; + { + StrFX *ft = findFXByNum(point.io_idx); + if (ft) + firstItem = ft->getIO(true, 0); + } + break; + case CON_IO_IN: + newType = StrLink::LinkIn; + { + StrInput *in = findInputByNum(point.io_idx); + if (in) + firstItem = in->getIO(true, 0); + } + break; + case CON_IO_OUT: + newType = StrLink::LinkOut; + { + StrOutput *out = findOutputByNum(point.io_idx); + if (out) + firstItem = out->getIO(false, 0); + } + break; + case CON_IO_NORMAL: + newType = StrLink::LinkNormal; + break; + } + + StrLink *link = findLinkById(id); + if (link) + { + bool actualized[POINTINFO_MAX_CONN_PER_POINT]; + RSItemIO *newIOs[POINTINFO_MAX_CONN_PER_POINT]; + unsigned int j; + unsigned int niosc = 0; + + for (j = 0; j < POINTINFO_MAX_CONN_PER_POINT; j++) + actualized[j] = false; + + int r = 0; + if (firstItem) + { + actualized[r] = true; + ((RSItemBaseWithType *)firstItem->getOwner())->setFlagUsed(true); + r++; + } + + // actualize current + for (j = 0; j < point.conn_count; j++) + { + RSItemIO *io = findPatchIO(point.io_type[j], point.patch[j], point.io[j]); + ((RSItemBaseWithType *)io->getOwner())->setFlagUsed(true); + + // find io + int rf = link->findRoute(io); + if (rf >= 0) + { + actualized[rf] = true; + link->setRoutePoint(rf, io); + } + else + { + newIOs[niosc++] = io; + } + } + + // delete old + for (j = 0; j < POINTINFO_MAX_CONN_PER_POINT; j++) + { + if (!actualized[j]) + { + link->setRoutePoint(j, NULL); + link->clearRoutesPoints(j); + } + } + + // add new + int l = 0; + for (j = 0; j < niosc; j++) + { + for (; l < POINTINFO_MAX_CONN_PER_POINT; l++) + { + if (!link->getRoutePoint(l)) + { + link->setRoutePoint(l, newIOs[j]); + break; + } + } + } + + link->setFlagChanged(true); + } + else + { + link = new StrLink(id, newType); + int r = 0; + if (firstItem) + { + link->setRoutePoint(r++, firstItem); + ((RSItemBaseWithType *)firstItem->getOwner())->setFlagUsed(true); + } + + unsigned int j = 0; + for (j = 0; j < point.conn_count; j++) + { + RSItemIO *io = findPatchIO(point.io_type[j], point.patch[j], point.io[j]); + ((RSItemBaseWithType *)io->getOwner())->setFlagUsed(true); + link->setRoutePoint(r++, io); + } + link->setFlagNew(true); + Links.append(link); + UsedItems.append(link); + } + link->setFlagUsed(true); + + *out = link; + return 0; +} + +void StrGlobal::updatePatchesOrder(void) +{ + CardParamPatchInfo **pi; + int i, cnt; + int err; + + if ((err = Card->getPatchesInfo(&pi, &cnt)) < 0) + return; + + for (i = 0; i < cnt; i++) + { + StrPatch *p = findPatchById(pi[i]->id); + if (p) + p->setOrder(i); + } + + for (i = 0; i < cnt; i++) + delete pi[i]; + delete pi; +} + +RSItemIO *StrGlobal::findPatchIO(bool out, int pid, int ionum) +{ + if (pid < 0 || ionum < 0) + return NULL; + StrPatch *p = findPatchById(pid); + if (!p) + return NULL; + + return p->getIO(out, ionum); +} + +int StrGlobal::deleteOneLink(StrLink *l) +{ + int err; + + for (int i = 0; i < l->getMaxRoute(); i++) + { + RSItemIO *io = l->getRoutePoint(i); + if (io) + { + RSItemBaseWithType *owner = (RSItemBaseWithType *)io->getOwner(); + if (owner->type() == RSItemBaseWithType::Patch) + { + // only patch can be disconnected + int conn_id; + if((err = conDel(io, &conn_id)) < 0) + return err; + if (conn_id < 0) + { + destroyLink(l); + return 0; + } + + } + } + } + return 0; +} + +int StrGlobal::deleteOneFX(StrFX *fx) +{ + int err; + + RSItemIO *io = fx->getIO(true, 0); + if (io) + { + StrLink *l = io->getConnectedTo(); + if (l) + { + if ((err = deleteOneLink(l)) < 0) + return err; + } + } + + UsedItems.remove(fx); + + // delete not needed - autodelete + FXs.remove(fx); + + return 0; +} + +int StrGlobal::deleteOneIn(StrInput *in) +{ + int err; + + RSItemIO *io = in->getIO(true, 0); + if (io) + { + StrLink *l = io->getConnectedTo(); + if (l) + { + if ((err = deleteOneLink(l)) < 0) + return err; + } + } + + UsedItems.remove(in); + + // delete not needed - autodelete + Inputs.remove(in); + + return 0; +} + +int StrGlobal::deleteOneOut(StrOutput *out) +{ + int err; + + RSItemIO *io = out->getIO(false, 0); + if (io) + { + StrLink *l = io->getConnectedTo(); + if (l) + { + if ((err = deleteOneLink(l)) < 0) + return err; + } + } + + UsedItems.remove(out); + + // delete not needed - autodelete + Outputs.remove(out); + + return 0; +} + +int StrGlobal::deleteOnePatch(StrPatch *p) +{ + int err; + int z; + int j; + + // store all conn ids + + QValueList actIds; + + actIds.clear(); + + for (z = 0; z < 2; z++) + { + for (j = 0; j < p->getMaxIOIdx(z); j++) + { + RSItemIO *io = p->getIO(z, j); + if (io) + { + StrLink *l = io->getConnectedTo(); + if (l && actIds.findIndex(l->id()) < 0) + actIds.append(l->id()); + } + } + } + + if ((err = unload(p)) < 0) + return err; + + // actualize links + for (unsigned int i = 0; i < actIds.count(); i++) + { + StrLink *link = NULL; + int aid = actIds[i]; + if ((err = actualizeLink(aid, &link)) < 0) + return err; + + if (link) + { + if (!link->isValid()) + destroyLink(link); + else + //wasn't error + link->calcSize(); + } + } + + return 0; +} + +int StrGlobal::deleteOneItem(RSItemBaseWithType *item) +{ + switch (item->type()) + { + case RSItemBaseWithType::In: + return deleteOneIn((StrInput *)item); + case RSItemBaseWithType::Out: + return deleteOneOut((StrOutput *)item); + case RSItemBaseWithType::FX: + return deleteOneFX((StrFX *)item); + case RSItemBaseWithType::Link: + return deleteOneLink((StrLink *)item); + case RSItemBaseWithType::Patch: + return deleteOnePatch((StrPatch *)item); + default: + return 0; + } +} + +int StrGlobal::deleteAllSelected() +{ + int err; + // through all selected + RSItemBaseWithType *item; + + // first connections + QPtrListIterator it1(UsedItems); + while ((item = it1.current()) != 0 ) + { + ++it1; + if (item->flagSelected() && item->type() == RSItemBaseWithType::Link) + { + if ((err = deleteOneLink((StrLink *)item)) < 0) + return err; + } + } + + // everything others + QPtrListIterator it2(UsedItems); + while ((item = it2.current()) != 0 ) + { + ++it2; + if (item->flagSelected()) + { + if ((err = deleteOneItem(item)) < 0) + return err; + } + } + + return 0; +} + +QString StrGlobal::errorStr(int err) +{ + return Card->errorStr(err); +} + +int StrGlobal::get(int patch_num, LD10k1File **dc) +{ + return Card->get(patch_num, dc); +} + + +int StrGlobal::getDspConfig(LD10k1DspFile **dc) +{ + return Card->getDspConfig(dc); +} + +int StrGlobal::putDspConfig(LD10k1DspFile *dc) +{ + return Card->putDspConfig(dc); +} + +StrCardGlobal::StrCardGlobal() +{ + // cards + Cards.setAutoDelete( TRUE ); // the list owns the objects +} diff --git a/qlo10k1/src/strglobal.h b/qlo10k1/src/strglobal.h new file mode 100644 index 0000000..d988de5 --- /dev/null +++ b/qlo10k1/src/strglobal.h @@ -0,0 +1,112 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRGLOBAL_H +#define STRGLOBAL_H + +#include +#include + +class StrGlobal; +class StrInput; +class StrOutput; +class StrFX; +class StrLink; +class StrPatch; +class RSItemBaseWithType; +class RSItemIO; +class CardParam; +class LD10k1File; +class LD10k1DspFile; + +class StrGlobal +{ +public: + CardParam *Card; + + QPtrList Inputs; + QPtrList Outputs; + QPtrList FXs; + QPtrList Links; + + QPtrList Patches; + + StrGlobal(CardParam *card); + ~StrGlobal(void); + + void clear(void); + void clearFlags(void); + int loadFromLD(void); + StrPatch *findPatchByNum(int num); + StrPatch *findPatchById(int id); + StrFX *findFXByNum(int num); + StrInput *findInputByNum(int num); + StrOutput *findOutputByNum(int num); + StrLink *findLinkById(int id); + + int load(LD10k1File *ld10k1file, StrPatch *before, StrPatch **loaded); + int get(int patch_num, LD10k1File **dc); + int unload(StrPatch *p); + int conAdd(bool multi, bool simple, RSItemIO *from_io, RSItemIO *to_io, int *id); + int conDel(RSItemIO *from_io, int *id); + QString errorStr(int err); + + QPtrList UsedItems; + + int getPio(int pnum, bool out, int idx, QString &name); + + int actualizeLink(int id, StrLink **out); + int actualizePatch(int pid, int pnum, QString pname, StrPatch **out); + + void destroyLink(StrLink *l); + int disconnectFromLink(RSItemIO *io); + + RSItemIO *findPatchIO(bool out, int pid, int ionum); + int clearDSP(void); + + static void AutoArange(QPtrList *items); + + void updatePatchesOrder(void); + + int deleteOneLink(StrLink *l); + int deleteOneFX(StrFX *fx); + int deleteOneIn(StrInput *in); + int deleteOneOut(StrOutput *out); + int deleteOnePatch(StrPatch *p); + int deleteOneItem(RSItemBaseWithType *item); + int deleteAllSelected(); + + int getDspConfig(LD10k1DspFile **dc); + int putDspConfig(LD10k1DspFile *dc); +}; + +class StrCardGlobal +{ +public: + QPtrList Cards; + + QString RepDirSystem; + QString RepDirUser; + + StrCardGlobal(); +}; + +#endif // STRGLOBAL_H diff --git a/qlo10k1/src/strparam.cpp b/qlo10k1/src/strparam.cpp new file mode 100644 index 0000000..9f0653d --- /dev/null +++ b/qlo10k1/src/strparam.cpp @@ -0,0 +1,314 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "strglobal.h" +#include "strparam.h" +#include "ld10k1file.h" + +class CardParamPrivate +{ +public: + liblo10k1_connection_t card_conn; + + liblo10k1_connection_t *conn() + { + return &card_conn; + } +}; + +CardParam::CardParam(void) +{ + prv = new CardParamPrivate(); + liblo10k1_connection_init(prv->conn()); + Structure = NULL; +} + +CardParam::~CardParam(void) +{ + disconnect(); + if (Structure) + delete Structure; + delete prv; +} + +StrGlobal *CardParam::getStructure() +{ + Structure = new StrGlobal(this); + return Structure; +} + +int CardParam::disconnect(void) +{ + if (liblo10k1_is_open(prv->conn())) + return liblo10k1_disconnect(prv->conn()); + return 0; +} + +int CardParam::isConnected(void) +{ + return liblo10k1_is_open(prv->conn()); +} + +int CardParam::clearDSP(void) +{ + return liblo10k1_dsp_init(prv->conn()); +} + +int CardParam::testConnection(void) +{ + int err = connect(); + if (err < 0) + return err; + disconnect(); + return 0; +} + +int CardParam::connect(void) +{ + int err; + + if (liblo10k1_is_open(prv->conn())) + disconnect(); + + liblo10k1_param params; + const char *tmp = NULL; + + tmp = CardSocket; + + params.wfc = 500; // FIXME - user selectable + params.type = COMM_TYPE_LOCAL; // FIXME + params.server = 0; + params.name = (char *)tmp; + params.port = 0; + + if ((err = liblo10k1_connect(¶ms, prv->conn())) < 0) + return err; + + return liblo10k1_check_version(prv->conn()); +} + +int CardParam::load(LD10k1File *ld10k1file, int before, int *loaded, int *loaded_id) +{ + int err; + liblo10k1_dsp_patch_t *patch = ld10k1file->getLD10k1Format(); + err = liblo10k1_patch_load(prv->conn(), patch, before, loaded, loaded_id); + return err; +} + +int CardParam::unload(int num) +{ + return liblo10k1_patch_unload(prv->conn(), num); +} + +int CardParam::get(int patch_num, LD10k1File **ld10k1file) +{ + liblo10k1_dsp_patch_t *patch; + int err; + + if ((err = liblo10k1_patch_get(prv->conn(), patch_num, &patch)) < 0) + return err; + + LD10k1File *tmp = new LD10k1File(); + tmp->setLD10k1Format(patch); + *ld10k1file = tmp; + + return 0; +} + +int CardParam::conAdd(bool multi, bool simple, int from_type, int from_patch, int from_io, int to_type,int to_patch, int to_io, int *id) +{ + return liblo10k1_con_add(prv->conn(), multi, simple, from_type, from_patch, from_io, to_type, to_patch, to_io, id); +} + +int CardParam::conDel(int from_type, int from_patch, int from_io, int *id) +{ + return liblo10k1_con_del(prv->conn(), from_type, from_patch, from_io, id); +} + +int CardParam::getPointsInfo(int **out, int *count) +{ + return liblo10k1_get_points_info(prv->conn(), out, count); +} + +int CardParam::getPointInfo(int point_id, CardParamPointInfo *out) +{ + int err; + + liblo10k1_point_info_t pi; + if ((err = liblo10k1_get_point_info(prv->conn(), point_id, &pi)) < 0) + return err; + + out->id = pi.id; + out->type = pi.type; + out->io_idx = pi.io_idx; + out->simple = pi.simple; + out->multi = pi.multi; + out->conn_count = pi.conn_count; + + for (int i = 0; i < POINTINFO_MAX_CONN_PER_POINT; i++) + { + out->io_type[i] = pi.io_type[i]; + out->patch[i] = pi.patch[i]; + out->io[i] = pi.io[i]; + } + + return 0; +} + +QString CardParam::errorStr(int err) +{ + return QString(liblo10k1_error_str(err)); +} + +CardParam::CardParam(CardParam *from) +{ + prv = new CardParamPrivate(); + liblo10k1_connection_init(prv->conn()); + CardName = from->CardName; + CardSocket = from->CardSocket; +}; + +int CardParam::getFXCount(int *cnt) +{ + return liblo10k1_get_fx_count(prv->conn(), cnt); +} + +int CardParam::getInputCount(int *cnt) +{ + return liblo10k1_get_in_count(prv->conn(), cnt); +} + +int CardParam::getOutputCount(int *cnt) +{ + return liblo10k1_get_out_count(prv->conn(), cnt); +} + +int CardParam::getFX(int i, QString &name) +{ + liblo10k1_get_io_t ld_tmp; + int err = 0; + + if ((err = liblo10k1_get_fx(prv->conn(), i, &ld_tmp)) < 0) + return err; + name = ld_tmp.name; + return 0; +} + +int CardParam::getInput(int i, QString &name) +{ + liblo10k1_get_io_t ld_tmp; + int err = 0; + + if ((err = liblo10k1_get_in(prv->conn(), i, &ld_tmp)) < 0) + return err; + name = ld_tmp.name; + return 0; +} + +int CardParam::getOutput(int i, QString &name) +{ + liblo10k1_get_io_t ld_tmp; + int err = 0; + + if ((err = liblo10k1_get_out(prv->conn(), i, &ld_tmp)) < 0) + return err; + name = ld_tmp.name; + return 0; +} + +int CardParam::getPInputCount(int pnum, int *cnt) +{ + return liblo10k1_get_pin_count(prv->conn(), pnum, cnt); +} + +int CardParam::getPOutputCount(int pnum, int *cnt) +{ + return liblo10k1_get_pout_count(prv->conn(), pnum, cnt); +} + +int CardParam::getPInput(int pnum, int i, QString &name) +{ + liblo10k1_get_io_t ld_tmp; + int err = 0; + + if ((err = liblo10k1_get_pin(prv->conn(), pnum, i, &ld_tmp)) < 0) + return err; + name = ld_tmp.name; + return 0; +} + +int CardParam::getPOutput(int pnum, int i, QString &name) +{ + liblo10k1_get_io_t ld_tmp; + int err = 0; + + if ((err = liblo10k1_get_pout(prv->conn(), pnum, i, &ld_tmp)) < 0) + return err; + name = ld_tmp.name; + return 0; +} + +int CardParam::getPatchesInfo(CardParamPatchInfo ***pi, int *cnt) +{ + liblo10k1_patches_info_t *ld_patches; + int err; + + CardParamPatchInfo **tmppi = NULL; + *pi = NULL; + + if ((err = liblo10k1_get_patches_info(prv->conn(), &ld_patches, cnt)) < 0) + return err; + + tmppi = new CardParamPatchInfo *[*cnt]; + + for (int i = 0; i < *cnt; i++) + { + tmppi[i] = new CardParamPatchInfo(); + tmppi[i]->patch_num = ld_patches[i].patch_num; + tmppi[i]->id = ld_patches[i].id; + tmppi[i]->patch_name = ld_patches[i].patch_name; + } + + free(ld_patches); + *pi = tmppi; + return 0; +} + +int CardParam::getDspConfig(LD10k1DspFile **dc) +{ + liblo10k1_file_dsp_setup_t *ds = NULL; + int err; + + if ((err = liblo10k1lf_get_dsp_config(prv->conn(), &ds)) < 0) + return err; + + LD10k1DspFile *ldc = new LD10k1DspFile(); + ldc->setLD10k1DspFormat(ds); + *dc = ldc; + return 0; +} + +int CardParam::putDspConfig(LD10k1DspFile *dc) +{ + return liblo10k1lf_put_dsp_config(prv->conn(), dc->getLD10k1DspFormat()); +} diff --git a/qlo10k1/src/strparam.h b/qlo10k1/src/strparam.h new file mode 100644 index 0000000..7ceef2c --- /dev/null +++ b/qlo10k1/src/strparam.h @@ -0,0 +1,104 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRPARAM_H +#define STRPARAM_H + +#include + +class StrGlobal; +class LD10k1File; +class LD10k1DspFile; +class CardParamPrivate; + +#define POINTINFO_MAX_CONN_PER_POINT 15 +class CardParamPointInfo +{ +public: + int id; + int type; + int io_idx; + int simple; + int multi; + unsigned int conn_count; + int io_type[POINTINFO_MAX_CONN_PER_POINT]; + int patch[POINTINFO_MAX_CONN_PER_POINT]; + int io[POINTINFO_MAX_CONN_PER_POINT]; +}; + +class CardParamPatchInfo +{ +public: + int patch_num; + int id; + QString patch_name; +}; + +class CardParam +{ + CardParamPrivate *prv; +public: + QString CardName; + QString CardSocket; + + StrGlobal *Structure; + + CardParam(void); + CardParam(CardParam *from); + ~CardParam(void); + StrGlobal *getStructure(); + + int connect(void); + int disconnect(void); + int isConnected(void); + int testConnection(void); + int clearDSP(void); + + int load(LD10k1File *ld10k1file, int before, int *loaded, int *loaded_id); + int unload(int num); + int get(int patch_num, LD10k1File **ld10k1file); + int getPointsInfo(int **out, int *count); + int getPointInfo(int point_id, CardParamPointInfo *out); + + int conAdd(bool multi, bool simple, int from_type, int from_patch, int from_io, int to_type, int to_patch, int to_io, int *id); + int conDel(int from_type, int from_patch, int from_io, int *id); + QString errorStr(int err); + + int getFXCount(int *cnt); + int getInputCount(int *cnt); + int getOutputCount(int *cnt); + + int getFX(int i, QString &name); + int getInput(int i, QString &name); + int getOutput(int i, QString &name); + + int getPInputCount(int pnum, int *cnt); + int getPOutputCount(int pnum, int *cnt); + int getPInput(int pnum, int i, QString &name); + int getPOutput(int pnum, int i, QString &name); + + int getPatchesInfo(CardParamPatchInfo ***pi, int *cnt); + + int getDspConfig(LD10k1DspFile **dc); + int putDspConfig(LD10k1DspFile *dc); +}; + +#endif // STRPARAM_H diff --git a/qlo10k1/src/structure.cpp b/qlo10k1/src/structure.cpp new file mode 100644 index 0000000..57d5c6e --- /dev/null +++ b/qlo10k1/src/structure.cpp @@ -0,0 +1,291 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "structure.h" +#include "structure_patch.h" +#include "structure_io.h" +#include "structure_link.h" +#include "ld10k1file.h" + +RSItemIO::RSItemIO(RSItemBase *o, bool out, int i, QString d) +{ + output = out; + idx = i; + desc = d; + owner = o; + connectedTo = NULL; +} + +RSItemIO::~RSItemIO() +{ + if (connectedTo) + { + int r = connectedTo->findRoute(this); + if (r >= 0) + connectedTo->setRoutePoint(r, NULL); + } +} + +bool RSItemIO::isOutput() +{ + return output; +} + +void RSItemIO::setOutput(bool o) +{ + output = o; +} + +int RSItemIO::getIdx() +{ + return idx; +} + +void RSItemIO::setIdx(int i) +{ + idx = i; +} + +QString RSItemIO::getDesc() +{ + return desc; +} + +void RSItemIO::setDesc(QString d) +{ + desc = d; +} + +RSItemBase *RSItemIO::getOwner() +{ + return owner; +} + +void RSItemIO::connectTo(StrLink *to) +{ + if (connectedTo) + { + int r = connectedTo->findRoute(this); + if (r >= 0) + connectedTo->setRoutePoint(r, NULL); + } + connectedTo = to; +} + +StrLink *RSItemIO::getConnectedTo() +{ + return connectedTo; +} + + + + +DrawingParams::DrawingParams(float zoom, QWidget *dt, QPaintEvent *pe, QPainter *p) +{ + zoomKoef = (float)zoom; + drawTo = dt; + paintEvent = pe; + painter = p; +} + +RSItemBase::RSItemBase() +{ + fNew = false; + fUsed = false; + fChanged = false; + fSelected = false; +} + +int RSItemBase::x() +{ + return position.x(); +} + +int RSItemBase::y() +{ + return position.y(); +} + +void RSItemBase::setPosition(int x, int y) +{ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + position.setX(x); + position.setY(y); +} + +int RSItemBase::width() +{ + return size.width(); +} + +int RSItemBase::height() +{ + return size.height(); +} + +int RSItemBase::minWidth() +{ + return minSize.width(); +} + +int RSItemBase::minHeight() +{ + return minSize.height(); +} + +void RSItemBase::setSize(int w, int h) +{ + if (w > minSize.width()) + size.setWidth(w); + if (h > minSize.height()) + size.setHeight(h); +} + +void RSItemBase::moveRel(int dx, int dy) +{ + setPosition(x() + dx, y() + dy); +} + +void RSItemBase::moveHandleRel(int num, int dx, int dy) +{ +} + +void RSItemBase::updateContents(QScrollView *sv, float zoom) +{ + sv->updateContents((int)(x() * zoom), + (int)(y() * zoom), + (int)(width() * zoom), + (int)(height() * zoom)); +} + +bool RSItemBase::containsPoint(int xp, int yp) +{ + return false; +} + +RSItemIO *RSItemBase::getIOAtPoint(int xp, int yp) +{ + return NULL; +} + + +bool RSItemBase::containsHandlePoint(int xp, int yp) +{ + return false; +} + +RSItemBase::RSItemHandle RSItemBase::getHandlePoint(int xp, int yp) +{ + return RSItemBase::None; +} + +int RSItemBase::getHandlePointNum(int xp, int yp) +{ + return -1; +} + +bool RSItemBase::flagUsed() +{ + return fUsed; +} + +void RSItemBase::setFlagUsed(bool u) +{ + fUsed = u; +} + +bool RSItemBase::flagNew() +{ + return fNew; +} + +void RSItemBase::setFlagNew(bool n) +{ + fNew = n; +} + +bool RSItemBase::flagChanged() +{ + return fNew; +} + +void RSItemBase::setFlagChanged(bool c) +{ + fChanged = c; +} + +bool RSItemBase::flagSelected() +{ + return fSelected; +} + +void RSItemBase::setFlagSelected(bool s) +{ + fSelected = s; +} + +QString RSItemBase::getDesc() +{ + return ""; +} + +void RSItemBase::draw(DrawingParams *dp) +{ +} + +void RSItemBase::calcSize() +{ + minSize = size; +} + + + + +RSItemBaseWithType::RSItemBaseWithType(ItemType type) +{ + iType = type; +} + +RSItemBaseWithType::ItemType RSItemBaseWithType::type() +{ + return iType; +} + +int RSItemBaseWithType::getMaxIOIdx(bool out) +{ + return 0; +} + +RSItemIO *RSItemBaseWithType::getIO(bool out, int idx) +{ + return NULL; +} + +void RSItemBaseWithType::getIOPoint(RSItemIO *item, int *xp, int *yp) +{ +} + +RSItemBaseWithType::~RSItemBaseWithType() +{ +} diff --git a/qlo10k1/src/structure.h b/qlo10k1/src/structure.h new file mode 100644 index 0000000..3342fa0 --- /dev/null +++ b/qlo10k1/src/structure.h @@ -0,0 +1,138 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRUCTURE_H +#define STRUCTURE_H + +#include +#include +#include +#include +#include + +class RSItemBase; +class StrPatch; +class StrInput; +class StrOutput; +class StrFX; +class StrLink; + +class RSItemIO +{ + bool output; + int idx; + QString desc; + RSItemBase *owner; + StrLink *connectedTo; +public: + RSItemIO(RSItemBase *o, bool out, int i, QString d); + ~RSItemIO(); + bool isOutput(); + void setOutput(bool o); + int getIdx(); + void setIdx(int i); + QString getDesc(); + void setDesc(QString d); + RSItemBase *getOwner(); + void connectTo(StrLink *to); + StrLink *getConnectedTo(); +}; + +class QWidget; +class QPainter; + +class DrawingParams +{ +public: + float zoomKoef; + DrawingParams(float zoom, QWidget *dt, QPaintEvent *pe, QPainter *p); + + QWidget *drawTo; + QPaintEvent *paintEvent; + QPainter *painter; +}; + +class RSItemBase +{ +public: + enum RSItemHandle {TopLeft, TopRight, BottomLeft, BottomRight, Other, None}; +private: + QPoint position; + QSize size; + QSize minSize; + + bool fNew; + bool fUsed; + bool fChanged; + + bool fSelected; +public: + RSItemBase(); + + // position + int x(); + int y(); + void setPosition(int x, int y); + // size + int width(); + int height(); + // size + int minWidth(); + int minHeight(); + void setSize(int w, int h); + virtual void moveRel(int dx, int dy); + virtual void moveHandleRel(int num, int dx, int dy); + virtual void updateContents(QScrollView *sv, float zoom); + QString getTooltipDecsription(); + virtual bool containsPoint(int xp, int yp); + virtual RSItemIO *getIOAtPoint(int xp, int yp); + virtual bool containsHandlePoint(int xp, int yp); + virtual RSItemHandle getHandlePoint(int xp, int yp); + virtual int getHandlePointNum(int xp, int yp); + bool flagUsed(); + void setFlagUsed(bool u); + bool flagNew(); + void setFlagNew(bool n); + bool flagChanged(); + void setFlagChanged(bool c); + bool flagSelected(); + void setFlagSelected(bool s); + virtual QString getDesc(); + virtual void draw(DrawingParams *dp); + virtual void calcSize(); +}; + +class RSItemBaseWithType : public RSItemBase +{ +public: + enum ItemType {In, Out, FX, Patch, Link}; +private: + ItemType iType; +public: + RSItemBaseWithType(ItemType type); + ItemType type(); + virtual int getMaxIOIdx(bool out); + virtual RSItemIO *getIO(bool out, int idx); + virtual void getIOPoint(RSItemIO *item, int *xp, int *yp); + virtual ~RSItemBaseWithType(); +}; + +#endif // STRUCTURE_H diff --git a/qlo10k1/src/structure_aa.cpp b/qlo10k1/src/structure_aa.cpp new file mode 100644 index 0000000..d0bddb9 --- /dev/null +++ b/qlo10k1/src/structure_aa.cpp @@ -0,0 +1,120 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include "structure.h" +#include "strglobal.h" + +// simple, but very far from perfect + +void StrGlobal::AutoArange(QPtrList *items) +{ + int maxx = 0; + int maxy = 0; + int inc = 0; + int pc = 0; + int outc = 0; + + // iterate through all + RSItemBaseWithType *item; + + for(item = items->first(); item; item = items->next() ) + { + if (item->flagNew()) + { + switch (item->type()) + { + case RSItemBaseWithType::In: + case RSItemBaseWithType::FX: + inc++; + break; + case RSItemBaseWithType::Out: + outc++; + break; + case RSItemBaseWithType::Patch: + pc++; + break; + default: + break; + } + } + else + { + int tmpx = item->x() + item->width(); + int tmpy = item->y() + item->height(); + + if (tmpx > maxx) + maxx = tmpx; + if (tmpy > maxy) + maxy = tmpy; + } + } + + int ini = 0; + int pi = 0; + int outi = 0; + + int sizex = (int)(sqrt(pc) + 1); + //int sizey = (int)((float)pc / sizex + 1); + + int offiny = maxy + 20; + int offinx = 0 + 20; + int offpy = maxy + 20; + int offpx = 0 + 20 + 90; + int offouty = maxy + 20; + int offoutx = sizex * 90 + 20 + 70 + 70; + int offheight = 0; + int maxoffheight = 0; + int heightaccum = 0; + + for(item = items->first(); item; item = items->next() ) + { + if (item->flagNew()) + { + switch (item->type()) + { + case RSItemBaseWithType::In: + case RSItemBaseWithType::FX: + item->setPosition(offinx, offiny + ini * 40); + ini++; + break; + case RSItemBaseWithType::Out: + item->setPosition(offoutx, offouty + outi * 40); + outi++; + break; + case RSItemBaseWithType::Patch: + item->setPosition(offpx + (pi % sizex) * 90, offpy + (pi / sizex) * 90 + heightaccum); + item->calcSize(); + offheight = item->height() - sizex * 10; + if ( offheight > maxoffheight ) + maxoffheight = offheight; + pi++; + break; + default: + break; + } + if(offpx + (pi % sizex) * 90 == offpx) { + heightaccum += maxoffheight; + maxoffheight = 0; + } + } + } +} diff --git a/qlo10k1/src/structure_io.cpp b/qlo10k1/src/structure_io.cpp new file mode 100644 index 0000000..466b023 --- /dev/null +++ b/qlo10k1/src/structure_io.cpp @@ -0,0 +1,151 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "structure_io.h" +#include "structure_link.h" + +#define IO_WIDTH 70 +#define IO_HEIGHT 20 + +StrIOBase::StrIOBase(RSItemBaseWithType::ItemType it) : RSItemBaseWithType(it) +{ +} + +void StrIOBase::calcSize() +{ + setSize(IO_WIDTH, IO_HEIGHT); + + RSItemBase::calcSize(); +} + +#define IO_SELECT_WH 7 +#define IO_INNER_SPACE_X 7 +#define IO_INNER_SPACE_Y 2 + +void StrIOBase::draw(DrawingParams *dp) +{ + int xp, yp, wp, hp; + xp = (int)(x() * dp->zoomKoef); + yp = (int)(y() * dp->zoomKoef); + wp = (int)(width() * dp->zoomKoef); + hp = (int)(height() * dp->zoomKoef); + + dp->painter->setPen(QPen(IO_BOX_COLOR, 1)); + dp->painter->drawRoundRect(xp, yp, wp, hp, 20, 50); + + if (flagSelected()) + { + // top left + dp->painter->fillRect( + xp, + yp, + (int)(IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + // top right + dp->painter->fillRect( + (int)(xp + wp - IO_SELECT_WH * dp->zoomKoef), + yp, + (int)(IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + // bottom left + dp->painter->fillRect( + xp, + (int)(yp + hp - IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + + // bottom right + dp->painter->fillRect( + (int)(xp + wp - IO_SELECT_WH * dp->zoomKoef), + (int)(yp + hp - IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + (int)(IO_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + } + + dp->painter->setPen(IO_TEXT_PEN); + dp->painter->drawText( + (int)((x() + 2 * IO_INNER_SPACE_X + (width() / 100) * 10) * dp->zoomKoef), + (int)((y() + IO_INNER_SPACE_Y + (height() / 100) * 10) * dp->zoomKoef), + (int)((width() - 4 * IO_INNER_SPACE_X) * dp->zoomKoef), + (int)((height() - 2 * IO_INNER_SPACE_Y) * dp->zoomKoef), + Qt::AlignLeft | Qt::WordBreak, + getIOName()); + dp->painter->setPen(DEF_PAINTING_PEN); +} + +bool StrIOBase::containsPoint(int xp, int yp) +{ + // FIXME - round shape + return QRect(x(), y(), width(), height()).contains(xp, yp); +} + +bool StrIOBase::containsHandlePoint(int xp, int yp) +{ + return getHandlePoint(xp, yp) != RSItemBase::None; +} + +RSItemBase::RSItemHandle StrIOBase::getHandlePoint(int xp, int yp) +{ + // top left + if (QRect(x(), y(), IO_SELECT_WH, IO_SELECT_WH).contains(xp, yp)) + return RSItemBase::TopLeft; + // top right + if (QRect(x() + width() - IO_SELECT_WH, y(), IO_SELECT_WH, IO_SELECT_WH).contains(xp, yp)) + return RSItemBase::TopRight; + // bottom left + if (QRect(x(), y() + height() - IO_SELECT_WH, IO_SELECT_WH, IO_SELECT_WH).contains(xp, yp)) + return RSItemBase::BottomLeft; + // bottom right + if (QRect(x() + width() - IO_SELECT_WH, y() + height() - IO_SELECT_WH, IO_SELECT_WH, IO_SELECT_WH).contains(xp, yp)) + return RSItemBase::BottomRight; + return RSItemBase::None; +} + +void StrIOBase::getIOPoint(RSItemIO *item, int *xp, int *yp) +{ + // for io it is in center + *xp = x() + width() / 2; + *yp = y() + height() / 2; +} + +void StrIOBase::updateContents(QScrollView *sv, float zoom) +{ + int i; + + for (i = 0; i < 2; i++) + { + RSItemIO *io = getIO(i, 0); + if (io) + { + StrLink *l = io->getConnectedTo(); + if (l) + l->updateOneSegment(sv, l->findRoute(io), zoom); + } + } + + RSItemBaseWithType::updateContents(sv, zoom); +} diff --git a/qlo10k1/src/structure_io.h b/qlo10k1/src/structure_io.h new file mode 100644 index 0000000..728647c --- /dev/null +++ b/qlo10k1/src/structure_io.h @@ -0,0 +1,245 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRUCTURE_IO_H +#define STRUCTURE_IO_H + +#include "structure.h" +#include "custom_colors.h" + +class StrIOBase : public RSItemBaseWithType +{ +public: + StrIOBase(RSItemBaseWithType::ItemType it); + + virtual void calcSize(); + virtual void draw(DrawingParams *dp); + virtual bool containsPoint(int xp, int yp); + virtual bool containsHandlePoint(int xp, int yp); + virtual RSItemHandle getHandlePoint(int xp, int yp); + + virtual QString getIOName() + { + return ""; + } + + virtual void getIOPoint(RSItemIO *item, int *xp, int *yp); + virtual void updateContents(QScrollView *sv, float zoom); +}; + + + +class StrInput : public StrIOBase +{ + QString inputName; + int inputNum; + + RSItemIO *io; +public: + QString name(void) + { + return inputName; + } + + virtual QString getIOName() + { + return "I " + QString().setNum(inputNum) + "\n" + inputName; + } + + void setName(QString nn) + { + inputName = nn; + io->setDesc(nn); + } + + StrInput(int in, QString name) : + StrIOBase(RSItemBaseWithType::In) + { + inputName = name; + inputNum = in; + + io = new RSItemIO(this, true, 0, name); + calcSize(); + } + + int num(void) + { + return inputNum; + } + + virtual int getMaxIOIdx(bool out) + { + if (out) + return 1; + else + return 0; + } + + virtual RSItemIO *getIO(bool out, int idx) + { + if (!out) + return NULL; + else if (idx == 0) + return io; + else + return NULL; + } + + virtual ~StrInput() + { + RSItemIO *tmp = io; + delete io; + io = NULL; + tmp->connectTo(NULL); + } +}; + +class StrOutput : public StrIOBase +{ + QString outputName; + int outputNum; + + RSItemIO *io; +public: + QString name(void) + { + return outputName; + } + + virtual QString getIOName() + { + return "O " + QString().setNum(outputNum) + "\n" + outputName; + } + + void setName(QString nn) + { + outputName = nn; + io->setDesc(nn); + } + + StrOutput(int on, QString name) : + StrIOBase(RSItemBaseWithType::Out) + { + outputName = name; + outputNum = on; + + io = new RSItemIO(this, false, 0, name); + calcSize(); + } + + int num(void) + { + return outputNum; + } + + virtual int getMaxIOIdx(bool out) + { + if (out) + return 0; + else + return 1; + } + + virtual RSItemIO *getIO(bool out, int idx) + { + if (out) + return NULL; + else if (idx == 0) + return io; + else + return NULL; + } + + virtual ~StrOutput() + { + RSItemIO *tmp = io; + delete io; + io = NULL; + tmp->connectTo(NULL); + } +}; + +class StrFX : public StrIOBase +{ + QString fxName; + int fxNum; + + RSItemIO *io; +public: + QString name(void) + { + return fxName; + } + + virtual QString getIOName() + { + return "F " + QString().setNum(fxNum) + "\n" + fxName; + } + + void setName(QString nn) + { + fxName = nn; + io->setDesc(nn); + } + + StrFX(int fn, QString name) : + StrIOBase(RSItemBaseWithType::FX) + { + fxName = name; + fxNum = fn; + + io = new RSItemIO(this, true, 0, name); + calcSize(); + } + + int num(void) + { + return fxNum; + } + + virtual int getMaxIOIdx(bool out) + { + if (out) + return 1; + else + return 0; + } + + virtual RSItemIO *getIO(bool out, int idx) + { + if (!out) + return NULL; + else if (idx == 0) + return io; + else + return NULL; + } + + virtual ~StrFX() + { + RSItemIO *tmp = io; + delete io; + io = NULL; + tmp->connectTo(NULL); + } +}; + +#endif // STRUCTURE_IO_H diff --git a/qlo10k1/src/structure_link.cpp b/qlo10k1/src/structure_link.cpp new file mode 100644 index 0000000..3920624 --- /dev/null +++ b/qlo10k1/src/structure_link.cpp @@ -0,0 +1,640 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include + +#include "structure_link.h" +#include "custom_colors.h" + +StrLink::StrLink(int id, LinkType t) + : RSItemBaseWithType(RSItemBaseWithType::Link) +{ + linkId = id; + type = t; + + for (int i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + routes[i] = NULL; + + useMixPoint = false; + + setSize(0, 0); + RSItemBaseWithType::calcSize(); +} + +StrLink::~StrLink() +{ + disconnectAll(); +} + +void StrLink::setId(int id) +{ + linkId = id; +} + +int StrLink::id() +{ + return linkId; +} + +void StrLink::setType(LinkType t) +{ + type = t; +} + +StrLink::LinkType StrLink::getType() +{ + return type; +} + +bool StrLink::isSimple() +{ + return simple; +} + +void StrLink::setSimple(bool s) +{ + simple = s; +} + +bool StrLink::isMulti() +{ + return multi; +} + +void StrLink::setMulti(bool m) +{ + multi = m; +} + +int StrLink::findRoute(RSItemIO *r) +{ + for (int i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i] == r) + return i; + } + return -1; +} + +RSItemIO *StrLink::getRoutePoint(int r) +{ + if (r >= POINTINFO_MAX_CONN_PER_POINT) + return NULL; + return routes[r]; +} + +void StrLink::setRoutePoint(int r, RSItemIO *ri) +{ + if (r >= POINTINFO_MAX_CONN_PER_POINT + 1) + return; + + RSItemIO *tmp = routes[r]; + routes[r] = NULL; + if (tmp) + tmp->connectTo(NULL); + + routes[r] = ri; + if (!ri) + routesPoints[r].clear(); + if (ri) + ri->connectTo(this); +} + +void StrLink::clearRoutesPoints(int r) +{ + if (r >= POINTINFO_MAX_CONN_PER_POINT + 1) + return; + routesPoints[r].clear(); +} + +#define LINK_SELECT_WH 7 + +void StrLink::setMinMaxPoint(QPoint p, int *minx, int *maxx, int *miny, int *maxy) +{ + if (p.x() - LINK_SELECT_WH / 2 < *minx) + *minx = p.x() - LINK_SELECT_WH / 2; + if (p.x() + LINK_SELECT_WH > *maxx) + *maxx = p.x() + LINK_SELECT_WH; + + if (p.y() - LINK_SELECT_WH / 2 < *miny) + *miny = p.y() - LINK_SELECT_WH / 2; + if (p.y() + LINK_SELECT_WH > *maxy) + *maxy = p.y() + LINK_SELECT_WH; +} + +void StrLink::setMinMax() +{ + int minx = 1000000; + int maxx = -1; + int miny = 1000000; + int maxy = -1; + + int i, j; + + if (useMixPoint) + setMinMaxPoint(mixPoint, &minx, &maxx, &miny, &maxy); + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + setMinMaxPoint(routesEndPoints[i], &minx, &maxx, &miny, &maxy); + + for (j = 0; j < (int)routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + setMinMaxPoint(tmpp, &minx, &maxx, &miny, &maxy); + } + } + } + + setPosition(minx, miny); + setSize(maxx - minx, maxy - miny); +} + +void StrLink::calcSize() +{ + int i; + int cnt = 0; + + int ioxp, ioyp; + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + cnt++; + + ((RSItemBaseWithType *)routes[i]->getOwner())->getIOPoint(routes[i], &ioxp, &ioyp); + routesEndPoints[i].setX(ioxp); + routesEndPoints[i].setY(ioyp); + } + } + + setMinMax(); + + if (cnt <= 2) + { + // not use mixpoint + useMixPoint = false; + } + else + { + // use mixpoint + if (!useMixPoint) + { + mixPoint.setX(x() + width() / 2); + mixPoint.setY(y() + height() / 2); + + useMixPoint = true; + } + } +} + +void StrLink::draw(DrawingParams *dp) +{ + int i, j; + for (i = useMixPoint ? 0 : 1; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + QPoint fp = routesEndPoints[i]; + if (flagSelected()) + dp->painter->fillRect( + (int)((fp.x() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)((fp.y() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + + for (j = 0; j < (int)routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + if (flagSelected()) + dp->painter->fillRect( + (int)((tmpp.x() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)((tmpp.y() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + + dp->painter->setPen(LINE_PEN); + dp->painter->drawLine((int)(fp.x() * dp->zoomKoef), + (int)(fp.y() * dp->zoomKoef), + (int)(tmpp.x() * dp->zoomKoef), + (int)(tmpp.y() * dp->zoomKoef)); + dp->painter->setPen(DEF_PAINTING_PEN); + fp = tmpp; + } + + if (useMixPoint) + { + dp->painter->setPen(LINE_PEN); + dp->painter->drawLine((int)(fp.x() * dp->zoomKoef), + (int)(fp.y() * dp->zoomKoef), + (int)(mixPoint.x() * dp->zoomKoef), + (int)(mixPoint.y() * dp->zoomKoef)); + dp->painter->setPen(DEF_PAINTING_PEN); + + if (flagSelected()) + dp->painter->fillRect( + (int)((mixPoint.x() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)((mixPoint.y() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + } + else + { + dp->painter->setPen(LINE_PEN); + dp->painter->drawLine((int)(fp.x() * dp->zoomKoef), + (int)(fp.y() * dp->zoomKoef), + (int)(routesEndPoints[0].x() * dp->zoomKoef), + (int)(routesEndPoints[0].y() * dp->zoomKoef)); + dp->painter->setPen(DEF_PAINTING_PEN); + + if (flagSelected()) + dp->painter->fillRect( + (int)((routesEndPoints[0].x() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)((routesEndPoints[0].y() - LINK_SELECT_WH / 2) * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + (int)(LINK_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + } + } + } + + if (useMixPoint) + { + dp->painter->drawEllipse((int)((mixPoint.x() - 1) * dp->zoomKoef), + (int)((mixPoint.y() - 1) * dp->zoomKoef), + (int)(3 * dp->zoomKoef), + (int)(3 * dp->zoomKoef)); + dp->painter->drawEllipse((int)((mixPoint.x() - 2) * dp->zoomKoef), + (int)((mixPoint.y() - 2) * dp->zoomKoef), + (int)(5 * dp->zoomKoef), + (int)(5 * dp->zoomKoef)); + dp->painter->drawEllipse((int)((mixPoint.x() - 3) * dp->zoomKoef), + (int)((mixPoint.y() - 3) * dp->zoomKoef), + (int)(7 * dp->zoomKoef), + (int)(7 * dp->zoomKoef)); + } +} + +void StrLink::moveRel(int dx, int dy) +{ + int i; + unsigned int j; + + if (useMixPoint) + moveRelPoint(&mixPoint, dx, dy); + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + for (j = 0; j < routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + moveRelPoint(&tmpp, dx, dy); + routesPoints[i][j] = tmpp; + } + } + } + + calcSize(); +} + +void StrLink::moveRelPoint(QPoint *p, int dx, int dy) +{ + p->setX(p->x() + dx); + p->setY(p->y() + dy); + + if (p->x() < 0) + p->setX(0); + if (p->y() < 0) + p->setY(0); +} + +void StrLink::updateOneSegment(QScrollView *sv, int r, float zoom) +{ + int ioxp; + int ioyp; + + if (r < 0 || r >= POINTINFO_MAX_CONN_PER_POINT + 1) + return; + + if (routes[r]) + { + ((RSItemBaseWithType *)routes[r]->getOwner())->getIOPoint(routes[r], &ioxp, &ioyp); + routesEndPoints[r].setX(ioxp); + routesEndPoints[r].setY(ioyp); + setMinMax(); + + if (routesPoints[r].count()) + { + QPoint rep = routesEndPoints[r]; + QPoint rp = routesPoints[r][0]; + + QRect rect(QPoint(rep.x(), rep.y()), QPoint(rp.x(), rp.y())); + rect = rect.normalize(); + rect.setX(rect.x() - LINK_SELECT_WH); + rect.setY(rect.y() - LINK_SELECT_WH); + rect.setWidth(rect.width() + 2 * LINK_SELECT_WH); + rect.setHeight(rect.height() + 2 * LINK_SELECT_WH); + sv->updateContents((int)(rect.x() * zoom), + (int)(rect.y() * zoom), + (int)(rect.width() * zoom), + (int)(rect.height() * zoom)); + } + else + { + if (useMixPoint) + { + QPoint rep = routesEndPoints[r]; + QRect rect(QPoint(rep.x(), rep.y()), QPoint(mixPoint.x(), mixPoint.y())); + rect = rect.normalize(); + rect.setX(rect.x() - LINK_SELECT_WH); + rect.setY(rect.y() - LINK_SELECT_WH); + rect.setWidth(rect.width() + 2 * LINK_SELECT_WH); + rect.setHeight(rect.height() + 2 * LINK_SELECT_WH); + sv->updateContents((int)(rect.x() * zoom), + (int)(rect.y() * zoom), + (int)(rect.width() * zoom), + (int)(rect.height() * zoom)); + } + else + sv->updateContents((int)((x() - LINK_SELECT_WH) * zoom), + (int)((y() - LINK_SELECT_WH) * zoom), + (int)((width() + 2 * LINK_SELECT_WH) * zoom), + (int)((height() + 2 * LINK_SELECT_WH) * zoom)); + } + } +} + +bool StrLink::containsPointPoint(QPoint &p, int xp, int yp) +{ + QRect r(p.x() - LINK_SELECT_WH / 2, p.y() - LINK_SELECT_WH / 2, + LINK_SELECT_WH + 1, LINK_SELECT_WH + 1); + + return r.contains(xp, yp); +} + +bool StrLink::containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp) +{ + QRect r(p1, p2); + if (!r.normalize().contains(xp, yp)) + return false; + + float v1 = p2.x() - p1.x(); + float v2 = p2.y() - p1.y(); + float a = v2; + float b = -v1; + + float c = v1 * p1.y() - v2 * p1.x(); + + if (fabs(a * xp + b * yp + c) / sqrt(a * a + b * b) < 4.0) + return true; + else + return false; +} + +bool StrLink::containsPoint(int xp, int yp) +{ + int i; + unsigned j; + + if (xp < x() || xp > x() + width() || + yp < y() || yp > y() + height()) + return false; + + if (useMixPoint) + { + if (containsPointPoint(mixPoint, xp, yp)) + return true; + } + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + QPoint fp = routesEndPoints[i]; + if (containsPointPoint(fp, xp, yp)) + return true; + + for (j = 0; j < routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + + if (containsPointPoint(tmpp, xp, yp)) + return true; + + if (containsPointSegment(fp, tmpp, xp, yp)) + return true; + fp = tmpp; + } + + if (useMixPoint) + { + if (containsPointSegment(fp, mixPoint, xp, yp)) + return true; + } + else + { + if (containsPointSegment(fp, routesEndPoints[0], xp, yp)) + return true; + } + } + } + return false; +} + +bool StrLink::containsHandlePoint(int xp, int yp) +{ + return getHandlePointNum(xp, yp) >= 0; +} + +int StrLink::getHandlePointNum(int xp, int yp) +{ + int i; + unsigned j; + + if (xp < x() || xp > x() + width() || + yp < y() || yp > y() + height()) + return -1; + + if (useMixPoint) + { + if (containsPointPoint(mixPoint, xp, yp)) + return 0; + } + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + for (j = 0; j < routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + + if (containsPointPoint(tmpp, xp, yp)) + return (i + 1) * 256 + j + 1; + } + } + } + + return -1; +} + +void StrLink::moveHandleRel(int num, int dx, int dy) +{ + int i; + int j; + + if (useMixPoint && num == 0) + { + moveRelPoint(&mixPoint, dx, dy); + setMinMax(); + return; + } + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + for (j = 0; j < (int)routesPoints[i].count(); j++) + { + if (num == (i + 1) * 256 + j + 1) + { + QPoint tmpp = routesPoints[i][j]; + moveRelPoint(&tmpp, dx, dy); + routesPoints[i][j] = tmpp; + setMinMax(); + return; + } + } + } + } +} + +void StrLink::disconnectAll() +{ + for (int i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + RSItemIO *tmp = routes[i]; + routes[i] = NULL; + tmp->connectTo(NULL); + } + } +} + +bool StrLink::isValid() +{ + int cnti = 0; + int cnto = 0; + for (int i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + if (routes[i]->isOutput()) + cnto++; + else + cnti++; + } + } + + if (getType() == LinkNormal) + return cnti + cnto > 1 && (cnti > 0 && cnto > 0); + else + return cnti + cnto > 1; + +} + +bool StrLink::addSegmentPoint(int xp, int yp) +{ + int i; + unsigned j; + + if (xp < x() || xp > x() + width() || + yp < y() || yp > y() + height()) + return false; + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + QPoint fp = routesEndPoints[i]; + for (j = 0; j < routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + + if (containsPointSegment(fp, tmpp, xp, yp)) + { + // add new point + routesPoints[i].insert(routesPoints[i].at(j), QPoint(xp,yp)); + return true; + } + fp = tmpp; + } + + if (useMixPoint) + { + if (containsPointSegment(fp, mixPoint, xp, yp)) + { + routesPoints[i].append(QPoint(xp,yp)); + return true; + } + } + else + { + if (containsPointSegment(fp, routesEndPoints[0], xp, yp)) + { + routesPoints[i].append(QPoint(xp,yp)); + return true; + } + } + } + } + return false; +} + +bool StrLink::delSegmentPoint(int num) +{ + if (num <= 0) + return false; + + int r = ((num - 1) / 256) - 1; + int i = ((num - 1) % 256); + + if (routes[r]) + { + if (i < (int)routesPoints[r].count()) + { + routesPoints[r].remove(routesPoints[r].at(i)); + return true; + } + } + + return false; +} diff --git a/qlo10k1/src/structure_link.h b/qlo10k1/src/structure_link.h new file mode 100644 index 0000000..d66b590 --- /dev/null +++ b/qlo10k1/src/structure_link.h @@ -0,0 +1,106 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRUCTURE_LINK_H +#define STRUCTURE_LINK_H + +#include "structure.h" +#include "strparam.h" + +class StrLink : public RSItemBaseWithType +{ +public: + enum LinkType {LinkFX, LinkIn, LinkOut, LinkNormal}; + enum IOType {IOIn, IOOut}; +private: + int linkId; + LinkType type; + bool simple; + bool multi; + + RSItemIO *routes[POINTINFO_MAX_CONN_PER_POINT + 1]; + + QValueList routesPoints[POINTINFO_MAX_CONN_PER_POINT + 1]; + QPoint routesEndPoints[POINTINFO_MAX_CONN_PER_POINT + 1]; + + bool useMixPoint; + QPoint mixPoint; + bool containsPointPoint(QPoint &p, int xp, int yp); + bool containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp); +public: + StrLink(int id, LinkType t); + virtual ~StrLink(); + + void setId(int id); + int id(); + + void setType(LinkType t); + LinkType getType(); + + bool isSimple(); + void setSimple(bool s); + + bool isMulti(); + void setMulti(bool m); + + int getMaxRoute() + { + return POINTINFO_MAX_CONN_PER_POINT; + } + + void disconnectAll(); + + int findRoute(RSItemIO *r); + RSItemIO *getRoutePoint(int r); + void setRoutePoint(int r, RSItemIO *ri); + void clearRoutesPoints(int r); + + virtual void calcSize(); + virtual void draw(DrawingParams *dp); + + virtual void moveRel(int dx, int dy); + + void setMinMaxPoint(QPoint p, int *minx, int *maxx, int *miny, int *maxy); + void setMinMax(); + void moveRelPoint(QPoint *p, int dx, int dy); + void updateOneSegment(QScrollView *sv, int r, float zoom); + + virtual bool containsPoint(int xp, int yp); + + virtual bool containsHandlePoint(int xp, int yp); + virtual int getHandlePointNum(int xp, int yp); + + virtual RSItemHandle getHandlePoint(int xp, int yp) + { + if (getHandlePointNum(xp, yp) >= 0) + return RSItemBase::Other; + else + return RSItemBase::None; + } + + virtual void moveHandleRel(int num, int dx, int dy); + + bool isValid(); + bool addSegmentPoint(int xp, int yp); + bool delSegmentPoint(int num); +}; + +#endif // STRUCTURE_LINK_H diff --git a/qlo10k1/src/structure_patch.cpp b/qlo10k1/src/structure_patch.cpp new file mode 100644 index 0000000..0fa1871 --- /dev/null +++ b/qlo10k1/src/structure_patch.cpp @@ -0,0 +1,365 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "structure_patch.h" +#include "structure_link.h" + +QString StrPatch::name(void) +{ + return patchName; +} + +void StrPatch::setName(QString pn) +{ + patchName = pn; +} + +StrPatch::StrPatch(int pn, int id, QString name) : + RSItemBaseWithType(RSItemBaseWithType::Patch) +{ + patchName = name; + patchNum = pn; + patchId = id; + patchOrder = 0; + + count[0] = 0; + count[1] = 0; + + int i, j; + for (i = 0; i < 2; i++) + for (j = 0; j < 32; j++) + ios[i][j] = NULL; +} + +int StrPatch::num(void) +{ + return patchNum; +} + +int StrPatch::id(void) +{ + return patchId; +} + +int StrPatch::order(void) +{ + return patchOrder; +} + +void StrPatch::setOrder(int o) +{ + patchOrder = o; +} + +int StrPatch::getMaxIOIdx(bool out) +{ + return 32; +} + +RSItemIO *StrPatch::getIO(bool out, int idx) +{ + if (idx >= 32) + return NULL; + else + return ios[out][idx]; +} + +void StrPatch::setIO(bool out, int idx, RSItemIO *io) +{ + if (idx >= 32) + return; + else + { + if (ios[out][idx]) + delete ios[out][idx]; + ios[out][idx] = io; + } + getIOCount(&(count[0]), &(count[1])); +} + +StrPatch::~StrPatch() +{ + int i, j; + for (i = 0; i < 2; i++) + for (j = 0; j < 32; j++) + if (ios[i][j]) + { + RSItemIO *tmp = ios[i][j]; + delete ios[i][j]; + ios[i][j] = NULL; + tmp->connectTo(NULL); + } +} + +void StrPatch::getIOCount(int *in, int *out) +{ + // get count of inputs and outputs + int i, j; + int count[2]; + for (i = 0; i < 2; i++) + { + count[i] = 0; + for (j = 0; j < 32; j++) + if (ios[i][j]) + count[i]++; + } + *in = count[0]; + *out = count[1]; +} + +#define PATCH_IO_WIDTH 8 +#define PATCH_IO_HEIGHT 8 + +#define PATCH_WIDTH 70 + +#define PATCH_SELECT_WH 7 + +void StrPatch::calcSize() +{ + // get count of inputs and outputs + int max_count; + if (count[0] > count[1]) + max_count = count[0]; + else + max_count = count[1]; + + setSize(PATCH_WIDTH, (max_count * 2 + 2) * PATCH_IO_HEIGHT + PATCH_SELECT_WH * 2); + + RSItemBase::calcSize(); +} + +void StrPatch::draw(DrawingParams *dp) +{ + int xp, yp, wp, hp; + xp = (int)(x() * dp->zoomKoef); + yp = (int)(y() * dp->zoomKoef); + wp = (int)(width() * dp->zoomKoef); + hp = (int)(height() * dp->zoomKoef); + + dp->painter->setPen(QPen(BOX_COLOR, 1)); + dp->painter->drawRect(xp, yp, wp, hp); + + if (flagSelected()) + { + // top left + dp->painter->fillRect( + xp, + yp, + (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + // top right + dp->painter->fillRect( + xp + wp - (int)(PATCH_SELECT_WH * dp->zoomKoef), + yp, + (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + // bottom left + dp->painter->fillRect( + xp, + yp + hp - (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + + // bottom right + dp->painter->fillRect( + xp + wp - (int)(PATCH_SELECT_WH * dp->zoomKoef), + yp + hp - (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + (int)(PATCH_SELECT_WH * dp->zoomKoef), + QBrush(BOX_SELECTED_COLOR)); + } + + int i; + + float tmpy = PATCH_IO_HEIGHT + PATCH_SELECT_WH; + + float stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[0]; + + if (count[0] > 1) + stepy = stepy / (count[0] - 1); + + for (i = 0; i < count[0]; i++) + { + dp->painter->setPen(QPen(BOX_COLOR, 1)); + dp->painter->drawRect( + (int)(x() * dp->zoomKoef), + (int)((y() + tmpy ) * dp->zoomKoef), + (int)(PATCH_IO_WIDTH * dp->zoomKoef), + (int)(PATCH_IO_HEIGHT * dp->zoomKoef) + ); + tmpy += stepy + PATCH_IO_HEIGHT; + } + + tmpy = PATCH_IO_HEIGHT + PATCH_SELECT_WH; + + stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[1]; + + if (count[1] > 1) + stepy = stepy / (count[1] - 1); + + + for (i = 0; i < count[1]; i++) + { + dp->painter->setPen(QPen(BOX_COLOR, 1)); + dp->painter->drawRect( + (int)((x() + width() - PATCH_IO_WIDTH) * dp->zoomKoef), + (int)((y() + tmpy) * dp->zoomKoef), + (int)(PATCH_IO_WIDTH * dp->zoomKoef), + (int)(PATCH_IO_HEIGHT * dp->zoomKoef)); + tmpy += stepy + PATCH_IO_HEIGHT; + } + + QString pname = QString("%1\n%2").arg(num()).arg(name()); + + dp->painter->setPen(QPen(TEXT_COLOR, 1)); + dp->painter->drawText( + (int)((x() + 2 * PATCH_IO_WIDTH) * dp->zoomKoef), + (int)((y() + PATCH_IO_HEIGHT) * dp->zoomKoef), + (int)((width() - 4 * PATCH_IO_WIDTH) * dp->zoomKoef), + (int)((height() - 2 * PATCH_IO_HEIGHT) * dp->zoomKoef), + Qt::AlignLeft | Qt::WordBreak, + pname); +} + +bool StrPatch::containsPoint(int xp, int yp) +{ + return QRect(x(), y(), width(), height()).contains(xp, yp); +} + +RSItemIO *StrPatch::getIOAtPoint(int xp, int yp) +{ + QRect r; + + for (int j = 0; j < 2; j++) + for (int i = 0; i < count[j]; i++) + { + if (ios[j][i]) + { + getIORect(j, i, r); + if (r.contains(xp, yp)) + return ios[j][i]; + } + } + return NULL; +} + +void StrPatch::getIORect(bool out, int idx, QRect &r) +{ + float tmpy = PATCH_IO_HEIGHT + PATCH_SELECT_WH; + + if (!out) + { + float stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[0]; + + if (count[0] > 1) + stepy = stepy / (count[0] - 1); + + r.setRect(x(), (int)(y() + tmpy + idx * (stepy + PATCH_IO_HEIGHT)), + PATCH_IO_WIDTH, PATCH_IO_HEIGHT); + } + else + { + float stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[1]; + + if (count[1] > 1) + stepy = stepy / (count[1] - 1); + + r.setRect(x() + width() - PATCH_IO_WIDTH, (int)(y() + tmpy + idx * (stepy + PATCH_IO_HEIGHT)), + PATCH_IO_WIDTH, PATCH_IO_HEIGHT); + } +} + +bool StrPatch::containsHandlePoint(int xp, int yp) +{ + return getHandlePoint(xp, yp) != RSItemBase::None; +} + +RSItemBase::RSItemHandle StrPatch::getHandlePoint(int xp, int yp) +{ + // top left + if (QRect(x(), y(), PATCH_SELECT_WH, PATCH_SELECT_WH).contains(xp, yp)) + return RSItemBase::TopLeft; + // top right + if (QRect(x() + width() - PATCH_SELECT_WH, y(), PATCH_SELECT_WH, PATCH_SELECT_WH).contains(xp, yp)) + return RSItemBase::TopRight; + // bottom left + if (QRect(x(), y() + height() - PATCH_SELECT_WH, PATCH_SELECT_WH, PATCH_SELECT_WH).contains(xp, yp)) + return RSItemBase::BottomLeft; + // bottom right + if (QRect(x() + width() - PATCH_SELECT_WH, y() + height() - PATCH_SELECT_WH, PATCH_SELECT_WH, PATCH_SELECT_WH).contains(xp, yp)) + return RSItemBase::BottomRight; + return RSItemBase::None; +} + +void StrPatch::getIOPoint(RSItemIO *item, int *xp, int *yp) +{ + // for io it is in center + if (item->isOutput()) + { + float tmpy = PATCH_IO_HEIGHT + PATCH_SELECT_WH; + + float stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[1]; + + if (count[1] > 1) + stepy = stepy / (count[1] - 1); + + *xp = x() + width() - PATCH_IO_WIDTH + PATCH_IO_WIDTH / 2; + *yp = (int)(y() + tmpy + (stepy + PATCH_IO_HEIGHT) * item->getIdx() + PATCH_IO_HEIGHT / 2); + return; + } + else + { + float tmpy = PATCH_IO_HEIGHT + PATCH_SELECT_WH; + + float stepy = height() - 2 * (PATCH_IO_HEIGHT + PATCH_SELECT_WH) - PATCH_IO_HEIGHT * count[0]; + + if (count[0] > 1) + stepy = stepy / (count[0] - 1); + + *xp = x() + PATCH_IO_WIDTH / 2; + *yp = (int)(y() + tmpy + (stepy + PATCH_IO_HEIGHT)* item->getIdx() + PATCH_IO_HEIGHT / 2); + return; + } +} + +void StrPatch::updateContents(QScrollView *sv, float zoom) +{ + int i; + int j; + + for (i = 0; i < 2; i++) + { + for (j = 0; j < 32; j++) + if (ios[i][j]) + { + StrLink *l = ios[i][j]->getConnectedTo(); + if (l) + l->updateOneSegment(sv, l->findRoute(ios[i][j]), zoom); + } + } + + RSItemBaseWithType::updateContents(sv, zoom); +} diff --git a/qlo10k1/src/structure_patch.h b/qlo10k1/src/structure_patch.h new file mode 100644 index 0000000..1e66336 --- /dev/null +++ b/qlo10k1/src/structure_patch.h @@ -0,0 +1,69 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef STRUCTURE_PATCH_H +#define STRUCTURE_PATCH_H + +#include "structure.h" +#include "custom_colors.h" + +class StrPatch : public RSItemBaseWithType +{ + QString patchName; + int patchNum; + int patchId; + int patchOrder; + + RSItemIO *ios[2][32]; + int count[2]; + + void getIOCount(int *in, int *out); +public: + QString name(void); + void setName(QString pn); + StrPatch(int pn, int id, QString name); + int num(void); + int id(void); + + int order(void); + void setOrder(int o); + + void getIORect(bool out, int idx, QRect &r); + + virtual int getMaxIOIdx(bool out); + virtual RSItemIO *getIO(bool out, int idx); + virtual void setIO(bool out, int idx, RSItemIO *io); + virtual ~StrPatch(); + virtual void calcSize(); + + virtual void draw(DrawingParams *dp); + + virtual bool containsPoint(int xp, int yp); + virtual RSItemIO *getIOAtPoint(int xp, int yp); + virtual bool containsHandlePoint(int xp, int yp); + virtual RSItemHandle getHandlePoint(int xp, int yp); + + virtual void getIOPoint(RSItemIO *item, int *xp, int *yp); + + virtual void updateContents(QScrollView *sv, float zoom); +}; + +#endif // STRUCTURE_PATCH_H diff --git a/qlo10k1/src/transformpatchdialog.cpp b/qlo10k1/src/transformpatchdialog.cpp new file mode 100644 index 0000000..9313053 --- /dev/null +++ b/qlo10k1/src/transformpatchdialog.cpp @@ -0,0 +1,462 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "app_global.h" +#include "transformpatchdialog.h" +#include "structure_patch.h" +#include "structure_io.h" + +TransformPatchDlg::TransformPatchDlg(QString efileName, EMU10k1File *efile) + : TransformPatchBase() +{ + fileName = efileName; + file = efile; + + leFileName->setText(fileName); + lePatchName->setText(file->getPatchName()); + + // load controls list + int i; + for (i = 0; i < file->getCtrlCount(); i++) + { + QString text = getName(i); + lbFileCtrl->insertItem(text); + ctrlFileList.append(i); + } + + // set default in names + switch (file->getInCount()) + { + case 1: + inputNames.append("I"); + break; + case 2: + inputNames.append("IL"); + inputNames.append("IR"); + break; + case 4: + inputNames.append("IL"); + inputNames.append("IR"); + inputNames.append("IRL"); + inputNames.append("IRR"); + break; + case 6: + inputNames.append("IL"); + inputNames.append("IR"); + inputNames.append("IRL"); + inputNames.append("IRR"); + inputNames.append("IC"); + inputNames.append("ILFE"); + break; + default: + for (i = 0; i < file->getInCount(); i++) + inputNames.append(""); + break; + } + + // set default out names + switch (file->getOutCount()) + { + case 1: + outputNames.append("O"); + break; + case 2: + outputNames.append("OL"); + outputNames.append("OR"); + break; + case 4: + outputNames.append("OL"); + outputNames.append("OR"); + outputNames.append("ORL"); + outputNames.append("ORR"); + break; + case 6: + outputNames.append("OL"); + outputNames.append("OR"); + outputNames.append("ORL"); + outputNames.append("ORR"); + outputNames.append("OC"); + outputNames.append("OLFE"); + break; + default: + for (i = 0; i < file->getOutCount(); i++) + outputNames.append(""); + break; + } + + for (i = 0; i < file->getInCount(); i++) + lbInputs->insertItem(inputNames[i]); + + for (i = 0; i < file->getOutCount(); i++) + lbOutputs->insertItem(outputNames[i]); + + connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + + connect(lbInputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(inputsDoubleClicked(QListBoxItem *))); + connect(lbOutputs, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(outputsDoubleClicked(QListBoxItem *))); + + connect(pbCtrlAdd, SIGNAL(clicked()), this, SLOT(ctrlAddClicked())); + connect(pbCtrlDel, SIGNAL(clicked()), this, SLOT(ctrlDelClicked())); + + connect(lbLoadedCtrl, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(loadedDoubleClicked(QListBoxItem *))); + connect(lbFileCtrl, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(fileDoubleClicked(QListBoxItem *))); +} + +QString TransformPatchDlg::getName(int i) +{ + EMU10k1Ctrl ctrl; + + file->getCtrl(i, &ctrl); + QString name = QString(ctrl.name) + " - " + QString().setNum(ctrl.value) + + " (" + QString().setNum(ctrl.min) + "," + + QString().setNum(ctrl.max) + ")"; + return name; +} + +void TransformPatchDlg::okClicked() +{ + // load patch + done(Accepted); +} + +void TransformPatchDlg::cancelClicked() +{ + done(Rejected); +} + +void TransformPatchDlg::inputsDoubleClicked(QListBoxItem *item) +{ + bool ok; + int idx = lbInputs->index(item); + QString text = inputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Input name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + inputNames[idx] = text; + lbInputs->changeItem(text, idx); + } +} + +void TransformPatchDlg::outputsDoubleClicked(QListBoxItem *item) +{ + bool ok; + int idx = lbOutputs->index(item); + QString text = outputNames[idx]; + text = QInputDialog::getText( + APP_NAME, "Output name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + outputNames[idx] = text; + lbOutputs->changeItem(text, idx); + } +} + +void TransformPatchDlg::ctrlAddClicked() +{ + QValueList selectedCtrl, *tmpList; + + int i; + unsigned int min = 0; + unsigned int max = 0; + bool first = true; + for (i = 0; i < (int)lbFileCtrl->count(); i++) + { + if (lbFileCtrl->isSelected(i)) + { + selectedCtrl.append(ctrlFileList[i]); + + EMU10k1Ctrl ctrl; + file->getCtrl(ctrlFileList[i], &ctrl); + + if (first) + { + min = ctrl.min; + max = ctrl.max; + } + else + { + if (min != ctrl.min || + max != ctrl.max) + { + QMessageBox::critical(0, APP_NAME, + QString("Wrong range for control %1").arg(ctrl.name)); + return; + } + } + first = false; + } + } + + if (selectedCtrl.count() > 0) + { + TranslatedCtrl ctrl; + tmpList = &selectedCtrl; + + for (;;) + { + FileControlDlg d(tmpList, file, &ctrl); + + if (d.exec() == QDialog::Accepted) + { + bool found = false; + // check name - in translated + for (i = 0; i < (int)translatedList.count(); i++) + { + if (translatedList[i].name == ctrl.name) + { + found = true; + break; + } + } + + // check in other + for (i = 0; i < (int)ctrlFileList.count(); i++) + { + EMU10k1Ctrl ctrl1; + file->getCtrl(ctrlFileList[i], &ctrl1); + if (selectedCtrl.findIndex(ctrlFileList[i]) < 0 && ctrl1.name == ctrl.name) + { + found = true; + break; + } + } + + if (found) + { + QMessageBox::critical( 0, APP_NAME, + QString("There already is control with this name %1").arg(ctrl.name)); + tmpList = NULL; + continue; + } + else + { + // add to translated + translatedList.append(ctrl); + // remove selected controls from ctrlList + for (i = 0; i < (int)selectedCtrl.count(); i++) + { + int fidx = ctrlFileList.findIndex(selectedCtrl[i]); + if (fidx >= 0) + { + ctrlFileList.remove(selectedCtrl[i]); + lbFileCtrl->removeItem(fidx); + } + } + lbLoadedCtrl->insertItem(ctrl.name); + + break; + } + } + else + break; + } + } +} + +void TransformPatchDlg::ctrlDelClicked() +{ + QValueList selectedCtrl; + + int i, j; + + for (i = 0; i < (int)lbLoadedCtrl->count(); i++) + { + if (lbLoadedCtrl->isSelected(i)) + { + selectedCtrl.append(i); + } + } + + if (selectedCtrl.count() > 0) + { + // add controls to FileList + for (i = 0; i < (int)selectedCtrl.count(); i++) + { + TranslatedCtrl ctrl = translatedList[selectedCtrl[i]]; + + for (j = 0; j < (int)ctrl.fileCtrlIdx.count(); j++) + { + lbFileCtrl->insertItem(getName(ctrl.fileCtrlIdx[j])); + ctrlFileList.append(ctrl.fileCtrlIdx[j]); + } + } + + // delete selected + for (i = 0; i < (int)selectedCtrl.count(); i++) + { + translatedList.remove(translatedList.at(selectedCtrl[i])); + lbLoadedCtrl->removeItem(selectedCtrl[i]); + } + } +} + +void TransformPatchDlg::loadedDoubleClicked(QListBoxItem *item) +{ + int idx = lbLoadedCtrl->index(item); + int i; + + TranslatedCtrl ctrl = translatedList[idx]; + + for (;;) + { + FileControlDlg d(NULL, file, &ctrl); + + if (d.exec() == QDialog::Accepted) + { + bool found = false; + // check name - in translated + for (i = 0; i < (int)translatedList.count(); i++) + { + if (i != idx && translatedList[i].name == ctrl.name) + { + found = true; + break; + } + } + + // check in other + for (i = 0; i < (int)ctrlFileList.count(); i++) + { + EMU10k1Ctrl ctrl1; + file->getCtrl(ctrlFileList[i], &ctrl1); + + if (ctrl.name == ctrl.name) + { + found = true; + break; + } + } + + if (found) + { + QMessageBox::critical( 0, APP_NAME, + QString("There already is control with this name %1").arg(ctrl.name)); + continue; + } + else + { + // update name + lbLoadedCtrl->changeItem(ctrl.name, idx); + translatedList[idx] = ctrl; + break; + } + } + else + break; + } +} + +void TransformPatchDlg::fileDoubleClicked(QListBoxItem *item) +{ + bool ok; + int idx = lbFileCtrl->index(item); + EMU10k1Ctrl ctrl; + file->getCtrl(ctrlFileList[idx], &ctrl); + QString text = ctrl.name; + text = QInputDialog::getText( + APP_NAME, "Control name:", QLineEdit::Normal, + text, &ok, this ); + if (ok && !text.isEmpty()) + { + ctrl.name= text; + file->setCtrl(ctrlFileList[idx], &ctrl); + lbFileCtrl->changeItem(getName(idx), idx); + } +} + +int TransformPatchDlg::transformFile(LD10k1File **outFile) +{ + // controls - translated + int i, j, err; + + LD10k1File *of = NULL; + + LD10k1FileTransfCtl translCtls[32]; + for (i = 0; i < (int)translatedList.count(); i++) + { + TranslatedCtrl tctrl = translatedList[i]; + + translCtls[i].emu_ctl_count = (int)tctrl.fileCtrlIdx.count(); + for (j = 0; j < translCtls[i].emu_ctl_count; j++) + translCtls[i].emu_ctls[j] = tctrl.fileCtrlIdx[j]; + + translCtls[i].ctl_name = tctrl.name; + } + + if ((err = LD10k1File::transformFromEmuFile(file, translCtls, (int)translatedList.count(), outFile)) < 0) + return err; + + of = *outFile; + + // rename inputs + for (i = 0; i < of->getIOCount(false); i++) + of->setIOName(false, i, inputNames[i]); + + // rename output + for (i = 0; i < of->getIOCount(true); i++) + of->setIOName(true, i, outputNames[i]); + + // set others parameters for patch controls + for (i = 0; i < (int)translatedList.count(); i++) + { + TranslatedCtrl tctrl = translatedList[i]; + + switch (tctrl.translation) + { + case TranslatedCtrl::None: + of->setCtlTranslation(i, LD10k1File::None); + break; + case TranslatedCtrl::Table100: + of->setCtlTranslation(i, LD10k1File::Table100); + break; + case TranslatedCtrl::Bass: + of->setCtlTranslation(i, LD10k1File::Bass); + break; + case TranslatedCtrl::Treble: + of->setCtlTranslation(i, LD10k1File::Treble); + break; + case TranslatedCtrl::OnOff: + of->setCtlTranslation(i, LD10k1File::OnOff); + break; + } + of->setCtlValVCount(i, tctrl.visible); + for (j = 0; j < (int)tctrl.values.count(); j++) + of->setCtlVal(i, j, tctrl.values[j]); + } + + return 0; +} diff --git a/qlo10k1/src/transformpatchdialog.h b/qlo10k1/src/transformpatchdialog.h new file mode 100644 index 0000000..8962180 --- /dev/null +++ b/qlo10k1/src/transformpatchdialog.h @@ -0,0 +1,65 @@ +/* + * qlo10k1 - GUI frontend for ld10k1 + * + * Copyright (c) 2004 by Peter Zubaj + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef TRANSFORMPATCHDIALOG_H +#define TRANSFORMPATCHDIALOG_H + +#include +#include +#include +#include "dlgs/transformpatchbase.h" +#include "filecontroldialog.h" +#include "connectionwizard.h" +#include "structure.h" +#include "structure_patch.h" +#include "ld10k1file.h" + +class TransformPatchDlg : public TransformPatchBase +{ + Q_OBJECT + EMU10k1File *file; + QString fileName; + QStringList inputNames; + QStringList outputNames; + + QValueList ctrlFileList; + QValueList translatedList; +public: + + TransformPatchDlg(QString efileName, EMU10k1File *efile); + + QString getName(int i); + int transformFile(LD10k1File **outFile); +public slots: + void okClicked(); + void cancelClicked(); + + void inputsDoubleClicked(QListBoxItem *item); + void outputsDoubleClicked(QListBoxItem *item); + + void ctrlAddClicked(); + void ctrlDelClicked(); + + void loadedDoubleClicked(QListBoxItem *item); + void fileDoubleClicked(QListBoxItem *item); +}; + +#endif // TRANSFORMPATCHDIALOG_H