bppphyview-0.3.0/README000644 000000 000000 00000000000 12147656666 014556 0ustar00rootroot000000 000000 bppphyview-0.3.0/CMakeLists.txt000644 000000 000000 00000015612 12147656666 016455 0ustar00rootroot000000 000000 # CMake script for Bio++ PhyView # Author: Julien Dutheil # Created: 22/08/2009 # Global parameters CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bppphyview CXX C) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_CXX_FLAGS "-Wall") IF(NOT NO_VIRTUAL_COV) SET(NO_VIRTUAL_COV FALSE CACHE BOOL "Disable covariant return type with virtual inheritance, for compilers that do not support it." FORCE) ENDIF(NOT NO_VIRTUAL_COV) IF(NO_VIRTUAL_COV) MESSAGE("-- Covariant return with virtual inheritance disabled.") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_VIRTUAL_COV=1") ENDIF(NO_VIRTUAL_COV) IF(NOT NO_DEP_CHECK) SET(NO_DEP_CHECK FALSE CACHE BOOL "Disable dependencies check for building distribution only." FORCE) ENDIF(NOT NO_DEP_CHECK) IF(NOT DOC_COMPRESS) SET(DOC_COMPRESS gzip CACHE STRING "Set program for compressing documentation." FORCE) ENDIF(NOT DOC_COMPRESS) IF(NOT DOC_COMPRESS_EXT) SET(DOC_COMPRESS_EXT gz CACHE STRING "Set extension of compressed documentation." FORCE) ENDIF(NOT DOC_COMPRESS_EXT) IF(NO_DEP_CHECK) MESSAGE("-- Dependencies checking disabled. Only distribution can be built.") ELSE(NO_DEP_CHECK) #static linkage? IF(NOT BUILD_STATIC) SET(BUILD_STATIC FALSE CACHE BOOL "Enable static linkage." FORCE) ENDIF() IF(BUILD_STATIC) MESSAGE("-- Static linkage requested.") SET(CMAKE_CXX_FLAGS "-static -static-libgcc ${CMAKE_CXX_FLAGS}") ENDIF() #build man pages? IF(NOT DEFINED MAN) SET(MAN UNIX) ENDIF(NOT DEFINED MAN) #find executables for documentation IF(MAN) FIND_PROGRAM(NROFF_EXE NAMES nroff) IF(NROFF_EXE) MESSAGE("-- Found nroff here: ${NROFF_EXE}") MESSAGE(" Adding targets: man") ADD_CUSTOM_TARGET(man ALL COMMAND cp phyview.1.txt phyview.1 COMMAND ${DOC_COMPRESS} -f phyview.1 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/man ) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES man/phyview.1.${DOC_COMPRESS_EXT}) ELSE() MESSAGE(FATAL_ERROR "Program nroff required but not found.") ENDIF() ENDIF(MAN) #here is a useful function: MACRO(IMPROVED_FIND_LIBRARY OUTPUT_LIBS lib_name include_to_find) #start: FIND_PATH(${lib_name}_INCLUDE_DIR ${include_to_find}) INCLUDE_DIRECTORIES(${${lib_name}_INCLUDE_DIR}) IF(BUILD_STATIC) SET(${lib_name}_STATIC_NAMES lib${lib_name}.a) FIND_LIBRARY(${lib_name}_STATIC_LIBRARY NAMES ${${lib_name}_STATIC_NAMES} PATH_SUFFIXES lib${LIB_SUFFIX}) IF(${lib_name}_STATIC_LIBRARY) MESSAGE("-- Library ${lib_name} found here:") MESSAGE(" includes: ${${lib_name}_INCLUDE_DIR}") MESSAGE(" static libraries: ${${lib_name}_STATIC_LIBRARY}") ELSE() MESSAGE(FATAL_ERROR "${lib_name} required but not found.") ENDIF() #add the dependency: SET(${OUTPUT_LIBS} ${${OUTPUT_LIBS}} ${${lib_name}_STATIC_LIBRARY}) ELSE() SET(${lib_name}_NAMES ${lib_name} ${lib_name}.lib ${lib_name}.dll) FIND_LIBRARY(${lib_name}_LIBRARY NAMES ${${lib_name}_NAMES} PATH_SUFFIXES lib${LIB_SUFFIX}) IF(${lib_name}_LIBRARY) MESSAGE("-- Library ${lib_name} found here:") MESSAGE(" includes: ${${lib_name}_INCLUDE_DIR}") MESSAGE(" dynamic libraries: ${${lib_name}_LIBRARY}") ELSE() MESSAGE(FATAL_ERROR "${lib_name} required but not found.") ENDIF() #add the dependency: SET(${OUTPUT_LIBS} ${${OUTPUT_LIBS}} ${${lib_name}_LIBRARY}) ENDIF() ENDMACRO(IMPROVED_FIND_LIBRARY) # Set the CMAKE_PREFIX_PATH for the find_library fonction when using non # standard install location IF(CMAKE_INSTALL_PREFIX) SET(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH}) ENDIF(CMAKE_INSTALL_PREFIX) #Find the libraries. The order is very important for static linkage, it won't #link if you change it! IMPROVED_FIND_LIBRARY(LIBS bpp-qt Bpp/Qt/QtGraphicDevice.h) IMPROVED_FIND_LIBRARY(LIBS bpp-phyl Bpp/Phyl/Tree.h) IMPROVED_FIND_LIBRARY(LIBS bpp-seq Bpp/Seq/Alphabet/Alphabet.h) IMPROVED_FIND_LIBRARY(LIBS bpp-core Bpp/Clonable.h) # Find the Qt installation FIND_PACKAGE(Qt4 4.4.0 COMPONENTS QtCore QtGui REQUIRED) INCLUDE(${QT_USE_FILE}) SET(LIBS ${LIBS} ${QT_LIBRARIES}) # Subdirectories ADD_SUBDIRECTORY(bppPhyView) ADD_SUBDIRECTORY(man) ENDIF(NO_DEP_CHECK) # Packager SET(CPACK_PACKAGE_NAME "bppphyview") SET(CPACK_PACKAGE_VENDOR "Bio++ Development Team") SET(CPACK_PACKAGE_VERSION "0.3.0") SET(CPACK_PACKAGE_VERSION_MAJOR "0") SET(CPACK_PACKAGE_VERSION_MINOR "3") SET(CPACK_PACKAGE_VERSION_PATCH "0") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Bio++ Phylogenetic Viewer") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt") SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS.txt") SET(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL.txt") SET(CPACK_SOURCE_GENERATOR "TGZ") SET(CPACK_SOURCE_IGNORE_FILES "CMakeFiles" "Makefile" "_CPack_Packages" "CMakeCache.txt" ".*\\\\.cmake" ".*\\\\.git" ".*\\\\.gz" ".*\\\\.deb" ".*\\\\.rpm" ".*\\\\.dmg" ".*\\\\.sh" ".*\\\\..*\\\\.swp" ".*moc_.*" "bppPhyView/\\\\..*" "bppPhyView/phyview" "man/.*\\\\.1.${DOC_COMPRESS_EXT}" "debian/tmp" "debian/bppphyview/" "debian/bppphyview\\\\.substvars" "debian/bppphyview\\\\.debhelper" "debian/debhelper\\\\.log" "install_manifest.txt" "DartConfiguration.tcl" ${CPACK_SOURCE_IGNORE_FILES} ) IF (MACOS) SET(CPACK_GENERATOR "Bundle") ENDIF() SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") SET(CPACK_DEBSOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.orig") INCLUDE(CPack) #This adds the 'dist' target ADD_CUSTOM_TARGET(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) # 'clean' is not (yet) a first class target. However, we need to clean the directories before building the sources: IF("${CMAKE_GENERATOR}" MATCHES "Make") ADD_CUSTOM_TARGET(make_clean COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR} ) ADD_DEPENDENCIES(dist make_clean) ADD_CUSTOM_TARGET(make_clean_man COMMAND rm -f *.${DOC_COMPRESS_EXT} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/man ) ADD_DEPENDENCIES(dist make_clean_man) ENDIF() IF(NOT NO_DEP_CHECK) IF (UNIX) #This creates deb packages: ADD_CUSTOM_TARGET(origdist COMMAND cp ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz ../${CPACK_DEBSOURCE_PACKAGE_FILE_NAME}.tar.gz) ADD_DEPENDENCIES(origdist dist) ADD_CUSTOM_TARGET(deb dpkg-buildpackage -uc -us -i${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz) ADD_DEPENDENCIES(deb origdist) ADD_DEPENDENCIES(deb man) #This creates rpm packages: ADD_CUSTOM_TARGET(rpm rpmbuild -ta ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz) ADD_DEPENDENCIES(rpm dist man) #ADD_DEPENDENCIES(info install) ENDIF(UNIX) ENDIF(NOT NO_DEP_CHECK) bppphyview-0.3.0/bppphyview.spec000644 000000 000000 00000005574 12147656666 016774 0ustar00rootroot000000 000000 %define _basename bppphyview %define _version 0.3.0 %define _release 1 %define _prefix /usr URL: http://biopp.univ-montp2.fr/forge/bppphyview Name: %{_basename} Version: %{_version} Release: %{_release} License: CECILL-2.0 Vendor: The Bio++ Project Source: http://biopp.univ-montp2.fr/repos/sources/%{_basename}-%{_version}.tar.gz Summary: Bio++ Phylogenetic Viewer Group: Productivity/Scientific/Other Requires: libbpp-phyl9 = 2.1.0 Requires: libbpp-core2 = 2.1.0 Requires: libbpp-qt1 = 2.1.0 %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} Requires: qt >= 4.6.0 %endif %if 0%{?suse_version} Requires: libqt4 >= 4.6.0 %endif %if 0%{?mdkversion} %ifarch x86_64 Requires: lib64qtgui4 >= 4.6.0 %else Requires: libqtgui4 >= 4.6.0 %endif %endif BuildRoot: %{_builddir}/%{_basename}-root BuildRequires: cmake >= 2.6.0 BuildRequires: gcc-c++ >= 4.0.0 BuildRequires: groff BuildRequires: libbpp-core2 = 2.1.0 BuildRequires: libbpp-core-devel = 2.1.0 BuildRequires: libbpp-phyl9 = 2.1.0 BuildRequires: libbpp-phyl-devel = 2.1.0 BuildRequires: libbpp-qt1 = 2.1.0 BuildRequires: libbpp-qt-devel = 2.1.0 %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} BuildRequires: qt >= 4.6.0 BuildRequires: qt-devel >= 4.6.0 %endif %if 0%{?suse_version} BuildRequires: libqt4 >= 4.6.0 BuildRequires: libqt4-devel >= 4.6.0 %endif %if 0%{?mdkversion} %ifarch x86_64 BuildRequires: lib64qtgui4 >= 4.6.0 BuildRequires: lib64qt4-devel >= 4.6.0 %else BuildRequires: libqtgui4 >= 4.6.0 BuildRequires: libqt4-devel >= 4.6.0 %endif %endif AutoReq: yes AutoProv: yes %if 0%{?mdkversion} %if 0%{?mdkversion} >= 201100 BuildRequires: xz %define zipext xz %else BuildRequires: lzma %define zipext lzma %endif %else BuildRequires: gzip %define zipext gz %endif %description Bio++ Phylogenetic Viewer, using the Qt library. %prep %setup -q %build CFLAGS="-I%{_prefix}/include $RPM_OPT_FLAGS" CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=%{_prefix}" if [ %{_lib} == 'lib64' ] ; then CMAKE_FLAGS="$CMAKE_FLAGS -DLIB_SUFFIX=64" fi if [ %{zipext} == 'lzma' ] ; then CMAKE_FLAGS="$CMAKE_FLAGS -DDOC_COMPRESS=lzma -DDOC_COMPRESS_EXT=lzma" fi if [ %{zipext} == 'xz' ] ; then CMAKE_FLAGS="$CMAKE_FLAGS -DDOC_COMPRESS=xz -DDOC_COMPRESS_EXT=xz" fi cmake $CMAKE_FLAGS . make %install make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf $RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root) %doc AUTHORS.txt COPYING.txt INSTALL.txt ChangeLog %{_prefix}/bin/phyview %{_prefix}/share/man/man1/phyview.1.%{zipext} %changelog * Fri Mar 08 2013 Julien Dutheil 0.3.0-1 - Compatibility update. - New option for header line in names translation. * Thu Feb 09 2012 Julien Dutheil 0.2.1-1 - Compatibility update. * Thu Jun 09 2011 Julien Dutheil 0.2.0-1 * Mon Feb 28 2011 Julien Dutheil 0.1.0-1 bppphyview-0.3.0/COPYING.txt000644 000000 000000 00000051153 12147656666 015566 0ustar00rootroot000000 000000 CeCILL FREE SOFTWARE LICENSE AGREEMENT Notice This Agreement is a Free Software license agreement that is the result of discussions between its authors in order to ensure compliance with the two main principles guiding its drafting: * firstly, compliance with the principles governing the distribution of Free Software: access to source code, broad rights granted to users, * secondly, the election of a governing law, French law, with which it is conformant, both as regards the law of torts and intellectual property law, and the protection that it offers to both authors and holders of the economic rights over software. The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) license are: Commissariat à l'Energie Atomique - CEA, a public scientific, technical and industrial research establishment, having its principal place of business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. Centre National de la Recherche Scientifique - CNRS, a public scientific and technological establishment, having its principal place of business at 3 rue Michel-Ange, 75794 Paris cedex 16, France. Institut National de Recherche en Informatique et en Automatique - INRIA, a public scientific and technological establishment, having its principal place of business at Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay cedex, France. Preamble The purpose of this Free Software license agreement is to grant users the right to modify and redistribute the software governed by this license within the framework of an open source distribution model. The exercising of these rights is conditional upon certain obligations for users so as to preserve this status for all subsequent redistributions. In consideration of access to the source code and the rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors only have limited liability. In this respect, the risks associated with loading, using, modifying and/or developing or reproducing the software by the user are brought to the user's attention, given its Free Software status, which may make it complicated to use, with the result that its use is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the suitability of the software as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions of security. This Agreement may be freely reproduced and published, provided it is not altered, and that no provisions are either added or removed herefrom. This Agreement may apply to any or all software for which the holder of the economic rights decides to submit the use thereof to its provisions. Article 1 - DEFINITIONS For the purpose of this Agreement, when the following expressions commence with a capital letter, they shall have the following meaning: Agreement: means this license agreement, and its possible subsequent versions and annexes. Software: means the software in its Object Code and/or Source Code form and, where applicable, its documentation, "as is" when the Licensee accepts the Agreement. Initial Software: means the Software in its Source Code and possibly its Object Code form and, where applicable, its documentation, "as is" when it is first distributed under the terms and conditions of the Agreement. Modified Software: means the Software modified by at least one Contribution. Source Code: means all the Software's instructions and program lines to which access is required so as to modify the Software. Object Code: means the binary files originating from the compilation of the Source Code. Holder: means the holder(s) of the economic rights over the Initial Software. Licensee: means the Software user(s) having accepted the Agreement. Contributor: means a Licensee having made at least one Contribution. Licensor: means the Holder, or any other individual or legal entity, who distributes the Software under the Agreement. Contribution: means any or all modifications, corrections, translations, adaptations and/or new functions integrated into the Software by any or all Contributors, as well as any or all Internal Modules. Module: means a set of sources files including their documentation that enables supplementary functions or services in addition to those offered by the Software. External Module: means any or all Modules, not derived from the Software, so that this Module and the Software run in separate address spaces, with one calling the other when they are run. Internal Module: means any or all Module, connected to the Software so that they both execute in the same address space. GNU GPL: means the GNU General Public License version 2 or any subsequent version, as published by the Free Software Foundation Inc. Parties: mean both the Licensee and the Licensor. These expressions may be used both in singular and plural form. Article 2 - PURPOSE The purpose of the Agreement is the grant by the Licensor to the Licensee of a non-exclusive, transferable and worldwide license for the Software as set forth in Article 5 hereinafter for the whole term of the protection granted by the rights over said Software. Article 3 - ACCEPTANCE 3.1 The Licensee shall be deemed as having accepted the terms and conditions of this Agreement upon the occurrence of the first of the following events: * (i) loading the Software by any or all means, notably, by downloading from a remote server, or by loading from a physical medium; * (ii) the first time the Licensee exercises any of the rights granted hereunder. 3.2 One copy of the Agreement, containing a notice relating to the characteristics of the Software, to the limited warranty, and to the fact that its use is restricted to experienced users has been provided to the Licensee prior to its acceptance as set forth in Article 3.1 hereinabove, and the Licensee hereby acknowledges that it has read and understood it. Article 4 - EFFECTIVE DATE AND TERM 4.1 EFFECTIVE DATE The Agreement shall become effective on the date when it is accepted by the Licensee as set forth in Article 3.1. 4.2 TERM The Agreement shall remain in force for the entire legal term of protection of the economic rights over the Software. Article 5 - SCOPE OF RIGHTS GRANTED The Licensor hereby grants to the Licensee, who accepts, the following rights over the Software for any or all use, and for the term of the Agreement, on the basis of the terms and conditions set forth hereinafter. Besides, if the Licensor owns or comes to own one or more patents protecting all or part of the functions of the Software or of its components, the Licensor undertakes not to enforce the rights granted by these patents against successive Licensees using, exploiting or modifying the Software. If these patents are transferred, the Licensor undertakes to have the transferees subscribe to the obligations set forth in this paragraph. 5.1 RIGHT OF USE The Licensee is authorized to use the Software, without any limitation as to its fields of application, with it being hereinafter specified that this comprises: 1. permanent or temporary reproduction of all or part of the Software by any or all means and in any or all form. 2. loading, displaying, running, or storing the Software on any or all medium. 3. entitlement to observe, study or test its operation so as to determine the ideas and principles behind any or all constituent elements of said Software. This shall apply when the Licensee carries out any or all loading, displaying, running, transmission or storage operation as regards the Software, that it is entitled to carry out hereunder. 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS The right to make Contributions includes the right to translate, adapt, arrange, or make any or all modifications to the Software, and the right to reproduce the resulting software. The Licensee is authorized to make any or all Contributions to the Software provided that it includes an explicit notice that it is the author of said Contribution and indicates the date of the creation thereof. 5.3 RIGHT OF DISTRIBUTION In particular, the right of distribution includes the right to publish, transmit and communicate the Software to the general public on any or all medium, and by any or all means, and the right to market, either in consideration of a fee, or free of charge, one or more copies of the Software by any means. The Licensee is further authorized to distribute copies of the modified or unmodified Software to third parties according to the terms and conditions set forth hereinafter. 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION The Licensee is authorized to distribute true copies of the Software in Source Code or Object Code form, provided that said distribution complies with all the provisions of the Agreement and is accompanied by: 1. a copy of the Agreement, 2. a notice relating to the limitation of both the Licensor's warranty and liability as set forth in Articles 8 and 9, and that, in the event that only the Object Code of the Software is redistributed, the Licensee allows future Licensees unhindered access to the full Source Code of the Software by indicating how to access it, it being understood that the additional cost of acquiring the Source Code shall not exceed the cost of transferring the data. 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE When the Licensee makes a Contribution to the Software, the terms and conditions for the distribution of the resulting Modified Software become subject to all the provisions of this Agreement. The Licensee is authorized to distribute the Modified Software, in source code or object code form, provided that said distribution complies with all the provisions of the Agreement and is accompanied by: 1. a copy of the Agreement, 2. a notice relating to the limitation of both the Licensor's warranty and liability as set forth in Articles 8 and 9, and that, in the event that only the object code of the Modified Software is redistributed, the Licensee allows future Licensees unhindered access to the full source code of the Modified Software by indicating how to access it, it being understood that the additional cost of acquiring the source code shall not exceed the cost of transferring the data. 5.3.3 DISTRIBUTION OF EXTERNAL MODULES When the Licensee has developed an External Module, the terms and conditions of this Agreement do not apply to said External Module, that may be distributed under a separate license agreement. 5.3.4 COMPATIBILITY WITH THE GNU GPL The Licensee can include a code that is subject to the provisions of one of the versions of the GNU GPL in the Modified or unmodified Software, and distribute that entire code under the terms of the same version of the GNU GPL. The Licensee can include the Modified or unmodified Software in a code that is subject to the provisions of one of the versions of the GNU GPL, and distribute that entire code under the terms of the same version of the GNU GPL. Article 6 - INTELLECTUAL PROPERTY 6.1 OVER THE INITIAL SOFTWARE The Holder owns the economic rights over the Initial Software. Any or all use of the Initial Software is subject to compliance with the terms and conditions under which the Holder has elected to distribute its work and no one shall be entitled to modify the terms and conditions for the distribution of said Initial Software. The Holder undertakes that the Initial Software will remain ruled at least by this Agreement, for the duration set forth in Article 4.2. 6.2 OVER THE CONTRIBUTIONS The Licensee who develops a Contribution is the owner of the intellectual property rights over this Contribution as defined by applicable law. 6.3 OVER THE EXTERNAL MODULES The Licensee who develops an External Module is the owner of the intellectual property rights over this External Module as defined by applicable law and is free to choose the type of agreement that shall govern its distribution. 6.4 JOINT PROVISIONS The Licensee expressly undertakes: 1. not to remove, or modify, in any manner, the intellectual property notices attached to the Software; 2. to reproduce said notices, in an identical manner, in the copies of the Software modified or not. The Licensee undertakes not to directly or indirectly infringe the intellectual property rights of the Holder and/or Contributors on the Software and to take, where applicable, vis-à-vis its staff, any and all measures required to ensure respect of said intellectual property rights of the Holder and/or Contributors. Article 7 - RELATED SERVICES 7.1 Under no circumstances shall the Agreement oblige the Licensor to provide technical assistance or maintenance services for the Software. However, the Licensor is entitled to offer this type of services. The terms and conditions of such technical assistance, and/or such maintenance, shall be set forth in a separate instrument. Only the Licensor offering said maintenance and/or technical assistance services shall incur liability therefor. 7.2 Similarly, any Licensor is entitled to offer to its licensees, under its sole responsibility, a warranty, that shall only be binding upon itself, for the redistribution of the Software and/or the Modified Software, under terms and conditions that it is free to decide. Said warranty, and the financial terms and conditions of its application, shall be subject of a separate instrument executed between the Licensor and the Licensee. Article 8 - LIABILITY 8.1 Subject to the provisions of Article 8.2, the Licensee shall be entitled to claim compensation for any direct loss it may have suffered from the Software as a result of a fault on the part of the relevant Licensor, subject to providing evidence thereof. 8.2 The Licensor's liability is limited to the commitments made under this Agreement and shall not be incurred as a result of in particular: (i) loss due the Licensee's total or partial failure to fulfill its obligations, (ii) direct or consequential loss that is suffered by the Licensee due to the use or performance of the Software, and (iii) more generally, any consequential loss. In particular the Parties expressly agree that any or all pecuniary or business loss (i.e. loss of data, loss of profits, operating loss, loss of customers or orders, opportunity cost, any disturbance to business activities) or any or all legal proceedings instituted against the Licensee by a third party, shall constitute consequential loss and shall not provide entitlement to any or all compensation from the Licensor. Article 9 - WARRANTY 9.1 The Licensee acknowledges that the scientific and technical state-of-the-art when the Software was distributed did not enable all possible uses to be tested and verified, nor for the presence of possible defects to be detected. In this respect, the Licensee's attention has been drawn to the risks associated with loading, using, modifying and/or developing and reproducing the Software which are reserved for experienced users. The Licensee shall be responsible for verifying, by any or all means, the suitability of the product for its requirements, its good working order, and for ensuring that it shall not cause damage to either persons or properties. 9.2 The Licensor hereby represents, in good faith, that it is entitled to grant all the rights over the Software (including in particular the rights set forth in Article 5). 9.3 The Licensee acknowledges that the Software is supplied "as is" by the Licensor without any other express or tacit warranty, other than that provided for in Article 9.2 and, in particular, without any warranty as to its commercial value, its secured, safe, innovative or relevant nature. Specifically, the Licensor does not warrant that the Software is free from any error, that it will operate without interruption, that it will be compatible with the Licensee's own equipment and software configuration, nor that it will meet the Licensee's requirements. 9.4 The Licensor does not either expressly or tacitly warrant that the Software does not infringe any third party intellectual property right relating to a patent, software or any other property right. Therefore, the Licensor disclaims any and all liability towards the Licensee arising out of any or all proceedings for infringement that may be instituted in respect of the use, modification and redistribution of the Software. Nevertheless, should such proceedings be instituted against the Licensee, the Licensor shall provide it with technical and legal assistance for its defense. Such technical and legal assistance shall be decided on a case-by-case basis between the relevant Licensor and the Licensee pursuant to a memorandum of understanding. The Licensor disclaims any and all liability as regards the Licensee's use of the name of the Software. No warranty is given as regards the existence of prior rights over the name of the Software or as regards the existence of a trademark. Article 10 - TERMINATION 10.1 In the event of a breach by the Licensee of its obligations hereunder, the Licensor may automatically terminate this Agreement thirty (30) days after notice has been sent to the Licensee and has remained ineffective. 10.2 A Licensee whose Agreement is terminated shall no longer be authorized to use, modify or distribute the Software. However, any licenses that it may have granted prior to termination of the Agreement shall remain valid subject to their having been granted in compliance with the terms and conditions hereof. Article 11 - MISCELLANEOUS 11.1 EXCUSABLE EVENTS Neither Party shall be liable for any or all delay, or failure to perform the Agreement, that may be attributable to an event of force majeure, an act of God or an outside cause, such as defective functioning or interruptions of the electricity or telecommunications networks, network paralysis following a virus attack, intervention by government authorities, natural disasters, water damage, earthquakes, fire, explosions, strikes and labor unrest, war, etc. 11.2 Any failure by either Party, on one or more occasions, to invoke one or more of the provisions hereof, shall under no circumstances be interpreted as being a waiver by the interested Party of its right to invoke said provision(s) subsequently. 11.3 The Agreement cancels and replaces any or all previous agreements, whether written or oral, between the Parties and having the same purpose, and constitutes the entirety of the agreement between said Parties concerning said purpose. No supplement or modification to the terms and conditions hereof shall be effective as between the Parties unless it is made in writing and signed by their duly authorized representatives. 11.4 In the event that one or more of the provisions hereof were to conflict with a current or future applicable act or legislative text, said act or legislative text shall prevail, and the Parties shall make the necessary amendments so as to comply with said act or legislative text. All other provisions shall remain effective. Similarly, invalidity of a provision of the Agreement, for any reason whatsoever, shall not cause the Agreement as a whole to be invalid. 11.5 LANGUAGE The Agreement is drafted in both French and English and both versions are deemed authentic. Article 12 - NEW VERSIONS OF THE AGREEMENT 12.1 Any person is authorized to duplicate and distribute copies of this Agreement. 12.2 So as to ensure coherence, the wording of this Agreement is protected and may only be modified by the authors of the License, who reserve the right to periodically publish updates or new versions of the Agreement, each with a separate number. These subsequent versions may address new issues encountered by Free Software. 12.3 Any Software distributed under a given version of the Agreement may only be subsequently distributed under the same version of the Agreement or a subsequent version, subject to the provisions of Article 5.3.4. Article 13 - GOVERNING LAW AND JURISDICTION 13.1 The Agreement is governed by French law. The Parties agree to endeavor to seek an amicable solution to any disagreements or disputes that may arise during the performance of the Agreement. 13.2 Failing an amicable solution within two (2) months as from their occurrence, and unless emergency proceedings are necessary, the disagreements or disputes shall be referred to the Paris Courts having jurisdiction, by the more diligent Party. Version 2.0 dated 2006-09-05. bppphyview-0.3.0/NEWS000644 000000 000000 00000000000 12147656666 014375 0ustar00rootroot000000 000000 bppphyview-0.3.0/INSTALL.txt000644 000000 000000 00000000700 12147656666 015554 0ustar00rootroot000000 000000 This software needs cmake >= 2.6 to build. After installing cmake, run it with the following command: cmake -DCMAKE_INSTALL_PREFIX=[where to install, for instance /usr/local or $HOME/.local] . If available, you can also use ccmake instead of cmake for a more user-friendly interface. Then compile and install the software with make install You may also consider installing and using the software checkinstall for easier system administration. bppphyview-0.3.0/AUTHORS.txt000644 000000 000000 00000000057 12147656666 015600 0ustar00rootroot000000 000000 Julien Dutheil bppphyview-0.3.0/debian/copyright000644 000000 000000 00000005500 12147656666 017065 0ustar00rootroot000000 000000 This package was debianized by Julien Dutheil on Fri, 08 Mar 2013 14:55:00 +0100 It was downloaded from Upstream Author: Julien Dutheil Copyright: Copyright (C) 2013 Bio++ Development Team License: This package 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 package 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA The Debian packaging is (C) 2013, Julien Dutheil and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. The provided software is distributed under the CeCILL license: This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. The complete text of the license may be found here: http://www.cecill.info/licences/Licence_CeCILL_V2-en.html bppphyview-0.3.0/debian/changelog000644 000000 000000 00000001356 12147656666 017011 0ustar00rootroot000000 000000 bppphyview (0.3.0-1) unstable; urgency=low * Compatibility update. * New option for header line in names translation. -- Julien Dutheil Fri, 08 Mar 2013 14:55:00 +0100 bppphyview (0.2.1-1) unstable; urgency=low * Compatibility update. -- Julien Dutheil Thu, 09 Feb 2012 21:38:00 +0100 bppphyview (0.2.0-1) unstable; urgency=low * RFP: Bio++ -- The Bio++ bioinformatics libraries. (Closes: #616373). * Packages are now non-native. -- Julien Dutheil Thu, 09 Jun 2011 11:00:00 +0100 bppphyview (0.1.0) unstable; urgency=low * Initial release. -- Julien Dutheil Mon, 28 Feb 2011 09:00:00 +0100 bppphyview-0.3.0/debian/rules000755 000000 000000 00000007213 12147656666 016215 0ustar00rootroot000000 000000 #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # # Modified to make a template file for a multi-binary package with separated # build-arch and build-indep targets by Bill Allombert 2001 # 25/03/10 Modification for use with CMake by Julien Dutheil. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This has to be exported to make some magic below work. export DH_OPTIONS # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif configure: cmake -DCMAKE_INSTALL_PREFIX=/usr . config.status: configure dh_testdir #Architecture build: build-arch build-indep build-arch: build-arch-stamp build-arch-stamp: config.status # Add here commands to compile the arch part of the package. #$(MAKE) touch $@ build-indep: build-indep-stamp build-indep-stamp: config.status # Add here commands to compile the indep part of the package. #$(MAKE) doc touch $@ clean: dh_testdir dh_testroot rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP# rm -f CMakeCache.txt # Add here commands to clean up after the build process. [ ! -f Makefile ] || $(MAKE) clean; [ ! -f Makefile ] || rm Makefile; [ ! -f bppPhyView/Makefile ] || rm bppPhyView/Makefile; [ ! -f man/Makefile ] || rm man/Makefile; rm -f man/*.gz; rm -f config.sub config.guess rm -f build-stamp rm -f CMakeCache.txt rm -f *.cmake rm -f bppPhyView/*.cmake #rm -f test/*.cmake rm -f man/*.cmake #rm -f doc/*.cmake rm -rf CMakeFiles rm -rf bppPhyView/CMakeFiles #rm -rf test/CMakeFiles rm -rf man/CMakeFiles #rm -rf doc/CMakeFiles rm -rf _CPack_Packages #rm -rf Testing #rm -f DartConfiguration.tcl dh_clean install: install-indep install-arch install-indep: dh_testdir dh_testroot dh_prep -i dh_installdirs -i # Add here commands to install the indep part of the package into # debian/-doc. #INSTALLDOC# dh_install -i install-arch: dh_testdir dh_testroot dh_prep -s dh_installdirs -s # Add here commands to install the arch part of the package into # debian/tmp. $(MAKE) DESTDIR=$(CURDIR)/debian/bppphyview man install dh_install -s # Must not depend on anything. This is to be called by # binary-arch/binary-indep # in another 'make' thread. binary-common: dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs dh_installexamples # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_python # dh_installinit # dh_installcron dh_installinfo dh_installman dh_link dh_strip dh_compress dh_fixperms # dh_perl # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture independant packages using the common target. binary-indep: build-indep install-indep $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common # Build architecture dependant packages using the common target. binary-arch: build-arch install-arch $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common binary: binary-arch binary-indep .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch bppphyview-0.3.0/debian/compat000644 000000 000000 00000000002 12147656666 016330 0ustar00rootroot000000 000000 5 bppphyview-0.3.0/debian/control000644 000000 000000 00000001055 12147656666 016536 0ustar00rootroot000000 000000 Source: bppphyview Section: science Priority: optional Maintainer: Loic Dachary Uploaders: Julien Dutheil Build-Depends: debhelper (>= 5), cmake (>= 2.6), qt4-qmake (>= 4.6.0), libqt4-dev (>= 4.6.0), libbpp-qt-dev (>= 2.1.0) Standards-Version: 3.9.1 Package: bppphyview Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libbpp-qt1 (>= 2.1.0), libqtcore4 (>= 4.6.0), libqtgui4 (>= 4.6.0) Description: Bio++ Phylogenetic Viewer A phylogenetic tree editor developed using Bio++ and Qt. bppphyview-0.3.0/debian/source/format000644 000000 000000 00000000014 12147656666 017640 0ustar00rootroot000000 000000 3.0 (quilt) bppphyview-0.3.0/debian/bppphyview.manpages000644 000000 000000 00000000021 12147656666 021035 0ustar00rootroot000000 000000 man/phyview.1.gz bppphyview-0.3.0/man/phyview.1.txt000644 000000 000000 00000001204 12147656666 017053 0ustar00rootroot000000 000000 .TH PHYVIEW 1 LOCAL .SH NAME bppml - Phylogenetic viewer and editor written with Bio++ .SH SYNOPSIS .B phyview [arguments] .SH AVAILABILITY All UNIX flavors .SH DESCRIPTION phyview allows you to visualize, edit, print and output phylogenetic trees and associated data. .SH OPTIONS .TP 5 file A tree file to open. By default, in the newick format. .TP --nhx switch to input format 'NHX' .TP --nexus switch to input format 'nexus' .TP --enc [text codec] specify the file name encoding, if different from the system default. See the Qt documentation for a list of available encodings. .SH AUTHOR The Bio++ Development Team. bppphyview-0.3.0/man/CMakeLists.txt000644 000000 000000 00000000251 12147656666 017221 0ustar00rootroot000000 000000 # CMake script for PhyView. # Author: Julien Dutheil # Created: 22/08/2009 IF(MAN) INSTALL(FILES phyview.1.${DOC_COMPRESS_EXT} DESTINATION share/man/man1) ENDIF(MAN) bppphyview-0.3.0/ChangeLog000644 000000 000000 00000000573 12147656666 015467 0ustar00rootroot000000 000000 08/03/12 -*- Version 0.3.0 -*- 04/06/12 Julien Dutheil * Added option for header line in name translation. 09/02/12 -*- Version 0.2.1 -*- 11/06/11 -*- Version 0.2.0 -*- * Small interface improvement (mainly associated data management) 28/02/11 -*- Version 0.1.0 -*- 28/02/11 Julien Dutheil * Added package files. 22/08/09 Julien Dutheil * Added CMake configuration files. bppphyview-0.3.0/bppPhyView/TreeDocument.h000644 000000 000000 00000007454 12147656666 020566 0ustar00rootroot000000 000000 // // File: TreeDocument.h // Created by: Julien Dutheil // Created on: Tue Oct 5 22:05 2006 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide classes for phylogenetic data analysis. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #ifndef _TREEDOCUMENT_H_ #define _TREEDOCUMENT_H_ #include //From PhylLib: #include #include //From the STL: #include //From Qt: #include using namespace bpp; using namespace std; /** * @brief Interface for document viewers. */ class DocumentView { public: virtual ~DocumentView() {} public: virtual void updateView() = 0; }; /** * Contains a tree and all associated data, if any. * Also contains a path where to write, and a format, * which are use for actions like "save", "save as", "save a copy". */ class TreeDocument { private: TreeTemplate* tree_; std::string documentName_; bool modified_; std::string currentFilePath_; std::string currentFileFormat_; QUndoStack undoStack_; vector viewers_; public: TreeDocument(): tree_(0), documentName_(), modified_(false), currentFilePath_(), currentFileFormat_(), undoStack_() {} virtual ~TreeDocument() { if (tree_) delete tree_; } public: const TreeTemplate* getTree() const { return tree_; } TreeTemplate* getTree() { return tree_; } void setTree(const Tree& tree) { if (tree_) delete tree_; tree_ = new TreeTemplate(tree); } const std::string& getName() const { return documentName_; } void setFile(const string& filePath, const string& fileFormat) { currentFilePath_ = filePath; currentFileFormat_ = fileFormat; documentName_ = FileTools::getFileName(filePath); } const string& getFilePath() const { return currentFilePath_; } const string& getFileFormat() const { return currentFileFormat_; } void modified(bool yn) { modified_ = yn; } bool modified() const { return modified_; } QUndoStack& getUndoStack() { return undoStack_; } void addView(DocumentView* viewer) { viewers_.push_back(viewer); } void updateAllViews() { for (unsigned int i = 0; i < viewers_.size(); i++) viewers_[i]->updateView(); } }; #endif //_TREEDOCUMENT_H_ bppphyview-0.3.0/bppPhyView/TreeSubWindow.h000644 000000 000000 00000006172 12147656666 020725 0ustar00rootroot000000 000000 // // File: TreeSubWindow.h // Created by: Julien Dutheil // Created on: Tue Aug 11 13:34 2009 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide graphic components to develop bioinformatics applications. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #ifndef _TREESUBWINDOW_H_ #define _TREESUBWINDOW_H_ #include "TreeDocument.h" //From Qt: #include #include #include //From PhylLib: #include //From Bpp-Qt #include using namespace bpp; class PhyView; class TreeSubWindow: public QMdiSubWindow, public DocumentView { Q_OBJECT private: PhyView* phyview_; TreeDocument* treeDocument_; TreeCanvas* treeCanvas_; QSplitter* splitter_; QTableWidget* nodeEditor_; std::vector nodes_; bool stopSignal_; public: TreeSubWindow(PhyView* phyview, TreeDocument* document, TreeDrawing* td); virtual ~TreeSubWindow() { delete treeDocument_; delete splitter_; } public: TreeDocument* getDocument() { return treeDocument_; } const Tree& getTree() const { return *treeDocument_->getTree(); } const TreeCanvas& getTreeCanvas() const { return *treeCanvas_; } TreeCanvas& getTreeCanvas() { return *treeCanvas_; } void duplicateDownSelection(unsigned int rep); void updateView() { treeCanvas_->setTree(treeDocument_->getTree()); updateTable(); } void updateTable(); void writeTableToFile(const string& file, const string& sep); private: QTableWidgetItem* getTableWigetItem_(Clonable* property); private slots: void nodeEditorHasChanged(QTableWidgetItem* item); }; #endif //_TREESUBWINDOW_H_ bppphyview-0.3.0/bppPhyView/CMakeLists.txt000644 000000 000000 00000000733 12147656666 020550 0ustar00rootroot000000 000000 # CMake script for Bio++ PhyView # Author: Julien Dutheil # Created: 22/08/2009 set(phyview_SRCS PhyView.cpp TreeSubWindow.cpp TreeCommands.cpp ) set(phyview_MOC_HDRS PhyView.h TreeSubWindow.h ) set(phyview_HDRS TreeDocument.h TreeCommands.h ) qt4_wrap_cpp(phyview_MOC_SRCS ${phyview_MOC_HDRS}) add_executable(phyview ${phyview_SRCS} ${phyview_MOC_SRCS}) target_link_libraries(phyview ${LIBS}) # Install libs install(TARGETS phyview DESTINATION bin) bppphyview-0.3.0/bppPhyView/TreeCommands.cpp000644 000000 000000 00000012657 12147656666 021105 0ustar00rootroot000000 000000 // // File: TreeCommands.cpp // Created by: Julien Dutheil // Created on: Fri Oct 13 21:25 2006 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide classes for phylogenetic data analysis. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #include "TreeCommands.h" using namespace std; TranslateNodeNamesCommand::TranslateNodeNamesCommand(TreeDocument* doc, const DataTable& table, unsigned int from, unsigned int to): AbstractCommand(QtTools::toQt("Translates nodes names from " + table.getColumnName(from) + " to " + table.getColumnName(to) + "."), doc) { new_ = new TreeTemplate(*old_); //Build translation: map tln; for(unsigned int i = 0; i < table.getNumberOfRows(); ++i) { tln[table(i, from)] = table(i, to); } vector nodes = new_->getNodes(); for (unsigned int i = 0; i < nodes.size(); i++) { if (nodes[i]->hasName()) { map::iterator it = tln.find(nodes[i]->getName()); if (it != tln.end()) { nodes[i]->setName(it->second); } } } } AttachDataCommand::AttachDataCommand(TreeDocument* doc, const DataTable& data, unsigned int index, bool useNames): AbstractCommand(QtTools::toQt("Attach data to tree."), doc) { new_ = new TreeTemplate(*old_); addProperties_(new_->getRootNode(), data, index, useNames); } void AttachDataCommand::addProperties_(Node* node, const DataTable& data, unsigned int index, bool useNames) { if (!useNames) { //Use id string id = TextTools::toString(node->getId()); for (unsigned int i = 0; i < data.getNumberOfRows(); ++i) { if (data(i, index) == id) { for (unsigned int j = 0; j < data.getNumberOfColumns(); ++j) { if (j != index) { node->setNodeProperty(data.getColumnName(j), BppString(data(i, j))); } } } } } else { //Use name: if (node->hasName()) { string name = node->getName(); for (unsigned int i = 0; i < data.getNumberOfRows(); ++i) { if (data(i, index) == name) { for (unsigned int j = 0; j < data.getNumberOfColumns(); ++j) { if (j != index) { node->setNodeProperty(data.getColumnName(j), BppString(data(i, j))); } } } } } } for (unsigned int i = 0; i < node->getNumberOfSons(); ++i) addProperties_(node->getSon(i), data, index, useNames); } AddDataCommand::AddDataCommand(TreeDocument* doc, const QString& name): AbstractCommand(QString("Add data '") + name + QString("' to tree."), doc) { new_ = new TreeTemplate(*old_); addProperty_(new_->getRootNode(), name); } void AddDataCommand::addProperty_(Node* node, const QString& name) { node->setNodeProperty(name.toStdString(), BppString("")); for (unsigned int i = 0; i < node->getNumberOfSons(); ++i) addProperty_(node->getSon(i), name); } RemoveDataCommand::RemoveDataCommand(TreeDocument* doc, const QString& name): AbstractCommand(QString("Remove data '") + name + QString("' from tree."), doc) { new_ = new TreeTemplate(*old_); removeProperty_(new_->getRootNode(), name); } void RemoveDataCommand::removeProperty_(Node* node, const QString& name) { node->deleteNodeProperty(name.toStdString()); for (unsigned int i = 0; i < node->getNumberOfSons(); ++i) removeProperty_(node->getSon(i), name); } RenameDataCommand::RenameDataCommand(TreeDocument* doc, const QString& oldName, const QString& newName): AbstractCommand(QString("Rename data '") + oldName + QString("' to '" + newName + "' from tree."), doc) { new_ = new TreeTemplate(*old_); renameProperty_(new_->getRootNode(), oldName, newName); } void RenameDataCommand::renameProperty_(Node* node, const QString& oldName, const QString& newName) { if (node->hasNodeProperty(oldName.toStdString())) { Clonable* property = node->removeNodeProperty(oldName.toStdString()); node->setNodeProperty(newName.toStdString(), *property); delete property; } for (unsigned int i = 0; i < node->getNumberOfSons(); ++i) renameProperty_(node->getSon(i), oldName, newName); } bppphyview-0.3.0/bppPhyView/TreeSubWindow.cpp000644 000000 000000 00000021162 12147656666 021254 0ustar00rootroot000000 000000 // // File: TreeSubWindow.cpp // Created by: Julien Dutheil // Created on: Tue Aug 11 13:34 2009 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide graphic components to develop bioinformatics applications. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #include "TreeSubWindow.h" #include "PhyView.h" //From Qt: #include #include //From bpp-qt: #include TreeSubWindow::TreeSubWindow(PhyView* phyview, TreeDocument* document, TreeDrawing* td): phyview_(phyview), treeDocument_(document), treeCanvas_() { setAttribute(Qt::WA_DeleteOnClose); setWindowFilePath(QtTools::toQt(treeDocument_->getFilePath())); treeDocument_->addView(this); treeCanvas_ = new TreeCanvas(); treeCanvas_->setTree(treeDocument_->getTree()); treeCanvas_->setTreeDrawing(*td); treeCanvas_->setMinimumSize(400,400); treeCanvas_->addMouseListener(reinterpret_cast(phyview_->getMouseActionListener())); connect(treeCanvas_, SIGNAL(drawingChanged()), phyview, SLOT(clearSearchResults())); nodeEditor_ = new QTableWidget(); nodeEditor_->setColumnCount(3); connect(nodeEditor_, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(nodeEditorHasChanged(QTableWidgetItem*))); QStringList labels; labels.append(tr("Id")); labels.append(tr("Name")); labels.append(tr("Branch length")); nodeEditor_->setHorizontalHeaderLabels(labels); splitter_ = new QSplitter(this); splitter_->addWidget(treeCanvas_); splitter_->addWidget(nodeEditor_); splitter_->setCollapsible(0, true); splitter_->setCollapsible(1, true); setMinimumSize(400, 400); setWidget(splitter_); updateTable(); } QTableWidgetItem* TreeSubWindow::getTableWigetItem_(Clonable* property) { QTableWidgetItem* propItem = 0; BppString* str = dynamic_cast(property); if (str) { propItem = new QTableWidgetItem(); propItem->setText(QtTools::toQt(*str)); } else { Number* num = dynamic_cast*>(property); if (num) { propItem = new QTableWidgetItem(); propItem->setText(QtTools::toQt(*num)); } } return propItem; } void TreeSubWindow::updateTable() { stopSignal_ = true; nodes_ = treeDocument_->getTree()->getNodes(); nodeEditor_->clearContents(); nodeEditor_->setRowCount(nodes_.size()); vector nodeProperties; TreeTemplateTools::getNodePropertyNames(*treeDocument_->getTree()->getRootNode(), nodeProperties); vector branchProperties; TreeTemplateTools::getBranchPropertyNames(*treeDocument_->getTree()->getRootNode(), branchProperties); QStringList labels; labels.append(tr("Id")); labels.append(tr("Name")); labels.append(tr("Branch length")); for (size_t i = 0; i < nodeProperties.size(); ++i) labels.append(QtTools::toQt(nodeProperties[i])); for (size_t i = 0; i < branchProperties.size(); ++i) labels.append(QtTools::toQt(branchProperties[i])); nodeEditor_->setColumnCount(labels.size()); nodeEditor_->setHorizontalHeaderLabels(labels); for (size_t i = 0; i < nodes_.size(); ++i) { QTableWidgetItem* idItem = new QTableWidgetItem(QtTools::toQt(TextTools::toString(nodes_[i]->getId()))); Qt::ItemFlags flags = idItem->flags(); flags &= ~Qt::ItemIsEditable; idItem->setFlags(flags); nodeEditor_->setItem(i, 0, idItem); QTableWidgetItem* nameItem = new QTableWidgetItem(); if (nodes_[i]->hasName()) nameItem->setText(QtTools::toQt(nodes_[i]->getName())); nodeEditor_->setItem(i, 1, nameItem); QTableWidgetItem* brlenItem = new QTableWidgetItem(); if (nodes_[i]->hasDistanceToFather()) brlenItem->setText(QtTools::toQt(TextTools::toString(nodes_[i]->getDistanceToFather()))); nodeEditor_->setItem(i, 2, brlenItem); for (size_t j = 0; j < nodeProperties.size(); ++j) { QTableWidgetItem* item = 0; if (nodes_[i]->hasNodeProperty(nodeProperties[j])) { item = getTableWigetItem_(nodes_[i]->getNodeProperty(nodeProperties[j])); } else { item = new QTableWidgetItem(); } nodeEditor_->setItem(i, 3 + j, item); } for (size_t j = 0; j < branchProperties.size(); ++j) { QTableWidgetItem* item = 0; if (nodes_[i]->hasBranchProperty(branchProperties[j])) { item = getTableWigetItem_(nodes_[i]->getBranchProperty(branchProperties[j])); } else { item = new QTableWidgetItem(); } nodeEditor_->setItem(i, 3 + nodeProperties.size() + j, item); } } stopSignal_ = false; } void TreeSubWindow::writeTableToFile(const string& file, const string& sep) { ofstream out(file.c_str(), ios::out); for (int j = 0; j < nodeEditor_->columnCount(); ++j) { QTableWidgetItem* hitem = nodeEditor_->horizontalHeaderItem(j); out << (j > 0 ? sep : "") << (hitem ? hitem->text().toStdString() : ""); } out << endl; for (int i = 0; i < nodeEditor_->rowCount(); ++i) { for (int j = 0; j < nodeEditor_->columnCount(); ++j) { QTableWidgetItem* item = nodeEditor_->item(i, j); out << (j > 0 ? sep : "") << (item ? item->text().toStdString() : 0); } out << endl; } out.close(); } void TreeSubWindow::nodeEditorHasChanged(QTableWidgetItem* item) { if (stopSignal_) return; if (item->column() == 1) { //Change name: phyview_->submitCommand(new ChangeNodeNameCommand(treeDocument_, nodes_[item->row()]->getId(), item->text().toStdString())); } else if (item->column() == 2) { //Change branch length: phyview_->submitCommand(new ChangeBranchLengthCommand(treeDocument_, nodes_[item->row()]->getId(), item->text().toDouble())); } else { //Change node property: nodes_[item->row()]->setNodeProperty(nodeEditor_->horizontalHeaderItem(item->column())->text().toStdString(), BppString(item->text().toStdString())); } treeCanvas_->setTree(treeDocument_->getTree()); } void TreeSubWindow::duplicateDownSelection(unsigned int rep) { QList selection = nodeEditor_->selectedRanges(); if (selection.size() == 0) { QMessageBox::critical(phyview_, QString("Oups..."), QString("No selection.")); return; } //Perform some checking: int row = -1; for (int i = 0; i < selection.size(); ++i) { QTableWidgetSelectionRange range = selection[i]; if (range.rowCount() != 1) { QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected.")); return; } if (i == 0) { row = range.topRow(); } else { if (range.topRow() != row) { QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected.")); return; } } } //Ok, if we reach this stage, then everything is ok... int j; for (j = row + 1; j < nodeEditor_->rowCount() && j - row <= static_cast(rep); ++j) { for (int i = 0; i < selection.size(); ++i) { QTableWidgetSelectionRange range = selection[i]; for (int k = range.leftColumn(); k <= range.rightColumn(); ++k) { nodeEditor_->setItem(j, k, nodeEditor_->item(row, k)->clone()); } } } //Shift selection: for (int i = 0; i < selection.size(); ++i) { QTableWidgetSelectionRange range = selection[i]; nodeEditor_->setRangeSelected(range, false); nodeEditor_->setRangeSelected(QTableWidgetSelectionRange(j - 1, range.leftColumn(), j - 1, range.rightColumn()), true); } } bppphyview-0.3.0/bppPhyView/PhyView.h000644 000000 000000 00000021557 12147656666 017563 0ustar00rootroot000000 000000 // // File: PhyView.h // Created by: Julien Dutheil // Created on: Tue Aug 05 14:59 2009 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide graphic components to develop bioinformatics applications. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #include "TreeSubWindow.h" #include "TreeCommands.h" //From Qt: #include #include #include #include #include #include #include #include #include #include #include class QAction; class QLabel; #include #include #include #include #include using namespace bpp; class PhyView; class MouseActionListener: public MouseAdapter { private: PhyView* phyview_; QDialog* treeChooser_; QListWidget* treeList_; public: MouseActionListener(PhyView* phyview); MouseActionListener* clone() const { return new MouseActionListener(*this); } void mousePressEvent(QMouseEvent *event); bool isAutonomous() const { return false; } private: TreeTemplate* pickTree_(); }; class TranslateNameChooser : public QDialog { Q_OBJECT private: PhyView* phyview_; QFileDialog* fileDialog_; QStringList fileFilters_; QComboBox* fromList_, * toList_; QCheckBox* hasHeader_; QPushButton* ok_, *cancel_; public: TranslateNameChooser(PhyView* phyview); ~TranslateNameChooser() { delete fileDialog_; } public: void translateTree(TreeTemplate& tree); }; class DataLoader : public QDialog { Q_OBJECT private: PhyView* phyview_; QRadioButton* idIndex_, * nameIndex_; QComboBox* indexCol_; QPushButton* ok_, * cancel_; public: DataLoader(PhyView* phyview); ~DataLoader() {} public: void load(const DataTable* data); private: void addProperties_(Node* node, const DataTable& data); }; class ImageExportDialog : public QDialog { Q_OBJECT private: PhyView* phyview_; QLabel* path_; QSpinBox* width_, * height_; QCheckBox* transparent_, * keepAspectRatio_; QPushButton* ok_, * cancel_, * browse_; QFileDialog* imageFileDialog_; QStringList imageFileFilters_; public: ImageExportDialog(PhyView* phyview); ~ImageExportDialog() {} public: void process(QGraphicsScene* scene); public slots: void chosePath(); }; class TypeNumberDialog : public QDialog { Q_OBJECT private: QSpinBox* spinBox_; QPushButton* ok_, * cancel_; public: TypeNumberDialog(PhyView* phyview, const string& what, unsigned int min, unsigned int max); ~TypeNumberDialog() {} public: unsigned int getValue() const { return spinBox_->value(); } }; class PhyView : public QMainWindow, public TreeCanvasControlersListener { Q_OBJECT private: QMenu* fileMenu_; QMenu* editMenu_; QMenu* viewMenu_; QMenu* helpMenu_; QAction* openAction_; QAction* saveAction_; QAction* saveAsAction_; QAction* closeAction_; QAction* printAction_; QAction* exportAction_; QAction* exitAction_; QAction* cascadeWinAction_; QAction* tileWinAction_; QAction* aboutAction_; QAction* aboutBppAction_; QAction* aboutQtAction_; QAction* undoAction_; QAction* redoAction_; QUndoGroup manager_; QMdiArea* mdiArea_; QFileDialog* treeFileDialog_; QStringList treeFileFilters_; QFileDialog* dataFileDialog_; QStringList dataFileFilters_; IOTreeFactory ioTreeFactory_; QPrinter* printer_; QPrintDialog* printDialog_; TreeCanvasControlers* treeControlers_; QWidget* displayPanel_; TreeStatisticsBox* statsBox_; QWidget* statsPanel_; QWidget* brlenPanel_; QWidget* mouseControlPanel_; QWidget* dataPanel_; QWidget* searchPanel_; QDockWidget* statsDockWidget_; QDockWidget* displayDockWidget_; QDockWidget* undoDockWidget_; //Branch lengths operations: QDockWidget* brlenDockWidget_; QDoubleSpinBox* brlenSetLengths_; QDoubleSpinBox* brlenComputeGrafen_; //Mouse actions change: QDockWidget* mouseControlDockWidget_; QComboBox* leftButton_; QComboBox* middleButton_; QComboBox* rightButton_; //Data operations: QDockWidget* dataDockWidget_; QPushButton* translateNames_; QPushButton* loadData_; QPushButton* saveData_; QPushButton* addData_; QPushButton* removeData_; QPushButton* renameData_; QPushButton* duplicateDownSelection_; QPushButton* snapData_; //Searching: QDockWidget* searchDockWidget_; QLineEdit* searchText_; QListWidget* searchResults_; LabelCollapsedNodesTreeDrawingListener collapsedNodesListener_; TranslateNameChooser* translateNameChooser_; DataLoader* dataLoader_; ImageExportDialog* imageExportDialog_; QList searchResultsItems_; public: PhyView(); public: bool hasActiveDocument() const { return mdiArea_->currentSubWindow() != 0; } TreeDocument* getActiveDocument() { return dynamic_cast(mdiArea_->currentSubWindow())->getDocument(); } QList getNonActiveDocuments(); TreeSubWindow* getActiveSubWindow() { return dynamic_cast(mdiArea_->currentSubWindow()); } void submitCommand(QUndoCommand* cmd) { manager_.activeStack()->push(cmd); } TreeDocument* createNewDocument(Tree* tree); MouseActionListener* getMouseActionListener() { return new MouseActionListener(this); } QString getMouseLeftButtonActionType() const { return leftButton_->currentText(); } QString getMouseMiddleButtonActionType() const { return middleButton_->currentText(); } QString getMouseRightButtonActionType() const { return rightButton_->currentText(); } void controlerTakesAction(); void readTree(const QString& path, const string& format); protected: void closeEvent(QCloseEvent* event); private slots: void openTree(); bool saveTree(); bool saveTreeAs(); void closeTree(); void exportTree(); void printTree(); void exit(); void about(); void aboutBpp(); void updateStatusBar(); void setCurrentSubWindow(TreeSubWindow* tsw); void setCurrentSubWindow(QMdiSubWindow *msw) { TreeSubWindow* tsw = dynamic_cast(msw); if (tsw) setCurrentSubWindow(tsw); } void updateStatistics() { statsBox_->updateTree(*getActiveDocument()->getTree()); } void setLengths(); void initLengthsGrafen(); void computeLengthsGrafen(); void convertToClockTree(); void midpointRooting(); void translateNames(); void attachData(); void saveData(); void addData(); void removeData(); void renameData(); void duplicateDownSelection(); void snapData(); void searchText(); void searchResultSelected(); void clearSearchResults() { searchResults_->clear(); searchResultsItems_.clear(); } private: void initGui_(); void createActions_(); void createMenus_(); void createStatusBar_(); void createStatsPanel_(); void createDisplayPanel_(); void createBrlenPanel_(); void createMouseControlPanel_(); void createDataPanel_(); void createSearchPanel_(); }; int main(int argc, char *argv[]); bppphyview-0.3.0/bppPhyView/PhyView.cpp000644 000000 000000 00000117345 12147656666 020117 0ustar00rootroot000000 000000 // // File: PhyView.cpp // Created by: Julien Dutheil // Created on: Tue Aug 05 14:59 2009 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide graphic components to develop bioinformatics applications. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #include "PhyView.h" #include "TreeSubWindow.h" #include "TreeDocument.h" #include #include #include #include #include #include #include #include using namespace std; using namespace bpp; MouseActionListener::MouseActionListener(PhyView* phyview): phyview_(phyview), treeChooser_(new QDialog()), treeList_(new QListWidget(treeChooser_)) { treeChooser_->setParent(phyview_); treeChooser_->setModal(true); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(treeList_); layout->addStretch(1); treeChooser_->setLayout(layout); treeChooser_->connect(treeList_, SIGNAL(itemClicked(QListWidgetItem*)), treeChooser_, SLOT(accept())); } TranslateNameChooser::TranslateNameChooser(PhyView* phyview) : QDialog(phyview), phyview_(phyview), fileDialog_(new QFileDialog(this)) { fileFilters_ << "Coma separated columns (*.txt *.csv)" << "Tab separated columns (*.txt *.csv)"; fileDialog_->setNameFilters(fileFilters_); hasHeader_ = new QCheckBox(tr("File has header line")); QGridLayout *dlayout = dynamic_cast(fileDialog_->layout()); dlayout->addWidget(hasHeader_, 4, 0); QFormLayout* layout = new QFormLayout; fromList_ = new QComboBox; toList_ = new QComboBox; ok_ = new QPushButton(tr("Ok")); cancel_ = new QPushButton(tr("Cancel")); layout->addRow(tr("From"), fromList_); layout->addRow(tr("To") , toList_); layout->addRow(cancel_, ok_); connect(ok_, SIGNAL(clicked(bool)), this, SLOT(accept())); connect(cancel_, SIGNAL(clicked(bool)), this, SLOT(reject())); setLayout(layout); } void TranslateNameChooser::translateTree(TreeTemplate& tree) { fileDialog_->setAcceptMode(QFileDialog::AcceptOpen); if (fileDialog_->exec() == QDialog::Accepted) { QStringList path = fileDialog_->selectedFiles(); string sep = ","; if (fileDialog_->selectedNameFilter() == fileFilters_[1]) sep = "\t"; ifstream file(path[0].toStdString().c_str(), ios::in); DataTable* table = DataTable::read(file, sep, hasHeader_->isChecked()); //Clean button groups: fromList_->clear(); toList_->clear(); //Now add the new ones: if (!hasHeader_->isChecked()) { vector names; for (unsigned int i = 0; i < table->getNumberOfColumns(); ++i) { names.push_back("Col" + TextTools::toString(i + 1)); } table->setColumnNames(names); } for (unsigned int i = 0; i < table->getNumberOfColumns(); ++i) { fromList_->addItem(QtTools::toQt(table->getColumnName(i))); toList_->addItem(QtTools::toQt(table->getColumnName(i))); } if (exec() == QDialog::Accepted) phyview_->submitCommand(new TranslateNodeNamesCommand(phyview_->getActiveDocument(), *table, fromList_->currentIndex(), toList_->currentIndex())); } } DataLoader::DataLoader(PhyView* phyview) : QDialog(phyview), phyview_(phyview) { QFormLayout* layout = new QFormLayout; idIndex_ = new QRadioButton(tr("Index from id")); idIndex_->setChecked(true); nameIndex_ = new QRadioButton(tr("Index from name")); indexCol_ = new QComboBox; QButtonGroup* bg = new QButtonGroup(); bg->addButton(idIndex_); bg->addButton(nameIndex_); ok_ = new QPushButton(tr("Ok")); cancel_ = new QPushButton(tr("Cancel")); layout->addRow(idIndex_, nameIndex_); layout->addRow(tr("Column"), indexCol_); layout->addRow(cancel_, ok_); connect(ok_, SIGNAL(clicked(bool)), this, SLOT(accept())); connect(cancel_, SIGNAL(clicked(bool)), this, SLOT(reject())); setLayout(layout); } void DataLoader::load(const DataTable* data) { indexCol_->clear(); for (unsigned int i = 0; i < data->getNumberOfColumns(); ++i) indexCol_->addItem(QtTools::toQt(data->getColumnName(i))); if (exec() == QDialog::Accepted) { unsigned int index = static_cast(indexCol_->currentIndex()); phyview_->submitCommand(new AttachDataCommand(phyview_->getActiveDocument(), *data, index, nameIndex_->isChecked())); } } ImageExportDialog::ImageExportDialog(PhyView* phyview): QDialog(phyview) { QGridLayout* layout = new QGridLayout; path_ = new QLabel; path_->setText("(none selected)"); layout->addWidget(path_, 1, 1); browse_ = new QPushButton(tr("&Browse")); connect(browse_, SIGNAL(clicked(bool)), this, SLOT(chosePath())); layout->addWidget(browse_, 1, 2); height_ = new QSpinBox; height_->setRange(100, 10000); layout->addWidget(new QLabel(tr("Height:")), 2, 1); layout->addWidget(height_, 2, 2); width_ = new QSpinBox; width_->setRange(100, 10000); layout->addWidget(new QLabel(tr("Width:")), 3, 1); layout->addWidget(width_, 3, 2); transparent_ = new QCheckBox(tr("Transparent")); layout->addWidget(transparent_, 4, 1, 1, 2); keepAspectRatio_ = new QCheckBox(tr("Keep aspect ratio")); layout->addWidget(keepAspectRatio_, 5, 1, 1, 2); ok_ = new QPushButton(tr("Ok")); ok_->setDisabled(true); connect(ok_, SIGNAL(clicked(bool)), this, SLOT(accept())); layout->addWidget(ok_, 6, 2); cancel_ = new QPushButton(tr("Cancel")); connect(cancel_, SIGNAL(clicked(bool)), this, SLOT(reject())); layout->addWidget(cancel_, 6, 1); setLayout(layout); imageFileDialog_ = new QFileDialog(this, "Image File"); QList formats = QImageWriter::supportedImageFormats(); for (int i = 0; i < formats.size(); ++i) imageFileFilters_ << QString(formats[i]) + QString(" (*.*)"); imageFileDialog_->setNameFilters(imageFileFilters_); } void ImageExportDialog::chosePath() { if (imageFileDialog_->exec() == QDialog::Accepted) { QStringList path = imageFileDialog_->selectedFiles(); int i = imageFileFilters_.indexOf(imageFileDialog_->selectedNameFilter()); path_->setText(path[0] + " (" + QString(QImageWriter::supportedImageFormats()[i]) + ")"); ok_->setEnabled(true); } } void ImageExportDialog::process(QGraphicsScene* scene) { if (ok_->isEnabled()) { QStringList path = imageFileDialog_->selectedFiles(); int i = imageFileFilters_.indexOf(imageFileDialog_->selectedNameFilter()); //Chose the correct format according to options: QImage::Format format = QImage::Format_RGB32; QBrush bckBrush = scene->backgroundBrush(); if (transparent_->isChecked()) { format = QImage::Format_ARGB32_Premultiplied; scene->setBackgroundBrush(Qt::NoBrush); } else { if (bckBrush == Qt::NoBrush) scene->setBackgroundBrush(Qt::white); } QImage image(width_->value(), height_->value(), format); QPainter painter; painter.begin(&image); if (keepAspectRatio_->isChecked()) scene->render(&painter); else scene->render(&painter, QRectF(), QRectF(), Qt::IgnoreAspectRatio); painter.end(); scene->setBackgroundBrush(bckBrush); image.save(path[0], QImageWriter::supportedImageFormats()[i]); } else { throw Exception("Can't process image as no file has been selected."); } } TypeNumberDialog::TypeNumberDialog(PhyView* phyview, const string& what, unsigned int min, unsigned int max) : QDialog(phyview) { QFormLayout* layout = new QFormLayout; spinBox_ = new QSpinBox; spinBox_->setRange(min, max); ok_ = new QPushButton(tr("Ok")); cancel_ = new QPushButton(tr("Cancel")); layout->addRow(QtTools::toQt(what), spinBox_); layout->addRow(cancel_, ok_); connect(ok_, SIGNAL(clicked(bool)), this, SLOT(accept())); connect(cancel_, SIGNAL(clicked(bool)), this, SLOT(reject())); setLayout(layout); } void MouseActionListener::mousePressEvent(QMouseEvent *event) { if (dynamic_cast(event)->hasNodeId()) { int nodeId = dynamic_cast(event)->getNodeId(); QString action; if (event->button() == Qt::LeftButton) action = phyview_->getMouseLeftButtonActionType(); else if (event->button() == Qt::MidButton) action = phyview_->getMouseMiddleButtonActionType(); else if (event->button() == Qt::RightButton) action = phyview_->getMouseRightButtonActionType(); else action = "None"; if (action == "Swap") { if (!phyview_->getActiveDocument()->getTree()->isRoot(nodeId)) { int fatherId = phyview_->getActiveDocument()->getTree()->getFatherId(nodeId); vector sonsId = phyview_->getActiveDocument()->getTree()->getSonsId(fatherId); unsigned int i1 = 0, i2 = 0; if (sonsId[0] == nodeId) { i1 = 0; i2 = sonsId.size() - 1; } else { for (unsigned int i = 1; i < sonsId.size(); ++i) if (sonsId[i] == nodeId) { i1 = i; i2 = i - 1; } } phyview_->submitCommand(new SwapCommand(phyview_->getActiveDocument(), fatherId, i1, i2 , nodeId, sonsId[i2])); } } else if (action == "Order down") { phyview_->submitCommand(new OrderCommand(phyview_->getActiveDocument(), nodeId, true)); } else if (action == "Order up") { phyview_->submitCommand(new OrderCommand(phyview_->getActiveDocument(), nodeId, false)); } else if (action == "Root on node") phyview_->submitCommand(new RerootCommand(phyview_->getActiveDocument(), nodeId)); else if (action == "Root on branch") phyview_->submitCommand(new OutgroupCommand(phyview_->getActiveDocument(), nodeId)); else if (action == "Collapse") { TreeCanvas& tc = phyview_->getActiveSubWindow()->getTreeCanvas(); tc.collapseNode(nodeId, !tc.isNodeCollapsed(nodeId)); tc.redraw(); } else if (action == "Sample subtree") { Node* n = phyview_->getActiveDocument()->getTree()->getNode(nodeId); TypeNumberDialog dial(phyview_, "Sample size", 1u, TreeTemplateTools::getNumberOfLeaves(*n)); if (dial.exec() == QDialog::Accepted) { unsigned int size = dial.getValue(); phyview_->submitCommand(new SampleSubtreeCommand(phyview_->getActiveDocument(), nodeId, size)); } } else if (action == "Delete subtree") { phyview_->submitCommand(new DeleteSubtreeCommand(phyview_->getActiveDocument(), nodeId)); } else if (action == "Copy subtree") { Node* subtree = TreeTemplateTools::cloneSubtree(*phyview_->getActiveDocument()->getTree()->getNode(nodeId)); auto_ptr< TreeTemplate > tt(new TreeTemplate(subtree)); phyview_->createNewDocument(tt.get()); } else if (action == "Cut subtree") { Node* subtree = TreeTemplateTools::cloneSubtree(*phyview_->getActiveDocument()->getTree()->getNode(nodeId)); auto_ptr< TreeTemplate > tt(new TreeTemplate(subtree)); phyview_->submitCommand(new DeleteSubtreeCommand(phyview_->getActiveDocument(), nodeId)); phyview_->createNewDocument(tt.get()); } else if (action == "Insert on node") { if (phyview_->getNonActiveDocuments().size() == 0) { QMessageBox::critical(phyview_, QString("Oups..."), QString("No tree to insert.")); return; } TreeTemplate* tree = pickTree_(); if (tree) { Node* subtree = TreeTemplateTools::cloneSubtree(*tree->getRootNode()); phyview_->submitCommand(new InsertSubtreeAtNodeCommand(phyview_->getActiveDocument(), nodeId, subtree)); } } else if (action == "Insert on branch") { if (phyview_->getNonActiveDocuments().size() == 0) { QMessageBox::critical(phyview_, QString("Oups..."), QString("No tree to insert.")); return; } TreeTemplate* tree = pickTree_(); if (tree) { Node* subtree = TreeTemplateTools::cloneSubtree(*tree->getRootNode()); phyview_->submitCommand(new InsertSubtreeOnBranchCommand(phyview_->getActiveDocument(), nodeId, subtree)); } } } } TreeTemplate* MouseActionListener::pickTree_() { QList documents = phyview_->getNonActiveDocuments(); treeList_->clear(); for (int i = 0; i < documents.size(); ++i) { QString text = QtTools::toQt(documents[i]->getName()); if (text == "") text = "(unknown)"; vector leaves = documents[i]->getTree()->getLeavesNames(); text += QtTools::toQt(" " + TextTools::toString(leaves.size()) + " leaves "); for (unsigned int j = 0; j < min(static_cast(leaves.size()), 5u); ++j) { text += QtTools::toQt(", " + leaves[j]); } if (leaves.size() >= 5) text += "..."; treeList_->addItem(text); } treeChooser_->exec(); return documents[treeList_->currentRow()]->getTree(); } PhyView::PhyView(): manager_(), collapsedNodesListener_(true) { setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_QuitOnClose); initGui_(); createActions_(); createMenus_(); createStatusBar_(); resize(1000, 600); } void PhyView::initGui_() { mdiArea_ = new QMdiArea; connect(mdiArea_, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(setCurrentSubWindow(QMdiSubWindow*))); setCentralWidget(mdiArea_); //Stats panel: createStatsPanel_(); statsDockWidget_ = new QDockWidget(tr("Statistics")); statsDockWidget_->setWidget(statsPanel_); statsDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, statsDockWidget_); //Display panel: createDisplayPanel_(); displayDockWidget_ = new QDockWidget(tr("Display")); displayDockWidget_->setWidget(displayPanel_); displayDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, displayDockWidget_); //Search panel: createSearchPanel_(); searchDockWidget_ = new QDockWidget(tr("Search in tree")); searchDockWidget_->setWidget(searchPanel_); searchDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, searchDockWidget_); //Undo panel: QUndoView* undoView = new QUndoView; undoView->setGroup(&manager_); undoDockWidget_ = new QDockWidget(tr("Undo list")); undoDockWidget_->setWidget(undoView); undoDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, undoDockWidget_); //Branch lengths panel: createBrlenPanel_(); brlenDockWidget_ = new QDockWidget(tr("Branch lengths")); brlenDockWidget_->setWidget(brlenPanel_); brlenDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, brlenDockWidget_); brlenDockWidget_->setVisible(false); //Mouse control panel: createMouseControlPanel_(); mouseControlDockWidget_ = new QDockWidget(tr("Mouse control")); mouseControlDockWidget_->setWidget(mouseControlPanel_); mouseControlDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, mouseControlDockWidget_); //Names operations panel: createDataPanel_(); dataDockWidget_ = new QDockWidget(tr("Associated Data")); dataDockWidget_->setWidget(dataPanel_); dataDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, dataDockWidget_); dataDockWidget_->setVisible(false); //Other stuff... treeFileDialog_ = new QFileDialog(this, "Tree File"); treeFileFilters_ << "Newick files (*.dnd *.tre *.tree *.nwk *.newick *.phy *.txt)" << "Nexus files (*.nx *.nex *.nexus)" << "Nhx files (*.nhx)"; treeFileDialog_->setNameFilters(treeFileFilters_); treeFileDialog_->setConfirmOverwrite(true); dataFileDialog_ = new QFileDialog(this, "Data File"); dataFileFilters_ << "Coma separated columns (*.txt *.csv)" << "Tab separated columns (*.txt *.csv)"; dataFileDialog_->setNameFilters(dataFileFilters_); imageExportDialog_ = new ImageExportDialog(this); printer_ = new QPrinter(QPrinter::HighResolution); printDialog_ = new QPrintDialog(printer_, this); translateNameChooser_ = new TranslateNameChooser(this); dataLoader_ = new DataLoader(this); } void PhyView::createDisplayPanel_() { displayPanel_ = new QWidget(this); treeControlers_ = new TreeCanvasControlers(); treeControlers_->addActionListener(this); for (unsigned int i = 0; i < treeControlers_->getNumberOfTreeDrawings(); ++i) treeControlers_->getTreeDrawing(i)->addTreeDrawingListener(&collapsedNodesListener_); QGroupBox* drawingOptions = new QGroupBox(tr("Drawing")); QFormLayout* drawingLayout = new QFormLayout; drawingLayout->addRow(tr("&Type:"), treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAWING_CTRL)); drawingLayout->addRow(tr("&Orientation:"), treeControlers_->getControlerById(TreeCanvasControlers::ID_ORIENTATION_CTRL)); drawingLayout->addRow(tr("Width (px):"), treeControlers_->getControlerById(TreeCanvasControlers::ID_WIDTH_CTRL)); drawingLayout->addRow(tr("&Height (px):"), treeControlers_->getControlerById(TreeCanvasControlers::ID_HEIGHT_CTRL)); drawingOptions->setLayout(drawingLayout); QGroupBox* displayOptions = new QGroupBox(tr("Display")); QVBoxLayout* displayLayout = new QVBoxLayout; displayLayout->addWidget(treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAW_NODE_IDS_CTRL)); displayLayout->addWidget(treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAW_LEAF_NAMES_CTRL)); displayLayout->addWidget(treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAW_BRANCH_LENGTHS_CTRL)); displayLayout->addWidget(treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAW_BOOTSTRAP_VALUES_CTRL)); displayLayout->addWidget(treeControlers_->getControlerById(TreeCanvasControlers::ID_DRAW_CLICKABLE_AREAS_CTRL)); displayOptions->setLayout(displayLayout); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(drawingOptions); layout->addWidget(displayOptions); layout->addStretch(1); displayPanel_->setLayout(layout); } void PhyView::createStatsPanel_() { statsPanel_ = new QWidget(this); QVBoxLayout* statsLayout = new QVBoxLayout; statsBox_ = new TreeStatisticsBox; statsLayout->addWidget(statsBox_); QPushButton* update = new QPushButton(tr("Update")); connect(update, SIGNAL(clicked(bool)), this, SLOT(updateStatistics())); statsLayout->addWidget(update); statsLayout->addStretch(1); statsPanel_->setLayout(statsLayout); } void PhyView::createBrlenPanel_() { brlenPanel_ = new QWidget(this); QVBoxLayout* brlenLayout = new QVBoxLayout; //Set all lengths: brlenSetLengths_ = new QDoubleSpinBox; brlenSetLengths_->setDecimals(6); brlenSetLengths_->setSingleStep(0.01); QPushButton* brlenSetLengthsGo = new QPushButton(tr("Go!")); connect(brlenSetLengthsGo, SIGNAL(clicked(bool)), this, SLOT(setLengths())); QGroupBox* brlenSetLengthsBox = new QGroupBox(tr("Set all lengths")); QHBoxLayout* brlenSetLengthsBoxLayout = new QHBoxLayout; brlenSetLengthsBoxLayout->addWidget(brlenSetLengths_); brlenSetLengthsBoxLayout->addWidget(brlenSetLengthsGo); brlenSetLengthsBoxLayout->addStretch(1); brlenSetLengthsBox->setLayout(brlenSetLengthsBoxLayout); brlenLayout->addWidget(brlenSetLengthsBox); //Grafen method: QPushButton* brlenInitGrafen = new QPushButton(tr("Init")); connect(brlenInitGrafen, SIGNAL(clicked(bool)), this, SLOT(initLengthsGrafen())); brlenComputeGrafen_ = new QDoubleSpinBox; brlenComputeGrafen_->setValue(1.); brlenComputeGrafen_->setDecimals(2); brlenComputeGrafen_->setSingleStep(0.1); QPushButton* brlenComputeGrafenGo = new QPushButton(tr("Go!")); connect(brlenComputeGrafenGo, SIGNAL(clicked(bool)), this, SLOT(computeLengthsGrafen())); QGroupBox* brlenGrafenBox = new QGroupBox(tr("Grafen")); QHBoxLayout* brlenGrafenBoxLayout = new QHBoxLayout; brlenGrafenBoxLayout->addWidget(brlenInitGrafen); brlenGrafenBoxLayout->addWidget(brlenComputeGrafen_); brlenGrafenBoxLayout->addWidget(brlenComputeGrafenGo); brlenGrafenBoxLayout->addStretch(1); brlenGrafenBox->setLayout(brlenGrafenBoxLayout); brlenLayout->addWidget(brlenGrafenBox); //To clock tree: QPushButton* brlenToClockTree = new QPushButton(tr("Convert to clock")); connect(brlenToClockTree, SIGNAL(clicked(bool)), this, SLOT(convertToClockTree())); brlenLayout->addWidget(brlenToClockTree); //Midpoint rooting: QPushButton* brlenMidpointRooting = new QPushButton(tr("Midpoint rooting")); connect(brlenMidpointRooting, SIGNAL(clicked(bool)), this, SLOT(midpointRooting())); brlenLayout->addWidget(brlenMidpointRooting); //// brlenLayout->addStretch(1); brlenPanel_->setLayout(brlenLayout); } void PhyView::createMouseControlPanel_() { mouseControlPanel_ = new QWidget; QStringList mouseActions; mouseActions.append(tr("None")); mouseActions.append(tr("Swap")); mouseActions.append(tr("Order down")); mouseActions.append(tr("Order up")); mouseActions.append(tr("Root on node")); mouseActions.append(tr("Root on branch")); mouseActions.append(tr("Sample subtree")); mouseActions.append(tr("Collapse")); mouseActions.append(tr("Delete subtree")); mouseActions.append(tr("Copy subtree")); mouseActions.append(tr("Cut subtree")); mouseActions.append(tr("Insert on node")); mouseActions.append(tr("Insert on branch")); leftButton_ = new QComboBox; leftButton_->addItems(mouseActions); middleButton_ = new QComboBox; middleButton_->addItems(mouseActions); rightButton_ = new QComboBox; rightButton_->addItems(mouseActions); QFormLayout* formLayout = new QFormLayout; formLayout->addRow(tr("Left:"), leftButton_); formLayout->addRow(tr("Middle:"), middleButton_); formLayout->addRow(tr("Right:"), rightButton_); mouseControlPanel_->setLayout(formLayout); } void PhyView::createDataPanel_() { dataPanel_ = new QWidget; QVBoxLayout* dataLayout = new QVBoxLayout; loadData_ = new QPushButton(tr("Load Data")); connect(loadData_, SIGNAL(clicked(bool)), this, SLOT(attachData())); dataLayout->addWidget(loadData_); saveData_ = new QPushButton(tr("Save Data")); connect(saveData_, SIGNAL(clicked(bool)), this, SLOT(saveData())); dataLayout->addWidget(saveData_); addData_ = new QPushButton(tr("Add Data")); connect(addData_, SIGNAL(clicked(bool)), this, SLOT(addData())); dataLayout->addWidget(addData_); removeData_ = new QPushButton(tr("Remove Data")); connect(removeData_, SIGNAL(clicked(bool)), this, SLOT(removeData())); dataLayout->addWidget(removeData_); renameData_ = new QPushButton(tr("Rename Data")); connect(renameData_, SIGNAL(clicked(bool)), this, SLOT(renameData())); dataLayout->addWidget(renameData_); translateNames_ = new QPushButton(tr("Translate")); connect(translateNames_, SIGNAL(clicked(bool)), this, SLOT(translateNames())); dataLayout->addWidget(translateNames_); duplicateDownSelection_ = new QPushButton(tr("Duplicate down")); connect(duplicateDownSelection_, SIGNAL(clicked(bool)), this, SLOT(duplicateDownSelection())); dataLayout->addWidget(duplicateDownSelection_); snapData_ = new QPushButton(tr("Snap shot")); connect(snapData_, SIGNAL(clicked(bool)), this, SLOT(snapData())); dataLayout->addWidget(snapData_); dataPanel_->setLayout(dataLayout); } void PhyView::createSearchPanel_() { searchPanel_ = new QWidget; QVBoxLayout* searchLayout = new QVBoxLayout; searchText_ = new QLineEdit(); connect(searchText_, SIGNAL(returnPressed()), this, SLOT(searchText())); searchLayout->addWidget(searchText_); searchResults_ = new QListWidget(); searchResults_->setSelectionMode(QAbstractItemView::SingleSelection); connect(searchResults_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(searchResultSelected())); searchLayout->addWidget(searchResults_); searchPanel_->setLayout(searchLayout); } void PhyView::createActions_() { openAction_ = new QAction(tr("&Open"), this); openAction_->setShortcut(tr("Ctrl+O")); openAction_->setStatusTip(tr("Open a new tree file")); connect(openAction_, SIGNAL(triggered()), this, SLOT(openTree())); saveAction_ = new QAction(tr("&Save"), this); saveAction_->setShortcut(tr("Ctrl+S")); saveAction_->setStatusTip(tr("Save the current tree to file")); saveAction_->setDisabled(true); connect(saveAction_, SIGNAL(triggered()), this, SLOT(saveTree())); saveAsAction_ = new QAction(tr("Save &as"), this); saveAsAction_->setShortcut(tr("Ctrl+Shift+S")); saveAsAction_->setStatusTip(tr("Save the current tree to a file")); saveAsAction_->setDisabled(true); connect(saveAsAction_, SIGNAL(triggered()), this, SLOT(saveTreeAs())); closeAction_ = new QAction(tr("&Close"), this); closeAction_->setShortcut(tr("Ctrl+W")); closeAction_->setStatusTip(tr("Close the current tree plot.")); closeAction_->setDisabled(true); connect(closeAction_, SIGNAL(triggered()), this, SLOT(closeTree())); exportAction_ = new QAction(tr("Export as &Image"), this); exportAction_->setShortcut(tr("Ctrl+I")); exportAction_->setStatusTip(tr("Print the current tree plot.")); exportAction_->setDisabled(true); connect(exportAction_, SIGNAL(triggered()), this, SLOT(exportTree())); printAction_ = new QAction(tr("&Print"), this); printAction_->setShortcut(tr("Ctrl+P")); printAction_->setStatusTip(tr("Print the current tree plot.")); printAction_->setDisabled(true); connect(printAction_, SIGNAL(triggered()), this, SLOT(printTree())); exitAction_ = new QAction(tr("&Quit"), this); exitAction_->setShortcut(tr("Ctrl+Q")); exitAction_->setStatusTip(tr("Quit PhyView")); connect(exitAction_, SIGNAL(triggered()), this, SLOT(exit())); cascadeWinAction_ = new QAction(tr("&Cascade windows"), this); connect(cascadeWinAction_, SIGNAL(triggered()), mdiArea_, SLOT(cascadeSubWindows())); tileWinAction_ = new QAction(tr("&Tile windows"), this); connect(tileWinAction_, SIGNAL(triggered()), mdiArea_, SLOT(tileSubWindows())); aboutAction_ = new QAction(tr("About"), this); connect(aboutAction_, SIGNAL(triggered()), this, SLOT(about())); aboutBppAction_ = new QAction(tr("About Bio++"), this); connect(aboutBppAction_, SIGNAL(triggered()), this, SLOT(aboutBpp())); aboutQtAction_ = new QAction(tr("About Qt"), this); connect(aboutQtAction_, SIGNAL(triggered()), qApp, SLOT(aboutQt())); undoAction_ = manager_.createUndoAction(this); redoAction_ = manager_.createRedoAction(this); undoAction_->setShortcut(QKeySequence("Ctrl+Z")); redoAction_->setShortcut(QKeySequence("Shift+Ctrl+Z")); } void PhyView::createMenus_() { fileMenu_ = menuBar()->addMenu(tr("&File")); fileMenu_->addAction(openAction_); fileMenu_->addAction(saveAction_); fileMenu_->addAction(saveAsAction_); fileMenu_->addAction(closeAction_); fileMenu_->addAction(exportAction_); fileMenu_->addAction(printAction_); fileMenu_->addAction(exitAction_); editMenu_ = menuBar()->addMenu(tr("&Edit")); editMenu_->addAction(undoAction_); editMenu_->addAction(redoAction_); viewMenu_ = menuBar()->addMenu(tr("&View")); viewMenu_->addAction(statsDockWidget_->toggleViewAction()); viewMenu_->addAction(displayDockWidget_->toggleViewAction()); viewMenu_->addAction(brlenDockWidget_->toggleViewAction()); viewMenu_->addAction(undoDockWidget_->toggleViewAction()); viewMenu_->addAction(mouseControlDockWidget_->toggleViewAction()); viewMenu_->addAction(dataDockWidget_->toggleViewAction()); viewMenu_->addAction(searchDockWidget_->toggleViewAction()); viewMenu_->addAction(cascadeWinAction_); viewMenu_->addAction(tileWinAction_); helpMenu_ = menuBar()->addMenu(tr("&Help")); helpMenu_->addAction(aboutAction_); helpMenu_->addAction(aboutBppAction_); helpMenu_->addAction(aboutQtAction_); } void PhyView::createStatusBar_() { updateStatusBar(); } void PhyView::closeEvent(QCloseEvent* event) { } TreeDocument* PhyView::createNewDocument(Tree* tree) { TreeDocument* doc = new TreeDocument(); doc->setTree(*tree); manager_.addStack(&doc->getUndoStack()); TreeSubWindow *subWindow = new TreeSubWindow(this, doc, treeControlers_->getSelectedTreeDrawing()); mdiArea_->addSubWindow(subWindow); treeControlers_->applyOptions(&subWindow->getTreeCanvas()); subWindow->show(); setCurrentSubWindow(subWindow); return doc; } QList PhyView::getNonActiveDocuments() { QList documents; QList lst = mdiArea_->subWindowList(); for (int i = 0; i < lst.size(); ++i) { if (lst[i] != mdiArea_->currentSubWindow()) documents.push_back(dynamic_cast(lst[i])->getDocument()); } return documents; } void PhyView::readTree(const QString& path, const string& format) { auto_ptr treeReader(ioTreeFactory_.createReader(format)); try { auto_ptr tree(treeReader->read(path.toStdString())); TreeDocument* doc = createNewDocument(tree.get()); doc->setFile(path.toStdString(), format); saveAction_->setEnabled(true); saveAsAction_->setEnabled(true); closeAction_->setEnabled(true); exportAction_->setEnabled(true); printAction_->setEnabled(true); //We need to remove and add action again for menu to be updated :s fileMenu_->removeAction(saveAction_); fileMenu_->removeAction(saveAsAction_); fileMenu_->removeAction(closeAction_); fileMenu_->removeAction(exportAction_); fileMenu_->removeAction(printAction_); fileMenu_->insertAction(exitAction_, saveAction_); fileMenu_->insertAction(exitAction_, saveAsAction_); fileMenu_->insertAction(exitAction_, closeAction_); fileMenu_->insertAction(exitAction_, exportAction_); fileMenu_->insertAction(exitAction_, printAction_); } catch (Exception& e) { QMessageBox::critical(this, tr("Ouch..."), tr("Error when reading file:\n") + tr(e.what())); } } void PhyView::openTree() { treeFileDialog_->setAcceptMode(QFileDialog::AcceptOpen); if (treeFileDialog_->exec() == QDialog::Accepted) { QStringList path = treeFileDialog_->selectedFiles(); string format = IOTreeFactory::NEWICK_FORMAT; if (treeFileDialog_->selectedNameFilter() == treeFileFilters_[1]) format = IOTreeFactory::NEXUS_FORMAT; else if (treeFileDialog_->selectedNameFilter() == treeFileFilters_[2]) format = IOTreeFactory::NHX_FORMAT; readTree(path[0], format); } } void PhyView::setCurrentSubWindow(TreeSubWindow* tsw) { clearSearchResults(); if (tsw) { statsBox_->updateTree(tsw->getTree()); treeControlers_->setTreeCanvas(&tsw->getTreeCanvas()); treeControlers_->actualizeOptions(); manager_.setActiveStack(&tsw->getDocument()->getUndoStack()); } } bool PhyView::saveTree() { TreeDocument* doc = getActiveDocument(); if (doc->getFilePath() == "") return saveTreeAs(); string format = doc->getFileFormat(); auto_ptr treeWriter(ioTreeFactory_.createWriter(format)); Nhx* nhx = dynamic_cast(treeWriter.get()); if (nhx) { TreeTemplate treeCopy(*doc->getTree()); nhx->changeNamesToTags(*treeCopy.getRootNode()); treeWriter->write(treeCopy, doc->getFilePath(), true); } else { treeWriter->write(*doc->getTree(), doc->getFilePath(), true); } return true; } bool PhyView::saveTreeAs() { treeFileDialog_->setAcceptMode(QFileDialog::AcceptSave); if (treeFileDialog_->exec() == QDialog::Accepted) { QStringList path = treeFileDialog_->selectedFiles(); TreeDocument* doc = getActiveDocument(); string format = IOTreeFactory::NEWICK_FORMAT; if (treeFileDialog_->selectedNameFilter() == treeFileFilters_[1]) format = IOTreeFactory::NEXUS_FORMAT; else if (treeFileDialog_->selectedNameFilter() == treeFileFilters_[2]) format = IOTreeFactory::NHX_FORMAT; doc->setFile(path[0].toStdString(), format); return saveTree(); } return false; } void PhyView::exportTree() { if (imageExportDialog_->exec() == QDialog::Accepted) { imageExportDialog_->process(getActiveSubWindow()->getTreeCanvas().scene()); } } void PhyView::printTree() { if (printDialog_->exec() == QDialog::Accepted) { QPainter painter(printer_); getActiveSubWindow()->getTreeCanvas().scene()->render(&painter); painter.end(); } } void PhyView::closeTree() { if (mdiArea_->currentSubWindow()) mdiArea_->currentSubWindow()->close(); if (mdiArea_->subWindowList().size() == 0) { saveAction_->setDisabled(true); saveAsAction_->setDisabled(true); closeAction_->setDisabled(true); exportAction_->setDisabled(true); saveAction_->setDisabled(true); } } void PhyView::exit() { close(); } void PhyView::aboutBpp() { QMessageBox msgBox; msgBox.setText("Bio++ 2.1.0."); msgBox.setInformativeText("bpp-core 2.1.0\nbpp-seq 2.1.0.\nbpp-phyl 2.1.0.\nbpp-qt 2.1.0"); msgBox.exec(); } void PhyView::about() { QMessageBox msgBox; msgBox.setText("This is Bio++ Phy View version 0.3.0."); msgBox.setInformativeText("Julien Dutheil ."); msgBox.exec(); } void PhyView::updateStatusBar() { } void PhyView::setLengths() { if (hasActiveDocument()) submitCommand(new SetLengthCommand(getActiveDocument(), brlenSetLengths_->value())); } void PhyView::initLengthsGrafen() { if (hasActiveDocument()) submitCommand(new InitGrafenCommand(getActiveDocument())); } void PhyView::computeLengthsGrafen() { if (hasActiveDocument()) submitCommand(new ComputeGrafenCommand(getActiveDocument(), brlenComputeGrafen_->value())); } void PhyView::convertToClockTree() { if (hasActiveDocument()) submitCommand(new ConvertToClockTreeCommand(getActiveDocument())); } void PhyView::midpointRooting() { if (hasActiveDocument()) try { submitCommand(new MidpointRootingCommand(getActiveDocument())); } catch (NodeException& ex) { QMessageBox::critical(this, tr("Oups..."), tr("Some branch do not have lengths.")); } } void PhyView::translateNames() { if (hasActiveDocument()) { translateNameChooser_->translateTree(*getActiveDocument()->getTree()); } } void PhyView::controlerTakesAction() { QList lst = mdiArea_->subWindowList(); for (int i = 0; i < lst.size(); ++i) { dynamic_cast(lst[i])->getTreeCanvas().redraw(); } } void PhyView::attachData() { dataFileDialog_->setAcceptMode(QFileDialog::AcceptOpen); if (dataFileDialog_->exec() == QDialog::Accepted) { QStringList path = dataFileDialog_->selectedFiles(); string sep = ","; if (dataFileDialog_->selectedNameFilter() == dataFileFilters_[1]) sep = "\t"; ifstream file(path[0].toStdString().c_str(), ios::in); DataTable* table = DataTable::read(file, sep); dataLoader_->load(table); } } void PhyView::saveData() { if (hasActiveDocument()) { dataFileDialog_->setAcceptMode(QFileDialog::AcceptSave); if (dataFileDialog_->exec() == QDialog::Accepted) { QStringList path = dataFileDialog_->selectedFiles(); string sep = ","; if (dataFileDialog_->selectedNameFilter() == dataFileFilters_[1]) sep = "\t"; getActiveSubWindow()->writeTableToFile(path[0].toStdString(), sep); } } } void PhyView::addData() { if (hasActiveDocument()) { bool ok; QString name = QInputDialog::getText(this, tr("Set property name"), tr("Property name"), QLineEdit::Normal, tr("New property"), &ok); if (ok) submitCommand(new AddDataCommand(getActiveDocument(), name)); } } void PhyView::removeData() { if (hasActiveDocument()) { vector tmp; TreeTemplateTools::getNodePropertyNames(*getActiveDocument()->getTree()->getRootNode(), tmp); if (tmp.size() == 0) { QMessageBox::information(this, tr("Warning"), tr("No removable data is attached to this tree."), QMessageBox::Cancel); return; } QStringList properties; for (size_t i = 0; i < tmp.size(); ++i) { properties.append(QtTools::toQt(tmp[i])); } bool ok; QString name = QInputDialog::getItem(this, tr("Get property name"), tr("Property name"), properties, 0, false, &ok); if (ok) submitCommand(new RemoveDataCommand(getActiveDocument(), name)); } } void PhyView::renameData() { if (hasActiveDocument()) { vector tmp; TreeTemplateTools::getNodePropertyNames(*getActiveDocument()->getTree()->getRootNode(), tmp); if (tmp.size() == 0) { QMessageBox::information(this, tr("Warning"), tr("No data which can be renaded is attached to this tree."), QMessageBox::Cancel); return; } QStringList properties; for (size_t i = 0; i < tmp.size(); ++i) { properties.append(QtTools::toQt(tmp[i])); } bool ok; QString fromName = QInputDialog::getItem(this, tr("Get property name"), tr("Property name"), properties, 0, false, &ok); if (ok) { QString toName = QInputDialog::getText(this, tr("Set property name"), tr("Property name"), QLineEdit::Normal, tr("New property"), &ok); if (ok) { submitCommand(new RenameDataCommand(getActiveDocument(), fromName, toName)); } } } } void PhyView::duplicateDownSelection() { if (hasActiveDocument()) { getActiveSubWindow()->duplicateDownSelection(1); } } void PhyView::snapData() { if (hasActiveDocument()) { submitCommand(new SnapCommand(getActiveDocument())); } } void PhyView::searchText() { if (!getActiveSubWindow()) return; getActiveSubWindow()->getTreeCanvas().redraw(); clearSearchResults(); QList results = getActiveSubWindow()->getTreeCanvas().searchText(searchText_->text()); for (int i = 0; i < results.size(); ++i) { searchResults_->addItem(results[i]->toPlainText()); searchResultsItems_.append(results[i]); results[i]->setDefaultTextColor(Qt::red); } } void PhyView::searchResultSelected() { getActiveSubWindow()->getTreeCanvas().ensureVisible(searchResultsItems_[searchResults_->currentRow()]); } int main(int argc, char *argv[]) { QApplication app(argc, argv); PhyView* phyview = new PhyView(); phyview->show(); //Parse command line arguments: QStringList args = app.arguments(); string format = IOTreeFactory::NEWICK_FORMAT; QTextCodec* codec = QTextCodec::codecForLocale(); for (int i = 1; i < args.size(); ++i) { if (args[i] == "--nhx") { format = IOTreeFactory::NHX_FORMAT; } else if (args[i] == "--nexus") { format = IOTreeFactory::NEWICK_FORMAT; } else if (args[i] == "--newick") { format = IOTreeFactory::NEWICK_FORMAT; } else if (args[i] == "--enc") { if (i == args.size() - 1) { cerr << "You must specify a text encoding after --enc tag." << endl; exit(1); } ++i; codec = QTextCodec::codecForName(args[i].toStdString().c_str()); } else { phyview->readTree(args[i], format); } } QTextCodec::setCodecForCStrings(codec); return app.exec(); } bppphyview-0.3.0/bppPhyView/TreeCommands.h000644 000000 000000 00000023310 12147656666 020536 0ustar00rootroot000000 000000 // // File: TreeCommands.h // Created by: Julien Dutheil // Created on: Fri Oct 13 21:25 2006 // /* Copyright or © or Copr. Bio++ Development Team, (November 16, 2004) This software is a computer program whose purpose is to provide classes for phylogenetic data analysis. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #ifndef _COMMANDS_H_ #define _COMMANDS_H_ #include "TreeDocument.h" #include #include //From PhylLib: #include //From Qt: #include #include //From bpp-qt: #include //From the STL: #include class AbstractCommand: public QUndoCommand { protected: TreeDocument* doc_; TreeTemplate* old_; TreeTemplate* new_; public: AbstractCommand(const QString& name, TreeDocument* doc): QUndoCommand(name), doc_(doc), old_(new TreeTemplate(*doc->getTree())), new_(0) {} virtual ~AbstractCommand() { if (old_) delete old_; if (new_) delete new_; } public: void redo() { doOrUndo(); } void undo() { doOrUndo(); } virtual void doOrUndo() { doc_->setTree(*new_); doc_->modified(true); doc_->updateAllViews(); TreeTemplate* tmp = new_; new_ = old_; old_ = tmp; } }; class SetLengthCommand: public AbstractCommand { public: SetLengthCommand(TreeDocument* doc, double length): AbstractCommand(QtTools::toQt("Set all lengths to " + TextTools::toString(length) + "."), doc) { new_ = new TreeTemplate(*old_); new_->setBranchLengths(length); } }; class InitGrafenCommand: public AbstractCommand { public: InitGrafenCommand(TreeDocument* doc): AbstractCommand("Init branch lengths (Grafen)", doc) { new_ = new TreeTemplate(*old_); TreeTools::initBranchLengthsGrafen(*new_); } }; class ComputeGrafenCommand: public AbstractCommand { public: ComputeGrafenCommand(TreeDocument* doc, double power): AbstractCommand(QtTools::toQt("Compute branch lengths (Grafen), power=" + TextTools::toString(power) + "."), doc) { new_ = new TreeTemplate(*old_); TreeTools::computeBranchLengthsGrafen(*new_, power, false); } }; class ConvertToClockTreeCommand: public AbstractCommand { public: ConvertToClockTreeCommand(TreeDocument* doc): AbstractCommand(QtTools::toQt("Convert to clock tree"), doc) { new_ = new TreeTemplate(*old_); TreeTools::convertToClockTree(*new_, new_->getRootId(), true); } }; class SwapCommand: public AbstractCommand { public: SwapCommand(TreeDocument* doc, int nodeId, unsigned int i1, unsigned int i2, int id1, int id2): AbstractCommand(QtTools::toQt("Swap nodes " + TextTools::toString(id1) + " and " + TextTools::toString(id2) + "."), doc) { new_ = new TreeTemplate(*old_); new_->swapNodes(nodeId, i1, i2); } }; class OrderCommand: public AbstractCommand { public: OrderCommand(TreeDocument* doc, int nodeId, bool downward): AbstractCommand(QtTools::toQt("Order nodes in subtree " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); TreeTemplateTools::orderTree(*new_->getNode(nodeId), downward); } }; class RerootCommand: public AbstractCommand { public: RerootCommand(TreeDocument* doc, int nodeId): AbstractCommand(QtTools::toQt("Reroot at " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); new_->rootAt(nodeId); } }; class OutgroupCommand: public AbstractCommand { public: OutgroupCommand(TreeDocument* doc, int nodeId): AbstractCommand(QtTools::toQt("New outgroup: " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); new_->newOutGroup(nodeId); } }; class MidpointRootingCommand: public AbstractCommand { public: MidpointRootingCommand(TreeDocument* doc) : AbstractCommand(QtTools::toQt("Midpoint rooting"), doc) { new_ = new TreeTemplate(*old_); TreeTools::midpointRooting(*new_); } }; class DeleteSubtreeCommand: public AbstractCommand { public: DeleteSubtreeCommand(TreeDocument* doc, int nodeId): AbstractCommand(QtTools::toQt("Delete substree " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); TreeTemplateTools::dropSubtree(*new_, node); } }; class InsertSubtreeAtNodeCommand: public AbstractCommand { public: InsertSubtreeAtNodeCommand(TreeDocument* doc, int nodeId, Node* subtree): AbstractCommand(QtTools::toQt("Insert substree at " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); node->addSon(subtree); new_->resetNodesId(); } }; class InsertSubtreeOnBranchCommand: public AbstractCommand { public: InsertSubtreeOnBranchCommand(TreeDocument* doc, int nodeId, Node* subtree): AbstractCommand(QtTools::toQt("Insert substree below " + TextTools::toString(nodeId) + "."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); if (!node->hasFather()) { //Need to change root: Node* father = new Node(); node->addSon(new_->getRootNode()); node->addSon(subtree); new_->setRootNode(father); } else { Node* father = node->getFather(); father->removeSon(node); Node* base = new Node(); base->addSon(node); base->addSon(subtree); father->addSon(base); } new_->resetNodesId(); } }; class ChangeBranchLengthCommand: public AbstractCommand { public: ChangeBranchLengthCommand(TreeDocument* doc, int nodeId, double newLength): AbstractCommand(QtTools::toQt("Change length of node " + TextTools::toString(nodeId) + " to " + TextTools::toString(newLength) + "."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); node->setDistanceToFather(newLength); } }; class ChangeNodeNameCommand: public AbstractCommand { public: ChangeNodeNameCommand(TreeDocument* doc, int nodeId, const string& newName): AbstractCommand(QtTools::toQt("Change name of node " + TextTools::toString(nodeId) + " to " + newName + "."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); node->setName(newName); } }; class TranslateNodeNamesCommand: public AbstractCommand { public: TranslateNodeNamesCommand(TreeDocument* doc, const DataTable& table, unsigned int from, unsigned int to); }; class AttachDataCommand: public AbstractCommand { public: AttachDataCommand(TreeDocument* doc, const DataTable& data, unsigned int index, bool useNames); private: static void addProperties_(Node* node, const DataTable& data, unsigned int index, bool useNames); }; class AddDataCommand: public AbstractCommand { public: AddDataCommand(TreeDocument* doc, const QString& name); private: static void addProperty_(Node* node, const QString& name); }; class RemoveDataCommand: public AbstractCommand { public: RemoveDataCommand(TreeDocument* doc, const QString& name); private: static void removeProperty_(Node* node, const QString& name); }; class RenameDataCommand: public AbstractCommand { public: RenameDataCommand(TreeDocument* doc, const QString& oldName, const QString& newName); private: static void renameProperty_(Node* node, const QString& oldName, const QString& newName); }; class SampleSubtreeCommand: public AbstractCommand { public: SampleSubtreeCommand(TreeDocument* doc, int nodeId, unsigned int size): AbstractCommand(QtTools::toQt("Sample subtree " + TextTools::toString(nodeId) + " to " + TextTools::toString(size) + " leaves."), doc) { new_ = new TreeTemplate(*old_); Node* node = new_->getNode(nodeId); TreeTemplateTools::sampleSubtree(*new_, TreeTemplateTools::getLeavesNames(*node), size); } }; class SnapCommand: public AbstractCommand { public: SnapCommand(TreeDocument* doc): AbstractCommand(QString("Tree snapshot (saved at ") + QTime::currentTime().toString("hh:mm:ss") + QString(")"), doc) { new_ = new TreeTemplate(*old_); } }; #endif //_COMMANDS_H_