pax_global_header00006660000000000000000000000064132521777610014525gustar00rootroot0000000000000052 comment=41356a08e6d60fa2a645fa48a55f4a9a1e08dc84 bppphyview-0.6.0/000077500000000000000000000000001325217776100137255ustar00rootroot00000000000000bppphyview-0.6.0/AUTHORS.txt000066400000000000000000000000571325217776100156150ustar00rootroot00000000000000Julien Dutheil bppphyview-0.6.0/CMakeLists.txt000066400000000000000000000102331325217776100164640ustar00rootroot00000000000000# CMake script for Bio++ PhyView # Authors: # Julien Dutheil # Francois Gindraud (2017) # Created: 22/08/2009 cmake_minimum_required (VERSION 2.8.11) project (bppphyview CXX) # Compile options set (CMAKE_CXX_FLAGS "-std=c++11 -Wall") 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) 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(NO_DEP_CHECK) MESSAGE(STATUS "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(STATUS "Static linkage requested.") set (CMAKE_CXX_FLAGS "-static -static-libgcc ${CMAKE_CXX_FLAGS}") ENDIF() # Check compression program # COMPRESS_PROGRAM controls the choice of program # COMPRESS_EXT can be used to override the file extension if (NOT COMPRESS_PROGRAM) set (COMPRESS_PROGRAM gzip CACHE STRING "Set program for compressing documentation" FORCE) endif () find_program (COMPRESS_BIN NAMES ${COMPRESS_PROGRAM} DOC "${COMPRESS_PROGRAM} compression program") if (NOT COMPRESS_BIN) message (STATUS "${COMPRESS_PROGRAM} program not found, text doc will not be compressed") else () # Deduce COMPRESS_EXT for known compression programs if not set if (NOT COMPRESS_EXT) if (${COMPRESS_PROGRAM} STREQUAL "gzip") set (COMPRESS_EXT "gz") elseif (${COMPRESS_PROGRAM} STREQUAL "bzip2") set (COMPRESS_EXT "bz2") else () set (COMPRESS_EXT "${COMPRESS_PROGRAM}") # Default: program name (works for xz/lzma) endif () endif () # Generate command line args (always add -c to output compressed file to stdout) if (${COMPRESS_PROGRAM} STREQUAL "gzip") # -n for no timestamp in files (reproducible builds) # -9 for maximal compression (lintian warning) set (COMPRESS_ARGS -c -9 -n) else () set (COMPRESS_ARGS -c) endif () message (STATUS "Found ${COMPRESS_BIN} compression program, using file extension .${COMPRESS_EXT}") endif () # Find dependencies (add install directory to search) if (CMAKE_INSTALL_PREFIX) set (CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH}) endif (CMAKE_INSTALL_PREFIX) include (GNUInstallDirs) find_package (bpp-qt 2.0.0 REQUIRED) # Find the Qt installation set(CMAKE_AUTOMOC ON) find_package (Qt5Widgets) find_package (Qt5Core) find_package (Qt5Gui) find_package (Qt5PrintSupport) set (qt-libs Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport) # 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.6.0") SET(CPACK_PACKAGE_VERSION_MAJOR "0") SET(CPACK_PACKAGE_VERSION_MINOR "6") 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") # /!\ This assumes that an external build is used SET(CPACK_SOURCE_IGNORE_FILES "/build/" "/\\\\.git/" "/\\\\.gitignore" ${CPACK_SOURCE_IGNORE_FILES} ) 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) IF(NOT NO_DEP_CHECK) IF (UNIX) #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.6.0/COPYING.txt000066400000000000000000000511531325217776100156030ustar00rootroot00000000000000CeCILL 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.6.0/ChangeLog000066400000000000000000000020741325217776100155020ustar00rootroot0000000000000025/02/18 -*- Version 0.6.0 -*- 27/12/17 Julien Dutheil * Added "removeAllLengths" command. 13/09/17 Julien Dutheil * Ported to Qt5. 10/05/17 -*- Version 0.5.0 -*- * Compatibility update with Bio++ 2.3.0. 28/09/14 -*- Version 0.4.0 -*- 23/09/14 Julien Dutheil * New clickable panel with currently loaded trees. * New dialog box for inserting (sub)trees. * Possibility to insert a tree into itself (!). * Root at node function fixed. 22/09/14 Julien Dutheil * Exceptions from Bio++ are caught instead of producing a crash. 25/07/13 Julien Dutheil * Added method for unresolving uncertain nodes, based on bottstrap values. * New midpoint rooting: faster, with two options: sum of square or variance. 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.6.0/INSTALL.txt000066400000000000000000000015751325217776100156040ustar00rootroot00000000000000This software needs cmake >= 2.8.11 and a C++11 capable compiler 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. If you install Bio++ in a non standard path (not /usr/), and compile bppsuite with shared libraries, you must also tell programs where to find them at startup: -> either by adding the path to LD_LIBRARY_PATH environment variable. -> or by using RPATHs to hard code the path in the executable (generates NON PORTABLE executables !) -> install Bio++ with the "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" option bppphyview-0.6.0/NEWS000066400000000000000000000000001325217776100144120ustar00rootroot00000000000000bppphyview-0.6.0/README000066400000000000000000000000001325217776100145730ustar00rootroot00000000000000bppphyview-0.6.0/bppPhyView/000077500000000000000000000000001325217776100160225ustar00rootroot00000000000000bppphyview-0.6.0/bppPhyView/CMakeLists.txt000066400000000000000000000010461325217776100205630ustar00rootroot00000000000000# CMake script for Bio++ PhyView # Authors: # Julien Dutheil # Francois Gindraud (2017) # Created: 22/08/2009 set (CPP_FILES PhyView.cpp TreeSubWindow.cpp TreeCommands.cpp ) set (H_MOC_FILES PhyView.h TreeSubWindow.h ) # Phyview add_executable (phyview ${CPP_FILES} ${CPP_FILES}) if (BUILD_STATIC) target_link_libraries (phyview ${BPP_LIBS_STATIC} ${qt-libs}) else (BUILD_STATIC) target_link_libraries (phyview ${BPP_LIBS_SHARED} ${qt-libs}) endif (BUILD_STATIC) install (TARGETS phyview DESTINATION ${CMAKE_INSTALL_BINDIR}) bppphyview-0.6.0/bppPhyView/PhyView.cpp000066400000000000000000001337731325217776100201370ustar00rootroot00000000000000// // 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 #include #include #include #include #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_); fileDialog_->setOptions(QFileDialog::DontUseNativeDialog); hasHeader_ = new QCheckBox(tr("File has header line")); QGridLayout *dlayout = dynamic_cast(fileDialog_->layout()); //Check that here!! 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); try { 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())); } catch (Exception& e) { QMessageBox::critical(this, tr("Ouch..."), tr("Error when reading table:\n") + tr(e.what())); } } } 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") { if (phyview_->getActiveDocument()->getTree()->getNode(nodeId)->isLeaf()) { QMessageBox::warning(phyview_, "PhyView", "Cannot root on a leaf.", QMessageBox::Cancel); } else { 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)); unique_ptr< TreeTemplate > tt(new TreeTemplate(subtree)); phyview_->createNewDocument(tt.get()); } else if (action == "Cut subtree") { Node* subtree = TreeTemplateTools::cloneSubtree(*phyview_->getActiveDocument()->getTree()->getNode(nodeId)); unique_ptr< TreeTemplate > tt(new TreeTemplate(subtree)); phyview_->submitCommand(new DeleteSubtreeCommand(phyview_->getActiveDocument(), nodeId)); phyview_->createNewDocument(tt.get()); } else if (action == "Insert on node") { TreeTemplate* tree = phyview_->pickTree(); if (tree) { Node* subtree = TreeTemplateTools::cloneSubtree(*tree->getRootNode()); phyview_->submitCommand(new InsertSubtreeAtNodeCommand(phyview_->getActiveDocument(), nodeId, subtree)); } } else if (action == "Insert on branch") { TreeTemplate* tree = phyview_->pickTree(); if (tree) { Node* subtree = TreeTemplateTools::cloneSubtree(*tree->getRootNode()); phyview_->submitCommand(new InsertSubtreeOnBranchCommand(phyview_->getActiveDocument(), nodeId, subtree)); } } } } 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_); //Trees panel: createTreesPanel_(); treesDockWidget_ = new QDockWidget(tr("Trees")); treesDockWidget_->setWidget(treesPanel_); treesDockWidget_->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, treesDockWidget_); //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::createTreesPanel_() { treesPanel_ = new QWidget(this); QVBoxLayout* treesLayout = new QVBoxLayout; treesTable_ = new QTableWidget; treesTable_->setColumnCount(2); treesTable_->setHorizontalHeaderLabels(QString("Tree;Size").split(";")); treesTable_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); treesTable_->setEditTriggers(QAbstractItemView::NoEditTriggers); treesTable_->setSelectionBehavior(QAbstractItemView::SelectRows); treesTable_->setSelectionMode(QAbstractItemView::SingleSelection); connect(treesTable_, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(activateSelectedDocument())); treesLayout->addWidget(treesTable_); treesLayout->addStretch(1); treesPanel_->setLayout(treesLayout); } 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); //Remove all branch lengths: QPushButton* brlenRemoveAll = new QPushButton(tr("Remove all lengths")); connect(brlenRemoveAll, SIGNAL(clicked(bool)), this, SLOT(deleteAllLengths())); brlenLayout->addWidget(brlenRemoveAll); //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: brlenMidpointRootingCriteria_ = new QComboBox; brlenMidpointRootingCriteria_->addItem("Sum of squares"); brlenMidpointRootingCriteria_->addItem("Variance"); brlenMidpointRootingCriteria_->setEditable(false); QPushButton* brlenMidpointRootingGo = new QPushButton(tr("Go!")); connect(brlenMidpointRootingGo, SIGNAL(clicked(bool)), this, SLOT(midpointRooting())); QGroupBox* brlenMidpointRootingBox = new QGroupBox(tr("Midpoint rooting")); QHBoxLayout* brlenMidpointRootingLayout = new QHBoxLayout; brlenMidpointRootingLayout->addWidget(brlenMidpointRootingCriteria_); brlenMidpointRootingLayout->addWidget(brlenMidpointRootingGo); brlenMidpointRootingLayout->addStretch(1); brlenMidpointRootingBox->setLayout(brlenMidpointRootingLayout); brlenLayout->addWidget(brlenMidpointRootingBox); //Unresolved uncertain trees: bootstrapThreshold_ = new QDoubleSpinBox; bootstrapThreshold_->setValue(60); bootstrapThreshold_->setDecimals(2); bootstrapThreshold_->setSingleStep(0.1); QPushButton* unresolveUncertainNodesGo = new QPushButton(tr("Go!")); connect(unresolveUncertainNodesGo, SIGNAL(clicked(bool)), this, SLOT(unresolveUncertainNodes())); QGroupBox* unresolveUncertainNodesBox = new QGroupBox(tr("Unresolve uncertain nodes")); QHBoxLayout* unresolveUncertainNodesLayout = new QHBoxLayout; unresolveUncertainNodesLayout->addWidget(bootstrapThreshold_); unresolveUncertainNodesLayout->addWidget(unresolveUncertainNodesGo); unresolveUncertainNodesLayout->addStretch(1); unresolveUncertainNodesBox->setLayout(unresolveUncertainNodesLayout); brlenLayout->addWidget(unresolveUncertainNodesBox); //// 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); updateTreesTable(); 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; } QList PhyView::getDocuments() { QList documents; QList lst = mdiArea_->subWindowList(); for (int i = 0; i < lst.size(); ++i) { documents.push_back(dynamic_cast(lst[i])->getDocument()); } return documents; } void PhyView::readTree(const QString& path, const string& format) { unique_ptr treeReader(ioTreeFactory_.createReader(format)); try { unique_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_); updateTreesTable(); } 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()); } //Update selection in tree table: updateTreesTable(); //We need this here as some windows may have been closed. QList lst = mdiArea_->subWindowList(); for (int i = 0; i < lst.size(); ++i) { if (lst[i] == mdiArea_->activeSubWindow()) { treesTable_->setRangeSelected(QTableWidgetSelectionRange(i, 0, i, 1), true); } else { treesTable_->setRangeSelected(QTableWidgetSelectionRange(i, 0, i, 1), false); } } } bool PhyView::saveTree() { TreeDocument* doc = getActiveDocument(); if (doc->getFilePath() == "") return saveTreeAs(); string format = doc->getFileFormat(); unique_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); } updateTreesTable(); } void PhyView::updateTreesTable() { //Update tree list: treesTable_->clearSelection(); treesTable_->clearContents(); QList lst = mdiArea_->subWindowList(); treesTable_->setRowCount(lst.size()); for (int i = 0; i < lst.size(); ++i) { TreeDocument* doc = dynamic_cast(lst[i])->getDocument(); string docName = doc->getName(); if (docName == "") docName = "Tree#" + TextTools::toString(i + 1); treesTable_->setItem(i, 0, new QTableWidgetItem(QtTools::toQt(docName))); treesTable_->setItem(i, 1, new QTableWidgetItem(QtTools::toQt(TextTools::toString(doc->getTree()->getNumberOfLeaves())))); } } void PhyView::exit() { close(); } void PhyView::aboutBpp() { QMessageBox msgBox; msgBox.setText("Bio++ 2.4.0."); msgBox.setInformativeText("bpp-core 2.4.0\nbpp-seq 2.4.0.\nbpp-phyl 2.4.0.\nbpp-qt 2.4.0"); msgBox.exec(); } void PhyView::about() { QMessageBox msgBox; msgBox.setText("This is Bio++ Phylogenetic Viewer version 0.6.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(), brlenMidpointRootingCriteria_->currentText().toStdString())); } catch (NodeException& ex) { QMessageBox::critical(this, tr("Oups..."), tr("Some branch do not have lengths.")); } } void PhyView::deleteAllLengths() { if (hasActiveDocument()) submitCommand(new DeleteLengthCommand(getActiveDocument())); } void PhyView::unresolveUncertainNodes() { if (hasActiveDocument()) { try { submitCommand(new UnresolveUnsupportedNodesCommand(getActiveDocument(), bootstrapThreshold_->value())); } catch (NodeException& ex) { QMessageBox::critical(this, tr("Oups..."), tr("An exception occurred while unresolving your tree!")); } } } 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()]); } void PhyView::activateSelectedDocument() { if (treesTable_->selectedItems().size() > 0) { int index = treesTable_->selectedItems()[0]->row(); mdiArea_->setActiveSubWindow(mdiArea_->subWindowList()[index]); mdiArea_->activeSubWindow()->showNormal(); mdiArea_->activeSubWindow()->raise(); } } TreeTemplate* PhyView::pickTree() { QList documents = getDocuments(); //treeList_->clear(); QStringList items; 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); items << text; } //treeChooser_->exec(); //int index = treeList_->currentRow(); //return index > 0 ? documents[index]->getTree() : 0; bool ok; QString item = QInputDialog::getItem(this, "Pick a tree", "Tree to insert:", items, 0, false, &ok); if (ok && !item.isEmpty()) return documents[items.indexOf(item)]->getTree(); else return 0; } // This class is necessary to reimplement the notify method, in order to catch any foreign exception. class PhyViewApplication: public QApplication { public: PhyViewApplication(int &argc, char *argv[]): QApplication(argc, argv) {} public: bool notify(QObject *receiver_, QEvent *event_) { try { return QApplication::notify(receiver_, event_); } catch (std::exception &ex) { std::cerr << "std::exception was caught" << std::endl; std::cerr << ex.what() << endl; QMessageBox msgBox; msgBox.setText(ex.what()); msgBox.exec(); } return false; } }; int main(int argc, char *argv[]) { PhyViewApplication 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(); Not supported in Qt5... 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); } } return app.exec(); } bppphyview-0.6.0/bppPhyView/PhyView.h000066400000000000000000000230641325217776100175730ustar00rootroot00000000000000// // 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; } }; 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* treesPanel_; QWidget* statsPanel_; QWidget* brlenPanel_; QWidget* mouseControlPanel_; QWidget* dataPanel_; QWidget* searchPanel_; QDockWidget* treesDockWidget_; QDockWidget* statsDockWidget_; QDockWidget* displayDockWidget_; QDockWidget* undoDockWidget_; //Trees: QTableWidget* treesTable_; //Branch lengths operations: QDockWidget* brlenDockWidget_; QDoubleSpinBox* brlenSetLengths_; QDoubleSpinBox* brlenComputeGrafen_; QComboBox* brlenMidpointRootingCriteria_; QDoubleSpinBox* bootstrapThreshold_; //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 getDocuments(); 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); TreeTemplate* pickTree(); void checkLastWindow() { //This is to avoid bugs when the last window is closed. //It should only be closed from the destructor of TreeSubWindow. if (mdiArea_->subWindowList().size() == 0) { treesTable_->clearContents(); treesTable_->setRowCount(0); } } protected: void closeEvent(QCloseEvent* event); public slots: void updateTreesTable(); 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 deleteAllLengths(); void unresolveUncertainNodes(); 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(); } void activateSelectedDocument(); private: void initGui_(); void createActions_(); void createMenus_(); void createStatusBar_(); void createTreesPanel_(); void createStatsPanel_(); void createDisplayPanel_(); void createBrlenPanel_(); void createMouseControlPanel_(); void createDataPanel_(); void createSearchPanel_(); }; int main(int argc, char *argv[]); bppphyview-0.6.0/bppPhyView/TreeCommands.cpp000066400000000000000000000126571325217776100211220ustar00rootroot00000000000000// // 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.6.0/bppPhyView/TreeCommands.h000066400000000000000000000252731325217776100205650ustar00rootroot00000000000000// // 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 bpp-phyl: #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 DeleteLengthCommand: public AbstractCommand { public: DeleteLengthCommand(TreeDocument* doc): AbstractCommand(QtTools::toQt("Delete all branch length."), doc) { new_ = new TreeTemplate(*old_); TreeTemplateTools::deleteBranchLengths(*new_->getRootNode()); } }; 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, const string& criterion) : AbstractCommand(QtTools::toQt("Midpoint rooting (" + criterion + ")."), doc) { short crit = 0; if (criterion == "Variance") crit = TreeTemplateTools::MIDROOT_VARIANCE; else if (criterion == "Sum of squares") crit = TreeTemplateTools::MIDROOT_SUM_OF_SQUARES; new_ = new TreeTemplate(*old_); TreeTemplateTools::midRoot(*new_, crit, true); } }; class UnresolveUnsupportedNodesCommand: public AbstractCommand { public: UnresolveUnsupportedNodesCommand(TreeDocument* doc, double threshold) : AbstractCommand(QtTools::toQt("Unresolve nodes with bootstrap < " + TextTools::toString(threshold) + "."), doc) { new_ = new TreeTemplate(*old_); TreeTemplateTools::unresolveUncertainNodes(*new_->getRootNode(), threshold, TreeTools::BOOTSTRAP); } }; 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_ bppphyview-0.6.0/bppPhyView/TreeDocument.h000066400000000000000000000074571325217776100206060ustar00rootroot00000000000000// // 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 bpp-phyl: #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 (size_t i = 0; i < viewers_.size(); i++) viewers_[i]->updateView(); } }; #endif //_TREEDOCUMENT_H_ bppphyview-0.6.0/bppPhyView/TreeSubWindow.cpp000066400000000000000000000216101325217776100212670ustar00rootroot00000000000000// // 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(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); //Move the splitter to the right: QList currentSizes = splitter_->sizes(); currentSizes[0] = currentSizes[0] + currentSizes[1]; currentSizes[1] = 0; splitter_->setSizes(currentSizes); setMinimumSize(400, 400); setWidget(splitter_); updateTable(); } TreeSubWindow::~TreeSubWindow() { delete treeDocument_; delete splitter_; phyview_->checkLastWindow(); } 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.6.0/bppPhyView/TreeSubWindow.h000066400000000000000000000060731325217776100207420ustar00rootroot00000000000000// // 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(); 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.6.0/bppphyview.spec000066400000000000000000000101331325217776100167740ustar00rootroot00000000000000%define _prefix /usr URL: https://github.com/BioPP/bppphyview Name: bppphyview Version: 0.6.0 Release: 1%{?dist} License: CECILL-2.0 Vendor: The Bio++ Project Source: %{name}-%{version}.tar.gz Summary: Bio++ Phylogenetic Viewer Group: Productivity/Scientific/Other Requires: libbpp-phyl12 = 2.4.0 Requires: libbpp-core4 = 2.4.0 Requires: libbpp-qt2 = 2.4.0 %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?scientificlinux_version} Requires: libqt5core5 >= 5.0.0 Requires: libqt5gui5 >= 5.0.0 Requires: libqt5widgets5 >= 5.0.0 %endif %if 0%{?suse_version} Requires: libQt5Core5 >= 5.0.0 Requires: libQt5Gui5 >= 5.0.0 Requires: libQt5Widgets5 >= 5.0.0 %endif %if 0%{?mageia} || 0%{?mdkversion} %ifarch x86_64 Requires: lib64proxy-webkit >= 0.4.14 Requires: lib64qt5core5 >= 5.0.0 Requires: lib64qt5gui5 >= 5.0.0 Requires: lib64qt5widgets5 >= 5.0.0 Requires: qt5-qtdeclarative >= 5.0.0 Requires: qt5-qtbase >= 5.0.0 %else Requires: libproxy-webkit >= 0.4.14 Requires: libqt5core5 >= 5.0.0 Requires: libqt5gui5 >= 5.0.0 Requires: libqt5widgets5 >= 5.0.0 Requires: qt5-qtdeclarative >= 5.0.0 Requires: qt5-qtbase >= 5.0.0 %endif %endif BuildRoot: %{_builddir}/%{name}-root BuildRequires: cmake >= 2.8.11 BuildRequires: gcc-c++ >= 4.7.0 BuildRequires: groff BuildRequires: libbpp-core4 = 2.4.0 BuildRequires: libbpp-core-devel = 2.4.0 BuildRequires: libbpp-phyl12 = 2.4.0 BuildRequires: libbpp-phyl-devel = 2.4.0 BuildRequires: libbpp-qt2 = 2.4.0 BuildRequires: libbpp-qt-devel = 2.4.0 %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} || 0%{?scientificlinux_version} BuildRequires: qt >= 5.0.0 BuildRequires: qt-devel >= 5.0.0 %endif %if 0%{?suse_version} BuildRequires: libQt5Core5 >= 5.0.0 BuildRequires: libQt5Gui5 >= 5.0.0 BuildRequires: libQt5Widgets5 >= 5.0.0 BuildRequires: libqt5-qtdeclarative-devel >= 5.0.0 BuildRequires: libqt5-qtbase-devel >= 5.0.0 %endif %if 0%{?mageia} || 0%{?mdkversion} %ifarch x86_64 BuildRequires: lib64proxy-webkit >= 0.4.14 BuildRequires: lib64qt5core5 >= 5.0.0 BuildRequires: lib64qt5gui5 >= 5.0.0 BuildRequires: lib64qt5widgets5 >= 5.0.0 BuildRequires: lib64qt5base5-devel >= 5.0.0 %else BuildRequires: libproxy-webkit >= 0.4.14 BuildRequires: libqt5core5 >= 5.0.0 BuildRequires: libqt5gui5 >= 5.0.0 BuildRequires: libqt5widgets5 >= 5.0.0 BuildRequires: libqt5base5-devel >= 5.0.0 %endif %endif AutoReq: yes AutoProv: yes %if 0%{?mandriva_version} %if %{mandriva_version} >= 2011 BuildRequires: xz %define compress_program xz %else BuildRequires: lzma %define compress_program lzma %endif %else %if 0%{?mageia} BuildRequires: xz %define compress_program xz %else #For all other distributions: BuildRequires: gzip %define compress_program gzip %endif %endif %description Bio++ Phylogenetic Viewer, using the Qt library. %prep %setup -q %build CFLAGS="$RPM_OPT_FLAGS" CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=%{_prefix} -DCOMPRESS_PROGRAM=%{compress_program}" 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* %changelog * Mon Mar 12 2018 Julien Dutheil 0.6.0-1 - Compatibility update with Bio++ 2.4.0. - More options in branch lengths panel. * Thu Jun 8 2017 Julien Dutheil 0.5.1-1 - Compatibility update with Bio++ 2.3.1. * Wed May 10 2017 Julien Dutheil 0.5.0-1 - Compatibility update with Bio++ 2.3.0. * Mon Sep 28 2014 Julien Dutheil 0.4.0-1 - Several bug fixed. - New clickable panel with list of trees in memory. - New dialog to insert subtrees. * 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.6.0/man/000077500000000000000000000000001325217776100145005ustar00rootroot00000000000000bppphyview-0.6.0/man/CMakeLists.txt000066400000000000000000000027341325217776100172460ustar00rootroot00000000000000# CMake script for PhyView. # Authors: # Julien Dutheil # Francois gindraud (2017) # Created: 22/08/2009 # Build manpages. # In practice, they are just compressed from the text files using COMPRESS_PROGRAM # Manpages are built and installed as part of "all" if a COMPRESS_PROGRAM is found. # Take all manpages files in the directory file (GLOB manpage_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.1) if (NOT COMPRESS_BIN) # Just install manpages from source foreach (manpage_file ${manpage_files}) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${manpage_file} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endforeach (manpage_file) else () # Create a list of manpage targets set (manpage-targets) foreach (manpage_file ${manpage_files}) # Compress manpage, install, add to manpage target list set (input ${CMAKE_CURRENT_SOURCE_DIR}/${manpage_file}) set (output ${CMAKE_CURRENT_BINARY_DIR}/${manpage_file}.${COMPRESS_EXT}) add_custom_command ( OUTPUT ${output} COMMAND ${COMPRESS_BIN} ${COMPRESS_ARGS} ${input} > ${output} DEPENDS ${input} COMMENT "Compressing manpage ${manpage_file}" VERBATIM ) install (FILES ${output} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) list (APPEND manpage-targets ${output}) unset (input) unset (output) endforeach (manpage_file) # Add target "man", built with "all" (needed because install will fail if not built). add_custom_target (man ALL DEPENDS ${manpage-targets}) endif () bppphyview-0.6.0/man/phyview.1000066400000000000000000000012041325217776100162520ustar00rootroot00000000000000.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.