diff --git a/CMakeLists.txt b/CMakeLists.txt index c328fc3..3188df9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ ### -### CMakeLists for playuver +### CMakeLists for calyp ### cmake_minimum_required( VERSION 3.2.0 ) @@ -16,13 +16,15 @@ INCLUDE(GNUInstallDirs) # Project Definition ###################################################################################### -set( PROJECT_NAME "playuver" CACHE INTERNAL "" FORCE ) +SET( PROJECT_NAME "calyp" CACHE INTERNAL "" FORCE ) +SET( PROJECT_LIBRARY "Calyp" CACHE INTERNAL "" FORCE ) + PROJECT( ${PROJECT_NAME} ) -SET( PLAYUVER_VERSION_MAJOR "0" ) -SET( PLAYUVER_VERSION_MINOR "18" ) -SET( PLAYUVER_VERSION_PATCH "3" ) -SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}" CACHE INTERNAL "" FORCE ) +SET( CALYP_VERSION_MAJOR "0" ) +SET( CALYP_VERSION_MINOR "9999" ) +SET( CALYP_VERSION_PATCH "0" ) +SET( CALYP_VERSION "${CALYP_VERSION_MAJOR}.${CALYP_VERSION_MINOR}.${CALYP_VERSION_PATCH}" CACHE INTERNAL "" FORCE ) ###################################################################################### # Variables @@ -50,7 +52,7 @@ OPTION( USE_STATIC "Use static libs" OFF ) OPTION(RELEASE_BUILD "Remove Git revision from program version (use for stable releases)" ON) # Get current version. -set(PLAYUVER_VERSION_STRING "${PLAYUVER_VERSION}") +set(CALYP_VERSION_STRING "${CALYP_VERSION}") if(NOT RELEASE_BUILD AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) # Probably a Git workspace; determine the revision. FIND_PACKAGE(Git QUIET) @@ -58,7 +60,7 @@ if(NOT RELEASE_BUILD AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) exec_program(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --tags" - OUTPUT_VARIABLE PLAYUVER_GIT_REVISION + OUTPUT_VARIABLE CALYP_GIT_REVISION RETURN_VALUE TAG_RESULT ) # git describe --tags failed; maybe the repository was checked with depth=1. @@ -66,18 +68,18 @@ if(NOT RELEASE_BUILD AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) exec_program(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --always" - OUTPUT_VARIABLE PLAYUVER_GIT_REVISION + OUTPUT_VARIABLE CALYP_GIT_REVISION ) endif() - message(STATUS "PlaYUVer Git revision: ${PLAYUVER_GIT_REVISION}") - set(PLAYUVER_VERSION_STRING "${PLAYUVER_VERSION} (rev. ${PLAYUVER_GIT_REVISION})") + message(STATUS "Calyp Git revision: ${CALYP_GIT_REVISION}") + set(CALYP_VERSION_STRING "${CALYP_VERSION} (rev. ${CALYP_GIT_REVISION})") else() - message(STATUS "PlaYUVer Git revision could not be determined") + message(STATUS "Calyp Git revision could not be determined") endif() endif() SET(UPDATE_CHANNEL "stable" CACHE STRING "Update channel" ) -CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/PlaYUVerUpdate.xml.in ${CMAKE_CURRENT_BINARY_DIR}/PlaYUVerUpdate-${UPDATE_CHANNEL}.xml ) +# CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/CalypUpdate.xml.in ${CMAKE_CURRENT_BINARY_DIR}/CalypUpdate-${UPDATE_CHANNEL}.xml ) ###################################################################################### @@ -101,29 +103,23 @@ IF( BUILD_TESTS ) ENDIF() OPTION( USE_OPENCV "Add OpenCV support" ON ) -SET( OPENCV_OPTFLOW_FOUND OFF ) IF( USE_OPENCV ) LIST(APPEND OPENCV_MODULES core highgui imgproc video videoio ) FIND_PACKAGE( OpenCV COMPONENTS ${OPENCV_MODULES} ) SET(USE_OPENCV ${OpenCV_FOUND}) ENDIF() -SET_PACKAGE_PROPERTIES(OpenCV PROPERTIES URL "http://opencv.willowgarage.com" DESCRIPTION "OpenCV library support in PlaYUVerFrame" TYPE OPTIONAL) +SET_PACKAGE_PROPERTIES(OpenCV PROPERTIES URL "http://opencv.willowgarage.com" DESCRIPTION "OpenCV library support in CalypFrame" TYPE OPTIONAL) OPTION( USE_FFMPEG "Add FFMPEG support" ON ) IF( USE_FFMPEG ) - FIND_PACKAGE( FFmpeg ) + FIND_PACKAGE( FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE ) IF( ${AVCODEC_VERSION} VERSION_LESS 56.0.0 ) SET(FFMPEG_FOUND FALSE ) SET(FFmpeg_FOUND FALSE ) ENDIF() SET(USE_FFMPEG ${FFMPEG_FOUND}) ENDIF() -SET_PACKAGE_PROPERTIES(FFmpeg PROPERTIES URL "http://ffmpeg.org/" DESCRIPTION "Libav library support in PlaYUVerStream" TYPE OPTIONAL) - -ADD_FEATURE_INFO(DynLoad USE_DYNLOAD "Support for dynamic module load" ) -ADD_FEATURE_INFO(SSE USE_SSE "SSE instructions support" ) -ADD_FEATURE_INFO(WErrors USE_WERROR "Warnings as errors" ) - +SET_PACKAGE_PROPERTIES(FFmpeg PROPERTIES URL "http://ffmpeg.org/" DESCRIPTION "Libav library support in CalypStream" TYPE OPTIONAL) IF( WIN32 ) SET( USE_STATIC ON ) @@ -170,9 +166,11 @@ ENDIF() SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" ) - -ADD_FEATURE_INFO(PlaYUVerApp BUILD_APP "Build Graphical Interface") -ADD_FEATURE_INFO(PlaYUVerTools BUILD_TOOLS "Build Command line tool" ) +ADD_FEATURE_INFO(CalypApp BUILD_APP "Build Graphical interface") +ADD_FEATURE_INFO(CalypTools BUILD_TOOLS "Build Command line tool" ) +ADD_FEATURE_INFO(DynLoad USE_DYNLOAD "Support for dynamic module load" ) +ADD_FEATURE_INFO(SSE USE_SSE "SSE instructions support" ) +ADD_FEATURE_INFO(WErrors USE_WERROR "Warnings as errors" ) ADD_SUBDIRECTORY( lib ) ADD_SUBDIRECTORY( modules ) @@ -197,7 +195,7 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_D ###################################################################################### MESSAGE("") MESSAGE( STATUS "${PROJECT_NAME} INFORMATION" ) -MESSAGE( STATUS "Version: " "${PLAYUVER_VERSION_STRING}" ) +MESSAGE( STATUS "Version: " "${CALYP_VERSION_STRING}" ) MESSAGE( STATUS "Configuration:" ) MESSAGE( STATUS " Static libs: " "${USE_STATIC}" ) MESSAGE( STATUS " Build type: " "${CMAKE_BUILD_TYPE}" ) diff --git a/Doxyfile b/Doxyfile index 90b1bf5..add9ce5 100644 --- a/Doxyfile +++ b/Doxyfile @@ -32,26 +32,26 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = PlaYUVer +PROJECT_NAME = Calyp # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = /home/joaoc/Programming/PlaYUVerDev/playuver/app/resources/playuver.ico +PROJECT_LOGO = app/resources/calyp.ico # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -162,7 +162,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -171,7 +171,7 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -244,7 +244,7 @@ ALIASES = "returns=\"\par Returns\" " # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. -TCL_SUBST = +TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -291,7 +291,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -648,7 +648,7 @@ GENERATE_DEPRECATEDLIST= YES # sections, marked by \if ... \endif and \cond # ... \endcond blocks. -ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -690,7 +690,7 @@ SHOW_NAMESPACES = YES # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -703,7 +703,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib @@ -713,7 +713,7 @@ LAYOUT_FILE = # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -778,7 +778,7 @@ WARN_FORMAT = "$file:$line: $text" # messages should be written. If left blank the output is written to standard # error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -790,10 +790,10 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = +INPUT = # This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# that doxygen parses. internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. @@ -896,7 +896,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -907,13 +907,13 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -933,7 +933,7 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = +IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -954,7 +954,7 @@ IMAGE_PATH = # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -INPUT_FILTER = +INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -967,7 +967,7 @@ INPUT_FILTER = # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -FILTER_PATTERNS = +FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for @@ -982,14 +982,14 @@ FILTER_SOURCE_FILES = NO # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -1101,7 +1101,7 @@ COLS_IN_ALPHA_INDEX = 5 # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output @@ -1145,7 +1145,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1155,7 +1155,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1167,7 +1167,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets @@ -1180,7 +1180,7 @@ HTML_STYLESHEET = # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1190,7 +1190,7 @@ HTML_EXTRA_STYLESHEET = # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to @@ -1319,7 +1319,7 @@ GENERATE_HTMLHELP = NO # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_FILE = +CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, @@ -1327,7 +1327,7 @@ CHM_FILE = # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -HHC_LOCATION = +HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). @@ -1340,7 +1340,7 @@ GENERATE_CHI = NO # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it @@ -1371,7 +1371,7 @@ GENERATE_QHP = NO # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace @@ -1396,7 +1396,7 @@ QHP_VIRTUAL_FOLDER = doc # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom @@ -1404,21 +1404,21 @@ QHP_CUST_FILTER_NAME = # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To @@ -1551,7 +1551,7 @@ MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site @@ -1559,7 +1559,7 @@ MATHJAX_EXTENSIONS = # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and @@ -1619,7 +1619,7 @@ EXTERNAL_SEARCH = NO # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. -SEARCHENGINE_URL = +SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the @@ -1635,7 +1635,7 @@ SEARCHDATA_FILE = searchdata.xml # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH_ID = +EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are @@ -1645,7 +1645,7 @@ EXTERNAL_SEARCH_ID = # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. -EXTRA_SEARCH_MAPPINGS = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output @@ -1709,7 +1709,7 @@ PAPER_TYPE = a4wide # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first @@ -1725,7 +1725,7 @@ EXTRA_PACKAGES = # to HTML_HEADER. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_HEADER = +LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last @@ -1736,7 +1736,7 @@ LATEX_HEADER = # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_FOOTER = +LATEX_FOOTER = # The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined # LaTeX style sheets that are included after the standard style sheets created @@ -1747,7 +1747,7 @@ LATEX_FOOTER = # list). # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_STYLESHEET = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output @@ -1755,7 +1755,7 @@ LATEX_EXTRA_STYLESHEET = # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_FILES = +LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will @@ -1863,14 +1863,14 @@ RTF_HYPERLINKS = NO # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is # similar to doxygen's config file. A template extensions file can be generated # using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = # If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code # with syntax highlighting in the RTF output. @@ -1915,7 +1915,7 @@ MAN_EXTENSION = .3 # MAN_EXTENSION with the initial . removed. # This tag requires that the tag GENERATE_MAN is set to YES. -MAN_SUBDIR = +MAN_SUBDIR = # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real @@ -2028,7 +2028,7 @@ PERLMOD_PRETTY = YES # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor @@ -2069,7 +2069,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -2077,7 +2077,7 @@ INCLUDE_PATH = # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. @@ -2087,7 +2087,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2096,7 +2096,7 @@ PREDEFINED = # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have @@ -2125,13 +2125,13 @@ SKIP_FUNCTION_MACROS = YES # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES, all external class will be listed in # the class index. If set to NO, only the inherited external classes will be @@ -2180,14 +2180,14 @@ CLASS_DIAGRAMS = YES # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. -DIA_PATH = +DIA_PATH = # If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. @@ -2236,7 +2236,7 @@ DOT_FONTSIZE = 10 # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. @@ -2367,7 +2367,7 @@ DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # -# Note that this requires a modern browser other than Internet Explorer. Tested +# Note that this requires a modern browser other than internet Explorer. Tested # and working are Firefox, Chrome, Safari, and Opera. # Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make # the SVG files visible. Older versions of IE do not have SVG support. @@ -2380,26 +2380,26 @@ INTERACTIVE_SVG = NO # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = +DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. -DOTFILE_DIRS = +DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). -MSCFILE_DIRS = +MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed @@ -2407,17 +2407,17 @@ DIAFILE_DIRS = # generate a warning when it encounters a \startuml command in this case and # will not generate output for the diagram. -PLANTUML_JAR_PATH = +PLANTUML_JAR_PATH = # When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a # configuration file for plantuml. -PLANTUML_CFG_FILE = +PLANTUML_CFG_FILE = # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. -PLANTUML_INCLUDE_PATH = +PLANTUML_INCLUDE_PATH = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes diff --git a/Mainpage.dox b/Mainpage.dox index 384716b..6a13770 100644 --- a/Mainpage.dox +++ b/Mainpage.dox @@ -1,9 +1,9 @@ -/** @mainpage PlaYUVer Project +/** @mainpage Calyp Project Description ---------------------------------------------------------------- -PlaYUVer is an open-source video player with the following features: +Calyp is an open-source video player with the following features: - Support for libavformat and libavcodec; - Support for wide range of raw video formats; - Support up to 16 bits per pixel @@ -12,17 +12,17 @@ PlaYUVer is an open-source video player with the following features: - Synchronized zoom across several videos (perfect for comparison operations) - Useful information in status bar, *e.g.*, pixel information Useful sidebars with frame information, *e.g.*, frame histogram -- Constant growing libs for stream and frame processing (PlaYUVerStream and PlaYUVerFrame) +- Constant growing libs for stream and frame processing (CalypStream and CalypFrame) - Advanced API for frame/video processing algorithms -- Frame level quality measurement API based on the PlaYUVerFrame class +- Frame level quality measurement API based on the CalypFrame class - Powefull command-line tool for quality and frame processing algorithms (uses the referred APIs) Modules ---------------------------------------------------------------- -- PlaYUVerLib: Low level library -- PlaYUVerModules: Abstract interface for frame processing modules -- PlaYUVerApp: High level graphical interface -- PlaYUVerTools: High level command line interface +- CalypLib: Low level library +- CalypModules: Abstract interface for frame processing modules +- Calyp: High level graphical interface +- CalypTools: High level command line interface Supported Quality Metrics @@ -83,7 +83,7 @@ Build/Install using cmake - OpenCv - FFmpeg -3. Run the following commands: (this will create an executable named playuver) +3. Run the following commands: (this will create an executable named calyp) ``` mkdir build cd build diff --git a/PlaYUVerUpdate.xml.in b/PlaYUVerUpdate.xml.in deleted file mode 100644 index a312f02..0000000 --- a/PlaYUVerUpdate.xml.in +++ /dev/null @@ -1,49 +0,0 @@ - - - - - Your Great App's Changelog - http://pypt.github.com/fervor/Appcast.xml - Most recent changes with links to updates. - en - - - - Version @PLAYUVER_VERSION_STRING@ - Mon, 09 Jan 2006 19:20:11 +0000 - http://192.168.96.201/share/PlaYUVerProject/ReleaseNotes-@UPDATE_CHANNEL@.html - - - http://192.168.96.201/share/PlaYUVerProject/ReleaseNotes-@UPDATE_CHANNEL@.html - http://192.168.96.201/share/PlaYUVerProject/ReleaseNotes-@UPDATE_CHANNEL@.html - - - - - - - - - - - - - - diff --git a/README.md b/README.md index 24d0bb1..1917aa8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PlaYUVer +# Calyp ## Enhanced YUV video player based on Qt focusing on image/video analysis @@ -11,16 +11,16 @@ - Synchronized zoom across several videos (perfect for comparison operations) - Useful information in status bar, *e.g.*, pixel information Useful sidebars with frame information, *e.g.*, frame histogram -- Constant growing libs for stream and frame processing (PlaYUVerStream and PlaYUVerFrame) +- Constant growing libs for stream and frame processing (CalypStream and CalypFrame) - Advanced API for frame/video processing algorithms -- Frame level quality measurement API based on the PlaYUVerFrame class +- Frame level quality measurement API based on the CalypFrame class - Powefull command-line tool for quality and frame processing algorithms (uses the referred APIs) ## Modules -- PlaYUVerLib: Low level library -- PlaYUVerModules: Abstract interface for frame processing modules -- PlaYUVerApp: High level graphical interface -- PlaYUVerTools: High level command line interface +- CalypLib: Low level library +- CalypModules: Abstract interface for frame processing modules +- Calyp: High level graphical interface +- CalypTools: High level command line interface ## Supported Quality Metrics - PSNR diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a2da427..ba73bda 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,8 +1,12 @@ ### -### CMakeLists for playuver app component +### CMakeLists for calyp app component ### -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/external ) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external + ${CMAKE_CURRENT_SOURCE_DIR}/dialog + ${CMAKE_CURRENT_SOURCE_DIR}/docks + ${CMAKE_CURRENT_SOURCE_DIR}/widgets ) OPTION( USE_QTDBUS "Build with QtDBus" ON ) OPTION( USE_FERVOR "Add Fervor support" OFF ) @@ -24,50 +28,51 @@ IF( USE_QTDBUS ) ENDIF() ENDIF() -set(plaYUVer_App_SRCS +set(Calyp_App_SRCS # Main main.cpp - PlaYUVerApp.cpp - PlaYUVerSubWindowHandle.cpp - PlaYUVerMdiSubWindow.cpp + MainWindow.cpp +# Module SubWindow + SubWindowHandle.cpp + MdiSubWindow.cpp SubWindowAbstract.cpp # Module Video + VideoHandle.cpp VideoSubWindow.cpp ViewArea.cpp - VideoHandle.cpp - FramePropertiesDock.cpp + GridManager.cpp # Module Quality QualityHandle.cpp - QualityMeasurementSidebar.cpp PlotSubWindow.cpp external/qcustomplot/qcustomplot.cpp # Module Plugins ModulesHandle.cpp - ModulesHandleOptDialog.cpp - ModuleHandleDock.cpp - PlaYUVerAppModuleIf.cpp - GridManager.cpp + CalypAppModuleIf.cpp # Dialogs - AboutDialog.cpp - ConfigureFormatDialog.cpp - DialogSubWindowSelector.cpp - ProgressBar.cpp - SeekStreamDialog.cpp + dialog/AboutDialog.cpp + dialog/ConfigureFormatDialog.cpp + dialog/SubWindowSelectorDialog.cpp + dialog/ProgressBar.cpp + dialog/SeekStreamDialog.cpp + dialog/ModulesHandleOptDialog.cpp # Widgets - HistogramWidget.cpp - WidgetFrameNumber.cpp - WidgetFrameNumber.cpp + widgets/HistogramWidget.cpp + widgets/FrameNumberWidget.cpp +# Docks + docks/FramePropertiesDock.cpp + docks/ModuleHandleDock.cpp + docks/QualityMeasurementSidebar.cpp ) IF( USE_QTDBUS ) - LIST( APPEND plaYUVer_App_SRCS PlaYUVerAppAdaptor.cpp ) + LIST( APPEND Calyp_App_SRCS DBusAppAdaptor.cpp ) ENDIF() -set(PlaYUVer_App_UI "" ) +set(Calyp_App_UI "" ) -set(PlaYUVer_App_RCC - resources/playuver.qrc +set(Calyp_App_RCC + resources/${PROJECT_NAME}.qrc ) @@ -78,7 +83,7 @@ IF( USE_FERVOR ) IF(EXISTS ${FERVOR_DIR} ) SET( FERVOR_APP_NAME ${PROJECT_NAME} ) - SET( FERVOR_APP_VERSION ${PLAYUVER_VERSION_STRING} ) + SET( FERVOR_APP_VERSION ${CALYP_VERSION_STRING} ) ADD_SUBDIRECTORY( ${FERVOR_DIR} ) @@ -106,8 +111,8 @@ ENDIF() SET_PACKAGE_PROPERTIES(Fervor PROPERTIES URL "https://github.com/pypt/fervor" DESCRIPTION "Fervor lib includes check for updates feature" TYPE OPTIONAL ) ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.") -QT5_WRAP_UI( PlaYUVer_App_UI_Wrap ${PlaYUVer_App_UI} ) -QT5_ADD_RESOURCES( PlaYUVer_App_RCC ${PlaYUVer_App_RCC} ) +QT5_WRAP_UI( Calyp_App_UI_Wrap ${Calyp_App_UI} ) +QT5_ADD_RESOURCES( Calyp_App_RCC ${Calyp_App_RCC} ) # Instruct CMake to run moc automatically when needed. SET( CMAKE_AUTOMOC ON ) @@ -117,27 +122,27 @@ IF( WIN32 ) set(WINDOWS_RES_FILE ${CMAKE_CURRENT_BINARY_DIR}/resources.obj) IF( MSVC ) add_custom_command(OUTPUT ${WINDOWS_RES_FILE} - COMMAND rc.exe /fo ${WINDOWS_RES_FILE} playuver.rc + COMMAND rc.exe /fo ${WINDOWS_RES_FILE} ${PROJECT_NAME}.rc WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources ) ELSE() add_custom_command(OUTPUT ${WINDOWS_RES_FILE} - COMMAND windres.exe playuver.rc ${WINDOWS_RES_FILE} + COMMAND windres.exe ${PROJECT_NAME}.rc ${WINDOWS_RES_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources ) ENDIF() ENDIF() -ADD_EXECUTABLE( ${PROJECT_NAME} ${plaYUVer_App_SRCS} ${HEADERS_MOC_FILES} ${PlaYUVer_App_UI_Wrap} ${PlaYUVer_App_RCC} ${WINDOWS_RES_FILE} ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} PlaYUVerLib PlaYUVerModules ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib ) +ADD_EXECUTABLE( ${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${WINDOWS_RES_FILE} ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${PROJECT_LIBRARY} CalypModules ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib ) # QT5_USE_MODULES( ${PROJECT_NAME} ${QT_MODULES} ) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin ) -INSTALL(FILES resources/playuver.desktop DESTINATION share/applications ) -INSTALL(FILES resources/playuver.png DESTINATION share/pixmaps ) -INSTALL(FILES resources/playuver.xml DESTINATION share/mime/packages ) +INSTALL(FILES resources/calyp.desktop DESTINATION share/applications ) +INSTALL(FILES resources/calyp.png DESTINATION share/pixmaps ) +INSTALL(FILES resources/calyp.xml DESTINATION share/mime/packages ) diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/CalypAppModuleIf.cpp similarity index 74% rename from app/PlaYUVerAppModuleIf.cpp rename to app/CalypAppModuleIf.cpp index 890e067..c8abd5b 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/CalypAppModuleIf.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,11 +18,11 @@ */ /** - * \file PlaYUVerAppModuleIf.cpp - * \brief PlaYUVer modules interface + * \file CalypAppModuleIf.cpp + * \brief Calyp modules interface */ -#include "PlaYUVerAppModuleIf.h" +#include "CalypAppModuleIf.h" #include "VideoSubWindow.h" @@ -30,7 +30,7 @@ #include #include -PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ) +CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModuleIf* module ) : m_bIsRunning( false ) , m_pcModuleAction( action ) , m_pcModule( module ) @@ -42,13 +42,13 @@ PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaY , m_dMeasurementResult( 0 ) { setParent( parent ); - for( Int i = 0; i < MODULE_REQUIRES_MAX_NUM_FRAMES; i++ ) + for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ ) { m_pcSubWindow[i] = NULL; } } -Void PlaYUVerAppModuleIf::update() +void CalypAppModuleIf::update() { if( m_pcDisplaySubWindow ) { @@ -60,21 +60,21 @@ Void PlaYUVerAppModuleIf::update() } } -Bool PlaYUVerAppModuleIf::isRunning() +bool CalypAppModuleIf::isRunning() { -#ifdef PLAYUVER_THREADED_MODULES +#ifdef CALYP_THREADED_MODULES return QThread::isRunning(); #else return false; #endif } -Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) +bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads ) { - Bool bRet = false; + bool bRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); - if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) + if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { if( m_pcDisplaySubWindow ) { @@ -85,9 +85,9 @@ Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) m_pcSubWindow[0]->setFillWindow( true ); } } - if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) ) + if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) ) { -#ifdef PLAYUVER_THREADED_MODULES +#ifdef CALYP_THREADED_MODULES if( !disableThreads ) { wait(); @@ -100,7 +100,7 @@ Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) show(); } - if( m_pcDisplaySubWindow || m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) + if( m_pcDisplaySubWindow || m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE ) { bRet = true; } @@ -113,19 +113,19 @@ Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) return bRet; } -Void PlaYUVerAppModuleIf::run() +void CalypAppModuleIf::run() { m_bIsRunning = true; m_bSuccess = false; - std::vector apcFrameList; - for( UInt i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ ) + std::vector apcFrameList; + for( unsigned int i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ ) { apcFrameList.push_back( m_pcSubWindow[i]->getCurrFrame() ); } - if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) + if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { - if( m_pcModule->m_iModuleAPI == MODULE_API_2 ) + if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 ) { m_pcProcessedFrame = m_pcModule->process( apcFrameList ); } @@ -134,9 +134,9 @@ Void PlaYUVerAppModuleIf::run() m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() ); } } - else if( m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) + else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE ) { - if( m_pcModule->m_iModuleAPI == MODULE_API_2 ) + if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 ) { m_dMeasurementResult = m_pcModule->measure( apcFrameList ); } @@ -151,7 +151,7 @@ Void PlaYUVerAppModuleIf::run() } m_bSuccess = true; m_bIsRunning = false; -#ifdef PLAYUVER_THREADED_MODULES +#ifdef CALYP_THREADED_MODULES EventData* eventData = new EventData( m_bSuccess, this ); if( parent() ) QCoreApplication::postEvent( parent(), eventData ); @@ -159,11 +159,11 @@ Void PlaYUVerAppModuleIf::run() return; } -Void PlaYUVerAppModuleIf::show() +void CalypAppModuleIf::show() { switch( m_pcModule->m_iModuleType ) { - case FRAME_PROCESSING_MODULE: + case CLP_FRAME_PROCESSING_MODULE: if( m_pcDisplaySubWindow ) { m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame ); @@ -177,13 +177,13 @@ Void PlaYUVerAppModuleIf::show() m_pcSubWindow[0]->clearWindowBusy(); } break; - case FRAME_MEASUREMENT_MODULE: + case CLP_FRAME_MEASUREMENT_MODULE: m_pcModuleDock->setModulueReturnValue( m_dMeasurementResult ); break; } } -Void PlaYUVerAppModuleIf::destroy() +void CalypAppModuleIf::destroy() { if( m_bIsRunning ) { @@ -207,7 +207,7 @@ Void PlaYUVerAppModuleIf::destroy() m_pcDisplaySubWindow->closeSubWindow(); m_pcDisplaySubWindow = NULL; - for( Int i = 0; i < MODULE_REQUIRES_MAX_NUM_FRAMES; i++ ) + for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ ) { if( m_pcSubWindow[i] ) { diff --git a/app/PlaYUVerAppModuleIf.h b/app/CalypAppModuleIf.h similarity index 59% rename from app/PlaYUVerAppModuleIf.h rename to app/CalypAppModuleIf.h index e4e8492..944b5cb 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/CalypAppModuleIf.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,19 +18,19 @@ */ /** - * \file PlaYUVerAppModuleIf.h - * \brief PlaYUVer App modules interface + * \file CalypAppModuleIf.h + * \brief Calyp App modules interface */ -#ifndef __PLAYUVERAPPMODULESIF_H__ -#define __PLAYUVERAPPMODULESIF_H__ +#ifndef __CALYPAPPMODULESIF_H__ +#define __CALYPAPPMODULESIF_H__ +#include "CommonDefs.h" #include "ModuleHandleDock.h" -#include "PlaYUVerAppDefs.h" #include "config.h" -#include "lib/PlaYUVerFrame.h" -#include "lib/PlaYUVerModuleIf.h" -#include "lib/PlaYUVerStream.h" +#include "lib/CalypFrame.h" +#include "lib/CalypModuleIf.h" +#include "lib/CalypStream.h" #include #include @@ -40,12 +40,12 @@ class QAction; class QDockWidget; -//#define PLAYUVER_THREADED_MODULES +#define CLP_MODULE_MAX_NUM_FRAMES 5 class VideoSubWindow; -class PlaYUVerAppModuleIf -#ifdef PLAYUVER_THREADED_MODULES +class CalypAppModuleIf +#ifdef CALYP_THREADED_MODULES : public QThread #else : public QObject @@ -56,58 +56,58 @@ class PlaYUVerAppModuleIf friend class ModulesHandleOptDialog; private: - Bool m_bIsRunning; - Bool m_bSuccess; + bool m_bIsRunning; + bool m_bSuccess; QAction* m_pcModuleAction; - PlaYUVerModuleIf* m_pcModule; + CalypModuleIf* m_pcModule; - VideoSubWindow* m_pcSubWindow[MODULE_REQUIRES_MAX_NUM_FRAMES]; + VideoSubWindow* m_pcSubWindow[CLP_MODULE_MAX_NUM_FRAMES]; VideoSubWindow* m_pcDisplaySubWindow; QDockWidget* m_pcDockWidget; ModuleHandleDock* m_pcModuleDock; - PlaYUVerStream* m_pcModuleStream; - PlaYUVerFrame* m_pcProcessedFrame; - Double m_dMeasurementResult; + CalypStream* m_pcModuleStream; + CalypFrame* m_pcProcessedFrame; + double m_dMeasurementResult; public: class EventData : public QEvent { public: - EventData( bool success, PlaYUVerAppModuleIf* module ) + EventData( bool success, CalypAppModuleIf* module ) : QEvent( QEvent::User ) { m_bSuccess = success; m_pcModule = module; } - Bool m_bSuccess; - PlaYUVerAppModuleIf* m_pcModule; + bool m_bSuccess; + CalypAppModuleIf* m_pcModule; }; - PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ); - virtual ~PlaYUVerAppModuleIf() {} + CalypAppModuleIf( QObject* parent, QAction* action, CalypModuleIf* module ); + virtual ~CalypAppModuleIf() {} QList getSubWindowList() { QList arraySubWindows; - for( Int i = 0; i < MODULE_REQUIRES_MAX_NUM_FRAMES; i++ ) + for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ ) if( m_pcSubWindow[i] ) arraySubWindows.append( m_pcSubWindow[i] ); return arraySubWindows; } - PlaYUVerModuleIf* getModule() { return m_pcModule; } - UInt getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; } - Void update(); - Bool apply( Bool isPlaying = false, Bool disableThreads = false ); - Bool isRunning(); - Void show(); - Void destroy(); + CalypModuleIf* getModule() { return m_pcModule; } + unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; } + void update(); + bool apply( bool isPlaying = false, bool disableThreads = false ); + bool isRunning(); + void show(); + void destroy(); protected: virtual void run(); }; -#endif // __PLAYUVERAPPMODULESIF_H__ +#endif // __CALYPAPPMODULESIF_H__ diff --git a/app/PlaYUVerAppDefs.h b/app/CommonDefs.h similarity index 85% rename from app/PlaYUVerAppDefs.h rename to app/CommonDefs.h index 1d3e668..30e84a2 100644 --- a/app/PlaYUVerAppDefs.h +++ b/app/CommonDefs.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,14 +18,14 @@ */ /** - * \file PlaYUVerAppDefs.h - * \brief Define types for PlaYUVerApp + * \file CommonDefs.h + * \brief Define common types */ -#ifndef __PLAYUVERAPPDEFS_H__ -#define __PLAYUVERAPPDEFS_H__ +#ifndef __COMMONDEFS_H__ +#define __COMMONDEFS_H__ -#include "lib/PlaYUVerDefs.h" +#include "lib/CalypDefs.h" // ==================================================================================================================== // Qt compatibility redefinition @@ -38,4 +38,4 @@ #define QStringLiteral( str ) QString::fromUtf8( "" str "", sizeof( str ) - 1 ) #endif -#endif // __PLAYUVERAPPDEFS_H__ +#endif // __COMMONDEFS_H__ diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/DBusAppAdaptor.cpp similarity index 70% rename from app/PlaYUVerAppAdaptor.cpp rename to app/DBusAppAdaptor.cpp index 65619cd..a6fd0f2 100644 --- a/app/PlaYUVerAppAdaptor.cpp +++ b/app/DBusAppAdaptor.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,32 +18,35 @@ */ /** - * \file PlaYUVerAppAdaptor.h + * \file DBusAppAdaptor.cpp * \brief Define function to manage the interface in DBus */ -#include "PlaYUVerAppAdaptor.h" +#include "DBusAppAdaptor.h" -#include "PlaYUVerApp.h" +#include "MainWindow.h" -#include +//#include +//#include +#include +#include -PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( PlaYUVerApp* app ) +DBusAppAdaptor::DBusAppAdaptor( MainWindow* app ) : QDBusAbstractAdaptor( app ), m_app( app ) { // application dbus interface - Bool isRegistered = QDBusConnection::sessionBus().registerObject( QStringLiteral( PLAYUVER_DBUS_PATH ), this, + bool isRegistered = QDBusConnection::sessionBus().registerObject( QStringLiteral( CALYP_DBUS_PATH ), this, QDBusConnection::ExportAllSlots ); Q_ASSERT( isRegistered == true ); } -PlaYUVerAppAdaptor::~PlaYUVerAppAdaptor() +DBusAppAdaptor::~DBusAppAdaptor() { - QDBusConnection::sessionBus().unregisterObject( QStringLiteral( PLAYUVER_DBUS_PATH ) ); + QDBusConnection::sessionBus().unregisterObject( QStringLiteral( CALYP_DBUS_PATH ) ); } -void PlaYUVerAppAdaptor::activate() +void DBusAppAdaptor::activate() { if( !m_app ) { @@ -52,13 +55,13 @@ void PlaYUVerAppAdaptor::activate() m_app->raise(); } -QString PlaYUVerAppAdaptor::activeSession() +QString DBusAppAdaptor::activeSession() { // return m_app->sessionManager()->activeSession()->name(); - return QString( "PlaYUVer" ); + return QString( "Calyp" ); } -bool PlaYUVerAppAdaptor::loadFile( const QString& filename ) +bool DBusAppAdaptor::loadFile( const QString& filename ) { m_app->loadFile( filename ); return true; diff --git a/app/PlaYUVerAppAdaptor.h b/app/DBusAppAdaptor.h similarity index 76% rename from app/PlaYUVerAppAdaptor.h rename to app/DBusAppAdaptor.h index 6d435d3..666ae17 100644 --- a/app/PlaYUVerAppAdaptor.h +++ b/app/DBusAppAdaptor.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,33 +18,31 @@ */ /** - * \file PlaYUVerAppAdaptor.h + * \file DBusAppAdaptor.h * \brief Define function to manage the interface in DBus */ -#ifndef __PlaYUVerAppAdaptor_H__ -#define __PlaYUVerAppAdaptor_H__ +#ifndef __DBUSAPPADAPTOR_H__ +#define __DBUSAPPADAPTOR_H__ +#include #include -#include -#include -#include #include #include -#define PLAYUVER_DBUS_SESSION_NAME "org.pixlra.PlaYUVer.application" -#define PLAYUVER_DBUS_PATH "/" +#define CALYP_DBUS_SESSION_NAME "org.pixlra.Calyp.application" +#define CALYP_DBUS_PATH "/" -class PlaYUVerApp; +class MainWindow; -class PlaYUVerAppAdaptor : public QDBusAbstractAdaptor +class DBusAppAdaptor : public QDBusAbstractAdaptor { Q_OBJECT - Q_CLASSINFO( "D-Bus Interface", PLAYUVER_DBUS_SESSION_NAME ) + Q_CLASSINFO( "D-Bus interface", CALYP_DBUS_SESSION_NAME ) Q_PROPERTY( QString activeSession READ activeSession ) public: - PlaYUVerAppAdaptor( PlaYUVerApp* app ); - ~PlaYUVerAppAdaptor(); + DBusAppAdaptor( MainWindow* app ); + ~DBusAppAdaptor(); /** * emit the exiting signal */ @@ -77,7 +75,7 @@ public: QString activeSession(); private: - PlaYUVerApp* m_app; + MainWindow* m_app; }; -#endif // __PlaYUVerAppAdaptor_H__ +#endif // __DBUSAPPADAPTOR_H__ diff --git a/app/GridManager.cpp b/app/GridManager.cpp index 4e70942..2f67fbf 100644 --- a/app/GridManager.cpp +++ b/app/GridManager.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -65,8 +65,8 @@ void GridManager::drawGrid( QPixmap& image, const QRect& area, QPainter* painter style = Solid; switch( style ) { - case IntersectionDot: - case IntersectionCross: + case intersectionDot: + case intersectionCross: { painter->setPen( mainPen ); // Draw crosses or dots on intersections @@ -82,7 +82,7 @@ void GridManager::drawGrid( QPixmap& image, const QRect& area, QPainter* painter if( x >= area.x() && y >= area.y() ) { - if( style == IntersectionDot ) + if( style == intersectionDot ) painter->drawPoint( x, y ); // Dot else { // Crosses: diff --git a/app/GridManager.h b/app/GridManager.h index 1cf9e60..e967fea 100644 --- a/app/GridManager.h +++ b/app/GridManager.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,7 +29,7 @@ #include #include #include -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" class QPoint; @@ -44,8 +44,8 @@ class GridManager public: enum Style { - IntersectionDot = 0, - IntersectionCross, + intersectionDot = 0, + intersectionCross, Dashed, Solid }; @@ -93,8 +93,8 @@ public: QPoint nearPos( int x = -1, int y = -1 ); private: - UInt m_uiHSpace; - UInt m_uiVSpace; + unsigned int m_uiHSpace; + unsigned int m_uiVSpace; QColor m_cGridColor; Style m_eGridStyle; QPoint m_nearPos; diff --git a/app/PlaYUVerApp.cpp b/app/MainWindow.cpp similarity index 84% rename from app/PlaYUVerApp.cpp rename to app/MainWindow.cpp index 2cffd1d..4726dd1 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/MainWindow.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * Joao Santos (joaompssantos@gmail.com) @@ -19,21 +19,21 @@ */ /** - * \file PlaYUVerApp.cpp - * \brief Main definition of the PlaYUVerApp app + * \file MainWindow.cpp + * \brief Definition of the main window */ -#include "PlaYUVerApp.h" +#include "MainWindow.h" #include "AboutDialog.h" -#include "DialogSubWindowSelector.h" #include "ModulesHandle.h" -#include "PlaYUVerSubWindowHandle.h" #include "QualityHandle.h" #include "SubWindowAbstract.h" +#include "SubWindowHandle.h" +#include "SubWindowSelectorDialog.h" #include "VideoHandle.h" #include "VideoSubWindow.h" -#include "lib/PlaYUVerOptions.h" +#include "lib/CalypOptions.h" #include #include @@ -47,9 +47,7 @@ #include "fvupdater.h" #endif -#define SYNCHRONISED_ZOON 1 - -PlaYUVerApp::PlaYUVerApp() +MainWindow::MainWindow() : m_pcCurrentSubWindow( NULL ), m_pcCurrentVideoSubWindow( NULL ), m_pcAboutDialog( NULL ) { setWindowModality( Qt::ApplicationModal ); @@ -57,10 +55,10 @@ PlaYUVerApp::PlaYUVerApp() // DBus #ifdef USE_QTDBUS - m_pDBusAdaptor = new PlaYUVerAppAdaptor( this ); + m_pDBusAdaptor = new DBusAppAdaptor( this ); #endif - m_pcWindowHandle = new PlaYUVerSubWindowHandle( this ); + m_pcWindowHandle = new SubWindowHandle( this ); m_appModuleVideo = new VideoHandle( this, m_pcWindowHandle ); m_appModuleQuality = new QualityHandle( this, m_pcWindowHandle ); @@ -76,7 +74,7 @@ PlaYUVerApp::PlaYUVerApp() readSettings(); setWindowTitle( QApplication::applicationName() ); - setWindowIcon( QIcon( ":/images/playuver.png" ) ); + setWindowIcon( QIcon( ":logos/calyp-icon.png" ) ); setUnifiedTitleAndToolBarOnMac( true ); setCentralWidget( m_pcWindowHandle ); setAcceptDrops( true ); @@ -89,14 +87,14 @@ PlaYUVerApp::PlaYUVerApp() connect( m_appModuleExtensions, SIGNAL( changed() ), this, SLOT( update() ) ); } -Bool PlaYUVerApp::parseArgs( Int argc, Char* argv[] ) +bool MainWindow::parseArgs( int argc, char* argv[] ) { - Bool bRet = false; - PlaYUVerOptions pcCmdParser; + bool bRet = false; + CalypOptions pcCmdParser; - std::vector m_apcInputs; - String strResolution( "" ); - String strPelFmt( "" ); + std::vector m_apcInputs; + ClpString strResolution( "" ); + ClpString strPelFmt( "" ); pcCmdParser.addOptions() /**/ ( "input,i", m_apcInputs, "input file" ) /**/ @@ -116,13 +114,13 @@ Bool PlaYUVerApp::parseArgs( Int argc, Char* argv[] ) } if( pcCmdParser.hasOpt( "input" ) ) { - for( UInt i = 1; i < m_apcInputs.size(); i++ ) + for( unsigned int i = 1; i < m_apcInputs.size(); i++ ) { loadFile( QString::fromStdString( m_apcInputs[i] ) ); } } - std::list& argv_unhandled = pcCmdParser.getUnhandledArgs(); - for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) + std::list& argv_unhandled = pcCmdParser.getUnhandledArgs(); + for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) { loadFile( QString::fromStdString( *it ) ); } @@ -131,22 +129,22 @@ Bool PlaYUVerApp::parseArgs( Int argc, Char* argv[] ) return bRet; } -Void PlaYUVerApp::about() +void MainWindow::about() { if( !m_pcAboutDialog ) m_pcAboutDialog = new AboutDialog( this ); m_pcAboutDialog->exec(); } -Void PlaYUVerApp::closeEvent( QCloseEvent* event ) +void MainWindow::closeEvent( QCloseEvent* event ) { - Int mayCloseAll = true; - Int msgBoxCloseRet = QMessageBox::Yes; + int mayCloseAll = true; + int msgBoxCloseRet = QMessageBox::Yes; QList subWindowList = m_pcWindowHandle->findSubWindow(); if( subWindowList.size() >= 1 ) { - QMessageBox msgBoxClose( QMessageBox::Question, "PlaYUVer", "There are open files!", + QMessageBox msgBoxClose( QMessageBox::Question, "Calyp", "There are open files!", QMessageBox::Yes | QMessageBox::No, this ); msgBoxClose.setDefaultButton( QMessageBox::No ); msgBoxClose.setInformativeText( "Close all?" ); @@ -156,7 +154,7 @@ Void PlaYUVerApp::closeEvent( QCloseEvent* event ) { case QMessageBox::Yes: mayCloseAll = true; - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { mayCloseAll &= subWindowList.at( i )->mayClose(); } @@ -179,19 +177,19 @@ Void PlaYUVerApp::closeEvent( QCloseEvent* event ) } } -Void PlaYUVerApp::closeAll() +void MainWindow::closeAll() { m_pcWindowHandle->removeAllSubWindow(); } -Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) +void MainWindow::loadFile( QString fileName, CalypFileInfo* pStreamInfo ) { if( !QFileInfo( fileName ).exists() ) { - printMessage( "File " + fileName + " do not exist!", LOG_ERROR ); + printMessage( "File " + fileName + " do not exist!", CLP_LOG_ERROR ); return; } - VideoSubWindow* videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); + VideoSubWindow* videoSubWindow = MainWindow::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); if( videoSubWindow ) { m_pcWindowHandle->setActiveSubWindow( videoSubWindow ); @@ -200,13 +198,13 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); // createSubWindow(); if( !pStreamInfo ) { - Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, fileName ); - pStreamInfo = (PlaYUVerStreamInfo*)( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL ); + int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName ); + pStreamInfo = (CalypFileInfo*)( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL ); } try { - Bool opened = false; + bool opened = false; if( !pStreamInfo ) opened = videoSubWindow->loadFile( fileName ); @@ -215,7 +213,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) if( opened ) { - printMessage( "Loading file...", LOG_INFO ); + printMessage( "Loading file...", CLP_LOG_INFO ); m_pcWindowHandle->addSubWindow( videoSubWindow ); videoSubWindow->show(); @@ -225,7 +223,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) addStreamInfoToRecentList( videoSubWindow->getStreamInfo() ); - printMessage( "File loaded", LOG_INFO ); + printMessage( "File loaded", CLP_LOG_INFO ); m_cLastOpenPath = QFileInfo( fileName ).path(); } else @@ -233,37 +231,37 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) videoSubWindow->close(); } } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { videoSubWindow->close(); QString warningMsg = "Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what(); QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - printMessage( warningMsg, LOG_ERROR ); + printMessage( warningMsg, CLP_LOG_ERROR ); } } // ----------------------- File Functions ----------------------- -QStringList PlaYUVerApp::showFileDialog( Bool bRead ) +QStringList MainWindow::showFileDialog( bool bRead ) { QString supported = tr( "Supported Files (" ); QStringList formatsList; - std::vector supportedFmts; + std::vector supportedFmts; if( bRead ) - supportedFmts = PlaYUVerStream::supportedReadFormats(); + supportedFmts = CalypStream::supportedReadFormats(); else - supportedFmts = PlaYUVerStream::supportedWriteFormats(); + supportedFmts = CalypStream::supportedWriteFormats(); - for( UInt i = 0; i < supportedFmts.size(); i++ ) + for( unsigned int i = 0; i < supportedFmts.size(); i++ ) { - std::vector arrayExt = supportedFmts[i].getExts(); + std::vector arrayExt = supportedFmts[i].getExts(); if( arrayExt.size() > 0 ) { QString currFmt( QString::fromStdString( supportedFmts[i].formatName ) ); currFmt.append( " (" ); - for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) + for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) { supported.append( " *." ); currFmt.append( "*." ); @@ -292,10 +290,10 @@ QStringList PlaYUVerApp::showFileDialog( Bool bRead ) return fileNameList; } -Void PlaYUVerApp::open() +void MainWindow::open() { QStringList fileNameList = showFileDialog( true ); - for( Int i = 0; i < fileNameList.size(); i++ ) + for( int i = 0; i < fileNameList.size(); i++ ) { if( !fileNameList.at( i ).isEmpty() ) { @@ -304,20 +302,20 @@ Void PlaYUVerApp::open() } } -// Void PlaYUVerApp::openDevice() +// void CalypApp::openDevice() //{ // loadFile( "/dev/video0", NULL ); //} -Void PlaYUVerApp::openRecent() +void MainWindow::openRecent() { QAction* action = qobject_cast( sender() ); - PlaYUVerStreamInfo recentFile = action->data().value(); + CalypFileInfo recentFile = action->data().value(); if( action ) loadFile( recentFile.m_cFilename, &recentFile ); } -Void PlaYUVerApp::saveFrame() +void MainWindow::saveFrame() { if( m_pcCurrentVideoSubWindow ) { @@ -332,20 +330,20 @@ Void PlaYUVerApp::saveFrame() { saveWindow->save( fileName ); } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { QApplication::restoreOverrideCursor(); QString warningMsg = "Cannot save file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what(); QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - printMessage( warningMsg, LOG_ERROR ); + printMessage( warningMsg, CLP_LOG_ERROR ); return; } } } } -Void PlaYUVerApp::saveStream() +void MainWindow::saveStream() { if( m_pcCurrentVideoSubWindow ) { @@ -360,20 +358,20 @@ Void PlaYUVerApp::saveStream() { saveWindow->save( fileName ); } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { QApplication::restoreOverrideCursor(); QString warningMsg = "Cannot save file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what(); QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - printMessage( warningMsg, LOG_ERROR ); + printMessage( warningMsg, CLP_LOG_ERROR ); return; } } } } -Void PlaYUVerApp::format() +void MainWindow::format() { if( m_pcCurrentVideoSubWindow ) { @@ -385,12 +383,12 @@ Void PlaYUVerApp::format() addStreamInfoToRecentList( pcVideoSubWindow->getStreamInfo() ); } } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" + e.what(); QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - printMessage( warningMsg, LOG_ERROR ); + printMessage( warningMsg, CLP_LOG_ERROR ); qDebug() << warningMsg; m_pcCurrentSubWindow->close(); } @@ -399,7 +397,7 @@ Void PlaYUVerApp::format() } } -Void PlaYUVerApp::reload() +void MainWindow::reload() { if( m_pcCurrentSubWindow ) { @@ -409,18 +407,18 @@ Void PlaYUVerApp::reload() } } -Void PlaYUVerApp::reloadAll() +void MainWindow::reloadAll() { - UInt windowCategoryOrder[] = { + unsigned int windowCategoryOrder[] = { SubWindowAbstract::VIDEO_STREAM_SUBWINDOW, SubWindowAbstract::MODULE_SUBWINDOW, SubWindowAbstract::MODULE_SUBWINDOW, }; - for( UInt c = 0; c < 3; c++ ) + for( unsigned int c = 0; c < 3; c++ ) { QList subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { subWindowList.at( i )->refreshSubWindow(); } @@ -429,19 +427,19 @@ Void PlaYUVerApp::reloadAll() update(); } -Void PlaYUVerApp::loadAll() +void MainWindow::loadAll() { if( m_pcCurrentVideoSubWindow ) { - printMessage( "Loading file into memory...", LOG_INFO ); + printMessage( "Loading file into memory...", CLP_LOG_INFO ); m_pcCurrentVideoSubWindow->loadAll(); - printMessage( "File loaded", LOG_INFO ); + printMessage( "File loaded", CLP_LOG_INFO ); } } // ----------------------- Zoom Functions ----------------------- -Void PlaYUVerApp::normalSize() +void MainWindow::normalSize() { if( m_pcCurrentSubWindow ) { @@ -450,7 +448,7 @@ Void PlaYUVerApp::normalSize() } } -Void PlaYUVerApp::zoomToFit() +void MainWindow::zoomToFit() { if( m_pcCurrentSubWindow ) { @@ -459,11 +457,11 @@ Void PlaYUVerApp::zoomToFit() } } -Void PlaYUVerApp::zoomToFitAll() +void MainWindow::zoomToFitAll() { VideoSubWindow* videoSubWindow; QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); videoSubWindow->zoomToFit(); @@ -472,28 +470,28 @@ Void PlaYUVerApp::zoomToFitAll() updateZoomFactorSBox(); } -Void PlaYUVerApp::scaleFrame( int ratio ) +void MainWindow::scaleFrame( int ratio ) { if( m_pcCurrentSubWindow ) { - m_pcCurrentSubWindow->scaleView( ( Double )( ratio ) / 100.0 ); + m_pcCurrentSubWindow->scaleView( (double)( ratio ) / 100.0 ); updateZoomFactorSBox(); } } -Void PlaYUVerApp::zoomFromSBox( double zoom ) +void MainWindow::zoomFromSBox( double zoom ) { SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow(); - Double factor = zoom / 100; + double factor = zoom / 100; if( activeSubWindow ) { activeSubWindow->zoomToFactor( factor ); } } -Void PlaYUVerApp::updateZoomFactorSBox() +void MainWindow::updateZoomFactorSBox() { - Double factor; + double factor; if( m_pcCurrentSubWindow ) { factor = m_pcCurrentSubWindow->getScaleFactor(); @@ -503,14 +501,14 @@ Void PlaYUVerApp::updateZoomFactorSBox() // ----------------------- Drag and drop functions ---------------------- -Void PlaYUVerApp::dragEnterEvent( QDragEnterEvent* event ) +void MainWindow::dragEnterEvent( QDragEnterEvent* event ) { // setText(tr("")); // mdiArea->setBackgroundRole( QPalette::Highlight ); event->acceptProposedAction(); } -Void PlaYUVerApp::dropEvent( QDropEvent* event ) +void MainWindow::dropEvent( QDropEvent* event ) { const QMimeData* mimeData = event->mimeData(); QList urlList = mimeData->urls(); @@ -524,13 +522,13 @@ Void PlaYUVerApp::dropEvent( QDropEvent* event ) // ----------------------- Sub Window Functions ----------------------- -VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, - const QString& fileName ) +VideoSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandle* windowManager, + const QString& fileName ) { QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); VideoSubWindow* pcSubWindow; QList subWindowList = windowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { pcSubWindow = qobject_cast( subWindowList.at( i ) ); if( pcSubWindow->getCurrentFileName() == canonicalFilePath ) @@ -541,7 +539,7 @@ VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHa // ----------------------- Update Functions ----------------------- -Void PlaYUVerApp::update() +void MainWindow::update() { SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow(); QCoreApplication::processEvents(); @@ -574,28 +572,28 @@ Void PlaYUVerApp::update() updateMenus(); } -Void PlaYUVerApp::printMessage( const QString& msg ) +void MainWindow::printMessage( const QString& msg ) { printMessage( msg, 0 ); } -Void PlaYUVerApp::printMessage( const QString& msg, UInt logLevel ) +void MainWindow::printMessage( const QString& msg, unsigned int logLevel ) { if( !msg.isEmpty() ) { statusBar()->showMessage( msg, 10000 ); - if( logLevel >= LOG_INFO ) + if( logLevel >= CLP_LOG_INFO ) { m_pcWindowHandle->processLogMsg( msg ); } } } -Void PlaYUVerApp::updateMenus() +void MainWindow::updateMenus() { - Bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 ); + bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 ); - Bool hasVideoStreamSubWindow = false; + bool hasVideoStreamSubWindow = false; if( m_pcCurrentSubWindow ) if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ) hasVideoStreamSubWindow = true; @@ -625,7 +623,7 @@ Void PlaYUVerApp::updateMenus() // ----------------------- Create Functions ----------------------- -Void PlaYUVerApp::createActions() +void MainWindow::createActions() { m_arrayActions.resize( TOTAL_ACT ); @@ -642,7 +640,7 @@ Void PlaYUVerApp::createActions() // SIGNAL( triggered() ), this, SLOT( openDevice() ) ); m_arrayRecentFilesActions.resize( MAX_RECENT_FILES ); - for( Int i = 0; i < MAX_RECENT_FILES; i++ ) + for( int i = 0; i < MAX_RECENT_FILES; i++ ) { m_arrayRecentFilesActions[i] = new QAction( this ); m_arrayRecentFilesActions[i]->setVisible( false ); @@ -748,7 +746,7 @@ Void PlaYUVerApp::createActions() #endif m_arrayActions[ABOUT_ACT] = new QAction( tr( "&About" ), this ); - m_arrayActions[ABOUT_ACT]->setIcon( QIcon( ":images/playuver.png" ) ); + m_arrayActions[ABOUT_ACT]->setIcon( QIcon( ":logos/calyp-icon.png" ) ); m_arrayActions[ABOUT_ACT]->setStatusTip( tr( "Show the application's About box" ) ); connect( m_arrayActions[ABOUT_ACT], SIGNAL( triggered() ), this, SLOT( about() ) ); @@ -758,7 +756,7 @@ Void PlaYUVerApp::createActions() connect( m_arrayActions[ABOUTQT_ACT], SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) ); } -Void PlaYUVerApp::createMenus() +void MainWindow::createMenus() { m_arrayMenu.resize( TOTAL_MENUS ); @@ -766,7 +764,7 @@ Void PlaYUVerApp::createMenus() m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[OPEN_ACT] ); // m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[OPEN_DEVICE_ACT] ); m_arrayMenu[RECENT_MENU] = m_arrayMenu[FILE_MENU]->addMenu( tr( "Open Recent" ) ); - for( Int i = 0; i < MAX_RECENT_FILES; ++i ) + for( int i = 0; i < MAX_RECENT_FILES; ++i ) { m_arrayMenu[RECENT_MENU]->addAction( m_arrayRecentFilesActions[i] ); } @@ -820,7 +818,7 @@ Void PlaYUVerApp::createMenus() m_arrayMenu[ABOUT_MENU]->addAction( m_arrayActions[ABOUTQT_ACT] ); } -Void PlaYUVerApp::createToolBars() +void MainWindow::createToolBars() { m_arrayToolBars.resize( TOTAL_TOOLBAR ); @@ -854,7 +852,7 @@ Void PlaYUVerApp::createToolBars() addToolBar( Qt::TopToolBarArea, m_appModuleVideo->createToolBar() ); } -Void PlaYUVerApp::createDockWidgets() +void MainWindow::createDockWidgets() { // Properties Dock Window m_arraySideBars.resize( TOTAL_DOCK ); @@ -862,16 +860,16 @@ Void PlaYUVerApp::createDockWidgets() addDockWidget( Qt::RightDockWidgetArea, m_appModuleQuality->createDock() ); } -Void PlaYUVerApp::createStatusBar() +void MainWindow::createStatusBar() { //! Warning: the following widget cannot change size too much statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); - printMessage( "Ready!", LOG_INFO ); + printMessage( "Ready!", CLP_LOG_INFO ); } -Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) +void MainWindow::addStreamInfoToRecentList( CalypFileInfo streamInfo ) { - Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, streamInfo.m_cFilename ); + int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, streamInfo.m_cFilename ); if( idx >= 0 ) m_aRecentFileStreamInfo.remove( idx ); m_aRecentFileStreamInfo.prepend( streamInfo ); @@ -880,11 +878,11 @@ Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) updateRecentFileActions(); } -Void PlaYUVerApp::updateRecentFileActions() +void MainWindow::updateRecentFileActions() { - Int numRecentFiles = m_aRecentFileStreamInfo.size(); + int numRecentFiles = m_aRecentFileStreamInfo.size(); numRecentFiles = qMin( numRecentFiles, MAX_RECENT_FILES ); - Int actionIdx = 0; + int actionIdx = 0; while( actionIdx < numRecentFiles ) { QString text = m_aRecentFileStreamInfo.at( actionIdx ).m_cFilename; @@ -904,9 +902,9 @@ Void PlaYUVerApp::updateRecentFileActions() m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false ); } -Void PlaYUVerApp::checkRecentFileActions() +void MainWindow::checkRecentFileActions() { - Int i = 0; + int i = 0; while( i < m_aRecentFileStreamInfo.size() ) { if( !QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).exists() ) @@ -916,7 +914,7 @@ Void PlaYUVerApp::checkRecentFileActions() } else { - UInt64 fileSize = QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).size(); + unsigned long long int fileSize = QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).size(); if( m_aRecentFileStreamInfo.at( i ).m_uiFileSize != fileSize ) { m_aRecentFileStreamInfo.remove( i ); @@ -927,7 +925,7 @@ Void PlaYUVerApp::checkRecentFileActions() } } -Void PlaYUVerApp::readSettings() +void MainWindow::readSettings() { QSettings appSettings; @@ -939,7 +937,7 @@ Void PlaYUVerApp::readSettings() m_cLastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString(); QVariant value = appSettings.value( "MainWindow/RecentFileList" ); - m_aRecentFileStreamInfo = value.value(); + m_aRecentFileStreamInfo = value.value(); checkRecentFileActions(); updateRecentFileActions(); @@ -949,7 +947,7 @@ Void PlaYUVerApp::readSettings() m_pcWindowHandle->readSettings(); } -Void PlaYUVerApp::writeSettings() +void MainWindow::writeSettings() { QSettings appSettings; @@ -958,7 +956,7 @@ Void PlaYUVerApp::writeSettings() appSettings.setValue( "MainWindow/LastOpenPath", m_cLastOpenPath ); QVariant var; - var.setValue( m_aRecentFileStreamInfo ); + var.setValue( m_aRecentFileStreamInfo ); appSettings.setValue( "MainWindow/RecentFileList", var ); m_appModuleVideo->writeSettings(); diff --git a/app/PlaYUVerApp.h b/app/MainWindow.h similarity index 74% rename from app/PlaYUVerApp.h rename to app/MainWindow.h index 8482851..2367240 100644 --- a/app/PlaYUVerApp.h +++ b/app/MainWindow.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,14 +18,14 @@ */ /** - * \file PlaYUVerApp.h - * \ingroup PlaYUVerApp - * \brief Main definition of the PlaYUVerApp app + * \file MainWindow.cpp + * \brief Definition of the main window + * \ingroup CalypApp * - * @defgroup PlaYUVerApp PlaYUVer App (GUI) + * @defgroup CalypApp Calyp App (GUI) * @{ * - * PlaYUVerApp is an high level interface providing a GUI + * CalypApp is an high level interface providing a GUI * based on the Qt libs in order to display provide important * information about video streams. * @@ -33,14 +33,14 @@ * */ -#ifndef __PLAYUVERAPP_H__ -#define __PLAYUVERAPP_H__ +#ifndef __MAINWINDOW_H__ +#define __MAINWINDOW_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "VideoSubWindow.h" #include "config.h" #ifdef USE_QTDBUS -#include "PlaYUVerAppAdaptor.h" +#include "DBusAppAdaptor.h" #endif #include @@ -55,32 +55,32 @@ class QActionGroup; class QAction; class QSignalMapper; -class PlaYUVerOptions; -class PlaYUVerStream; -class PlaYUVerSubWindowHandle; +class CalypOptions; +class CalypStream; +class SubWindowHandle; class VideoHandle; class QualityHandle; class ModulesHandle; -class PlaYUVerAppAdaptor; +class DBusAppAdaptor; class VideoSubWindow; class SubWindowAbstract; class AboutDialog; -class PlaYUVerApp : public QMainWindow +class MainWindow : public QMainWindow { Q_OBJECT public: - PlaYUVerApp(); - Bool parseArgs( Int argc, Char* argv[] ); - Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); + MainWindow(); + bool parseArgs( int argc, char* argv[] ); + void loadFile( QString fileName, CalypFileInfo* pStreamInfo = NULL ); public Q_SLOTS: void printMessage( const QString& msg ); - void printMessage( const QString& msg, UInt logLevel ); + void printMessage( const QString& msg, unsigned int logLevel ); protected: - Void closeEvent( QCloseEvent* event ); + void closeEvent( QCloseEvent* event ); private Q_SLOTS: @@ -118,8 +118,8 @@ private Q_SLOTS: void updateZoomFactorSBox(); private: - PlaYUVerAppAdaptor* m_pDBusAdaptor; - PlaYUVerOptions* m_pcCmdParser; + DBusAppAdaptor* m_pDBusAdaptor; + CalypOptions* m_pcCmdParser; /** * Save the current subwindow for every category */ @@ -127,25 +127,25 @@ private: VideoSubWindow* m_pcCurrentVideoSubWindow; QString m_cLastOpenPath; - QStringList showFileDialog( Bool bRead ); + QStringList showFileDialog( bool bRead ); - static VideoSubWindow* findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, + static VideoSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager, const QString& fileName ); - Void updateMenus(); + void updateMenus(); - Void createActions(); - Void createMenus(); - Void createToolBars(); - Void createDockWidgets(); - Void createStatusBar(); + void createActions(); + void createMenus(); + void createToolBars(); + void createDockWidgets(); + void createStatusBar(); - Void addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ); - Void updateRecentFileActions(); - Void checkRecentFileActions(); + void addStreamInfoToRecentList( CalypFileInfo streamInfo ); + void updateRecentFileActions(); + void checkRecentFileActions(); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); QDoubleSpinBox* m_pcZoomFactorSBox; @@ -161,7 +161,7 @@ private: VideoHandle* m_appModuleVideo; QualityHandle* m_appModuleQuality; ModulesHandle* m_appModuleExtensions; - PlaYUVerSubWindowHandle* m_pcWindowHandle; + SubWindowHandle* m_pcWindowHandle; /** * Array of menus for the main app @@ -235,9 +235,9 @@ private: #define MAX_RECENT_FILES 20 QVector m_arrayRecentFilesActions; - PlaYUVerStreamInfoVector m_aRecentFileStreamInfo; + CalypFileInfoVector m_aRecentFileStreamInfo; AboutDialog* m_pcAboutDialog; }; -#endif // __PLAYUVERAPP_H__ +#endif // __MAINWINDOW_H__ diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/MdiSubWindow.cpp similarity index 82% rename from app/PlaYUVerMdiSubWindow.cpp rename to app/MdiSubWindow.cpp index 1b31eeb..b761ea7 100644 --- a/app/PlaYUVerMdiSubWindow.cpp +++ b/app/MdiSubWindow.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,24 +18,24 @@ */ /** - * \file PlaYUVerMdiSubWindow.cpp + * \file MdiSubWindow.cpp * \brief Re-implementation QMdiSubWindow */ -#include "PlaYUVerMdiSubWindow.h" +#include "MdiSubWindow.h" #include "SubWindowAbstract.h" #include -PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget* parent ) +MdiSubWindow::MdiSubWindow( QWidget* parent ) : QMdiSubWindow( parent ) { setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Background ); } -QSize PlaYUVerMdiSubWindow::sizeHint() const +QSize MdiSubWindow::sizeHint() const { QSize maxSize; if( parent() ) @@ -44,7 +44,7 @@ QSize PlaYUVerMdiSubWindow::sizeHint() const return sizeHint; } -Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent* event ) +void MdiSubWindow::closeEvent( QCloseEvent* event ) { emit aboutToClose( this ); event->accept(); diff --git a/app/PlaYUVerMdiSubWindow.h b/app/MdiSubWindow.h similarity index 75% rename from app/PlaYUVerMdiSubWindow.h rename to app/MdiSubWindow.h index 0c4f7db..bae332e 100644 --- a/app/PlaYUVerMdiSubWindow.h +++ b/app/MdiSubWindow.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,30 +18,30 @@ */ /** - * \file PlaYUVerMdiSubWindow.h + * \file MdiSubWindow.h * \brief Re-implementation QMdiSubWindow */ -#ifndef __PLAYUVERMDISUBWINDOW_H__ -#define __PLAYUVERMDISUBWINDOW_H__ +#ifndef __MDISUBWINDOW_H_ +#define __MDISUBWINDOW_H_ #include -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" -class PlaYUVerMdiSubWindow : public QMdiSubWindow +class MdiSubWindow : public QMdiSubWindow { Q_OBJECT public: - PlaYUVerMdiSubWindow( QWidget* parent = 0 ); + MdiSubWindow( QWidget* parent = 0 ); Q_SIGNALS: - void aboutToClose( PlaYUVerMdiSubWindow* ); + void aboutToClose( MdiSubWindow* ); protected: QSize sizeHint() const; void closeEvent( QCloseEvent* event ); }; -#endif // __PLAYUVERMDISUBWINDOW_H__ +#endif // __MDISUBWINDOW_H_ diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 613c500..4af7f55 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,22 +19,22 @@ /** * \file ModulesHandle.cpp - * \brief PlaYUVer modules handle + * \brief Calyp modules handle */ #include "ModulesHandle.h" -#include "DialogSubWindowSelector.h" +#include "MainWindow.h" #include "ModulesHandleOptDialog.h" -#include "PlaYUVerApp.h" -#include "PlaYUVerSubWindowHandle.h" +#include "SubWindowHandle.h" +#include "SubWindowSelectorDialog.h" #include "VideoHandle.h" #include "VideoSubWindow.h" -#include "modules/PlaYUVerModuleFactory.h" +#include "modules/CalypModulesFactory.h" #include -ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, VideoHandle* moduleVideo ) +ModulesHandle::ModulesHandle( QWidget* parent, SubWindowHandle* windowManager, VideoHandle* moduleVideo ) : QWidget( parent ), m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo ) { setParent( m_pcParent ); @@ -42,7 +42,7 @@ ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowMa ModulesHandle::~ModulesHandle() {} -Void ModulesHandle::createActions() +void ModulesHandle::createActions() { m_arrayActions.resize( MODULES_TOTAL_ACT ); @@ -89,14 +89,14 @@ QMenu* ModulesHandle::createMenu() return m_pcModulesMenu; } -Void ModulesHandle::buildMenu() +void ModulesHandle::buildMenu() { - PlaYUVerModuleIf* pcCurrModuleIf; - QString ModuleIfInternalName; + CalypModuleIf* pcCurrModuleIf; + QString ModuleIfinternalName; QAction* currAction; QMenu* currSubMenu; - for( Int i = 0; i < m_arrayModulesActions.size(); i++ ) + for( int i = 0; i < m_arrayModulesActions.size(); i++ ) { delete m_arrayModulesActions.at( i ); } @@ -104,17 +104,17 @@ Void ModulesHandle::buildMenu() m_pcModulesMenu->clear(); m_pcModulesSubMenuList.clear(); - PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); - PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); - for( ; it != PlaYUVerModuleFactoryMap.end(); ++it ) + CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); + CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin(); + for( ; it != moduleFactoryMap.end(); ++it ) { pcCurrModuleIf = it->second(); - ModuleIfInternalName = QString::fromLocal8Bit( it->first ); + ModuleIfinternalName = QString::fromLocal8Bit( it->first ); currSubMenu = NULL; if( pcCurrModuleIf->m_pchModuleCategory ) { - for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ ) + for( int j = 0; j < m_pcModulesSubMenuList.size(); j++ ) { if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_pchModuleCategory ) ) { @@ -135,7 +135,7 @@ Void ModulesHandle::buildMenu() moduleTooltip += QString( " | Requires %1 frames" ).arg( pcCurrModuleIf->m_uiNumberOfFrames ); currAction->setStatusTip( moduleTooltip ); - currAction->setData( ModuleIfInternalName ); + currAction->setData( ModuleIfinternalName ); currAction->setCheckable( false ); connect( currAction, SIGNAL( triggered() ), this, SLOT( activateModule() ) ); m_arrayModulesActions.append( currAction ); @@ -157,41 +157,41 @@ Void ModulesHandle::buildMenu() m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] ); } -Void ModulesHandle::updateMenus() +void ModulesHandle::updateMenus() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); - Bool hasSubWindow = pcSubWindow ? true : false; + bool hasSubWindow = pcSubWindow ? true : false; QAction* currModuleAction; - for( Int i = 0; i < m_arrayModulesActions.size(); i++ ) + for( int i = 0; i < m_arrayModulesActions.size(); i++ ) { currModuleAction = m_arrayModulesActions.at( i ); //currModuleAction->setEnabled( hasSubWindow ); currModuleAction->setChecked( false ); } - //for( Int i = 0; i < m_pcModulesSubMenuList.size(); i++ ) + //for( int i = 0; i < m_pcModulesSubMenuList.size(); i++ ) //{ // m_pcModulesSubMenuList.at( i )->setEnabled( hasSubWindow ); //} - for( Int i = 0; i < m_arrayActions.size(); i++ ) + for( int i = 0; i < m_arrayActions.size(); i++ ) { m_arrayActions.at( i )->setEnabled( false ); } m_arrayActions[LOAD_EXTERNAL_ACT]->setEnabled( true ); m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcPlaYUVerAppModuleIfList.size() > 0 ); + m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcCalypAppModuleIfList.size() > 0 ); if( pcSubWindow ) { - QList apcCurrentModule = pcSubWindow->getModuleArray(); + QList apcCurrentModule = pcSubWindow->getModuleArray(); m_arrayActions[DISABLE_ACT]->setEnabled( apcCurrentModule.size() > 0 ); if( pcSubWindow->getDisplayModule() ) { m_arrayActions[APPLY_ALL_ACT]->setEnabled( true ); m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true ); } - for( Int i = 0; i < apcCurrentModule.size(); i++ ) + for( int i = 0; i < apcCurrentModule.size(); i++ ) { currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction; currModuleAction->setChecked( true ); @@ -199,27 +199,27 @@ Void ModulesHandle::updateMenus() } } -Void ModulesHandle::readSettings() +void ModulesHandle::readSettings() { QSettings appSettings; m_arrayActions[FORCE_NEW_WINDOW_ACT]->setChecked( appSettings.value( "ModulesHandle/UseNewWindow", false ).toBool() ); } -Void ModulesHandle::writeSettings() +void ModulesHandle::writeSettings() { QSettings appSettings; appSettings.setValue( "ModulesHandle/UseNewWindow", m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() ); } -Void ModulesHandle::processOpt( Int index ) +void ModulesHandle::processOpt( int index ) { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcSubWindow ) { - PlaYUVerAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule(); + CalypAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule(); if( pcCurrentModule ) { - PlaYUVerAppModuleIf* pcCurrModule = pcCurrentModule; + CalypAppModuleIf* pcCurrModule = pcCurrentModule; switch( index ) { case INVALID_OPT: @@ -238,9 +238,9 @@ Void ModulesHandle::processOpt( Int index ) } } -Void ModulesHandle::loadExternalModule() +void ModulesHandle::loadExternalModule() { - Bool bUpdate = false; + bool bUpdate = false; QString supported = tr( "Supported Files (*.so)" ); QStringList formatsList; formatsList << "Shared Libraries (*.so)"; @@ -249,19 +249,19 @@ Void ModulesHandle::loadExternalModule() QStringList fileNames = QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) ); - for( Int i = 0; i < fileNames.size(); i++ ) + for( int i = 0; i < fileNames.size(); i++ ) { - bUpdate |= PlaYUVerModuleFactory::Get()->RegisterDl( fileNames.at( i ).toStdString().data() ); + bUpdate |= CalypModulesFactory::Get()->RegisterDl( fileNames.at( i ).toStdString().data() ); } if( bUpdate ) buildMenu(); } -Void ModulesHandle::activateModule() +void ModulesHandle::activateModule() { QAction* pcAction = qobject_cast( sender() ); Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers(); - Bool bTmpForceNewWindow = false; + bool bTmpForceNewWindow = false; VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( !pcVideoSubWindow ) @@ -275,28 +275,28 @@ Void ModulesHandle::activateModule() } QString ModuleIfName = pcAction->data().toString(); - PlaYUVerModuleIf* pcCurrModuleIf = - PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() ); - PlaYUVerAppModuleIf* pcCurrAppModuleIf = new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf ); + CalypModuleIf* pcCurrModuleIf = + CalypModulesFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() ); + CalypAppModuleIf* pcCurrAppModuleIf = new CalypAppModuleIf( this, pcAction, pcCurrModuleIf ); QList videoSubWindowList; - Int numberOfFrames = pcCurrAppModuleIf->m_pcModule->m_uiNumberOfFrames; - if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows + int numberOfFrames = pcCurrAppModuleIf->m_pcModule->m_uiNumberOfFrames; + if( numberOfFrames > 1 ) // Show dialog to select sub windows { - Int minNumFrames = numberOfFrames; - Int maxNumFrames = numberOfFrames; - if( numberOfFrames == MODULE_REQUIRES_SEVERAL_FRAMES ) + int minNumFrames = numberOfFrames; + int maxNumFrames = numberOfFrames; + if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULES_VARIABLE_NUM_FRAMES ) { - minNumFrames = 0; + minNumFrames = numberOfFrames; maxNumFrames = 255; } - DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, + SubWindowSelectorDialog dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames, maxNumFrames ); QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); if( windowsList.size() == minNumFrames && windowsList.size() == maxNumFrames ) { - for( Int i = 0; i < windowsList.size(); i++ ) + for( int i = 0; i < windowsList.size(); i++ ) { videoSubWindowList.append( qobject_cast( windowsList.at( i ) ) ); } @@ -305,7 +305,7 @@ Void ModulesHandle::activateModule() { if( windowsList.size() <= minNumFrames ) { - for( Int i = 0; i < windowsList.size(); i++ ) + for( int i = 0; i < windowsList.size(); i++ ) { dialogWindowsSelection.selectSubWindow( windowsList.at( i ) ); } @@ -318,22 +318,22 @@ Void ModulesHandle::activateModule() { VideoSubWindow* videoSubWindow; QList subWindowList = dialogWindowsSelection.getSelectedWindows(); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); videoSubWindowList.append( videoSubWindow ); } } } - if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_1 ) + if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_1 ) { // Check for same fmt in more than one frame modules - for( Int i = 1; i < videoSubWindowList.size(); i++ ) + for( int i = 1; i < videoSubWindowList.size(); i++ ) { if( !videoSubWindowList.at( i )->getCurrFrame()->haveSameFmt( videoSubWindowList.at( 0 )->getCurrFrame() ) ) { videoSubWindowList.clear(); - qobject_cast( m_pcParent )->printMessage( "Error! Incompatible frames", LOG_ERROR ); + qobject_cast( m_pcParent )->printMessage( "Error! Incompatible frames", CLP_LOG_ERROR ); destroyModuleIf( pcCurrAppModuleIf ); return; } @@ -347,36 +347,36 @@ Void ModulesHandle::activateModule() if( videoSubWindowList.size() == 0 ) { - qobject_cast( m_pcParent ) - ->printMessage( "Error! There is no windows to apply the module", LOG_ERROR ); + qobject_cast( m_pcParent ) + ->printMessage( "Error! There is no windows to apply the module", CLP_LOG_ERROR ); destroyModuleIf( pcCurrAppModuleIf ); return; } - for( Int i = 0; i < videoSubWindowList.size(); i++ ) + for( int i = 0; i < videoSubWindowList.size(); i++ ) { pcCurrAppModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i ); } - if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_OPTIONS ) + if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_OPTIONS ) { ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrAppModuleIf ); if( moduleOptDialog.runConfiguration() == QDialog::Rejected ) { - qobject_cast( m_pcParent )->printMessage( "Module canceled by user!", LOG_WARNINGS ); + qobject_cast( m_pcParent )->printMessage( "Module canceled by user!", CLP_LOG_WARNINGS ); destroyModuleIf( pcCurrAppModuleIf ); return; } } - Bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() | bTmpForceNewWindow; + bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() | bTmpForceNewWindow; QString windowName; VideoSubWindow* pcModuleSubWindow = NULL; - if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) + if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { - if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) + if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) { pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW ); windowName.append( QStringLiteral( "Module " ) ); @@ -390,7 +390,7 @@ Void ModulesHandle::activateModule() // SLOT( moveAllScrollBars( const QPoint ) ) ); } } - else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) + else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE ) { pcCurrAppModuleIf->m_pcDisplaySubWindow = NULL; pcCurrAppModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrAppModuleIf ); @@ -414,24 +414,24 @@ Void ModulesHandle::activateModule() { if( pcCurrAppModuleIf->m_pcDisplaySubWindow ) pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrAppModuleIf ); - for( Int i = 0; i < videoSubWindowList.size(); i++ ) + for( int i = 0; i < videoSubWindowList.size(); i++ ) { pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf ); } } // Create Module - Bool moduleCreated = false; - if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_2 ) + bool moduleCreated = false; + if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 ) { - std::vector apcFrameList; - for( Int i = 0; i < videoSubWindowList.size(); i++ ) + std::vector apcFrameList; + for( int i = 0; i < videoSubWindowList.size(); i++ ) { apcFrameList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrFrame() ); } moduleCreated = pcCurrAppModuleIf->m_pcModule->create( apcFrameList ); } - else if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_1 ) + else if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_1 ) { pcCurrAppModuleIf->m_pcModule->create( pcCurrAppModuleIf->m_pcSubWindow[0]->getCurrFrame() ); moduleCreated = true; @@ -439,7 +439,7 @@ Void ModulesHandle::activateModule() if( !moduleCreated ) { - qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be created", LOG_ERROR ); + qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be created", CLP_LOG_ERROR ); destroyModuleIf( pcCurrAppModuleIf ); return; } @@ -462,12 +462,12 @@ Void ModulesHandle::activateModule() videoSubWindowList.at( 0 )->setWindowName( windowName ); } - m_pcPlaYUVerAppModuleIfList.append( pcCurrAppModuleIf ); + m_pcCalypAppModuleIfList.append( pcCurrAppModuleIf ); emit changed(); } -Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) +void ModulesHandle::destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf ) { if( pcCurrModuleIf ) { @@ -475,7 +475,7 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) } } -Void ModulesHandle::destroyWindowModules() +void ModulesHandle::destroyWindowModules() { VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcVideoSubWindow ) @@ -485,44 +485,44 @@ Void ModulesHandle::destroyWindowModules() } } -Void ModulesHandle::destroyAllModulesIf() +void ModulesHandle::destroyAllModulesIf() { - for( Int i = 0; i < m_pcPlaYUVerAppModuleIfList.size(); i++ ) + for( int i = 0; i < m_pcCalypAppModuleIfList.size(); i++ ) { - destroyModuleIf( m_pcPlaYUVerAppModuleIfList.at( i ) ); + destroyModuleIf( m_pcCalypAppModuleIfList.at( i ) ); } emit changed(); } -Void ModulesHandle::applyModuleIf( QList pcCurrModuleIfList, Bool isPlaying, Bool disableThreads ) +void ModulesHandle::applyModuleIf( QList pcCurrModuleIfList, bool isPlaying, bool disableThreads ) { - for( Int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ ) + for( int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ ) { pcCurrModuleIfList.at( i )->apply( isPlaying, disableThreads ); } } -Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) +void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf ) { if( pcCurrModuleIf ) { if( !pcCurrModuleIf->m_pcModuleStream ) { - UInt Width = 0, Height = 0, FrameRate = 30; - Int BitsPixel, InputFormat = -1; + unsigned int Width = 0, Height = 0, FrameRate = 30; + int BitsPixel, InputFormat = -1; QString supported = tr( "Supported Files (" ); QStringList formatsList; - std::vector supportedFmts = PlaYUVerStream::supportedWriteFormats(); + std::vector supportedFmts = CalypStream::supportedWriteFormats(); - for( UInt i = 0; i < supportedFmts.size(); i++ ) + for( unsigned int i = 0; i < supportedFmts.size(); i++ ) { - std::vector arrayExt = supportedFmts[i].getExts(); + std::vector arrayExt = supportedFmts[i].getExts(); if( arrayExt.size() > 0 ) { QString currFmt( QString::fromStdString( supportedFmts[i].formatName ) ); currFmt.append( " (" ); - for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) + for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) { supported.append( " *." ); currFmt.append( "*." ); @@ -549,9 +549,9 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel(); FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate(); - pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream; + pcCurrModuleIf->m_pcModuleStream = new CalypStream; if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, - PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) ) + CLP_LITTLE_ENDIAN, FrameRate, false ) ) { delete pcCurrModuleIf->m_pcModuleStream; pcCurrModuleIf->m_pcModuleStream = NULL; @@ -561,10 +561,10 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) } if( pcCurrModuleIf->m_pcModuleStream ) { - UInt numberOfWindows = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; - UInt64 currFrames = 0; - UInt64 numberOfFrames = INT_MAX; - for( UInt i = 0; i < numberOfWindows; i++ ) + unsigned int numberOfWindows = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; + unsigned long long int currFrames = 0; + unsigned long long int numberOfFrames = INT_MAX; + for( unsigned int i = 0; i < numberOfWindows; i++ ) { currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getInputStream()->getFrameNum(); if( currFrames < numberOfFrames ) @@ -572,18 +572,18 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) pcCurrModuleIf->m_pcSubWindow[i]->stop(); } QApplication::setOverrideCursor( Qt::WaitCursor ); - for( UInt f = 1; f < numberOfFrames; f++ ) + for( unsigned int f = 1; f < numberOfFrames; f++ ) { pcCurrModuleIf->apply( false, true ); QCoreApplication::processEvents(); pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame ); - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->play(); pcCurrModuleIf->m_pcSubWindow[i]->playEvent(); } } - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->stop(); } @@ -591,9 +591,9 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) } } -Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) +void ModulesHandle::swapModulesWindowsIf( CalypAppModuleIf* pcCurrModuleIf ) { - if( pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames == MODULE_REQUIRES_TWO_FRAMES ) + if( pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames == 2 ) { VideoSubWindow* auxWindowHandle = pcCurrModuleIf->m_pcSubWindow[0]; pcCurrModuleIf->m_pcSubWindow[0] = pcCurrModuleIf->m_pcSubWindow[1]; @@ -602,13 +602,13 @@ Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf* pcCurrModuleIf ) } } -Void ModulesHandle::customEvent( QEvent* event ) +void ModulesHandle::customEvent( QEvent* event ) { if( !event ) { return; } - PlaYUVerAppModuleIf::EventData* eventData = (PlaYUVerAppModuleIf::EventData*)event; + CalypAppModuleIf::EventData* eventData = (CalypAppModuleIf::EventData*)event; if( eventData->m_bSuccess ) { eventData->m_pcModule->show(); diff --git a/app/ModulesHandle.h b/app/ModulesHandle.h index 38717a0..5dfa51c 100644 --- a/app/ModulesHandle.h +++ b/app/ModulesHandle.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,7 +18,7 @@ */ /** * \file ModulesHandle.h - * \brief PlaYUVer modules handle + * \brief Calyp modules handle */ #ifndef __MODULESHANDLE_H__ @@ -31,38 +31,38 @@ #include #include -#include "PlaYUVerAppDefs.h" -#include "PlaYUVerAppModuleIf.h" -#include "lib/PlaYUVerFrame.h" +#include "CalypAppModuleIf.h" +#include "CommonDefs.h" +#include "lib/CalypFrame.h" class VideoHandle; -class PlaYUVerSubWindowHandle; -class PlaYUVerAppModuleIf; +class SubWindowHandle; +class CalypAppModuleIf; class SubWindowHandle; class ModulesHandle : public QWidget { Q_OBJECT public: - ModulesHandle( QWidget*, PlaYUVerSubWindowHandle*, VideoHandle* ); + ModulesHandle( QWidget*, SubWindowHandle*, VideoHandle* ); ~ModulesHandle(); - Void createActions(); + void createActions(); QMenu* createMenu(); // QDockWidget* createDock(); - Void buildMenu(); - Void updateMenus(); + void buildMenu(); + void updateMenus(); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); - static Void destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ); - static Void applyModuleIf( QList pcCurrModuleIfList, Bool isPlaying = false, - Bool disableThreads = false ); + static void destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf ); + static void applyModuleIf( QList pcCurrModuleIfList, bool isPlaying = false, + bool disableThreads = false ); private: QWidget* m_pcParent; - PlaYUVerSubWindowHandle* m_pcMainWindowManager; + SubWindowHandle* m_pcMainWindowManager; VideoHandle* m_appModuleVideo; enum @@ -74,7 +74,7 @@ private: QMenu* m_pcModulesMenu; QList m_pcModulesSubMenuList; - QList m_pcPlaYUVerAppModuleIfList; + QList m_pcCalypAppModuleIfList; QVector m_arrayModulesActions; @@ -92,11 +92,11 @@ private: QVector m_arrayActions; QSignalMapper* m_pcActionMapper; - Void enableModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ); - Void applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ); - Void swapModulesWindowsIf( PlaYUVerAppModuleIf* pcCurrModuleIf ); + void enableModuleIf( CalypAppModuleIf* pcCurrModuleIf ); + void applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf ); + void swapModulesWindowsIf( CalypAppModuleIf* pcCurrModuleIf ); - Void customEvent( QEvent* event ); + void customEvent( QEvent* event ); Q_SIGNALS: void changed(); diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 07363d0..8af1e6b 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,7 +27,7 @@ #include "qcustomplot.h" //#include "external/qcustomplot/qcustomplot.h" -Void PlotSubWindow::definePlotColors() +void PlotSubWindow::definePlotColors() { m_arrayColorList.append( Qt::blue ); m_arrayColorList.append( Qt::red ); @@ -121,7 +121,7 @@ PlotSubWindow::~PlotSubWindow() delete m_cPlotArea; } -Void PlotSubWindow::normalSize() +void PlotSubWindow::normalSize() { m_cPlotArea->xAxis->setRange( m_aAxisRange[HORIZONTAL][0], m_aAxisRange[HORIZONTAL][1] ); m_cPlotArea->yAxis->setRange( m_aAxisRange[VERTICAL][0], m_aAxisRange[VERTICAL][1] ); @@ -129,14 +129,14 @@ Void PlotSubWindow::normalSize() m_dScaleFactor = 1; } -Void PlotSubWindow::zoomToFit() +void PlotSubWindow::zoomToFit() { normalSize(); } -Void PlotSubWindow::zoomToFactor( Double factor, QPoint center ) {} +void PlotSubWindow::zoomToFactor( double factor, QPoint center ) {} -Void PlotSubWindow::scaleView( Double scale, QPoint center ) +void PlotSubWindow::scaleView( double scale, QPoint center ) { scale -= 1; scale /= 10; @@ -144,9 +144,9 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center ) m_dScaleFactor *= scale; // - // UInt aNewAxisRange[2][2]; - // for( UInt axis = 0; axis < 2; axis++ ) - // for( UInt dim = 0; dim < 2; dim++ ) + // unsigned int aNewAxisRange[2][2]; + // for( unsigned int axis = 0; axis < 2; axis++ ) + // for( unsigned int dim = 0; dim < 2; dim++ ) // aNewAxisRange[axis][dim] = m_aAxisRange[axis][dim] / m_dScaleFactor; // // m_cPlotArea->xAxis->setRange( aNewAxisRange[HORIZONTAL][0], @@ -179,19 +179,19 @@ QSize PlotSubWindow::sizeHint( const QSize& maxSize ) const return maxSize * 2 / 3; } -Void PlotSubWindow::setAxisName( const QString& nameAxisX, const QString& nameAxisY ) +void PlotSubWindow::setAxisName( const QString& nameAxisX, const QString& nameAxisY ) { m_cPlotArea->xAxis->setLabel( nameAxisX ); m_cPlotArea->yAxis->setLabel( nameAxisY ); } -Void PlotSubWindow::setAxisRange( const QLine& axisLimits ) +void PlotSubWindow::setAxisRange( const QLine& axisLimits ) { setAxisRange( HORIZONTAL, axisLimits.x1(), axisLimits.x2() ); setAxisRange( VERTICAL, axisLimits.y1(), axisLimits.y2() ); } -Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd ) +void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const int& axisStart, const int& axisEnd ) { if( eAxis == HORIZONTAL ) { @@ -210,7 +210,7 @@ Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStar m_cPlotArea->replot(); } -Void PlotSubWindow::addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key ) +void PlotSubWindow::addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key ) { QCPGraph* newPlot = m_cPlotArea->addGraph(); QColor plotColor = m_arrayColorList.at( 0 ); diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index 5678575..52c9d2b 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,7 +25,7 @@ #ifndef __PLOTWINDOWHANDLE_H__ #define __PLOTWINDOWHANDLE_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "SubWindowAbstract.h" #include "config.h" @@ -48,40 +48,40 @@ private: HORIZONTAL, VERTICAL, }; - Double m_aAxisRange[2][2]; - Double m_dScaleFactor; - Int m_iNumberPlots; + double m_aAxisRange[2][2]; + double m_dScaleFactor; + int m_iNumberPlots; public: PlotSubWindow( const QString& windowTitle, QWidget* parent = NULL ); ~PlotSubWindow(); - Void definePlotColors(); + void definePlotColors(); - Void refreshSubWindow() {} + void refreshSubWindow() {} /** * Virtual functions from SubWindowAbstract */ - Void normalSize(); - Void zoomToFit(); - Void zoomToFactor( Double factor, QPoint center = QPoint() ); - Void scaleView( Double scale, QPoint center = QPoint() ); + void normalSize(); + void zoomToFit(); + void zoomToFactor( double factor, QPoint center = QPoint() ); + void scaleView( double scale, QPoint center = QPoint() ); - Double getScaleFactor() { return m_dScaleFactor; } + double getScaleFactor() { return m_dScaleFactor; } /** * Size related functions */ QSize sizeHint() const; QSize sizeHint( const QSize& ) const; - Void setAxisName( const QString& nameAxisX, const QString& nameAxisY ); + void setAxisName( const QString& nameAxisX, const QString& nameAxisY ); - Void setAxisRange( const QLine& axisLimits ); - Void setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd ); + void setAxisRange( const QLine& axisLimits ); + void setAxisRange( PlotSubWindow::Axis eAxis, const int& axisStart, const int& axisEnd ); - Void setKey( const QString& key ); + void setKey( const QString& key ); - Void addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key = QString() ); + void addPlot( const QVector& arrayX, const QVector& arrayY, const QString& key = QString() ); }; #endif // __PLOTWINDOWHANDLE_H__ diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 39e64ac..d44a39c 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,24 +24,24 @@ #include "QualityHandle.h" -#include "DialogSubWindowSelector.h" -#include "PlaYUVerSubWindowHandle.h" #include "PlotSubWindow.h" #include "ProgressBar.h" +#include "SubWindowHandle.h" +#include "SubWindowSelectorDialog.h" #include "VideoSubWindow.h" #include "lib/LibMemory.h" #include #include "QtConcurrent/qtconcurrentrun.h" -QualityHandle::QualityHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager ) +QualityHandle::QualityHandle( QWidget* parent, SubWindowHandle* windowManager ) : m_pcParet( parent ), m_pcMainWindowManager( windowManager ) { } QualityHandle::~QualityHandle() {} -Void QualityHandle::createActions() +void QualityHandle::createActions() { m_actionGroupQualityMetric = new QActionGroup( this ); m_actionGroupQualityMetric->setExclusive( true ); @@ -49,9 +49,9 @@ Void QualityHandle::createActions() m_mapperQualityMetric = new QSignalMapper( this ); QAction* currAction; - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ ) { - currAction = new QAction( PlaYUVerFrame::supportedQualityMetricsList()[i].c_str(), this ); + currAction = new QAction( CalypFrame::supportedQualityMetricsList()[i].c_str(), this ); currAction->setCheckable( true ); m_actionGroupQualityMetric->addAction( currAction ); connect( currAction, SIGNAL( triggered() ), m_mapperQualityMetric, SLOT( map() ) ); @@ -97,12 +97,12 @@ QDockWidget* QualityHandle::createDock() return m_pcQualityHandleDock; } -Void QualityHandle::updateMenus() +void QualityHandle::updateMenus() { VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); - Bool hasSubWindow = pcCurrentVideoSubWindow ? true : false; - Bool hasReference = false; - Bool isReference = false; + bool hasSubWindow = pcCurrentVideoSubWindow ? true : false; + bool hasReference = false; + bool isReference = false; if( hasSubWindow ) { @@ -112,7 +112,7 @@ Void QualityHandle::updateMenus() VideoSubWindow* pcVideoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); if( pcVideoSubWindow->getRefSubWindow() == pcCurrentVideoSubWindow ) @@ -133,36 +133,36 @@ Void QualityHandle::updateMenus() m_pcQualityHandleSideBar->updateSideBar( hasSubWindow ); } -Void QualityHandle::readSettings() +void QualityHandle::readSettings() { QSettings appSettings; - Int metric = appSettings.value( "QualityHandle/Metric", 0 ).toInt(); + int metric = appSettings.value( "QualityHandle/Metric", 0 ).toInt(); slotQualityMetricChanged( metric ); if( !appSettings.value( "QualityHandle/QualitySideBar", true ).toBool() ) m_pcQualityHandleDock->close(); } -Void QualityHandle::writeSettings() +void QualityHandle::writeSettings() { QSettings appSettings; appSettings.setValue( "QualityHandle/Metric", m_iQualityMetricIdx ); appSettings.setValue( "QualityHandle/QualitySideBar", m_pcQualityHandleDock->isVisible() ); } -Void QualityHandle::update( VideoSubWindow* currSubWindow ) +void QualityHandle::update( VideoSubWindow* currSubWindow ) { m_pcQualityHandleSideBar->updateCurrentWindow( currSubWindow ); } -Void QualityHandle::measureQuality( QVector apcWindowList ) +void QualityHandle::measureQuality( QVector apcWindowList ) { - QVector* padQualityValues; - UInt numberOfWindows = apcWindowList.size(); - UInt64 currFrames = 0; - UInt64 numberOfFrames = INT_MAX; + QVector* padQualityValues; + unsigned int numberOfWindows = apcWindowList.size(); + unsigned long long int currFrames = 0; + unsigned long long int numberOfFrames = INT_MAX; //! Check reference window - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { if( !apcWindowList.at( i )->getRefSubWindow() ) { @@ -172,7 +172,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow(); numberOfFrames = pcReferenceWindow->getInputStream()->getFrameNum(); - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum(); if( currFrames < numberOfFrames ) @@ -183,24 +183,24 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames ); - padQualityValues = new QVector[numberOfWindows + 1]; + padQualityValues = new QVector[numberOfWindows + 1]; - PlaYUVerFrame* pcReferenceFrame; - PlaYUVerFrame* pcCurrFrame; - for( UInt f = 0; f < numberOfFrames; f++ ) + CalypFrame* pcReferenceFrame; + CalypFrame* pcCurrFrame; + for( unsigned int f = 0; f < numberOfFrames; f++ ) { padQualityValues[0].append( f ); pcReferenceFrame = pcReferenceWindow->getCurrFrame(); - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { pcCurrFrame = apcWindowList.at( i )->getCurrFrame(); - padQualityValues[i + 1].append( pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, LUMA ) ); + padQualityValues[i + 1].append( pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, CLP_LUMA ) ); apcWindowList.at( i )->seekRelativeEvent( true ); } pcReferenceWindow->seekRelativeEvent( true ); pcProgressBar->incrementProgress( 1 ); } - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { apcWindowList.at( i )->stop(); } @@ -213,12 +213,12 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) } PlotSubWindow* pcPlotWindow = new PlotSubWindow( plotWindowTitle ); pcPlotWindow->setAxisName( - "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) ); + "Frame Number", QString::fromStdString( CalypFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) ); if( apcWindowList.size() > 1 ) { QString key; - for( UInt i = 0; i < numberOfWindows; i++ ) + for( unsigned int i = 0; i < numberOfWindows; i++ ) { key = apcWindowList.at( i )->getWindowName(); pcPlotWindow->addPlot( padQualityValues[0], padQualityValues[i + 1], key ); @@ -235,7 +235,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) pcProgressBar->close(); } -Void QualityHandle::slotQualityMetricChanged( Int idx ) +void QualityHandle::slotQualityMetricChanged( int idx ) { m_actionGroupQualityMetric->actions().at( idx )->setChecked( true ); m_pcQualityHandleSideBar->updateQualityMetric( idx ); @@ -243,7 +243,7 @@ Void QualityHandle::slotQualityMetricChanged( Int idx ) m_iQualityMetricIdx = idx; } -Void QualityHandle::slotSelectCurrentAsReference() +void QualityHandle::slotSelectCurrentAsReference() { VideoSubWindow* pcRefSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcRefSubWindow ) @@ -251,7 +251,7 @@ Void QualityHandle::slotSelectCurrentAsReference() VideoSubWindow* pcVideoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); if( pcVideoSubWindow != pcRefSubWindow ) @@ -263,7 +263,7 @@ Void QualityHandle::slotSelectCurrentAsReference() } } -Void QualityHandle::slotPlotQualitySingle() +void QualityHandle::slotPlotQualitySingle() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcSubWindow ) @@ -287,7 +287,7 @@ Void QualityHandle::slotPlotQualitySingle() } } -Void QualityHandle::slotPlotQualitySeveral() +void QualityHandle::slotPlotQualitySeveral() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcSubWindow ) @@ -303,7 +303,7 @@ Void QualityHandle::slotPlotQualitySeveral() VideoSubWindow* pcVideoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); if( pcVideoSubWindow->getRefSubWindow() == pcRefSubWindow ) diff --git a/app/QualityHandle.h b/app/QualityHandle.h index 92902b6..157db43 100644 --- a/app/QualityHandle.h +++ b/app/QualityHandle.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,34 +27,34 @@ #include #include -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "QFuture" #include "QualityMeasurementSidebar.h" #include "config.h" -class PlaYUVerSubWindowHandle; +class SubWindowHandle; class VideoSubWindow; class QualityHandle : public QWidget { Q_OBJECT public: - QualityHandle( QWidget*, PlaYUVerSubWindowHandle* ); + QualityHandle( QWidget*, SubWindowHandle* ); ~QualityHandle(); - Void createActions(); + void createActions(); QMenu* createMenu(); QDockWidget* createDock(); - Void updateMenus(); + void updateMenus(); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); - Void update( VideoSubWindow* currSubWindow ); + void update( VideoSubWindow* currSubWindow ); private: QWidget* m_pcParet; - PlaYUVerSubWindowHandle* m_pcMainWindowManager; + SubWindowHandle* m_pcMainWindowManager; enum { @@ -66,7 +66,7 @@ private: QVector m_arrayActions; QActionGroup* m_actionGroupQualityMetric; QSignalMapper* m_mapperQualityMetric; - Int m_iQualityMetricIdx; + int m_iQualityMetricIdx; QMenu* m_pcMenuQuality; QMenu* m_pcSubMenuQualityMetrics; @@ -74,8 +74,8 @@ private: QDockWidget* m_pcQualityHandleDock; QualityMeasurementSidebar* m_pcQualityHandleSideBar; - QFuture m_cMeasurementResult; - Void measureQuality( QVector apcWindowList ); + QFuture m_cMeasurementResult; + void measureQuality( QVector apcWindowList ); Q_SIGNALS: void changed(); diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp index 0073b26..f44c90a 100644 --- a/app/SubWindowAbstract.cpp +++ b/app/SubWindowAbstract.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,7 +24,7 @@ #include "SubWindowAbstract.h" -#include "PlaYUVerMdiSubWindow.h" +#include "MdiSubWindow.h" #include #include @@ -32,7 +32,7 @@ #include #include -SubWindowAbstract::SubWindowAbstract( QWidget* parent, UInt category ) +SubWindowAbstract::SubWindowAbstract( QWidget* parent, unsigned int category ) : QWidget( parent ), m_cSubWindow( NULL ) { setParent( parent ); @@ -42,7 +42,7 @@ SubWindowAbstract::SubWindowAbstract( QWidget* parent, UInt category ) setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Background ); - setWindowIcon( QIcon( ":/images/playuver.png" ) ); + setWindowIcon( QIcon( ":/logos/calyp-icon.png" ) ); // setWidgetResizable( true ); m_pcLayout = NULL; @@ -57,7 +57,7 @@ SubWindowAbstract::~SubWindowAbstract() return; } -Void SubWindowAbstract::setWidget( QWidget* widget ) +void SubWindowAbstract::setWidget( QWidget* widget ) { QGridLayout* layout = new QGridLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); @@ -69,7 +69,7 @@ void SubWindowAbstract::onDestroyed() return; } -Void SubWindowAbstract::setWindowName( QString name ) +void SubWindowAbstract::setWindowName( QString name ) { m_cWindowName = name; setWindowTitle( m_cWindowName ); @@ -80,7 +80,7 @@ QString SubWindowAbstract::getWindowName() return m_cWindowName; } -Bool SubWindowAbstract::mayClose() +bool SubWindowAbstract::mayClose() { return true; } @@ -95,18 +95,18 @@ QSize SubWindowAbstract::sizeHint( const QSize& ) const return QSize(); } -Void SubWindowAbstract::focusInEvent( QFocusEvent* event ) +void SubWindowAbstract::focusInEvent( QFocusEvent* event ) { emit aboutToActivate( this ); } -Void SubWindowAbstract::closeEvent( QCloseEvent* event ) +void SubWindowAbstract::closeEvent( QCloseEvent* event ) { emit aboutToClose( this ); event->accept(); } -Void SubWindowAbstract::closeSubWindow() +void SubWindowAbstract::closeSubWindow() { close(); if( m_cSubWindow ) diff --git a/app/SubWindowAbstract.h b/app/SubWindowAbstract.h index 2baa016..c5aaa22 100644 --- a/app/SubWindowAbstract.h +++ b/app/SubWindowAbstract.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,14 +19,14 @@ /** * \file SubWindowAbstract.h - * \ingroup PlaYUVerApp PlaYUVerApp_Subwindow + * \ingroup CalypApp CalypApp_Subwindow * \brief Abstract class to handle subwindows * - * @defgroup PlaYUVerApp_Subwindow SubWindow definition + * @defgroup CalypApp_Subwindow SubWindow definition * @{ - * \ingroup PlaYUVerApp + * \ingroup CalypApp * - * Different SubWindow may be found in the PlaYUVerApp + * Different SubWindow may be found in the CalypApp * Each one provide different functionality and serve * different purposes, ( e.g., displaying a video stream * or displaying a quality plot) @@ -41,14 +41,14 @@ #include #include #include -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" class QHBoxLayout; class QFocusEvent; class QCloseEvent; -class PlaYUVerMdiSubWindow; +class MdiSubWindow; class SubWindowAbstract : public QWidget { @@ -56,10 +56,10 @@ class SubWindowAbstract : public QWidget private: QHBoxLayout* m_pcLayout; - UInt m_uiCategory; + unsigned int m_uiCategory; QString m_cWindowName; - PlaYUVerMdiSubWindow* m_cSubWindow; + MdiSubWindow* m_cSubWindow; public: enum SubWindowCategory @@ -72,35 +72,35 @@ public: }; Q_DECLARE_FLAGS( SubWindowCategories, SubWindowCategory ) - SubWindowAbstract( QWidget*, UInt ); + SubWindowAbstract( QWidget*, unsigned int ); ~SubWindowAbstract(); /** * Show the image at its original size */ - virtual Void refreshSubWindow() = 0; + virtual void refreshSubWindow() = 0; /** * Show the image at its original size */ - virtual Void normalSize() = 0; + virtual void normalSize() = 0; /** * Scale the image (zoomed in or out) to fit on the window. */ - virtual Void zoomToFit() = 0; + virtual void zoomToFit() = 0; /** * Scale the image (zoomed in or out) to speficied absolute zoom value (1.0 = * original size). */ - virtual Void zoomToFactor( Double factor, QPoint center = QPoint() ) = 0; + virtual void zoomToFactor( double factor, QPoint center = QPoint() ) = 0; /** * Scale the image by a given factor * @param factor factor of scale. Ex: 1.2 scale the image up by 20% and * 0.8 scale the image down by 25% */ - virtual Void scaleView( Double, QPoint center = QPoint() ) = 0; + virtual void scaleView( double, QPoint center = QPoint() ) = 0; - virtual Double getScaleFactor() = 0; + virtual double getScaleFactor() = 0; /** * Size related functions @@ -112,10 +112,10 @@ public: * Window name */ - Void setWindowName( QString ); + void setWindowName( QString ); QString getWindowName(); - virtual Bool mayClose(); + virtual bool mayClose(); /** * Get category of the SubWindow @@ -123,22 +123,22 @@ public: * @note This function should be used with enum SubWindowCategories * with an & operation and it may belong to several categories */ - UInt getCategory() { return m_uiCategory; } + unsigned int getCategory() { return m_uiCategory; } /** * Check category of the SubWindow * @param checkCateory SubWindow category to check against; * it should be enum SubWindowCategories type * @return true when SubWindow belong to checkCateory */ - Bool checkCategory( UInt checkCateory ) { return m_uiCategory & checkCateory; } - Void setSubWindow( PlaYUVerMdiSubWindow* subWindow ) { m_cSubWindow = subWindow; } - Void closeSubWindow(); + bool checkCategory( unsigned int checkCateory ) { return m_uiCategory & checkCateory; } + void setSubWindow( MdiSubWindow* subWindow ) { m_cSubWindow = subWindow; } + void closeSubWindow(); protected: void focusInEvent( QFocusEvent* event ); virtual void closeEvent( QCloseEvent* event ); - Void setWidget( QWidget* widget ); + void setWidget( QWidget* widget ); Q_SIGNALS: /** diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/SubWindowHandle.cpp similarity index 82% rename from app/PlaYUVerSubWindowHandle.cpp rename to app/SubWindowHandle.cpp index babfd04..6ec0be7 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * Joao Santos (joaompssantos@gmail.com) @@ -19,14 +19,14 @@ */ /** - * \file PlaYUVerSubWindowHandle.cpp + * \file SubWindowHandle.cpp * \brief Handle multiple sub-windows */ -#include "PlaYUVerSubWindowHandle.h" +#include "SubWindowHandle.h" -#include "PlaYUVerApp.h" -#include "PlaYUVerMdiSubWindow.h" +#include "MainWindow.h" +#include "MdiSubWindow.h" #include "SubWindowAbstract.h" #include @@ -41,16 +41,16 @@ #include #include -class PlaYUVerMdiArea : public QMdiArea +class MdiArea : public QMdiArea { public: - PlaYUVerMdiArea( QWidget* parent = 0 ) - : QMdiArea( parent ), m_pixmapLogo( ":/images/playuver-background-logo.png" ) + MdiArea( QWidget* parent = 0 ) + : QMdiArea( parent ), m_pixmapLogo( ":/logos/calyp-logo.png" ) { setBackgroundRole( QPalette::Background ); } - Void appendLogMessage( const QString& msg ) + void appendLogMessage( const QString& msg ) { m_acLogMessages.push_front( msg ); if( m_acLogMessages.size() > 5 ) @@ -63,13 +63,13 @@ protected: { QMdiArea::paintEvent( event ); QPainter painter( viewport() ); - QPixmap pixFinalLogo = m_pixmapLogo.scaled( 2 * size() / 3, Qt::KeepAspectRatio ); + QPixmap pixFinalLogo = m_pixmapLogo.scaled( 2 * size() / 5, Qt::KeepAspectRatio ); // Calculate the logo position - the bottom right corner of the mdi area. int x = width() / 2 - pixFinalLogo.width() / 2; int y = height() / 2 - pixFinalLogo.height() / 2; painter.drawPixmap( x, y, pixFinalLogo ); - // for( Int i = 0; i < m_acLogMessages.size(); i++ ) + // for( int i = 0; i < m_acLogMessages.size(); i++ ) // { // painter.drawText( 5, height() - 5 - i * 15, m_acLogMessages.at( i ) // ); @@ -82,7 +82,7 @@ private: QPixmap m_pixmapLogo; }; -PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget* parent ) +SubWindowHandle::SubWindowHandle( QWidget* parent ) : QWidget( parent ) { m_iWindowMode = -1; @@ -92,12 +92,12 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget* parent ) m_apcSubWindowList.clear(); m_apcMdiSubWindowList.clear(); - m_pcApp = qobject_cast( parentWidget() ); + m_pcApp = qobject_cast( parentWidget() ); // setWindowMode( DETACHEDSUBWINDOWMODE ); setWindowMode( MDISUBWINDOWMODE ); } -Void PlaYUVerSubWindowHandle::processLogMsg( const QString& msg ) +void SubWindowHandle::processLogMsg( const QString& msg ) { if( m_pcMdiArea ) { @@ -105,7 +105,7 @@ Void PlaYUVerSubWindowHandle::processLogMsg( const QString& msg ) } } -Void PlaYUVerSubWindowHandle::resetWindowMode() +void SubWindowHandle::resetWindowMode() { QList apcSubWindowList = m_apcSubWindowList; @@ -116,14 +116,14 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() { m_cMdiModeWindowPosition = m_pcApp->pos(); m_cMdiModeWindowSize = m_pcApp->size(); - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { m_apcSubWindowList.at( i )->setParent( NULL ); } - for( Int i = 0; i < m_apcMdiSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcMdiSubWindowList.size(); i++ ) { - disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, - SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); + disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( MdiSubWindow* ) ), this, + SLOT( removeMdiSubWindow( MdiSubWindow* ) ) ); m_apcMdiSubWindowList.at( i )->close(); } m_apcMdiSubWindowList.clear(); @@ -135,7 +135,7 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() } } -Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) +void SubWindowHandle::setWindowMode( int iWindowMode ) { if( m_iWindowMode == iWindowMode ) return; @@ -144,7 +144,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) if( iWindowMode == DETACHEDSUBWINDOWMODE ) { - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { m_apcSubWindowList.at( i )->setParent( NULL ); m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() ); @@ -163,13 +163,13 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) if( iWindowMode == MDISUBWINDOWMODE ) { setVisible( true ); - m_pcMdiArea = new PlaYUVerMdiArea; + m_pcMdiArea = new MdiArea; m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); connect( m_pcMdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), this, SLOT( updateActiveSubWindow() ) ); m_pcWindowManagerLayout = new QHBoxLayout( this ); m_pcWindowManagerLayout->addWidget( m_pcMdiArea ); setLayout( m_pcWindowManagerLayout ); - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { addMdiSubWindow( m_apcSubWindowList.at( i ) ); m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() ); @@ -187,7 +187,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) // qApp->processEvents(); } -Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window ) +void SubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window ) { if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { @@ -205,7 +205,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window ) if( mdiSubWindow ) { QWidget* activeWidget = m_pcMdiArea->activeSubWindow()->widget(); - Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) ); + int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) ); if( windowIdx >= 0 ) { m_pcActiveWindow = m_apcSubWindowList.at( windowIdx ); @@ -219,18 +219,18 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window ) } } -Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract* window ) +void SubWindowHandle::addMdiSubWindow( SubWindowAbstract* window ) { - PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow; + MdiSubWindow* mdiSubWindow = new MdiSubWindow; mdiSubWindow->setWidget( window ); m_pcMdiArea->addSubWindow( mdiSubWindow ); m_apcMdiSubWindowList.append( mdiSubWindow ); window->setSubWindow( mdiSubWindow ); - connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, - SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); + connect( mdiSubWindow, SIGNAL( aboutToClose( MdiSubWindow* ) ), this, + SLOT( removeMdiSubWindow( MdiSubWindow* ) ) ); } -Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract* window, Qt::WindowFlags flags ) +void SubWindowHandle::addSubWindow( SubWindowAbstract* window, Qt::WindowFlags flags ) { if( window ) { @@ -251,7 +251,7 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract* window, Qt::Windo } } -Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) +void SubWindowHandle::removeSubWindow( int windowIdx ) { if( windowIdx >= 0 ) { @@ -263,7 +263,7 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) } if( m_iWindowMode == MDISUBWINDOWMODE ) { - PlaYUVerMdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx ); + MdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx ); m_apcMdiSubWindowList.removeAt( windowIdx ); m_pcMdiArea->removeSubWindow( m_apcSubWindowList.at( windowIdx ) ); m_apcSubWindowList.at( windowIdx )->close(); @@ -280,17 +280,17 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) } } -Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowAbstract* window ) +void SubWindowHandle::removeSubWindow( SubWindowAbstract* window ) { removeSubWindow( m_apcSubWindowList.indexOf( window ) ); } -Void PlaYUVerSubWindowHandle::removeMdiSubWindow( PlaYUVerMdiSubWindow* window ) +void SubWindowHandle::removeMdiSubWindow( MdiSubWindow* window ) { removeSubWindow( m_apcMdiSubWindowList.indexOf( window ) ); } -Void PlaYUVerSubWindowHandle::removeAllSubWindow() +void SubWindowHandle::removeAllSubWindow() { while( m_apcSubWindowList.size() > 0 ) { @@ -298,17 +298,17 @@ Void PlaYUVerSubWindowHandle::removeAllSubWindow() } } -Void PlaYUVerSubWindowHandle::removeActiveSubWindow() +void SubWindowHandle::removeActiveSubWindow() { removeSubWindow( m_pcActiveWindow ); } -SubWindowAbstract* PlaYUVerSubWindowHandle::activeSubWindow() const +SubWindowAbstract* SubWindowHandle::activeSubWindow() const { return m_pcActiveWindow; } -QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const +QList SubWindowHandle::findSubWindow( const unsigned int uiCategory ) const { QList apcSubWindowList; if( uiCategory == 0 ) @@ -317,7 +317,7 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiC } else { - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { if( m_apcSubWindowList.at( i )->getCategory() & uiCategory ) apcSubWindowList.append( m_apcSubWindowList.at( i ) ); @@ -326,14 +326,14 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiC return apcSubWindowList; } -QList PlaYUVerSubWindowHandle::findSubWindow( const QString& windowName, - const UInt uiCategory ) const +QList SubWindowHandle::findSubWindow( const QString& windowName, + const unsigned int uiCategory ) const { QList subWindowList = findSubWindow( uiCategory ); QList apcSubWindowList; if( !windowName.isEmpty() ) { - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { if( subWindowList.at( i )->getWindowName() == windowName ) apcSubWindowList.append( subWindowList.at( i ) ); @@ -342,10 +342,10 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const QString& return apcSubWindowList; } -SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstract* subWindow ) const +SubWindowAbstract* SubWindowHandle::findSubWindow( const SubWindowAbstract* subWindow ) const { QList subWindowList = findSubWindow(); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { if( subWindow == subWindowList.at( i ) ) return subWindowList.at( i ); @@ -353,7 +353,7 @@ SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstra return 0; } -Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget* window ) +void SubWindowHandle::setActiveSubWindow( QWidget* window ) { if( !window ) return; @@ -370,16 +370,16 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget* window ) } } -Void PlaYUVerSubWindowHandle::tileSubWindows() +void SubWindowHandle::tileSubWindows() { - UInt numberOfWindows = m_apcSubWindowList.size(); + unsigned int numberOfWindows = m_apcSubWindowList.size(); if( numberOfWindows == 0 ) return; if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { QSize screenSize = QApplication::desktop()->availableGeometry().size(); - UInt minWindowsInRow = 1; + unsigned int minWindowsInRow = 1; while( ( screenSize.width() / minWindowsInRow ) > 500 ) { minWindowsInRow++; @@ -396,12 +396,12 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() { numberOfWindows++; } - UInt numberTillingRows = 1; - UInt numberTillingColumns; + unsigned int numberTillingRows = 1; + unsigned int numberTillingColumns; if( numberOfWindows > minWindowsInRow ) { numberTillingColumns = minWindowsInRow; - for( Int i = numberOfWindows; i > 0; ) + for( int i = numberOfWindows; i > 0; ) { numberTillingRows = ( numberOfWindows + numberTillingColumns - 1 ) / numberTillingColumns; if( numberTillingColumns > numberTillingRows ) @@ -423,7 +423,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() QSize totalWindowsSize( screenSize.width(), screenSize.height() - topLeftCornerWindow.y() ); QSize windowsSize( totalWindowsSize.width() / numberTillingColumns, totalWindowsSize.height() / numberTillingRows ); QPoint windowRelativePos; - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { windowRelativePos.setY( ( i / numberTillingColumns ) * windowsSize.height() ); windowRelativePos.setX( ( i % numberTillingColumns ) * windowsSize.width() ); @@ -437,7 +437,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() } } -Void PlaYUVerSubWindowHandle::cascadeSubWindows() +void SubWindowHandle::cascadeSubWindows() { if( m_iWindowMode == MDISUBWINDOWMODE ) { @@ -445,7 +445,7 @@ Void PlaYUVerSubWindowHandle::cascadeSubWindows() } } -Void PlaYUVerSubWindowHandle::createActions() +void SubWindowHandle::createActions() { m_mapperWindow = new QSignalMapper( this ); connect( m_mapperWindow, SIGNAL( mapped( QWidget* ) ), this, SLOT( setActiveSubWindow( QWidget* ) ) ); @@ -518,7 +518,7 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions[SEPARATOR_ACT]->setSeparator( true ); } -QMenu* PlaYUVerSubWindowHandle::createMenu() +QMenu* SubWindowHandle::createMenu() { m_pcMenuWindow = new QMenu( "&Window", this ); updateMenu(); @@ -526,7 +526,7 @@ QMenu* PlaYUVerSubWindowHandle::createMenu() return m_pcMenuWindow; } -Void PlaYUVerSubWindowHandle::updateMenu() +void SubWindowHandle::updateMenu() { m_pcMenuWindow->clear(); m_pcMenuWindow->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); @@ -542,7 +542,7 @@ Void PlaYUVerSubWindowHandle::updateMenu() // m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] ); // m_pcMenuWindow->addSeparator(); - Int number_windows = m_apcSubWindowList.size(); + int number_windows = m_apcSubWindowList.size(); if( number_windows > 1 ) { m_arrayActions[NEXT_WINDOWS_ACT]->setEnabled( true ); @@ -556,7 +556,7 @@ Void PlaYUVerSubWindowHandle::updateMenu() m_arrayActions[SEPARATOR_ACT]->setVisible( number_windows > 0 ); - for( Int i = 0; i < number_windows; ++i ) + for( int i = 0; i < number_windows; ++i ) { SubWindowAbstract* subWindow = m_apcSubWindowList.at( i ); @@ -577,17 +577,17 @@ Void PlaYUVerSubWindowHandle::updateMenu() } } -Void PlaYUVerSubWindowHandle::readSettings() +void SubWindowHandle::readSettings() { QSettings appSettings; m_cMdiModeWindowPosition = appSettings.value( "SubWindowManager/LastMdiPosition", QPoint( 200, 200 ) ).toPoint(); m_cMdiModeWindowSize = appSettings.value( "SubWindowManager/LastMdiSize", QSize( 500, 400 ) ).toSize(); - Int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MDISUBWINDOWMODE ).toInt(); + int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MDISUBWINDOWMODE ).toInt(); setWindowMode( iWindowMode ); m_actionGroupWindowMode->actions().at( iWindowMode )->setChecked( true ); } -Void PlaYUVerSubWindowHandle::writeSettings() +void SubWindowHandle::writeSettings() { QSettings appSettings; appSettings.setValue( "SubWindowManager/LastMdiPosition", m_cMdiModeWindowPosition ); diff --git a/app/PlaYUVerSubWindowHandle.h b/app/SubWindowHandle.h similarity index 71% rename from app/PlaYUVerSubWindowHandle.h rename to app/SubWindowHandle.h index 6e9f0aa..35344e2 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,14 +18,14 @@ */ /** - * \file PlaYUVerSubWindowHandle.h + * \file SubWindowHandle.h * \brief Handle multiple sub-windows */ -#ifndef __PLAYUVERSUBWINDOWHANDLE_H__ -#define __PLAYUVERSUBWINDOWHANDLE_H__ +#ifndef __SUBWINDOWHANDLE_H__ +#define __SUBWINDOWHANDLE_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include #include @@ -37,33 +37,33 @@ class QHBoxLayout; class QMenu; class QSignalMapper; -class PlaYUVerApp; +class MainWindow; class SubWindowAbstract; -class PlaYUVerMdiArea; -class PlaYUVerMdiSubWindow; +class MdiArea; +class MdiSubWindow; -class PlaYUVerSubWindowHandle : public QWidget +class SubWindowHandle : public QWidget { Q_OBJECT public: - PlaYUVerSubWindowHandle( QWidget* parent ); + SubWindowHandle( QWidget* parent ); - Void processLogMsg( const QString& msg ); + void processLogMsg( const QString& msg ); - Void addSubWindow( SubWindowAbstract* widget, Qt::WindowFlags flags = 0 ); + void addSubWindow( SubWindowAbstract* widget, Qt::WindowFlags flags = 0 ); SubWindowAbstract* activeSubWindow() const; - QList findSubWindow( const UInt uiCategory = 0 ) const; - QList findSubWindow( const QString& aName, const UInt uiCategory = 0 ) const; + QList findSubWindow( const unsigned int uiCategory = 0 ) const; + QList findSubWindow( const QString& aName, const unsigned int uiCategory = 0 ) const; SubWindowAbstract* findSubWindow( const SubWindowAbstract* subWindow ) const; - Void createActions(); + void createActions(); QMenu* createMenu(); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); enum WindowMode { @@ -72,13 +72,13 @@ public: }; private: - PlaYUVerApp* m_pcApp; - Int m_iWindowMode; + MainWindow* m_pcApp; + int m_iWindowMode; QList m_apcSubWindowList; QHBoxLayout* m_pcWindowManagerLayout; - PlaYUVerMdiArea* m_pcMdiArea; - QList m_apcMdiSubWindowList; + MdiArea* m_pcMdiArea; + QList m_apcMdiSubWindowList; SubWindowAbstract* m_pcActiveWindow; @@ -105,18 +105,18 @@ private: QMenu* m_pcMenuWindow; /** - * Internal functions + * internal functions */ - Void addMdiSubWindow( SubWindowAbstract* window ); - Void resetWindowMode(); - Void removeSubWindow( Int windowIdx ); + void addMdiSubWindow( SubWindowAbstract* window ); + void resetWindowMode(); + void removeSubWindow( int windowIdx ); public Q_SLOTS: void setWindowMode( int iWindowMode ); void updateActiveSubWindow( SubWindowAbstract* window = 0 ); void setActiveSubWindow( QWidget* window ); void removeSubWindow( SubWindowAbstract* window ); - void removeMdiSubWindow( PlaYUVerMdiSubWindow* window ); + void removeMdiSubWindow( MdiSubWindow* window ); void removeActiveSubWindow(); void removeAllSubWindow(); void tileSubWindows(); @@ -128,4 +128,4 @@ Q_SIGNALS: void windowActivated(); }; -#endif // __PLAYUVERSUBWINDOWHANDLE_H__ +#endif // __SUBWINDOWHANDLE_H__ diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index dabd158..04dbe05 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,13 +24,13 @@ #include "VideoHandle.h" -#include "DialogSubWindowSelector.h" +#include "FrameNumberWidget.h" #include "FramePropertiesDock.h" -#include "PlaYUVerApp.h" -#include "PlaYUVerSubWindowHandle.h" +#include "MainWindow.h" #include "SeekStreamDialog.h" +#include "SubWindowHandle.h" +#include "SubWindowSelectorDialog.h" #include "VideoSubWindow.h" -#include "WidgetFrameNumber.h" #include #include @@ -43,7 +43,7 @@ #include #endif -VideoHandle::VideoHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager ) +VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager ) : m_pcParet( parent ), m_pcMainWindowManager( windowManager ) { m_pcCurrentVideoSubWindow = NULL; @@ -56,7 +56,7 @@ VideoHandle::VideoHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManage VideoHandle::~VideoHandle() {} -Void VideoHandle::createActions() +void VideoHandle::createActions() { m_arrayActions.resize( TOTAL_ACT ); m_arrayActions[PLAY_ACT] = new QAction( "Play", this ); @@ -201,7 +201,7 @@ QToolBar* VideoHandle::createToolBar() m_toolbarVideo->addWidget( m_pcFrameSlider ); m_toolbarVideo->addAction( m_arrayActions[VIDEO_FORWARD_ACT] ); m_toolbarVideo->addWidget( new QLabel ); - m_pcFrameNumInfo = new WidgetFrameNumber; + m_pcFrameNumInfo = new FrameNumberWidget; m_toolbarVideo->addWidget( m_pcFrameNumInfo ); return m_toolbarVideo; @@ -242,10 +242,10 @@ QWidget* VideoHandle::createStatusBarMessage() return pcStatusBarWidget; } -Void VideoHandle::updateMenus() +void VideoHandle::updateMenus() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); - Bool hasSubWindow = pcSubWindow ? true : false; + bool hasSubWindow = pcSubWindow ? true : false; m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow ); // m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow ); @@ -272,7 +272,7 @@ Void VideoHandle::updateMenus() m_arrayActions[SHOW_GRID_ACT]->setEnabled( hasSubWindow ); } -Void VideoHandle::readSettings() +void VideoHandle::readSettings() { QSettings appSettings; m_arrayActions[VIDEO_REPEAT_ACT]->setChecked( appSettings.value( "VideoHandle/Repeat", false ).toBool() ); @@ -284,7 +284,7 @@ Void VideoHandle::readSettings() setTool( m_uiViewTool ); } -Void VideoHandle::writeSettings() +void VideoHandle::writeSettings() { QSettings appSettings; appSettings.setValue( "VideoHandle/Repeat", m_arrayActions[VIDEO_REPEAT_ACT]->isChecked() ); @@ -293,15 +293,15 @@ Void VideoHandle::writeSettings() appSettings.setValue( "VideoHandle/SelectedTool", m_uiViewTool ); } -Void VideoHandle::update() +void VideoHandle::update() { if( m_pcCurrentVideoSubWindow ) { - PlaYUVerStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream(); - PlaYUVerFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); + CalypStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream(); + CalypFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); - Int frame_num = 0; - UInt64 total_frame_num = 1; + int frame_num = 0; + unsigned long long int total_frame_num = 1; m_pcVideoFormatLabel->setText( m_pcCurrentVideoSubWindow->getStreamInformation() ); @@ -325,7 +325,7 @@ Void VideoHandle::update() } if( pcStream && pcFrame->getBitsPel() > 8 ) { - if( pcStream->getEndianess() == PLAYUVER_BIG_ENDIAN ) + if( pcStream->getEndianess() == CLP_BIG_ENDIAN ) { resolution.append( QStringLiteral( " (BE)" ) ); } @@ -367,13 +367,13 @@ Void VideoHandle::update() } } -Void VideoHandle::update( VideoSubWindow* currSubWindow ) +void VideoHandle::update( VideoSubWindow* currSubWindow ) { m_pcCurrentVideoSubWindow = currSubWindow; update(); } -Void VideoHandle::updateSelectionArea( QRect area ) +void VideoHandle::updateSelectionArea( QRect area ) { if( m_pcCurrentVideoSubWindow ) { @@ -381,7 +381,7 @@ Void VideoHandle::updateSelectionArea( QRect area ) } } -Void VideoHandle::addSubWindow( VideoSubWindow* window ) +void VideoHandle::addSubWindow( VideoSubWindow* window ) { window->zoomToFit(); window->getViewArea()->setTool( m_uiViewTool ); @@ -399,13 +399,13 @@ Void VideoHandle::addSubWindow( VideoSubWindow* window ) connect( window->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectionArea( QRect ) ) ); } -Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow ) +void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow ) { VideoSubWindow* videoSubWindow = qobject_cast( subWindow ); if( m_acPlayingSubWindows.contains( videoSubWindow ) ) { - Int pos = m_acPlayingSubWindows.indexOf( videoSubWindow ); + int pos = m_acPlayingSubWindows.indexOf( videoSubWindow ); m_acPlayingSubWindows.at( pos )->stop(); m_acPlayingSubWindows.remove( pos ); if( m_acPlayingSubWindows.size() < 2 ) @@ -415,9 +415,9 @@ Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow ) } } -Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center ) +void VideoHandle::zoomToFactorAll( const double scale, const QPoint center ) { - Double factor; + double factor; if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { @@ -426,7 +426,7 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center ) SubWindowAbstract* subWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { subWindow = subWindowList.at( i ); if( m_pcCurrentVideoSubWindow == subWindow ) @@ -440,7 +440,7 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center ) } #if 0 -Void VideoHandle::moveAllScrollBars( const QPoint& offset ) +void VideoHandle::moveAllScrollBars( const QPoint& offset ) { QPoint newOffset = offset; if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() && m_pcCurrentVideoSubWindow ) @@ -465,7 +465,7 @@ Void VideoHandle::moveAllScrollBars( const QPoint& offset ) if( scrollBar->value() == scrollBar->minimum() && offset.y() < 0 ) newOffset.setY( 0 ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); if( m_pcCurrentVideoSubWindow == videoSubWindow ) @@ -478,14 +478,14 @@ Void VideoHandle::moveAllScrollBars( const QPoint& offset ) } } #else -Void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRatio ) +void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRatio ) { if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() && m_pcCurrentVideoSubWindow ) { VideoSubWindow* videoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); if( m_pcCurrentVideoSubWindow == videoSubWindow ) @@ -499,15 +499,15 @@ Void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa } #endif -UInt64 VideoHandle::getMaxFrameNumber() +unsigned long long int VideoHandle::getMaxFrameNumber() { - UInt currFrames; - UInt64 maxFrames = INT_MAX; + unsigned int currFrames; + unsigned long long int maxFrames = INT_MAX; if( m_pcCurrentVideoSubWindow ) { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum(); if( currFrames < maxFrames ) @@ -522,10 +522,10 @@ UInt64 VideoHandle::getMaxFrameNumber() return maxFrames; } -Void VideoHandle::setTimerStatus() +void VideoHandle::setTimerStatus() { - Bool status = false; - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + bool status = false; + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { status |= m_acPlayingSubWindows.at( i )->isPlaying(); } @@ -563,7 +563,7 @@ Void VideoHandle::setTimerStatus() } } -Void VideoHandle::play() +void VideoHandle::play() { if( !m_pcCurrentVideoSubWindow ) return; @@ -573,11 +573,11 @@ Void VideoHandle::play() if( !m_pcCurrentVideoSubWindow->isPlaying() ) // Not playing { - Double frameRate; - UInt timeInterval; + double frameRate; + unsigned int timeinterval; if( m_acPlayingSubWindows.size() < 2 ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->pause(); } @@ -586,20 +586,20 @@ Void VideoHandle::play() } if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->play(); } frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate(); - timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); - m_pcPlayingTimer->setInterval( timeInterval ); + timeinterval = (unsigned int)( 1000.0 / frameRate + 0.5 ); + m_pcPlayingTimer->setInterval( timeinterval ); } } else { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->pause(); } @@ -614,11 +614,11 @@ Void VideoHandle::play() // update(); } -Void VideoHandle::stop() +void VideoHandle::stop() { if( m_acPlayingSubWindows.size() > 0 ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->stop(); } @@ -636,9 +636,9 @@ Void VideoHandle::stop() m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false ); } -Void VideoHandle::playEvent() +void VideoHandle::playEvent() { - Bool bEndOfSequence = false; + bool bEndOfSequence = false; #if( _CONTROL_PLAYING_TIME_ == 1 ) m_dAverageFps = Double( m_dAverageFps * m_uiNumberPlayedFrames + m_pcPlayControlTimer->elapsed() ) / Double( m_uiNumberPlayedFrames + 1 ); @@ -647,7 +647,7 @@ Void VideoHandle::playEvent() #endif try { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { bEndOfSequence |= m_acPlayingSubWindows.at( i )->playEvent(); } @@ -656,7 +656,7 @@ Void VideoHandle::playEvent() if( !m_arrayActions[VIDEO_REPEAT_ACT]->isChecked() ) stop(); else - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 ); } } @@ -673,16 +673,16 @@ Void VideoHandle::playEvent() emit changed(); } -Void VideoHandle::seekEvent( Int direction ) +void VideoHandle::seekEvent( int direction ) { if( m_pcCurrentVideoSubWindow ) { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - if( !( ( UInt )( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() && + if( !( (unsigned int)( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() && direction > 0 ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->seekRelativeEvent( direction > 0 ? true : false ); } @@ -697,7 +697,7 @@ Void VideoHandle::seekEvent( Int direction ) } } -Void VideoHandle::seekVideo() +void VideoHandle::seekVideo() { if( m_pcCurrentVideoSubWindow ) { @@ -705,19 +705,19 @@ Void VideoHandle::seekVideo() { SeekStreamDialog* dialogSeekVideo = new SeekStreamDialog( m_pcCurrentVideoSubWindow->getInputStream(), m_pcParet ); - Int newFrameNum = dialogSeekVideo->runDialog(); + int newFrameNum = dialogSeekVideo->runDialog(); if( newFrameNum >= 0 ) { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { - m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (UInt)newFrameNum ); + m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)newFrameNum ); } } else { - m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (UInt)newFrameNum ); + m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum ); } emit changed(); } @@ -725,26 +725,26 @@ Void VideoHandle::seekVideo() } } -Void VideoHandle::seekSliderEvent( Int new_frame_num ) +void VideoHandle::seekSliderEvent( int new_frame_num ) { if( m_pcCurrentVideoSubWindow && !m_bIsPlaying ) // TODO: Fix this slot { if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { - m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (UInt)new_frame_num ); + m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)new_frame_num ); } } else { - m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (UInt)new_frame_num ); + m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (unsigned int)new_frame_num ); } emit changed(); } } -Void VideoHandle::videoSelectionButtonEvent() +void VideoHandle::videoSelectionButtonEvent() { VideoSubWindow* videoSubWindow; @@ -753,7 +753,7 @@ Void VideoHandle::videoSelectionButtonEvent() { QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); m_acPlayingSubWindows.append( videoSubWindow ); @@ -761,10 +761,10 @@ Void VideoHandle::videoSelectionButtonEvent() } else { - DialogSubWindowSelector dialogWindowsSelection( m_pcParet, m_pcMainWindowManager, + SubWindowSelectorDialog dialogWindowsSelection( m_pcParet, m_pcMainWindowManager, SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); QStringList cWindowListNames; - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { dialogWindowsSelection.selectSubWindow( m_acPlayingSubWindows.at( i ) ); } @@ -773,7 +773,7 @@ Void VideoHandle::videoSelectionButtonEvent() m_acPlayingSubWindows.clear(); QList selectedSubWindowList = dialogWindowsSelection.getSelectedWindows(); - for( Int i = 0; i < selectedSubWindowList.size(); i++ ) + for( int i = 0; i < selectedSubWindowList.size(); i++ ) { videoSubWindow = qobject_cast( selectedSubWindowList.at( i ) ); m_acPlayingSubWindows.append( videoSubWindow ); @@ -794,7 +794,7 @@ Void VideoHandle::videoSelectionButtonEvent() } if( m_bIsPlaying ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + for( int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->play(); } @@ -806,21 +806,21 @@ Void VideoHandle::videoSelectionButtonEvent() } } -Void VideoHandle::setTool( Int tool ) +void VideoHandle::setTool( int tool ) { m_uiViewTool = tool; actionGroupTools->actions().at( m_uiViewTool )->setChecked( true ); QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { qobject_cast( subWindowList.at( i ) )->getViewArea()->setTool( m_uiViewTool ); } } -Void VideoHandle::toggleGrid( Bool checked ) +void VideoHandle::toggleGrid( bool checked ) { QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { qobject_cast( subWindowList.at( i ) )->getViewArea()->setGridVisible( checked ); } diff --git a/app/VideoHandle.h b/app/VideoHandle.h index f7b9472..bb607e2 100644 --- a/app/VideoHandle.h +++ b/app/VideoHandle.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,7 +25,7 @@ #ifndef __VIDEOHANDLE_H__ #define __VIDEOHANDLE_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" #include @@ -43,37 +43,37 @@ class QLabel; class QSlider; class QElapsedTimer; -class PlaYUVerSubWindowHandle; +class SubWindowHandle; class SubWindowAbstract; class VideoSubWindow; class FramePropertiesDock; -class WidgetFrameNumber; +class FrameNumberWidget; class VideoHandle : public QObject { Q_OBJECT public: - VideoHandle( QWidget*, PlaYUVerSubWindowHandle* ); + VideoHandle( QWidget*, SubWindowHandle* ); ~VideoHandle(); - Void createActions(); + void createActions(); QMenu* createVideoMenu(); QMenu* createImageMenu(); QToolBar* createToolBar(); QDockWidget* createDock(); QWidget* createStatusBarMessage(); - Void updateMenus(); + void updateMenus(); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); - Void update( VideoSubWindow* currSubWindow ); + void update( VideoSubWindow* currSubWindow ); - Void addSubWindow( VideoSubWindow* subWindow ); + void addSubWindow( VideoSubWindow* subWindow ); private: QWidget* m_pcParet; - PlaYUVerSubWindowHandle* m_pcMainWindowManager; + SubWindowHandle* m_pcMainWindowManager; enum { PLAY_ACT, @@ -95,12 +95,12 @@ private: QSignalMapper* m_mapperVideoSeek; QSlider* m_pcFrameSlider; - WidgetFrameNumber* m_pcFrameNumInfo; + FrameNumberWidget* m_pcFrameNumInfo; // Tools Actions; QActionGroup* actionGroupTools; QSignalMapper* m_mapperTools; - UInt m_uiViewTool; + unsigned int m_uiViewTool; QMenu* m_pcMenuVideo; QMenu* m_pcMenuImage; @@ -116,16 +116,16 @@ private: QVector m_acPlayingSubWindows; QTimer* m_pcPlayingTimer; - Bool m_bIsPlaying; + bool m_bIsPlaying; #if( _CONTROL_PLAYING_TIME_ == 1 ) - UInt m_uiNumberPlayedFrames; + unsigned int m_uiNumberPlayedFrames; Double m_dAverageFps; QElapsedTimer* m_pcPlayControlTimer; #endif - UInt64 getMaxFrameNumber(); - Void setTimerStatus(); + unsigned long long int getMaxFrameNumber(); + void setTimerStatus(); Q_SIGNALS: void changed(); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index b4b3bb5..c6e41c4 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -36,11 +36,11 @@ * \brief Functions to control data stream from stream information */ -QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array ) +QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& array ) { - PlaYUVerStreamInfo d; + CalypFileInfo d; out << array.size(); - for( Int i = 0; i < array.size(); i++ ) + for( int i = 0; i < array.size(); i++ ) { d = array.at( i ); out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness @@ -49,12 +49,12 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array return out; } -QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array ) +QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array ) { - PlaYUVerStreamInfo d; - Int array_size; + CalypFileInfo d; + int array_size; in >> array_size; - for( Int i = 0; i < array_size; i++ ) + for( int i = 0; i < array_size; i++ ) { in >> d.m_cFilename; in >> d.m_uiWidth; @@ -69,9 +69,9 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array ) return in; } -Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename ) +int findCalypStreamInfo( CalypFileInfoVector array, QString filename ) { - for( Int i = 0; i < array.size(); i++ ) + for( int i = 0; i < array.size(); i++ ) if( array.at( i ).m_cFilename == filename ) return i; return -1; @@ -88,7 +88,7 @@ private: QList m_cTopLeftTextList; QFont m_cTopLeftTextFont; QFont m_cCenterTextFont; - Bool m_bBusyWindow; + bool m_bBusyWindow; public: VideoInformation( QWidget* parent ) @@ -99,15 +99,15 @@ public: m_cTopLeftTextFont.setPointSize( 8 ); m_cCenterTextFont.setPointSize( 12 ); } - Void setInformationTopLeft( const QStringList& textLines ) + void setInformationTopLeft( const QStringList& textLines ) { m_cTopLeftTextList.clear(); - for( Int i = 0; i < textLines.size(); i++ ) + for( int i = 0; i < textLines.size(); i++ ) { m_cTopLeftTextList.append( QStaticText( textLines.at( i ) ) ); } } - Void setBusyWindow( Bool bFlag ) { m_bBusyWindow = bFlag; } + void setBusyWindow( bool bFlag ) { m_bBusyWindow = bFlag; } protected: void paintEvent( QPaintEvent* event ) @@ -117,7 +117,7 @@ protected: if( !m_cTopLeftTextList.isEmpty() && size().width() > 300 ) { QPoint topLeftCorner( 10, 10 ); - for( Int i = 0; i < m_cTopLeftTextList.size(); i++ ) + for( int i = 0; i < m_cTopLeftTextList.size(); i++ ) { painter.drawStaticText( topLeftCorner, m_cTopLeftTextList.at( i ) ); topLeftCorner += QPoint( 0, 15 ); @@ -196,19 +196,19 @@ VideoSubWindow::~VideoSubWindow() * Events handlers */ -Void VideoSubWindow::closeEvent( QCloseEvent* event ) +void VideoSubWindow::closeEvent( QCloseEvent* event ) { stop(); SubWindowAbstract::closeEvent( event ); } -Void VideoSubWindow::keyPressEvent( QKeyEvent* event ) +void VideoSubWindow::keyPressEvent( QKeyEvent* event ) { if( m_pcCurrentDisplayModule ) { - if( m_pcCurrentDisplayModule->getModuleRequirements() & MODULE_USES_KEYS ) + if( m_pcCurrentDisplayModule->getModuleRequirements() & CLP_MODULE_USES_KEYS ) { - Bool bRet = false; + bool bRet = false; switch( event->key() ) { case Qt::Key_A: @@ -234,7 +234,7 @@ Void VideoSubWindow::keyPressEvent( QKeyEvent* event ) QWidget::keyPressEvent( event ); } -Void VideoSubWindow::resizeEvent( QResizeEvent* event ) +void VideoSubWindow::resizeEvent( QResizeEvent* event ) { m_pcVideoInfo->resize( event->size() ); } @@ -276,12 +276,12 @@ QSize VideoSubWindow::sizeHint( const QSize& maxSize ) const return isize; } -Void VideoSubWindow::updateWindowOnTimeout() +void VideoSubWindow::updateWindowOnTimeout() { m_pcVideoInfo->update(); } -Void VideoSubWindow::loadAll() +void VideoSubWindow::loadAll() { QApplication::setOverrideCursor( Qt::WaitCursor ); m_pCurrStream->loadAll(); @@ -289,7 +289,7 @@ Void VideoSubWindow::loadAll() QApplication::restoreOverrideCursor(); } -Void VideoSubWindow::refreshSubWindow() +void VideoSubWindow::refreshSubWindow() { if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ) { @@ -304,24 +304,24 @@ Void VideoSubWindow::refreshSubWindow() refreshFrame(); } -Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) +bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog ) { ConfigureFormatDialog formatDialog( this ); - UInt Width = 0, Height = 0, BitsPel = 8, FrameRate = 30; - Int Endianness = PLAYUVER_BIG_ENDIAN; - Int InputFormat = PlaYUVerFrame::YUV420p; + unsigned int Width = 0, Height = 0, BitsPel = 8, FrameRate = 30; + int Endianness = CLP_BIG_ENDIAN; + int InputFormat = CLP_YUV420P; if( m_pCurrStream ) m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, Endianness, FrameRate ); if( !m_pCurrStream ) { - m_pCurrStream = new PlaYUVerStream; + m_pCurrStream = new CalypStream; } - Bool bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog; - Bool bRet = false; - for( Int iPass = 0; iPass < 2 && !bRet; iPass++ ) + bool bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog; + bool bRet = false; + for( int iPass = 0; iPass < 2 && !bRet; iPass++ ) { if( iPass || bConfig ) { @@ -355,11 +355,11 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) return true; } -Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) +bool VideoSubWindow::loadFile( CalypFileInfo* streamInfo ) { if( !m_pCurrStream ) { - m_pCurrStream = new PlaYUVerStream; + m_pCurrStream = new CalypStream; } if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, @@ -381,7 +381,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) return true; } -Void VideoSubWindow::updateVideoWindowInfo() +void VideoSubWindow::updateVideoWindowInfo() { m_cStreamInformation = ""; if( m_pcCurrentDisplayModule ) @@ -391,7 +391,7 @@ Void VideoSubWindow::updateVideoWindowInfo() QStringList sourceWindowList; if( arraySubWindows.size() > 0 ) { - for( Int i = 0; i < arraySubWindows.size(); i++ ) + for( int i = 0; i < arraySubWindows.size(); i++ ) { if( arraySubWindows.at( i )->getWindowName() != getWindowName() ) { @@ -427,12 +427,12 @@ Void VideoSubWindow::updateVideoWindowInfo() } } -Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, - Int& rEndianness ) +bool VideoSubWindow::guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel, + int& rEndianness ) { - std::vector stdResList = PlaYUVerStream::stdResolutionSizes(); - Bool bGuessed = true; - Bool bGuessedByFilesize = false; + std::vector stdResList = CalypStream::stdResolutionSizes(); + bool bGuessed = true; + bool bGuessedByFilesize = false; QString FilenameShort = QFileInfo( filename ).fileName(); QString fileExtension = QFileInfo( filename ).suffix(); @@ -445,8 +445,8 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, { bGuessed = false; // Guess pixel format - QVector formats_list = QVector::fromStdVector( PlaYUVerFrame::supportedPixelFormatListNames() ); - for( Int i = 0; i < formats_list.size(); i++ ) + QVector formats_list = QVector::fromStdVector( CalypFrame::supportedPixelFormatListNames() ); + for( int i = 0; i < formats_list.size(); i++ ) { if( FilenameShort.contains( formats_list.at( i ).c_str(), Qt::CaseInsensitive ) ) { @@ -458,8 +458,8 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, if( rWidth == 0 || rHeight == 0 ) { // Guess resolution - match resolution name - Int iMatch = -1; - for( UInt i = 0; i < stdResList.size(); i++ ) + int iMatch = -1; + for( unsigned int i = 0; i < stdResList.size(); i++ ) { if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) ) { @@ -497,14 +497,14 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, if( pF ) { fseek( pF, 0, SEEK_END ); - UInt64 uiFileSize = ftell( pF ); + unsigned long long int uiFileSize = ftell( pF ); fclose( pF ); - Int count = 0, module, frame_bytes, match; - for( UInt i = 0; i < stdResList.size(); i++ ) + int count = 0, module, frame_bytes, match; + for( unsigned int i = 0; i < stdResList.size(); i++ ) { frame_bytes = - PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 ); + CalypFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 ); module = uiFileSize % frame_bytes; if( module == 0 ) { @@ -538,11 +538,11 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, // Guess Endianness if( FilenameShort.contains( QStringLiteral( "be" ), Qt::CaseInsensitive ) ) { - rEndianness = PLAYUVER_BIG_ENDIAN; + rEndianness = CLP_BIG_ENDIAN; } if( FilenameShort.contains( QStringLiteral( "le" ), Qt::CaseInsensitive ) ) { - rEndianness = PLAYUVER_LITTLE_ENDIAN; + rEndianness = CLP_LITTLE_ENDIAN; } if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 ) @@ -551,7 +551,7 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, return !bGuessed; } -Void VideoSubWindow::updateSelectedArea( QRect area ) +void VideoSubWindow::updateSelectedArea( QRect area ) { m_cSelectedArea = area; } @@ -560,7 +560,7 @@ Void VideoSubWindow::updateSelectedArea( QRect area ) * Functions to enable a module in the * current SubWindow */ -Void VideoSubWindow::enableModule( PlaYUVerAppModuleIf* pcModule ) +void VideoSubWindow::enableModule( CalypAppModuleIf* pcModule ) { if( m_pcCurrentDisplayModule ) { @@ -570,12 +570,12 @@ Void VideoSubWindow::enableModule( PlaYUVerAppModuleIf* pcModule ) updateVideoWindowInfo(); } -Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) +void VideoSubWindow::disableModule( CalypAppModuleIf* pcModule ) { - Bool bRefresh = false; + bool bRefresh = false; if( pcModule ) { - Int modIdx = m_apcCurrentModule.indexOf( pcModule ); + int modIdx = m_apcCurrentModule.indexOf( pcModule ); if( modIdx != -1 ) { m_apcCurrentModule.removeAt( modIdx ); @@ -593,8 +593,8 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) } else { - QList apcCurrentModule = m_apcCurrentModule; - for( Int i = 0; i < apcCurrentModule.size(); i++ ) + QList apcCurrentModule = m_apcCurrentModule; + for( int i = 0; i < apcCurrentModule.size(); i++ ) { m_apcCurrentModule.removeOne( apcCurrentModule.at( i ) ); ModulesHandle::destroyModuleIf( apcCurrentModule.at( i ) ); @@ -617,39 +617,39 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) } } -Void VideoSubWindow::associateModule( PlaYUVerAppModuleIf* pcModule ) +void VideoSubWindow::associateModule( CalypAppModuleIf* pcModule ) { m_apcCurrentModule.append( pcModule ); } -Bool VideoSubWindow::hasRunningModule() +bool VideoSubWindow::hasRunningModule() { - Bool bRet = false; + bool bRet = false; if( m_pcCurrentDisplayModule ) { bRet |= m_pcCurrentDisplayModule->isRunning(); } - for( Int i = 0; i < m_apcCurrentModule.size() && !bRet; i++ ) + for( int i = 0; i < m_apcCurrentModule.size() && !bRet; i++ ) { bRet |= m_apcCurrentModule.at( i )->isRunning(); } return bRet; } -Void VideoSubWindow::setFillWindow( Bool bFlag ) +void VideoSubWindow::setFillWindow( bool bFlag ) { m_pcVideoInfo->setBusyWindow( bFlag ); } -Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) +void VideoSubWindow::setCurrFrame( CalypFrame* pcCurrFrame ) { m_pcCurrFrame = pcCurrFrame; m_cViewArea->setImage( m_pcCurrFrame ); } -Void VideoSubWindow::refreshFrameOperation() +void VideoSubWindow::refreshFrameOperation() { - Bool bSetFrame = false; + bool bSetFrame = false; if( m_pCurrStream ) { m_pcCurrFrame = m_pCurrStream->getCurrFrame(); @@ -665,13 +665,13 @@ Void VideoSubWindow::refreshFrameOperation() { m_cViewArea->setImage( m_pcCurrFrame ); } - for( Int i = 0; i < m_apcCurrentModule.size(); i++ ) + for( int i = 0; i < m_apcCurrentModule.size(); i++ ) { m_apcCurrentModule.at( i )->update(); } } -Void VideoSubWindow::refreshFrame( Bool bThreaded ) +void VideoSubWindow::refreshFrame( bool bThreaded ) { #ifndef QT_NO_CONCURRENT m_cRefreshResult.waitForFinished(); @@ -686,13 +686,13 @@ Void VideoSubWindow::refreshFrame( Bool bThreaded ) } } -Bool VideoSubWindow::goToNextFrame( Bool bThreaded ) +bool VideoSubWindow::goToNextFrame( bool bThreaded ) { #ifndef QT_NO_CONCURRENT m_cRefreshResult.waitForFinished(); m_cReadResult.waitForFinished(); #endif - Bool bEndOfSeq = m_pCurrStream->setNextFrame(); + bool bEndOfSeq = m_pCurrStream->setNextFrame(); if( !bEndOfSeq ) { #ifndef QT_NO_CONCURRENT @@ -700,7 +700,7 @@ Bool VideoSubWindow::goToNextFrame( Bool bThreaded ) if( bThreaded ) { refreshFrame(); - m_cReadResult = QtConcurrent::run( m_pCurrStream, &PlaYUVerStream::readNextFrameFillRGBBuffer ); + m_cReadResult = QtConcurrent::run( m_pCurrStream, &CalypStream::readNextFrameFillRGBBuffer ); } else #endif @@ -712,29 +712,29 @@ Bool VideoSubWindow::goToNextFrame( Bool bThreaded ) return bEndOfSeq; } -Bool VideoSubWindow::save( QString filename ) +bool VideoSubWindow::save( QString filename ) { - Bool iRet = false; + bool iRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); - PlaYUVerFrame* saveFrame = m_pcCurrFrame; + CalypFrame* saveFrame = m_pcCurrFrame; if( m_cSelectedArea.isValid() ) { - saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(), - m_cSelectedArea.height() ); + saveFrame = new CalypFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(), + m_cSelectedArea.height() ); } if( !saveFrame ) { return false; } - iRet = PlaYUVerStream::saveFrame( filename.toStdString(), saveFrame ); + iRet = CalypStream::saveFrame( filename.toStdString(), saveFrame ); QApplication::restoreOverrideCursor(); return iRet; } -Bool VideoSubWindow::saveStream( QString filename ) +bool VideoSubWindow::saveStream( QString filename ) { - Bool iRet = false; + bool iRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); // TODO: implement this @@ -742,7 +742,7 @@ Bool VideoSubWindow::saveStream( QString filename ) return iRet; } -Bool VideoSubWindow::play() +bool VideoSubWindow::play() { if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 ) { @@ -755,9 +755,9 @@ Bool VideoSubWindow::play() return m_bIsPlaying; } -Bool VideoSubWindow::playEvent() +bool VideoSubWindow::playEvent() { - Bool bEndOfSeq = false; + bool bEndOfSeq = false; if( m_pCurrStream && m_bIsPlaying ) { bEndOfSeq = goToNextFrame( true ); @@ -765,22 +765,22 @@ Bool VideoSubWindow::playEvent() return bEndOfSeq; } -Void VideoSubWindow::pause() +void VideoSubWindow::pause() { m_bIsPlaying = false; refreshFrame(); } -Void VideoSubWindow::seekAbsoluteEvent( UInt new_frame_num ) +void VideoSubWindow::seekAbsoluteEvent( unsigned int new_frame_num ) { if( m_pCurrStream ) if( m_pCurrStream->seekInput( new_frame_num ) ) refreshFrame(); } -Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward ) +void VideoSubWindow::seekRelativeEvent( bool bIsFoward ) { - Bool bRefresh = false; + bool bRefresh = false; if( m_pCurrStream ) { if( bIsFoward ) @@ -798,7 +798,7 @@ Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward ) } } -Void VideoSubWindow::stop() +void VideoSubWindow::stop() { #ifndef QT_NO_CONCURRENT m_cRefreshResult.waitForFinished(); @@ -814,7 +814,7 @@ QSize VideoSubWindow::getScrollSize() return QSize( m_pcScrollArea->viewport()->size().width() - 5, m_pcScrollArea->viewport()->size().height() - 5 ); } -Void VideoSubWindow::adjustScrollBarToRatio( const Double& horRatio, const Double& verRatio ) +void VideoSubWindow::adjustScrollBarToRatio( const double& horRatio, const double& verRatio ) { QScrollBar* scrollBarH = m_pcScrollArea->horizontalScrollBar(); QScrollBar* scrollBarV = m_pcScrollArea->verticalScrollBar(); @@ -823,14 +823,14 @@ Void VideoSubWindow::adjustScrollBarToRatio( const Double& horRatio, const Doubl updateScrollValues(); } -Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) +void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) { QPoint cLastScroll = m_cCurrScroll; QScrollBar* scrollBarH = m_pcScrollArea->horizontalScrollBar(); QScrollBar* scrollBarV = m_pcScrollArea->verticalScrollBar(); - Int valueX = int( cLastScroll.x() + Offset.x() ); - Int valueY = int( cLastScroll.y() + Offset.y() ); + int valueX = int( cLastScroll.x() + Offset.x() ); + int valueY = int( cLastScroll.y() + Offset.y() ); scrollBarH->setValue( valueX ); scrollBarV->setValue( valueY ); @@ -842,7 +842,7 @@ Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) // This function was developed with help of the schematics presented in // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position -Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center ) +void VideoSubWindow::adjustScrollBarByScale( double scale, QPoint center ) { QPoint cLastScroll = m_cCurrScroll; QScrollBar* scrollBarH = m_pcScrollArea->horizontalScrollBar(); @@ -855,13 +855,13 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center ) } else { - Int value; + int value; - Int x = center.x() - cLastScroll.x(); + int x = center.x() - cLastScroll.x(); value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); m_cCurrScroll.setX( value ); - Int y = center.y() - cLastScroll.y(); + int y = center.y() - cLastScroll.y(); value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); m_cCurrScroll.setY( value ); } @@ -875,10 +875,10 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center ) scrollBarMoved( m_dHorScroll, m_dVerScroll ); } -Void VideoSubWindow::updateScrollValues() +void VideoSubWindow::updateScrollValues() { - Double xPos = m_pcScrollArea->horizontalScrollBar()->value(); - Double yPos = m_pcScrollArea->verticalScrollBar()->value(); + double xPos = m_pcScrollArea->horizontalScrollBar()->value(); + double yPos = m_pcScrollArea->verticalScrollBar()->value(); m_cCurrScroll.setX( xPos ); m_cCurrScroll.setY( yPos ); @@ -886,13 +886,13 @@ Void VideoSubWindow::updateScrollValues() m_dHorScroll = m_dVerScroll = 0; if( xPos ) - m_dHorScroll = xPos / Double( m_pcScrollArea->horizontalScrollBar()->maximum() ); + m_dHorScroll = xPos / double( m_pcScrollArea->horizontalScrollBar()->maximum() ); if( yPos ) - m_dVerScroll = yPos / Double( m_pcScrollArea->verticalScrollBar()->maximum() ); + m_dVerScroll = yPos / double( m_pcScrollArea->verticalScrollBar()->maximum() ); } -//Void VideoSubWindow::setCurScrollValues() +//void VideoSubWindow::setCurScrollValues() //{ // QScrollBar* scrollBar = m_pcScrollArea->horizontalScrollBar(); // scrollBar->setValue( m_cCurrScroll.x() ); @@ -900,48 +900,48 @@ Void VideoSubWindow::updateScrollValues() // scrollBar->setValue( m_cCurrScroll.y() ); //} -Void VideoSubWindow::normalSize() +void VideoSubWindow::normalSize() { - Double factor = 1.0; - Double curFactor = getScaleFactor(); + double factor = 1.0; + double curFactor = getScaleFactor(); if( factor != curFactor ) { - Double usedScale; + double usedScale; usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, QPoint(), QSize() ); adjustScrollBarByScale( usedScale, QPoint() ); } } -Void VideoSubWindow::zoomToFit() +void VideoSubWindow::zoomToFit() { // Scale to a smaller size that the real to a nicer look scaleView( getScrollSize() ); } -Void VideoSubWindow::zoomToFactor( Double factor, QPoint center ) +void VideoSubWindow::zoomToFactor( double factor, QPoint center ) { - Double curFactor; + double curFactor; curFactor = getScaleFactor(); if( factor != curFactor ) { - Double usedScale; + double usedScale; usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, QSize() ); adjustScrollBarByScale( usedScale, center ); } } -Void VideoSubWindow::scaleView( Double scale, QPoint center ) +void VideoSubWindow::scaleView( double scale, QPoint center ) { Q_ASSERT( !m_cViewArea->image().isNull() ); if( scale != 1.0 ) { - Double usedScale; + double usedScale; usedScale = m_cViewArea->scaleZoomFactor( scale, center, getScrollSize() ); adjustScrollBarByScale( usedScale, center ); } } -Void VideoSubWindow::scaleView( const QSize& size, QPoint center ) +void VideoSubWindow::scaleView( const QSize& size, QPoint center ) { QSize imgViewSize; if( m_pcCurrFrame ) @@ -952,34 +952,34 @@ Void VideoSubWindow::scaleView( const QSize& size, QPoint center ) newSize.scale( size, Qt::KeepAspectRatio ); // Calc the zoom factor - Double wfactor = 1; - Double hfactor = 1; - Double factor; + double wfactor = 1; + double hfactor = 1; + double factor; - wfactor = (Double)newSize.width() / imgViewSize.width(); - hfactor = (Double)newSize.height() / imgViewSize.height(); + wfactor = (double)newSize.width() / imgViewSize.width(); + hfactor = (double)newSize.height() / imgViewSize.height(); if( wfactor < hfactor ) factor = wfactor; else factor = hfactor; - Double curFactor = getScaleFactor(); + double curFactor = getScaleFactor(); if( factor != curFactor ) { - Double usedScale; + double usedScale; usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, getScrollSize() ); adjustScrollBarByScale( usedScale, center ); } } -Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) +void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) { if( m_pcCurrFrame ) { - Int iWidth, iHeight; - Int posX = pos.x(); - Int posY = pos.y(); + int iWidth, iHeight; + int posX = pos.x(); + int posY = pos.y(); QString strStatus; iWidth = m_pcCurrFrame->getWidth(); @@ -989,31 +989,31 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) { strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY ); - Int colorSpace = m_pcCurrFrame->getColorSpace(); - PlaYUVerPixel pixelValue = m_pcCurrFrame->getPixel( pos.x(), pos.y() ); + int colorSpace = m_pcCurrFrame->getColorSpace(); + CalypPixel pixelValue = m_pcCurrFrame->getPixel( pos.x(), pos.y() ); switch( colorSpace ) { - case PlaYUVerPixel::COLOR_GRAY: - strStatus.append( QString( "Y: %1" ).arg( pixelValue.Y() ) ); + case CLP_COLOR_GRAY: + strStatus.append( QString( "Y: %1" ).arg( pixelValue[0] ) ); break; - case PlaYUVerPixel::COLOR_YUV: + case CLP_COLOR_YUV: strStatus.append( QString( "Y: %1 U: %2 V: %3" ) - .arg( pixelValue.Y() ) - .arg( pixelValue.Cb() ) - .arg( pixelValue.Cr() ) ); + .arg( pixelValue[0] ) + .arg( pixelValue[1] ) + .arg( pixelValue[2] ) ); break; - case PlaYUVerPixel::COLOR_RGB: + case CLP_COLOR_RGB: strStatus.append( QString( "R: %1 G: %2 B: %3" ) - .arg( pixelValue.R() ) - .arg( pixelValue.G() ) - .arg( pixelValue.B() ) ); + .arg( pixelValue[0] ) + .arg( pixelValue[1] ) + .arg( pixelValue[2] ) ); break; - case PlaYUVerPixel::COLOR_RGBA: + case CLP_COLOR_RGBA: strStatus.append( QString( "R: %1 G: %2 B: %3 A: %4" ) - .arg( pixelValue.R() ) - .arg( pixelValue.G() ) - .arg( pixelValue.B() ) - .arg( pixelValue.A() ) ); + .arg( pixelValue[0] ) + .arg( pixelValue[1] ) + .arg( pixelValue[2] ) + .arg( pixelValue[3] ) ); break; } diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 177185a..9ff722b 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -30,46 +30,46 @@ #include #include #include -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "SubWindowAbstract.h" #include "ViewArea.h" #include "config.h" -#include "lib/PlaYUVerStream.h" +#include "lib/CalypStream.h" class QScrollArea; class VideoInformation; class VideoSubWindow; -class PlaYUVerAppModuleIf; +class CalypAppModuleIf; typedef struct { QString m_cFilename; - UInt m_uiWidth; - UInt m_uiHeight; - Int m_iPelFormat; - UInt m_uiBitsPelPixel; - UInt m_iEndianness; - UInt m_uiFrameRate; - UInt64 m_uiFileSize; -} PlaYUVerStreamInfo; -typedef QVector PlaYUVerStreamInfoVector; + unsigned int m_uiWidth; + unsigned int m_uiHeight; + int m_iPelFormat; + unsigned int m_uiBitsPelPixel; + unsigned int m_iEndianness; + unsigned int m_uiFrameRate; + unsigned long long int m_uiFileSize; +} CalypFileInfo; +typedef QVector CalypFileInfoVector; -QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& d ); -QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& d ); -Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename ); +QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d ); +QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d ); +int findCalypStreamInfo( CalypFileInfoVector array, QString filename ); class VideoSubWindow : public SubWindowAbstract { Q_OBJECT private: - Bool m_bWindowBusy; + bool m_bWindowBusy; QScrollArea* m_pcScrollArea; QPoint m_cCurrScroll; - Double m_dHorScroll; - Double m_dVerScroll; + double m_dHorScroll; + double m_dVerScroll; ViewArea* m_cViewArea; @@ -77,29 +77,29 @@ private: QString m_cFilename; QString m_cStreamInformation; - PlaYUVerStreamInfo m_sStreamInfo; - PlaYUVerStream* m_pCurrStream; + CalypFileInfo m_sStreamInfo; + CalypStream* m_pCurrStream; - PlaYUVerFrame* m_pcCurrFrame; + CalypFrame* m_pcCurrFrame; QRect m_cSelectedArea; - PlaYUVerAppModuleIf* m_pcCurrentDisplayModule; - QList m_apcCurrentModule; + CalypAppModuleIf* m_pcCurrentDisplayModule; + QList m_apcCurrentModule; VideoSubWindow* m_pcReferenceSubWindow; // QString m_cWindowShortName; QString m_cCurrFileName; - Bool m_bIsPlaying; + bool m_bIsPlaying; QTimer* m_pcUpdateTimer; /** * Threads variables * QtConcurrent */ - QFuture m_cRefreshResult; - QFuture m_cReadResult; + QFuture m_cRefreshResult; + QFuture m_cReadResult; public: enum VideoSubWindowCategories @@ -110,34 +110,34 @@ public: VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 ); ~VideoSubWindow(); - Bool loadFile( QString cFilename, Bool bForceDialog = false ); - Bool loadFile( PlaYUVerStreamInfo* streamInfo ); - Void loadAll(); - Bool save( QString filename ); - Bool saveStream( QString filename ); + bool loadFile( QString cFilename, bool bForceDialog = false ); + bool loadFile( CalypFileInfo* streamInfo ); + void loadAll(); + bool save( QString filename ); + bool saveStream( QString filename ); - Void refreshSubWindow(); - Void refreshFrame( Bool bThreaded = false ); + void refreshSubWindow(); + void refreshFrame( bool bThreaded = false ); - Bool play(); - Void pause(); - Bool playEvent(); - Void stop(); + bool play(); + void pause(); + bool playEvent(); + void stop(); - Bool isPlaying() { return m_bIsPlaying; } - Void seekAbsoluteEvent( UInt new_frame_num ); - Void seekRelativeEvent( Bool bIsFoward ); + bool isPlaying() { return m_bIsPlaying; } + void seekAbsoluteEvent( unsigned int new_frame_num ); + void seekRelativeEvent( bool bIsFoward ); - Void setCurrFrame( PlaYUVerFrame* pcCurrFrame ); + void setCurrFrame( CalypFrame* pcCurrFrame ); QScrollArea* getScroll() { return m_pcScrollArea; } - PlaYUVerStreamInfo getStreamInfo() { return m_sStreamInfo; } + CalypFileInfo getStreamInfo() { return m_sStreamInfo; } QString getStreamInformation() { return m_cStreamInformation; } - PlaYUVerStream* getInputStream() { return m_pCurrStream; } - PlaYUVerStream* getCurrStream() { return m_pCurrStream; } - PlaYUVerFrame* getCurrFrame() { return m_pcCurrFrame; } + CalypStream* getInputStream() { return m_pCurrStream; } + CalypStream* getCurrStream() { return m_pCurrStream; } + CalypFrame* getCurrFrame() { return m_pcCurrFrame; } ViewArea* getViewArea() { return m_cViewArea; } - Void setRefSubWindow( VideoSubWindow* subWindow ) + void setRefSubWindow( VideoSubWindow* subWindow ) { m_pcReferenceSubWindow = NULL; if( subWindow ) @@ -150,14 +150,14 @@ public: * Functions to enable a module in the * current SubWindow */ - Void enableModule( PlaYUVerAppModuleIf* pcModule ); - Void disableModule( PlaYUVerAppModuleIf* pcModule = NULL ); - Void associateModule( PlaYUVerAppModuleIf* pcModule ); + void enableModule( CalypAppModuleIf* pcModule ); + void disableModule( CalypAppModuleIf* pcModule = NULL ); + void associateModule( CalypAppModuleIf* pcModule ); - PlaYUVerAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; } - QList getModuleArray() + CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; } + QList getModuleArray() { - QList apcModulesArray; + QList apcModulesArray; if( m_pcCurrentDisplayModule ) apcModulesArray.append( m_pcCurrentDisplayModule ); apcModulesArray.append( m_apcCurrentModule ); @@ -167,12 +167,12 @@ public: /** * Virtual functions from SubWindowAbstract */ - Void normalSize(); - Void zoomToFit(); - Void scaleView( Double scale, QPoint center = QPoint() ); - Void zoomToFactor( Double factor, QPoint center = QPoint() ); + void normalSize(); + void zoomToFit(); + void scaleView( double scale, QPoint center = QPoint() ); + void zoomToFactor( double factor, QPoint center = QPoint() ); - Double getScaleFactor() { return m_cViewArea->getZoomFactor(); } + double getScaleFactor() { return m_cViewArea->getZoomFactor(); } /** * Size related functions */ @@ -180,34 +180,34 @@ public: QSize sizeHint( const QSize& ) const; QString getCurrentFileName() { return m_cFilename; } - Bool getIsModule() { return getCategory() | SubWindowAbstract::MODULE_SUBWINDOW; } - Void clearWindowBusy() { m_bWindowBusy = false; } - Void setFillWindow( Bool bFlag ); + bool getIsModule() { return getCategory() | SubWindowAbstract::MODULE_SUBWINDOW; } + void clearWindowBusy() { m_bWindowBusy = false; } + void setFillWindow( bool bFlag ); - Void adjustScrollBarToRatio( const Double& horRatio, const Double& verRatio ); + void adjustScrollBarToRatio( const double& horRatio, const double& verRatio ); private: - Void refreshFrameOperation(); - Bool goToNextFrame( Bool bThreaded = false ); + void refreshFrameOperation(); + bool goToNextFrame( bool bThreaded = false ); - static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, - Int& rEndianness ); + static bool guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel, + int& rEndianness ); - Bool hasRunningModule(); + bool hasRunningModule(); /** * Private zoom function to handle * zoom to fit */ - Void scaleView( const QSize& size, QPoint center = QPoint() ); - Void updateVideoWindowInfo(); + void scaleView( const QSize& size, QPoint center = QPoint() ); + void updateVideoWindowInfo(); QSize getScrollSize(); protected: - Void keyPressEvent( QKeyEvent* event ); - Void resizeEvent( QResizeEvent* event ); - Void closeEvent( QCloseEvent* event ); + void keyPressEvent( QKeyEvent* event ); + void resizeEvent( QResizeEvent* event ); + void closeEvent( QCloseEvent* event ); public Q_SLOTS: void updateWindowOnTimeout(); @@ -218,7 +218,7 @@ public Q_SLOTS: void updatePixelValueStatusBar( const QPoint& pos ); }; -Q_DECLARE_METATYPE( PlaYUVerStreamInfo ); -Q_DECLARE_METATYPE( PlaYUVerStreamInfoVector ); +Q_DECLARE_METATYPE( CalypFileInfo ); +Q_DECLARE_METATYPE( CalypFileInfoVector ); #endif // __VIDEOSUBWINDOW_H__ diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index ee8a78c..ee06297 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -70,7 +70,7 @@ ViewArea::ViewArea( QWidget* parent ) connect( &m_zoomWinTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); } -Void ViewArea::setImage( PlaYUVerFrame* pcFrame ) +void ViewArea::setImage( CalypFrame* pcFrame ) { m_pcCurrFrame = pcFrame; m_uiPixelHalfScale = 1 << ( m_pcCurrFrame->getBitsPel() - 1 ); @@ -80,7 +80,7 @@ Void ViewArea::setImage( PlaYUVerFrame* pcFrame ) setImage( QPixmap::fromImage( qimg ) ); } -Void ViewArea::setImage( const QPixmap& pixmap ) +void ViewArea::setImage( const QPixmap& pixmap ) { m_pixmap = pixmap; m_mask = QBitmap( pixmap.width(), pixmap.height() ); @@ -92,7 +92,7 @@ Void ViewArea::setImage( const QPixmap& pixmap ) initZoomWinRect(); } -Void ViewArea::clear() +void ViewArea::clear() { m_pixmap = QPixmap(); m_mask = QBitmap(); @@ -102,7 +102,7 @@ Void ViewArea::clear() updateGeometry(); } -Void ViewArea::setTool( UInt view ) +void ViewArea::setTool( unsigned int view ) { switch( view ) { @@ -131,13 +131,13 @@ Void ViewArea::setTool( UInt view ) update(); } -Void ViewArea::setGridVisible( Bool enable ) +void ViewArea::setGridVisible( bool enable ) { m_bGridVisible = enable; update(); } -Void ViewArea::clearMask() +void ViewArea::clearMask() { m_mask.clear(); } @@ -145,12 +145,12 @@ Void ViewArea::clearMask() /** * Zoom related function */ -Void ViewArea::startZoomWinTimer() +void ViewArea::startZoomWinTimer() { m_zoomWinTimer.start(); } -Void ViewArea::setZoomFactor( Double f ) +void ViewArea::setZoomFactor( double f ) { m_dZoomFactor = f; @@ -159,11 +159,11 @@ Void ViewArea::setZoomFactor( Double f ) update(); } -Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize ) +double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize ) { - Double maxZoom = 100.0; - Double minZoom = 0.01; //( 1.0 / m_pixmap.width() ); - Double new_scale = 1.0; + double maxZoom = 100.0; + double minZoom = 0.01; //( 1.0 / m_pixmap.width() ); + double new_scale = 1.0; if( ( m_dZoomFactor == minZoom ) && ( scale < 1 ) ) return new_scale; @@ -171,19 +171,19 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize if( ( m_dZoomFactor == maxZoom ) && ( scale > 1 ) ) return new_scale; - Double zoomFactor = m_dZoomFactor * scale * 100.0; + double zoomFactor = m_dZoomFactor * scale * 100.0; zoomFactor = round( zoomFactor ); zoomFactor = zoomFactor / 100.0; scale = zoomFactor / m_dZoomFactor; if( !minimumSize.isNull() ) { - Double cw = m_pixmap.width() * m_dZoomFactor; - Double ch = m_pixmap.height() * m_dZoomFactor; - Double fw = m_pixmap.width() * zoomFactor; - Double fh = m_pixmap.height() * zoomFactor; - Double mw = minimumSize.width(); - Double mh = minimumSize.height(); + double cw = m_pixmap.width() * m_dZoomFactor; + double ch = m_pixmap.height() * m_dZoomFactor; + double fw = m_pixmap.width() * zoomFactor; + double fh = m_pixmap.height() * zoomFactor; + double mw = minimumSize.width(); + double mh = minimumSize.height(); if( ( cw < mw ) && ( ch < mh ) && ( scale < 1 ) ) { @@ -192,8 +192,8 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize if( ( fw < mw ) && ( fh < mh ) && ( scale < 1 ) ) { - Double wfactor = mw / fw; - Double hfactor = mh / fh; + double wfactor = mw / fw; + double hfactor = mh / fh; if( wfactor < hfactor ) scale = wfactor; @@ -228,7 +228,7 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize return new_scale; } -// Void ViewArea::setMode( Int mode ) +// void ViewArea::setMode( int mode ) //{ // if( m_mode == mode ) // return; @@ -237,56 +237,56 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize // update(); //} // -// Void ViewArea::setNormalMode() +// void ViewArea::setNormalMode() //{ // setMode( NormalMode ); //} // -// Void ViewArea::setMaskMode() +// void ViewArea::setMaskMode() //{ // setMode( MaskMode ); //} // -// Void ViewArea::setMaskColor( const QColor &color ) +// void ViewArea::setMaskColor( const QColor &color ) //{ // m_maskColor = color; // update(); //} // -// Void ViewArea::setMaskTool() +// void ViewArea::setMaskTool() //{ // setMode( MaskMode ); // setTool( MaskTool ); // m_blockTrackEnable = true; //} // -// Void ViewArea::setEraserTool() +// void ViewArea::setEraserTool() //{ // setMode( MaskMode ); // setTool( EraserTool ); // m_blockTrackEnable = true; //} // -// Void ViewArea::setSelectionTool() +// void ViewArea::setSelectionTool() //{ // setMode( NormalMode ); // setTool( SelectionTool ); // m_blockTrackEnable = false; //} // -// Void ViewArea::setBlockSelectionTool() +// void ViewArea::setBlockSelectionTool() //{ // setMode( NormalMode ); // setTool( BlockSelectionTool ); // m_blockTrackEnable = true; //} -Void ViewArea::setSnapToGrid( Bool enable ) +void ViewArea::setSnapToGrid( bool enable ) { m_snapToGrid = enable; } -// Void ViewArea::setSelectedArea( QRect &rect ) +// void ViewArea::setSelectedArea( QRect &rect ) //{ // if( rect.isNull() ) // { @@ -312,17 +312,17 @@ Void ViewArea::setSnapToGrid( Bool enable ) // update( updateRect.normalized() ); //} -Void ViewArea::initZoomWinRect() +void ViewArea::initZoomWinRect() { - Int iMinX = 80; - Int iMinY = 80; + int iMinX = 80; + int iMinY = 80; - Int iMaxX = iMinX * 5; - Int iMaxY = iMinY * 5; + int iMaxX = iMinX * 5; + int iMaxY = iMinY * 5; double dSizeRatio, dWinZoomRatio; - Int iHorizontalImg = ( m_pixmap.width() > m_pixmap.height() ) ? 1 : 0; + int iHorizontalImg = ( m_pixmap.width() > m_pixmap.height() ) ? 1 : 0; if( iHorizontalImg ) { @@ -362,10 +362,10 @@ Void ViewArea::initZoomWinRect() //////////////////////////////////////////////////////////////////////////////// // Geometry Updates //////////////////////////////////////////////////////////////////////////////// -Void ViewArea::updateSize() +void ViewArea::updateSize() { - Int w = m_pixmap.width() * m_dZoomFactor; - Int h = m_pixmap.height() * m_dZoomFactor; + int w = m_pixmap.width() * m_dZoomFactor; + int h = m_pixmap.height() * m_dZoomFactor; setMinimumSize( w, h ); QWidget* p = parentWidget(); @@ -381,7 +381,7 @@ Void ViewArea::updateSize() updateOffset(); } -Void ViewArea::updateOffset() +void ViewArea::updateOffset() { if( width() > m_pixmap.width() * m_dZoomFactor ) { @@ -404,7 +404,7 @@ Void ViewArea::updateOffset() //////////////////////////////////////////////////////////////////////////////// // Resize Event //////////////////////////////////////////////////////////////////////////////// -Void ViewArea::resizeEvent( QResizeEvent* event ) +void ViewArea::resizeEvent( QResizeEvent* event ) { if( size().isEmpty() || m_pixmap.isNull() ) return; @@ -414,10 +414,10 @@ Void ViewArea::resizeEvent( QResizeEvent* event ) update(); } //////////////////////////////////////////////////////////////////////////////// -// PaInt Event +// Paint Event //////////////////////////////////////////////////////////////////////////////// -Void ViewArea::paintEvent( QPaintEvent* event ) +void ViewArea::paintEvent( QPaintEvent* event ) { QRect winRect = event->rect(); @@ -427,31 +427,31 @@ Void ViewArea::paintEvent( QPaintEvent* event ) if( size().isEmpty() || m_pixmap.isNull() ) return; - QPainter paInter( this ); + QPainter painter( this ); - // Save the actual paInter properties and scales the coordinate system. - paInter.save(); - paInter.translate( m_xOffset, m_yOffset ); - paInter.scale( m_dZoomFactor, m_dZoomFactor ); + // Save the actual painter properties and scales the coordinate system. + painter.save(); + painter.translate( m_xOffset, m_yOffset ); + painter.scale( m_dZoomFactor, m_dZoomFactor ); - // This line is for fast paiting. Only visible area of the image is paInted. + // This line is for fast paiting. Only visible area of the image is painted. // We take the exposed rect from the event (that gives us scroll/expose // optimizations for free – no need // to draw the whole pixmap if your widget is only partially exposed), and - // reverse map it with the paInter matrix. + // reverse map it with the painter matrix. // That gives us the part of the pixmap that has actually been exposed. // See: // http://blog.qt.digia.com/blog/2006/05/13/fast-transformed-pixmapimage-drawing/ - QRect exposedRect = paInter.worldTransform().inverted().mapRect( event->rect() ).adjusted( -1, -1, 1, 1 ); + QRect exposedRect = painter.worldTransform().inverted().mapRect( event->rect() ).adjusted( -1, -1, 1, 1 ); // Draw the pixmap. - paInter.drawPixmap( exposedRect, m_pixmap, exposedRect ); + painter.drawPixmap( exposedRect, m_pixmap, exposedRect ); // Draw the Grid if it's visible. if( m_bGridVisible ) { // Do we need to draw the whole grid? // To know that, we need to perform a transformation of the rectangle - // area that the paInter needs to update - transform the windows + // area that the painter needs to update - transform the windows // coordinates (origin at the top-left corner of the widget), to the // relatives coordinates of the image at it's original size (origin at // the top-left corner of the image). @@ -460,174 +460,145 @@ Void ViewArea::paintEvent( QPaintEvent* event ) // Now we have the (to update) rectangle area on a coordinates system // that has it's origin at the top-left corner of the image. That // is, is referenced to the not scaled image. - // To know what image area we need to update, just Intersects the + // To know what image area we need to update, just intersects the // rectangle area with the image area. vr &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ); // Set up for the grid drawer. - paInter.setRenderHint( QPainter::Antialiasing ); + painter.setRenderHint( QPainter::Antialiasing ); // Draw grid. - m_grid.drawGrid( m_pixmap, vr, &paInter ); + m_grid.drawGrid( m_pixmap, vr, &painter ); } - paInter.restore(); + painter.restore(); // Draw a border around the image. /* if( m_xOffset || m_yOffset ) - { - paInter.setPen( Qt::black ); - paInter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * - m_dZoomFactor + 1, m_pixmap.height() * - m_dZoomFactor + 1 ); - }*/ + { + painter.setPen( Qt::black ); + painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * + m_dZoomFactor + 1, m_pixmap.height() * + m_dZoomFactor + 1 ); + }*/ + + int frFormat = m_pcCurrFrame->getColorSpace(); // Draw pixel values in grid - if( m_dZoomFactor >= 50.0 ) + if( m_dZoomFactor >= 60.0 || ( frFormat != CLP_COLOR_RGBA && m_dZoomFactor >= 50.0 ) ) { - Int imageWidth = m_pixmap.width(); - Int imageHeight = m_pixmap.height(); - PlaYUVerPixel pixelValue; + int imageWidth = m_pixmap.width(); + int imageHeight = m_pixmap.height(); + ; QFont font( "Helvetica" ); font.setPixelSize( 12 ); - paInter.setFont( font ); + painter.setFont( font ); QRect vr = windowToView( winRect ); vr &= QRect( 0, 0, imageWidth, imageHeight ); - for( Int i = vr.x(); i <= vr.right(); i++ ) + for( int i = vr.x(); i <= vr.right(); i++ ) { - for( Int j = vr.y(); j <= vr.bottom(); j++ ) + for( int j = vr.y(); j <= vr.bottom(); j++ ) { QPoint pixelTopLeft( i, j ); QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_dZoomFactor, m_dZoomFactor ) ); + QString pixelValue; + CalypPixel pixel = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() ); - Int frFormat = m_pcCurrFrame->getColorSpace(); - - if( frFormat == PlaYUVerPixel::COLOR_YUV ) + if( frFormat == CLP_COLOR_YUV || frFormat == CLP_COLOR_GRAY ) { - pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() ); - - if( pixelValue.Y() < m_uiPixelHalfScale ) - paInter.setPen( QColor( Qt::white ) ); + if( pixel[0] < m_uiPixelHalfScale ) + painter.setPen( QColor( Qt::white ) ); else - paInter.setPen( QColor( Qt::black ) ); + painter.setPen( QColor( Qt::black ) ); - paInter.drawText( pixelRect, Qt::AlignCenter, - "Y: " + QString::number( pixelValue.Y() ) + "\n" + - "U: " + QString::number( pixelValue.Cb() ) + "\n" + - "V: " + QString::number( pixelValue.Cr() ) ); - } - if( frFormat == PlaYUVerPixel::COLOR_GRAY ) - { - pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() ); - - if( pixelValue.Y() < m_uiPixelHalfScale ) - paInter.setPen( QColor( Qt::white ) ); - else - paInter.setPen( QColor( Qt::black ) ); - - paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( pixelValue.Y() ) ); + pixelValue = QString( "Y: %1" ).arg( pixel[0] ); + if( frFormat == CLP_COLOR_YUV ) + pixelValue += QString( "\nU: %1\nV: %2" ).arg( pixel[1] ).arg( pixel[2] ); } - if( ( frFormat == PlaYUVerPixel::COLOR_RGB ) ) + if( frFormat == CLP_COLOR_RGB || frFormat == CLP_COLOR_RGBA ) { - pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() ); - - if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) ) - paInter.setPen( QColor( Qt::white ) ); + if( ( pixel[0] + pixel[1] + pixel[2] ) < ( m_uiPixelHalfScale * 3 ) ) + painter.setPen( QColor( Qt::white ) ); else - paInter.setPen( QColor( Qt::black ) ); + painter.setPen( QColor( Qt::black ) ); - paInter.drawText( pixelRect, Qt::AlignCenter, - "R: " + QString::number( pixelValue.R() ) + - "\nG: " + QString::number( pixelValue.G() ) + - "\nB: " + QString::number( pixelValue.B() ) ); - } - if( ( frFormat == PlaYUVerPixel::COLOR_RGBA ) ) - { - pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() ); - - if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) ) - paInter.setPen( QColor( Qt::white ) ); - else - paInter.setPen( QColor( Qt::black ) ); - - paInter.drawText( pixelRect, Qt::AlignCenter, - "R: " + QString::number( pixelValue.R() ) + - "\nG: " + QString::number( pixelValue.G() ) + - "\nB: " + QString::number( pixelValue.B() ) + - "\nA: " + QString::number( pixelValue.A() ) ); + pixelValue = QString( "R: %1\nG: %2\nB: %3" ).arg( pixel[0] ).arg( pixel[1] ).arg( pixel[2] ); + if( frFormat == CLP_COLOR_RGBA ) + pixelValue += QString( "\nA: %1" ).arg( pixel[3] ); } + painter.drawText( pixelRect, Qt::AlignCenter, pixelValue ); } } QColor color( Qt::white ); QPen mainPen = QPen( color, 1, Qt::SolidLine ); - paInter.setPen( mainPen ); + painter.setPen( mainPen ); // Draw vertical line - for( Int x = vr.x(); x <= ( vr.right() + 1 ); x++ ) + for( int x = vr.x(); x <= ( vr.right() + 1 ); x++ ) { // Always draw the full line otherwise the line stippling // varies with the location of view area and we get glitchy // patterns. - paInter.drawLine( viewToWindow( QPoint( x, 0 ) ), viewToWindow( QPoint( x, imageHeight ) ) ); + painter.drawLine( viewToWindow( QPoint( x, 0 ) ), viewToWindow( QPoint( x, imageHeight ) ) ); } // Draw horizontal line - for( Int y = vr.y(); y <= ( vr.bottom() + 1 ); y++ ) + for( int y = vr.y(); y <= ( vr.bottom() + 1 ); y++ ) { - paInter.drawLine( viewToWindow( QPoint( 0, y ) ), viewToWindow( QPoint( imageWidth, y ) ) ); + painter.drawLine( viewToWindow( QPoint( 0, y ) ), viewToWindow( QPoint( imageWidth, y ) ) ); } } -// VISIBLE ZOOM RECT + // VISIBLE ZOOM RECT #if 0 - if( m_visibleZoomRect && m_zoomWinTimer.isActive() ) - { - double dRatio = m_dZoomWinRatio; + if( m_visibleZoomRect && m_zoomWinTimer.isActive() ) + { + double dRatio = m_dZoomWinRatio; - QRect cImg = QRect(0, 0, m_pixmap.width(), m_pixmap.height() ); - QPoint cZWinRBpos = QPoint(winRect.bottomRight()) - QPoint(15,15); - QRect cImgWinRect(0, 0, round((double)cImg.width()/dRatio), round((double)cImg.height()/dRatio) ); - cImgWinRect.moveBottomRight(cZWinRBpos); + QRect cImg = QRect(0, 0, m_pixmap.width(), m_pixmap.height() ); + QPoint cZWinRBpos = QPoint(winRect.bottomRight()) - QPoint(15,15); + QRect cImgWinRect(0, 0, round((double)cImg.width()/dRatio), round((double)cImg.height()/dRatio) ); + cImgWinRect.moveBottomRight(cZWinRBpos); - QRect vr = windowToView( winRect ); - QRect cVisibleImg = vr & cImg; - //cVisibleImg.moveTopLeft(vr.topLeft()); - QRect cVisibleWinRect; - cVisibleWinRect.setLeft(floor((double)cVisibleImg.x()/dRatio)); - cVisibleWinRect.setTop(floor((double)cVisibleImg.y()/dRatio)); - cVisibleWinRect.setRight(round((double)cVisibleImg.right()/dRatio)); - cVisibleWinRect.setBottom(round((double)cVisibleImg.bottom()/dRatio)); + QRect vr = windowToView( winRect ); + QRect cVisibleImg = vr & cImg; + //cVisibleImg.moveTopLeft(vr.topLeft()); + QRect cVisibleWinRect; + cVisibleWinRect.setLeft(floor((double)cVisibleImg.x()/dRatio)); + cVisibleWinRect.setTop(floor((double)cVisibleImg.y()/dRatio)); + cVisibleWinRect.setRight(round((double)cVisibleImg.right()/dRatio)); + cVisibleWinRect.setBottom(round((double)cVisibleImg.bottom()/dRatio)); - paInter.fillRect(cImgWinRect, QBrush(QColor(128, 128, 128, 128))); - paInter.setPen(QColor(50, 50, 50, 128)); - paInter.drawRect(cImgWinRect); + painter.fillRect(cImgWinRect, QBrush(QColor(128, 128, 128, 128))); + painter.setPen(QColor(50, 50, 50, 128)); + painter.drawRect(cImgWinRect); - cVisibleWinRect.moveTopLeft( cImgWinRect.topLeft() + cVisibleWinRect.topLeft() ); + cVisibleWinRect.moveTopLeft( cImgWinRect.topLeft() + cVisibleWinRect.topLeft() ); - cVisibleWinRect = cVisibleWinRect & cImgWinRect; + cVisibleWinRect = cVisibleWinRect & cImgWinRect; - if(cVisibleWinRect.left()<0) - cVisibleWinRect.moveLeft(0); - if(cVisibleWinRect.top()<0) - cVisibleWinRect.moveTop(0); + if(cVisibleWinRect.left()<0) + cVisibleWinRect.moveLeft(0); + if(cVisibleWinRect.top()<0) + cVisibleWinRect.moveTop(0); - if(cVisibleWinRect.width()<=0) - cVisibleWinRect.setWidth(1); - if(cVisibleWinRect.height()<=0) - cVisibleWinRect.setHeight(1); + if(cVisibleWinRect.width()<=0) + cVisibleWinRect.setWidth(1); + if(cVisibleWinRect.height()<=0) + cVisibleWinRect.setHeight(1); - paInter.fillRect(cVisibleWinRect, QBrush(QColor(200, 200, 200, 128))); - paInter.setPen(QColor(255, 255, 255, 128)); - paInter.drawRect(cVisibleWinRect); + painter.fillRect(cVisibleWinRect, QBrush(QColor(200, 200, 200, 128))); + painter.setPen(QColor(255, 255, 255, 128)); + painter.drawRect(cVisibleWinRect); - //qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio; + //qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio; - } + } #endif QRect sr = viewToWindow( m_selectedArea ); @@ -645,13 +616,13 @@ Void ViewArea::paintEvent( QPaintEvent* event ) QBrush brush( selectColor ); if( m_blockTrackEnable ) - paInter.setBrush( Qt::NoBrush ); + painter.setBrush( Qt::NoBrush ); else - paInter.setBrush( brush ); + painter.setBrush( brush ); - paInter.setPen( Qt::darkCyan ); + painter.setPen( Qt::darkCyan ); - // paInter.drawRect( sr/*m_selectedArea*/ ); + // painter.drawRect( sr/*m_selectedArea*/ ); } else { @@ -660,23 +631,23 @@ Void ViewArea::paintEvent( QPaintEvent* event ) fill.setAlpha( 150 ); QBrush brush( fill ); - paInter.setBrush( fill ); - paInter.setPen( Qt::NoPen ); + painter.setBrush( fill ); + painter.setPen( Qt::NoPen ); QPainterPath myPath; QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) ); myPath.addRect( imgr ); myPath.addRect( sr ); // m_selectedArea - paInter.drawPath( myPath ); + painter.drawPath( myPath ); // 2) Draw the selection rectangle - paInter.setBrush( Qt::NoBrush ); - paInter.setPen( Qt::darkCyan ); - // paInter.drawRect( sr/*m_selectedArea*/ ); + painter.setBrush( Qt::NoBrush ); + painter.setPen( Qt::darkCyan ); + // painter.drawRect( sr/*m_selectedArea*/ ); } if( !ir.isNull() ) - paInter.drawRect( sr /*m_selectedArea*/ ); + painter.drawRect( sr /*m_selectedArea*/ ); } // Mask Mode ---------------------------------------------------------- @@ -695,12 +666,12 @@ Void ViewArea::paintEvent( QPaintEvent* event ) color = imageMaskColor; color.setAlpha( 120 ); - paInter.setPen( color ); - paInter.save(); - paInter.translate( m_xOffset, m_yOffset ); - paInter.scale( m_dZoomFactor, m_dZoomFactor ); - paInter.drawPixmap( QPoint( 0, 0 ), m_mask ); - paInter.restore(); + painter.setPen( color ); + painter.save(); + painter.translate( m_xOffset, m_yOffset ); + painter.scale( m_dZoomFactor, m_dZoomFactor ); + painter.drawPixmap( QPoint( 0, 0 ), m_mask ); + painter.restore(); if( !m_selectedArea.isNull() ) { @@ -730,13 +701,13 @@ Void ViewArea::paintEvent( QPaintEvent* event ) brush = QBrush( color ); if( m_blockTrackEnable ) - paInter.setBrush( Qt::NoBrush ); + painter.setBrush( Qt::NoBrush ); else - paInter.setBrush( brush ); + painter.setBrush( brush ); - paInter.setPen( color ); + painter.setPen( color ); if( !ir.isNull() ) - paInter.drawRect( sr ); + painter.drawRect( sr ); } } } @@ -744,10 +715,10 @@ Void ViewArea::paintEvent( QPaintEvent* event ) //////////////////////////////////////////////////////////////////////////////// // Mouse Events //////////////////////////////////////////////////////////////////////////////// -Void ViewArea::wheelEvent( QWheelEvent* event ) +void ViewArea::wheelEvent( QWheelEvent* event ) { - Double scale; - Double usedScale; + double scale; + double usedScale; if( event->modifiers() & Qt::ControlModifier ) { @@ -767,7 +738,7 @@ Void ViewArea::wheelEvent( QWheelEvent* event ) } } -Void ViewArea::mousePressEvent( QMouseEvent* event ) +void ViewArea::mousePressEvent( QMouseEvent* event ) { event->accept(); @@ -800,12 +771,12 @@ Void ViewArea::mousePressEvent( QMouseEvent* event ) // If grid tracking if( m_snapToGrid ) { - // Find if the cursor is near a grid Intersection - Bool isNear = m_grid.isNear( m_lastPos ); + // Find if the cursor is near a grid intersection + bool isNear = m_grid.isNear( m_lastPos ); isNear = true; if( isNear ) { - // The grid 'near Intersection' found when used isNear() + // The grid 'near intersection' found when used isNear() m_lastPos = m_grid.nearPos(); } } @@ -833,12 +804,12 @@ Void ViewArea::mousePressEvent( QMouseEvent* event ) } } -Void ViewArea::mouseMoveEvent( QMouseEvent* event ) +void ViewArea::mouseMoveEvent( QMouseEvent* event ) { event->accept(); #ifndef _MSC_VER - // Add this code line to aVoid slow navigation with some specific mouses + // Add this code line to avoid slow navigation with some specific mouses // This seems to always appear on windows if( qApp->hasPendingEvents() ) return; @@ -855,12 +826,12 @@ Void ViewArea::mouseMoveEvent( QMouseEvent* event ) // Grid tracking if( m_snapToGrid ) { - // Find if the cursor is near a grid Intersection - Bool isNear = m_grid.isNear( actualPos ); + // Find if the cursor is near a grid intersection + bool isNear = m_grid.isNear( actualPos ); if( isNear ) { - // Return the last grid near Intersection found + // Return the last grid near intersection found actualPos = m_grid.nearPos(); } } @@ -920,21 +891,21 @@ Void ViewArea::mouseMoveEvent( QMouseEvent* event ) } } /* else // if tool() == BlockSelectionTool || MaskTool || EraserTool - { - m_blockTrackEnable = false; - // If cursor is inside the selected area, we most redraw - // the selection rect because it may be smaller. - if( m_selectedArea.contains( actualPos ) ) - { - m_selectedArea = m_grid.rectContains( m_lastPos ); - } + { + m_blockTrackEnable = false; + // If cursor is inside the selected area, we most redraw + // the selection rect because it may be smaller. + if( m_selectedArea.contains( actualPos ) ) + { + m_selectedArea = m_grid.rectContains( m_lastPos ); + } - m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) ); - } - */ + m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) ); + } + */ if( tool() == SelectionTool ) { - // Intercept the selected area with the image area to limit the + // intercept the selected area with the image area to limit the // selection only to the image area, preventing it to come outside // the image. m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ); @@ -975,7 +946,7 @@ Void ViewArea::mouseMoveEvent( QMouseEvent* event ) } } -Void ViewArea::mouseReleaseEvent( QMouseEvent* event ) +void ViewArea::mouseReleaseEvent( QMouseEvent* event ) { event->accept(); @@ -1019,7 +990,7 @@ Void ViewArea::mouseReleaseEvent( QMouseEvent* event ) //////////////////////////////////////////////////////////////////////////////// -Bool ViewArea::isPosValid( const QPoint& pos ) const +bool ViewArea::isPosValid( const QPoint& pos ) const { if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() ) return false; @@ -1032,8 +1003,8 @@ Bool ViewArea::isPosValid( const QPoint& pos ) const QPoint ViewArea::windowToView( const QPoint& pt ) const { QPoint p; - p.setX( static_cast( ( pt.x() - m_xOffset ) / m_dZoomFactor ) ); - p.setY( static_cast( ( pt.y() - m_yOffset ) / m_dZoomFactor ) ); + p.setX( static_cast( ( pt.x() - m_xOffset ) / m_dZoomFactor ) ); + p.setY( static_cast( ( pt.y() - m_yOffset ) / m_dZoomFactor ) ); return p; } @@ -1043,11 +1014,11 @@ QRect ViewArea::windowToView( const QRect& rc ) const QRect r; r.setTopLeft( windowToView( rc.topLeft() ) ); - // r.setRight ( (Int)( ceil(( rc.right() - m_xOffset)/m_dZoomFactor ))); - // r.setBottom( (Int)( ceil(( rc.bottom()- m_yOffset)/m_dZoomFactor ))); - // r.setRight ( static_cast(( rc.right() - m_xOffset ) / + // r.setRight ( (int)( ceil(( rc.right() - m_xOffset)/m_dZoomFactor ))); + // r.setBottom( (int)( ceil(( rc.bottom()- m_yOffset)/m_dZoomFactor ))); + // r.setRight ( static_cast(( rc.right() - m_xOffset ) / // m_dZoomFactor +1)); - // r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / + // r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / // m_dZoomFactor+1)); r.setBottomRight( windowToView( rc.bottomRight() ) ); return r; @@ -1057,8 +1028,8 @@ QPoint ViewArea::viewToWindow( const QPoint& pt ) const { QPoint p; - p.setX( static_cast( pt.x() * m_dZoomFactor + m_xOffset ) ); - p.setY( static_cast( pt.y() * m_dZoomFactor + m_yOffset ) ); + p.setX( static_cast( pt.x() * m_dZoomFactor + m_xOffset ) ); + p.setY( static_cast( pt.y() * m_dZoomFactor + m_yOffset ) ); return p; } @@ -1068,18 +1039,18 @@ QRect ViewArea::viewToWindow( const QRect& rc ) const QRect r; r.setTopLeft( viewToWindow( rc.topLeft() ) ); - // r.setRight ( (Int)( ceil(( rc.right() +1+m_xOffset )*m_dZoomFactor ) - + // r.setRight ( (int)( ceil(( rc.right() +1+m_xOffset )*m_dZoomFactor ) - // 1 )); - // r.setBottom( (Int)( ceil(( rc.bottom()+1+m_yOffset )*m_dZoomFactor ) - + // r.setBottom( (int)( ceil(( rc.bottom()+1+m_yOffset )*m_dZoomFactor ) - // 1 )); - // r.setRight ( (Int)( ceil(( rc.right()+0.5)*m_dZoomFactor )+ m_xOffset + // r.setRight ( (int)( ceil(( rc.right()+0.5)*m_dZoomFactor )+ m_xOffset // )-1); - // r.setBottom( (Int)( ceil(( rc.bottom()+0.5)*m_dZoomFactor ) +m_yOffset + // r.setBottom( (int)( ceil(( rc.bottom()+0.5)*m_dZoomFactor ) +m_yOffset // )-1); // qDebug()<<"Right = "<< r.right(); - // r.setRight ( static_cast(( rc.right()+1) * m_dZoomFactor + + // r.setRight ( static_cast(( rc.right()+1) * m_dZoomFactor + // m_xOffset -1) ); - // r.setBottom( static_cast(( rc.bottom()+1) * m_dZoomFactor + + // r.setBottom( static_cast(( rc.bottom()+1) * m_dZoomFactor + // m_yOffset -1)); r.setBottomRight( viewToWindow( rc.bottomRight() ) ); @@ -1089,28 +1060,28 @@ QRect ViewArea::viewToWindow( const QRect& rc ) const //////////////////////////////////////////////////////////////////////////////// // Masks Management //////////////////////////////////////////////////////////////////////////////// -Void ViewArea::updateMask( const QRect& rect ) +void ViewArea::updateMask( const QRect& rect ) { switch( tool() ) { case MaskTool: { // Add rect to the mask - QPainter paInter( &m_mask ); - paInter.setBrush( Qt::color1 ); - paInter.setPen( Qt::NoPen ); - paInter.drawRect( rect ); - paInter.end(); + QPainter painter( &m_mask ); + painter.setBrush( Qt::color1 ); + painter.setPen( Qt::NoPen ); + painter.drawRect( rect ); + painter.end(); break; } case EraserTool: { // Clears rect area in the mask - QPainter paInter( &m_mask ); - paInter.setBrush( Qt::color0 ); - paInter.setPen( Qt::NoPen ); - paInter.drawRect( rect ); - paInter.end(); + QPainter painter( &m_mask ); + painter.setBrush( Qt::color0 ); + painter.setPen( Qt::NoPen ); + painter.drawRect( rect ); + painter.end(); break; } default: /* Do Nothing */ diff --git a/app/ViewArea.h b/app/ViewArea.h index 4a319f0..405a1d9 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -26,10 +26,10 @@ #ifndef __VIEWAREA_H__ #define __VIEWAREA_H__ +#include "CommonDefs.h" #include "GridManager.h" -#include "PlaYUVerAppDefs.h" #include "config.h" -#include "lib/PlaYUVerFrame.h" +#include "lib/CalypFrame.h" #include #include @@ -37,7 +37,7 @@ #include #include -class PlaYUVerStream; +class CalypStream; /** * @@ -56,38 +56,38 @@ public: ViewArea( QWidget* parent = 0 ); - Void setImage( PlaYUVerFrame* pcFrame ); - Void setImage( const QPixmap& pixmap ); + void setImage( CalypFrame* pcFrame ); + void setImage( const QPixmap& pixmap ); - Void setMode( Int mode ); - Void setMaskColor( const QColor& color = QColor() ); + void setMode( int mode ); + void setMaskColor( const QColor& color = QColor() ); /** * Clears any contents. */ - Void clear(); + void clear(); /** * Select tool from the menu */ - Void setTool( UInt view ); + void setTool( unsigned int view ); - Void setGridVisible( Bool enable ); + void setGridVisible( bool enable ); /** * Clears any mask content. */ - Void clearMask(); + void clearMask(); QPixmap image() const { return m_pixmap; } QBitmap mask() const { return m_mask; } QRect selectedArea() const { return m_selectedArea; } GridManager gridManager() const { return m_grid; } QColor maskColor() const { return m_maskColor; } - Double getZoomFactor() { return m_dZoomFactor; } + double getZoomFactor() { return m_dZoomFactor; } // Scale function. Return used scale value (it may change when it touches the // min or max zoom value) - Double scaleZoomFactor( Double scale, QPoint center, QSize minimumSize ); + double scaleZoomFactor( double scale, QPoint center, QSize minimumSize ); Q_SIGNALS: void selectionChanged( const QRect& rect ); @@ -96,25 +96,25 @@ Q_SIGNALS: void zoomFactorChanged_byWheel( const double factor, const QPoint center ); public Q_SLOTS: - // Void setNormalMode(); - // Void setMaskMode(); - // Void setMaskTool(); - // Void setEraserTool(); - // Void setNormalSelectionTool(); - // Void setBlockSelectionTool(); + // void setNormalMode(); + // void setMaskMode(); + // void setMaskTool(); + // void setEraserTool(); + // void setNormalSelectionTool(); + // void setBlockSelectionTool(); void setSnapToGrid( bool enable ); // void setSelectedArea( QRect &rect ); protected: - Void paintEvent( QPaintEvent* event ); - Void resizeEvent( QResizeEvent* event ); - Void mousePressEvent( QMouseEvent* event ); - Void mouseMoveEvent( QMouseEvent* event ); - Void mouseReleaseEvent( QMouseEvent* event ); - Void wheelEvent( QWheelEvent* event ); + void paintEvent( QPaintEvent* event ); + void resizeEvent( QResizeEvent* event ); + void mousePressEvent( QMouseEvent* event ); + void mouseMoveEvent( QMouseEvent* event ); + void mouseReleaseEvent( QMouseEvent* event ); + void wheelEvent( QWheelEvent* event ); - Void updateSize(); - Void updateOffset(); + void updateSize(); + void updateOffset(); private: enum ViewMode @@ -133,12 +133,12 @@ private: ViewMode mode() const { return m_mode; } Tool tool() const { return m_eTool; } - Void initZoomWinRect(); - Void startZoomWinTimer(); - Void setZoomFactor( Double ); + void initZoomWinRect(); + void startZoomWinTimer(); + void setZoomFactor( double ); - Bool isPosValid( const QPoint& pos ) const; - Void updateMask( const QRect& rect ); + bool isPosValid( const QPoint& pos ) const; + void updateMask( const QRect& rect ); QPoint windowToView( const QPoint& pt ) const; QRect windowToView( const QRect& rc ) const; @@ -146,16 +146,16 @@ private: QPoint viewToWindow( const QPoint& pt ) const; QRect viewToWindow( const QRect& rc ) const; - PlaYUVerFrame* m_pcCurrFrame; + CalypFrame* m_pcCurrFrame; - Pel m_uiPixelHalfScale; + ClpPel m_uiPixelHalfScale; Tool m_eTool; - Bool m_bGridVisible; + bool m_bGridVisible; QTimer m_zoomWinTimer; - Double m_dZoomWinRatio; - Double m_dZoomFactor; + double m_dZoomWinRatio; + double m_dZoomFactor; QPixmap m_pixmap; QBitmap m_mask; @@ -166,13 +166,13 @@ private: ViewMode m_mode; QColor m_maskColor; - Int m_xOffset; - Int m_yOffset; - Bool m_blockTrackEnable; - Bool m_newShape; - Bool m_snapToGrid; - Bool m_cursorInGrid; - Bool m_visibleZoomRect; + int m_xOffset; + int m_yOffset; + bool m_blockTrackEnable; + bool m_newShape; + bool m_snapToGrid; + bool m_cursorInGrid; + bool m_visibleZoomRect; }; #endif // __VIEWAREA_H__ diff --git a/app/AboutDialog.cpp b/app/dialog/AboutDialog.cpp similarity index 84% rename from app/AboutDialog.cpp rename to app/dialog/AboutDialog.cpp index 07205a1..40d7e9f 100644 --- a/app/AboutDialog.cpp +++ b/app/dialog/AboutDialog.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * Joao Santos (joaompssantos@gmail.com) @@ -40,17 +40,16 @@ AboutDialog::AboutDialog( QWidget* parent ) : QDialog( parent ) { - QPixmap logo = QPixmap( ":/images/playuver-background-logo.png" ).scaled( QSize( 500, 350 ), Qt::KeepAspectRatio ); + QPixmap logo = QPixmap( ":logos/calyp-logo.png" ).scaledToWidth( 200, Qt::SmoothTransformation ); QLabel* pixmapLabel = new QLabel; pixmapLabel->setPixmap( logo ); - QLabel* label = new QLabel( QString( "

%1 Version %2

%3

" ) - .arg( QApplication::applicationName() ) - .arg( QApplication::applicationVersion() ) - .arg( tr( "Enhanced open-source Qt-based raw video player" ) ) ); - label->setWordWrap( true ); + QLabel* label = new QLabel( QString( "

%1

Version %2

" ) + .arg( tr( "Enhanced open-source video player" ) ) + .arg( QApplication::applicationVersion() ) ); + label->setWordWrap( false ); - QString featuresList = QStringLiteral( "

Features:

    " ); + QString featuresList = QStringLiteral( "

    Features:

      " ); #ifdef USE_QTDBUS featuresList.append( QStringLiteral( "
    • Support for Qt DBus messages" ) ); @@ -62,14 +61,13 @@ AboutDialog::AboutDialog( QWidget* parent ) featuresList.append( QStringLiteral( "
    • Support for OpenCV" ) ); #endif featuresList.append( QStringLiteral( "

    " ) ); - QLabel* labelFeatures = new QLabel( featuresList ); - QLabel* labelCopyright = new QLabel( QStringLiteral( "Copyright © 2014–2017 Luis Lucas and Joao Carreira" ) ); + QLabel* labelCopyright = new QLabel( QStringLiteral( "Copyright © 2014–2018 Joao Carreira and Luis Lucas" ) ); QWidget* topWidget = new QWidget; QVBoxLayout* topLayout = new QVBoxLayout; - topLayout->addWidget( pixmapLabel ); + topLayout->addWidget( pixmapLabel, 0, Qt::AlignHCenter ); topLayout->addWidget( label ); topLayout->addWidget( labelFeatures ); topLayout->addWidget( labelCopyright ); @@ -96,4 +94,7 @@ AboutDialog::AboutDialog( QWidget* parent ) buttonBox->setFocus(); setWindowTitle( tr( "About %1" ).arg( QApplication::applicationName() ) ); + + // Prevent window resize + this->layout()->setSizeConstraint( QLayout::SetFixedSize ); } diff --git a/app/AboutDialog.h b/app/dialog/AboutDialog.h similarity index 96% rename from app/AboutDialog.h rename to app/dialog/AboutDialog.h index d56f2ea..bf726f8 100644 --- a/app/AboutDialog.h +++ b/app/dialog/AboutDialog.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * diff --git a/app/ConfigureFormatDialog.cpp b/app/dialog/ConfigureFormatDialog.cpp similarity index 85% rename from app/ConfigureFormatDialog.cpp rename to app/dialog/ConfigureFormatDialog.cpp index 4c8faf4..664bc7d 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/dialog/ConfigureFormatDialog.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,7 +24,7 @@ #include "ConfigureFormatDialog.h" -#include "lib/PlaYUVerFrame.h" +#include "lib/CalypFrame.h" #include #include @@ -41,11 +41,11 @@ #define MAX_SUPPORTED_RESOLUTION 99999 -QDataStream& operator<<( QDataStream& out, const PlaYUVerStdResolutionVector& array ) +QDataStream& operator<<( QDataStream& out, const CalypStandardResolutionVector& array ) { - PlaYUVerStdResolution d; + CalypStandardResolution d; out << array.size(); - for( Int i = 0; i < array.size(); i++ ) + for( int i = 0; i < array.size(); i++ ) { d = array.at( i ); out << QString::fromStdString( d.shortName ) << d.uiWidth << d.uiHeight; @@ -53,13 +53,13 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStdResolutionVector& ar return out; } -QDataStream& operator>>( QDataStream& in, PlaYUVerStdResolutionVector& array ) +QDataStream& operator>>( QDataStream& in, CalypStandardResolutionVector& array ) { - PlaYUVerStdResolution d; + CalypStandardResolution d; QString auxName; - Int array_size; + int array_size; in >> array_size; - for( Int i = 0; i < array_size; i++ ) + for( int i = 0; i < array_size; i++ ) { in >> auxName; d.shortName = auxName.toStdString(); @@ -118,9 +118,9 @@ public: connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); } - PlaYUVerStdResolution runDialog() + CalypStandardResolution runDialog() { - PlaYUVerStdResolution stdResolution; + CalypStandardResolution stdResolution; stdResolution.shortName = ""; if( exec() == QDialog::Accepted ) { @@ -141,10 +141,10 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( parent ) { QString Name; - UInt uiWidth, uiHeight; + unsigned int uiWidth, uiHeight; readSettings(); - for( Int i = 0; i < aRCustomFileFormats.size(); i++ ) + for( int i = 0; i < aRCustomFileFormats.size(); i++ ) { Name = QString::fromStdString( aRCustomFileFormats[i].shortName ); uiWidth = aRCustomFileFormats[i].uiWidth; @@ -153,12 +153,12 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) standardResolutionSizes.append( QSize( uiWidth, uiHeight ) ); } - std::vector listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes(); - for( UInt i = 0; i < listPlaYUVerStdResolution.size(); i++ ) + std::vector listCalypStdResolution = CalypStream::stdResolutionSizes(); + for( unsigned int i = 0; i < listCalypStdResolution.size(); i++ ) { - Name = QString::fromStdString( listPlaYUVerStdResolution[i].shortName ); - uiWidth = listPlaYUVerStdResolution[i].uiWidth; - uiHeight = listPlaYUVerStdResolution[i].uiHeight; + Name = QString::fromStdString( listCalypStdResolution[i].shortName ); + uiWidth = listCalypStdResolution[i].uiWidth; + uiHeight = listCalypStdResolution[i].uiHeight; standardResolutionNames.append( QString( "%1 (%2x%3)" ).arg( Name ).arg( uiWidth ).arg( uiHeight ) ); standardResolutionSizes.append( QSize( uiWidth, uiHeight ) ); } @@ -283,9 +283,9 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) m_comboBoxPixelFormat->setFont( normalFont ); m_comboBoxPixelFormat->clear(); - for( UInt i = 0; i < PlaYUVerFrame::supportedColorSpacesListNames().size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedColorSpacesListNames().size(); i++ ) { - m_comboBoxColorSpace->insertItem( i, PlaYUVerFrame::supportedColorSpacesListNames()[i].c_str() ); + m_comboBoxColorSpace->insertItem( i, CalypFrame::supportedColorSpacesListNames()[i].c_str() ); } m_comboBoxColorSpace->setCurrentIndex( 1 ); @@ -382,8 +382,8 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) setFixedSize( MainLayout->sizeHint() ); } -Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UInt& rWidth, UInt& rHeight, - Int& rInputFormat, UInt& rBits, Int& rEndianess, UInt& rFrameRate ) +int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, + int& rInputFormat, unsigned int& rBits, int& rEndianess, unsigned int& rFrameRate ) { // Set default values // setWindowTitle( "Configure resolution for " + Filename ); @@ -391,16 +391,16 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UI m_spinBoxWidth->setValue( rWidth ); m_spinBoxheight->setValue( rHeight ); - Int colorSpace = 0; - Int sampling = 0; + int colorSpace = 0; + int sampling = 0; if( rInputFormat >= 0 ) { - String pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[rInputFormat]; - for( UInt j = 0; j < PlaYUVerFrame::supportedColorSpacesListNames().size(); j++ ) + ClpString pelFmtName = CalypFrame::supportedPixelFormatListNames()[rInputFormat]; + for( unsigned int j = 0; j < CalypFrame::supportedColorSpacesListNames().size(); j++ ) { - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( j ).size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( j ).size(); i++ ) { - if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames( j )[i] ) + if( pelFmtName == CalypFrame::supportedPixelFormatListNames( j )[i] ) { colorSpace = j; sampling = i; @@ -423,7 +423,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UI } m_spinBoxFrameRate->setValue( rFrameRate ); - for( Int i = 0; i < standardResolutionSizes.size() - 1; i++ ) + for( int i = 0; i < standardResolutionSizes.size() - 1; i++ ) { if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) ) { @@ -442,10 +442,10 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UI rHeight = m_spinBoxheight->value(); colorSpace = m_comboBoxColorSpace->currentIndex(); sampling = m_comboBoxPixelFormat->currentIndex(); - String pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames( colorSpace )[sampling]; - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + ClpString pelFmtName = CalypFrame::supportedPixelFormatListNames( colorSpace )[sampling]; + for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ ) { - if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames()[i] ) + if( pelFmtName == CalypFrame::supportedPixelFormatListNames()[i] ) { rInputFormat = i; break; @@ -458,12 +458,12 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UI return QDialog::Accepted; } -void ConfigureFormatDialog::slotStandardResolutionSelected( Int idx ) +void ConfigureFormatDialog::slotStandardResolutionSelected( int idx ) { if( idx == standardResolutionSizes.size() - 1 ) { AddCustomFormat* pcCustomFmtDialog = new AddCustomFormat; - PlaYUVerStdResolution customResolution = pcCustomFmtDialog->runDialog(); + CalypStandardResolution customResolution = pcCustomFmtDialog->runDialog(); aRCustomFileFormats.append( customResolution ); if( customResolution.shortName != "" ) { @@ -493,8 +493,8 @@ void ConfigureFormatDialog::slotStandardResolutionSelected( Int idx ) void ConfigureFormatDialog::slotResolutionChange() { m_comboBoxStandardResolution->blockSignals( true ); - Int newIdx = -1; - for( Int i = 0; i < standardResolutionSizes.size(); i++ ) + int newIdx = -1; + for( int i = 0; i < standardResolutionSizes.size(); i++ ) { if( standardResolutionSizes.at( i ) == QSize( m_spinBoxWidth->value(), m_spinBoxheight->value() ) ) { @@ -506,20 +506,20 @@ void ConfigureFormatDialog::slotResolutionChange() m_comboBoxStandardResolution->blockSignals( false ); } -Void ConfigureFormatDialog::slotColorSpaceChange( Int idx ) +void ConfigureFormatDialog::slotColorSpaceChange( int idx ) { if( idx == -1 ) return; m_comboBoxPixelFormat->clear(); - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( idx ).size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( idx ).size(); i++ ) { - m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames( idx )[i].c_str() ); + m_comboBoxPixelFormat->insertItem( i, CalypFrame::supportedPixelFormatListNames( idx )[i].c_str() ); } m_comboBoxPixelFormat->setCurrentIndex( 0 ); } -Void ConfigureFormatDialog::slotBitsChange( Int idx ) +void ConfigureFormatDialog::slotBitsChange( int idx ) { if( idx > 8 ) { @@ -531,17 +531,17 @@ Void ConfigureFormatDialog::slotBitsChange( Int idx ) } } -Void ConfigureFormatDialog::readSettings() +void ConfigureFormatDialog::readSettings() { QSettings appSettings; QVariant value = appSettings.value( "ConfigureFormatDialog/CustomFormats" ); - aRCustomFileFormats = value.value(); + aRCustomFileFormats = value.value(); } -Void ConfigureFormatDialog::writeSettings() +void ConfigureFormatDialog::writeSettings() { QSettings appSettings; QVariant var; - var.setValue( aRCustomFileFormats ); + var.setValue( aRCustomFileFormats ); appSettings.setValue( "ConfigureFormatDialog/CustomFormats", var ); } diff --git a/app/ConfigureFormatDialog.h b/app/dialog/ConfigureFormatDialog.h similarity index 72% rename from app/ConfigureFormatDialog.h rename to app/dialog/ConfigureFormatDialog.h index 00706ce..51b1c85 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/dialog/ConfigureFormatDialog.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -28,8 +28,8 @@ #include #include -#include "PlaYUVerAppDefs.h" -#include "lib/PlaYUVerStream.h" +#include "CommonDefs.h" +#include "lib/CalypStream.h" class QComboBox; class QHBoxLayout; @@ -38,9 +38,9 @@ class QSpinBox; class QString; class QWidget; -typedef QVector PlaYUVerStdResolutionVector; -QDataStream& operator<<( QDataStream& out, const PlaYUVerStdResolutionVector& array ); -QDataStream& operator>>( QDataStream& in, PlaYUVerStdResolutionVector& array ); +typedef QVector CalypStandardResolutionVector; +QDataStream& operator<<( QDataStream& out, const CalypStandardResolutionVector& array ); +QDataStream& operator>>( QDataStream& in, CalypStandardResolutionVector& array ); /** * @@ -51,11 +51,11 @@ class ConfigureFormatDialog : public QDialog public: ConfigureFormatDialog( QWidget* parent = 0 ); - Int runConfigureFormatDialog( const QString& Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, - Int& rEndianess, UInt& rFrameRate ); + int runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBits, + int& rEndianess, unsigned int& rFrameRate ); - Void readSettings(); - Void writeSettings(); + void readSettings(); + void writeSettings(); private Q_SLOTS: void slotStandardResolutionSelected( int ); @@ -66,7 +66,7 @@ private Q_SLOTS: private: QStringList standardResolutionNames; QVector standardResolutionSizes; - PlaYUVerStdResolutionVector aRCustomFileFormats; + CalypStandardResolutionVector aRCustomFileFormats; QLabel* m_labelFilename; QComboBox* m_comboBoxStandardResolution; @@ -81,7 +81,7 @@ private: QSpinBox* m_spinBoxFrameRate; }; -Q_DECLARE_METATYPE( PlaYUVerStdResolution ); -Q_DECLARE_METATYPE( PlaYUVerStdResolutionVector ); +Q_DECLARE_METATYPE( CalypStandardResolution ); +Q_DECLARE_METATYPE( CalypStandardResolutionVector ); #endif // __CONFIGUREFORMATDIALOG_H__ diff --git a/app/ModulesHandleOptDialog.cpp b/app/dialog/ModulesHandleOptDialog.cpp similarity index 87% rename from app/ModulesHandleOptDialog.cpp rename to app/dialog/ModulesHandleOptDialog.cpp index 15b4bbb..3d81502 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/dialog/ModulesHandleOptDialog.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,7 +24,7 @@ #include "ModulesHandleOptDialog.h" -#include "lib/PlaYUVerOptions.h" +#include "lib/CalypOptions.h" #include #include @@ -71,26 +71,26 @@ public: } return m_pcValue->text(); } - const String& getName() { return m_cName; } + const ClpString& getName() { return m_cName; } private: QLineEdit* m_pcValue; QCheckBox* m_pcChecked; QLabel* m_pcDescription; - String m_cName; + ClpString m_cName; }; -ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, PlaYUVerAppModuleIf* pcCurrModuleIf ) +ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, CalypAppModuleIf* pcCurrModuleIf ) : QDialog( parent ), m_pcCurrModuleIf( pcCurrModuleIf ) { resize( 400, 10 ); setWindowTitle( "Select module parameters" ); - const PlaYUVerOptions::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); + const CalypOptions::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); QVBoxLayout* optionsLayout = new QVBoxLayout; OpionConfiguration* pcOption; - for( PlaYUVerOptions::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) + for( CalypOptions::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) { pcOption = new OpionConfiguration( ( *it )->opt ); m_apcOptionList.append( pcOption ); @@ -113,18 +113,18 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, PlaYUVerAppModu connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); } -Int ModulesHandleOptDialog::runConfiguration() +int ModulesHandleOptDialog::runConfiguration() { if( exec() == QDialog::Rejected ) { return QDialog::Rejected; } - std::vector argsArray; - String optionString; + std::vector argsArray; + ClpString optionString; QString valueString( "" ); - for( Int i = 0; i < m_apcOptionList.size(); i++ ) + for( int i = 0; i < m_apcOptionList.size(); i++ ) { valueString = m_apcOptionList.at( i )->getValue(); if( !valueString.isEmpty() ) diff --git a/app/ModulesHandleOptDialog.h b/app/dialog/ModulesHandleOptDialog.h similarity index 83% rename from app/ModulesHandleOptDialog.h rename to app/dialog/ModulesHandleOptDialog.h index b00ee51..3c760fb 100644 --- a/app/ModulesHandleOptDialog.h +++ b/app/dialog/ModulesHandleOptDialog.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,8 +25,8 @@ #ifndef __MODULEHANDLEOPTDIALOG_H__ #define __MODULEHANDLEOPTDIALOG_H__ -#include "PlaYUVerAppDefs.h" -#include "PlaYUVerAppModuleIf.h" +#include "CalypAppModuleIf.h" +#include "CommonDefs.h" #include "config.h" #include @@ -42,11 +42,11 @@ class ModulesHandleOptDialog : public QDialog Q_OBJECT public: - ModulesHandleOptDialog( QWidget* parent, PlaYUVerAppModuleIf* pcCurrModuleIf ); - Int runConfiguration(); + ModulesHandleOptDialog( QWidget* parent, CalypAppModuleIf* pcCurrModuleIf ); + int runConfiguration(); private: - PlaYUVerAppModuleIf* m_pcCurrModuleIf; + CalypAppModuleIf* m_pcCurrModuleIf; QVector m_apcOptionList; }; diff --git a/app/ProgressBar.cpp b/app/dialog/ProgressBar.cpp similarity index 92% rename from app/ProgressBar.cpp rename to app/dialog/ProgressBar.cpp index 4921f1f..2b72b80 100644 --- a/app/ProgressBar.cpp +++ b/app/dialog/ProgressBar.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -30,7 +30,7 @@ #include #include -ProgressBar::ProgressBar( QWidget* parent, UInt maxValue ) +ProgressBar::ProgressBar( QWidget* parent, unsigned int maxValue ) : QWidget( parent ), m_uiTotalProgress( maxValue ), m_uiProgress( 0 ) { QVBoxLayout* mainLayout = new QVBoxLayout( this ); @@ -51,7 +51,7 @@ ProgressBar::ProgressBar( QWidget* parent, UInt maxValue ) show(); } -Void ProgressBar::incrementProgress( UInt increment ) +void ProgressBar::incrementProgress( unsigned int increment ) { m_uiProgress += increment; m_pcProgressBar->setValue( m_uiProgress ); diff --git a/app/ProgressBar.h b/app/dialog/ProgressBar.h similarity index 84% rename from app/ProgressBar.h rename to app/dialog/ProgressBar.h index 8f2366b..c0655a7 100644 --- a/app/ProgressBar.h +++ b/app/dialog/ProgressBar.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,7 +25,7 @@ #ifndef __PROGRESSBAR_H__ #define __PROGRESSBAR_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include #include @@ -37,13 +37,13 @@ class ProgressBar : public QWidget Q_OBJECT public: - ProgressBar( QWidget* parent, UInt maxValue ); + ProgressBar( QWidget* parent, unsigned int maxValue ); - Void incrementProgress( UInt ); + void incrementProgress( unsigned int ); private: - UInt m_uiTotalProgress; - UInt m_uiProgress; + unsigned int m_uiTotalProgress; + unsigned int m_uiProgress; QProgressBar* m_pcProgressBar; }; diff --git a/app/SeekStreamDialog.cpp b/app/dialog/SeekStreamDialog.cpp similarity index 93% rename from app/SeekStreamDialog.cpp rename to app/dialog/SeekStreamDialog.cpp index ca18e10..5a08c12 100644 --- a/app/SeekStreamDialog.cpp +++ b/app/dialog/SeekStreamDialog.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,7 +24,7 @@ #include "SeekStreamDialog.h" -#include "lib/PlaYUVerStream.h" +#include "lib/CalypStream.h" #include #include @@ -33,7 +33,7 @@ #include #include -SeekStreamDialog::SeekStreamDialog( PlaYUVerStream* pcCurrStream, QWidget* parent ) +SeekStreamDialog::SeekStreamDialog( CalypStream* pcCurrStream, QWidget* parent ) : QDialog( parent, Qt::Dialog | Qt::WindowTitleHint ), m_iSelectedFrameNum() { m_iSelectedFrameNum = pcCurrStream->getCurrFrameNum(); @@ -70,7 +70,7 @@ SeekStreamDialog::SeekStreamDialog( PlaYUVerStream* pcCurrStream, QWidget* paren connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); } -Int SeekStreamDialog::runDialog() +int SeekStreamDialog::runDialog() { m_spinFrameNum->selectAll(); if( exec() == QDialog::Rejected ) diff --git a/app/SeekStreamDialog.h b/app/dialog/SeekStreamDialog.h similarity index 84% rename from app/SeekStreamDialog.h rename to app/dialog/SeekStreamDialog.h index 4555b36..90d4df5 100644 --- a/app/SeekStreamDialog.h +++ b/app/dialog/SeekStreamDialog.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,8 +25,8 @@ #ifndef __SEEKSTREAMDIALOG_H__ #define __SEEKSTREAMDIALOG_H__ -#include "PlaYUVerAppDefs.h" -#include "PlaYUVerAppModuleIf.h" +#include "CalypAppModuleIf.h" +#include "CommonDefs.h" #include "config.h" #include @@ -42,12 +42,12 @@ class SeekStreamDialog : public QDialog Q_OBJECT public: - SeekStreamDialog( PlaYUVerStream* pcCurrStream, QWidget* parent = 0 ); - Int runDialog(); + SeekStreamDialog( CalypStream* pcCurrStream, QWidget* parent = 0 ); + int runDialog(); private: QSpinBox* m_spinFrameNum; - Int m_iSelectedFrameNum; + int m_iSelectedFrameNum; }; #endif // __MODULEHANDLEOPTDIALOG_H__ diff --git a/app/DialogSubWindowSelector.cpp b/app/dialog/SubWindowSelectorDialog.cpp similarity index 82% rename from app/DialogSubWindowSelector.cpp rename to app/dialog/SubWindowSelectorDialog.cpp index 6794362..6b4c172 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/dialog/SubWindowSelectorDialog.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -22,16 +22,16 @@ * \brief Dialog box to select sub windows */ -#include "DialogSubWindowSelector.h" +#include "SubWindowSelectorDialog.h" -#include "PlaYUVerSubWindowHandle.h" +#include "SubWindowHandle.h" #include "VideoSubWindow.h" #include #include -DialogSubWindowSelector::DialogSubWindowSelector( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, - UInt uiCategory, Int minWindowsSelected, Int maxWindowsSelected ) +SubWindowSelectorDialog::SubWindowSelectorDialog( QWidget* parent, SubWindowHandle* windowManager, + unsigned int uiCategory, int minWindowsSelected, int maxWindowsSelected ) : QDialog( parent ) , m_uiCategory( uiCategory ) , m_iMinSelectedWindows( minWindowsSelected ) @@ -86,7 +86,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget* parent, PlaYUVerSubWi QString currSubWindowName; QCheckBox* windowCheckBox; m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSubWindowList.size(); i++ ) { subWindow = m_apcSubWindowList.at( i ); currSubWindowName = subWindow->getWindowName(); @@ -101,17 +101,17 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget* parent, PlaYUVerSubWi setFixedSize( mainLayout->sizeHint() ); } -Void DialogSubWindowSelector::updateSubWindowList() +void SubWindowSelectorDialog::updateSubWindowList() { QLayout* pcLayout = m_pcGroupCheckBox->layout(); QLayoutItem* pcLayoutItem; QCheckBox* windowCheckBox; - Int iIdx; + int iIdx; /** * Remove all check boxes */ - for( Int i = 0; i < pcLayout->count(); i++ ) + for( int i = 0; i < pcLayout->count(); i++ ) { pcLayoutItem = pcLayout->itemAt( i ); if( pcLayoutItem ) @@ -121,7 +121,7 @@ Void DialogSubWindowSelector::updateSubWindowList() } } - for( Int i = 0; i < m_apcSelectedSubWindowList.size(); i++ ) + for( int i = 0; i < m_apcSelectedSubWindowList.size(); i++ ) { iIdx = m_apcSubWindowList.indexOf( m_apcSelectedSubWindowList.at( i ) ); if( iIdx >= 0 ) @@ -130,23 +130,23 @@ Void DialogSubWindowSelector::updateSubWindowList() m_pcGroupCheckBox->layout()->addWidget( windowCheckBox ); } } - for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + for( int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { if( !m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) ) m_pcGroupCheckBox->layout()->addWidget( m_apcWindowsListCheckBox.at( i ) ); } } -Void DialogSubWindowSelector::selectSubWindow( SubWindowAbstract* subWindow ) +void SubWindowSelectorDialog::selectSubWindow( SubWindowAbstract* subWindow ) { - Int iIdx = m_apcSubWindowList.indexOf( subWindow ); + int iIdx = m_apcSubWindowList.indexOf( subWindow ); if( iIdx >= 0 ) { m_apcWindowsListCheckBox.at( iIdx )->setChecked( true ); } } -Void DialogSubWindowSelector::update() +void SubWindowSelectorDialog::update() { if( m_apcSelectedSubWindowList.size() > 0 ) { @@ -178,7 +178,7 @@ Void DialogSubWindowSelector::update() } if( m_apcSelectedSubWindowList.size() >= m_iMaxSlectedWindows ) { - for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + for( int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { if( m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) ) { @@ -192,7 +192,7 @@ Void DialogSubWindowSelector::update() } else { - for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + for( int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { m_apcWindowsListCheckBox.at( i )->setEnabled( true ); } @@ -203,9 +203,9 @@ Void DialogSubWindowSelector::update() // ----------------------- Slot Functions ----------------------- -Void DialogSubWindowSelector::toggleSubWindow( Int idx ) +void SubWindowSelectorDialog::toggleSubWindow( int idx ) { - Bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked(); + bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked(); if( isChecked ) { @@ -218,19 +218,19 @@ Void DialogSubWindowSelector::toggleSubWindow( Int idx ) update(); } -Void DialogSubWindowSelector::addAllSubWindow() +void SubWindowSelectorDialog::addAllSubWindow() { m_apcSelectedSubWindowList.clear(); - for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + for( int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { m_apcWindowsListCheckBox.at( i )->setChecked( true ); } update(); } -Void DialogSubWindowSelector::removeAllSubWindow() +void SubWindowSelectorDialog::removeAllSubWindow() { - for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + for( int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { m_apcWindowsListCheckBox.at( i )->setChecked( false ); } diff --git a/app/DialogSubWindowSelector.h b/app/dialog/SubWindowSelectorDialog.h similarity index 78% rename from app/DialogSubWindowSelector.h rename to app/dialog/SubWindowSelectorDialog.h index 869c54b..19e9496 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/dialog/SubWindowSelectorDialog.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,7 +25,7 @@ #ifndef __DIALOGSUBWINDOWSELECTOR_H__ #define __DIALOGSUBWINDOWSELECTOR_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" #include @@ -38,29 +38,29 @@ class QColor; class QCheckBox; class QGroupBox; -class PlaYUVerSubWindowHandle; +class SubWindowHandle; class SubWindowAbstract; /** * Class to define the dialog box to select sub windows * This class enable the selection of several group of windows */ -class DialogSubWindowSelector : public QDialog +class SubWindowSelectorDialog : public QDialog { Q_OBJECT public: - DialogSubWindowSelector( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, UInt uiCategory, - Int minWindowsSelected = 1, Int maxWindowsSelected = -1 ); + SubWindowSelectorDialog( QWidget* parent, SubWindowHandle* windowManager, unsigned int uiCategory, + int minWindowsSelected = 1, int maxWindowsSelected = -1 ); - Void selectSubWindow( SubWindowAbstract* subWindow ); + void selectSubWindow( SubWindowAbstract* subWindow ); QList getSelectedWindows() { return m_apcSelectedSubWindowList; } private: - UInt m_uiCategory; - Int m_iMinSelectedWindows; - Int m_iMaxSlectedWindows; - PlaYUVerSubWindowHandle* m_pcMainWindowManager; + unsigned int m_uiCategory; + int m_iMinSelectedWindows; + int m_iMaxSlectedWindows; + SubWindowHandle* m_pcMainWindowManager; QList m_apcSubWindowList; QList m_apcSelectedSubWindowList; @@ -74,8 +74,8 @@ private: QPushButton* m_pushButtonAddAll; QPushButton* m_pushButtonRemoveAll; - Void updateSubWindowList(); - Void update(); + void updateSubWindowList(); + void update(); private Q_SLOTS: void toggleSubWindow( int ); diff --git a/app/FramePropertiesDock.cpp b/app/docks/FramePropertiesDock.cpp similarity index 81% rename from app/FramePropertiesDock.cpp rename to app/docks/FramePropertiesDock.cpp index 68faab1..bbc18c9 100644 --- a/app/FramePropertiesDock.cpp +++ b/app/docks/FramePropertiesDock.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -28,7 +28,7 @@ #include #include -FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ) +FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch ) : QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch ) { // -------------- Variables definition -------------- @@ -146,24 +146,24 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc QLabel* rangeSelectionLabel = new QLabel( tr( "Range:" ) ); rangeSelectionLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - minInterv = new QSpinBox; - minInterv->setRange( 0, 255 ); - minInterv->setSingleStep( 1 ); - minInterv->setValue( 0 ); - minInterv->setWhatsThis( tr( "

    Select here the minimal intensity " + mininterv = new QSpinBox; + mininterv->setRange( 0, 255 ); + mininterv->setSingleStep( 1 ); + mininterv->setValue( 0 ); + mininterv->setWhatsThis( tr( "

    Select here the minimal intensity " "value of the histogram selection." ) ); - maxInterv = new QSpinBox; - maxInterv->setRange( 0, 255 ); - maxInterv->setSingleStep( 1 ); - maxInterv->setValue( 0 ); - minInterv->setWhatsThis( tr( "

    Select here the maximal intensity value" + maxinterv = new QSpinBox; + maxinterv->setRange( 0, 255 ); + maxinterv->setSingleStep( 1 ); + maxinterv->setValue( 0 ); + mininterv->setWhatsThis( tr( "

    Select here the maximal intensity value" " of the histogram selection." ) ); QHBoxLayout* rangeLayout = new QHBoxLayout; rangeLayout->addWidget( rangeSelectionLabel ); - rangeLayout->addWidget( minInterv ); - rangeLayout->addWidget( maxInterv ); + rangeLayout->addWidget( mininterv ); + rangeLayout->addWidget( maxinterv ); mainLayout->addLayout( rangeLayout, 4, 0, 1, 4 ); @@ -204,7 +204,7 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc labelPercentileValue = new QLabel; labelPercentileValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - Int gridRow = 0; + int gridRow = 0; QGridLayout* statisticsLayout = new QGridLayout; statisticsLayout->addWidget( pixelsLabel, gridRow, 0 ); statisticsLayout->addWidget( labelPixelsValue, gridRow++, 1 ); @@ -235,13 +235,13 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc connect( scaleButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotScaleChanged( int ) ) ); connect( colorsCB, SIGNAL( activated( int ) ), this, SLOT( slotColorsChanged( int ) ) ); connect( renderingButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotRenderingChanged( int ) ) ); - connect( histogramWidget, SIGNAL( signalIntervalChanged( int, int ) ), this, SLOT( slotUpdateInterval( int, int ) ) ); - connect( histogramWidget, SIGNAL( signalMaximumValueChanged( int ) ), this, SLOT( slotUpdateIntervRange( int ) ) ); + connect( histogramWidget, SIGNAL( signalintervalChanged( int, int ) ), this, SLOT( slotUpdateinterval( int, int ) ) ); + connect( histogramWidget, SIGNAL( signalMaximumValueChanged( int ) ), this, SLOT( slotUpdateintervRange( int ) ) ); connect( histogramWidget, SIGNAL( signalHistogramComputationDone( int ) ), this, SLOT( slotRefreshOptions( int ) ) ); connect( histogramWidget, SIGNAL( signalHistogramComputationFailed( void ) ), this, SLOT( slotHistogramComputationFailed( void ) ) ); - connect( minInterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinValueChanged( int ) ) ); - connect( maxInterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxValueChanged( int ) ) ); + connect( mininterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinValueChanged( int ) ) ); + connect( maxinterv, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxValueChanged( int ) ) ); } FramePropertiesDock::~FramePropertiesDock() @@ -262,7 +262,7 @@ QSize FramePropertiesDock::sizeHint() const return currSize; } -Void FramePropertiesDock::reset() +void FramePropertiesDock::reset() { m_pcFrame = NULL; m_cSelectionArea = QRect(); @@ -287,29 +287,29 @@ Void FramePropertiesDock::reset() setEnabled( false ); } -Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame ) +void FramePropertiesDock::setFrame( CalypFrame* pcFrame ) { - Int colorSpace = pcFrame->getColorSpace(); + int colorSpace = pcFrame->getColorSpace(); if( m_iLastFrameType != colorSpace ) { m_iLastFrameType = colorSpace; - if( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA ) + if( colorSpace == CLP_COLOR_RGB || colorSpace == CLP_COLOR_RGBA ) { channelCB->clear(); - channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA ); - channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", PlaYUVerFrame::HIST_COLOR_R ); - channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", PlaYUVerFrame::HIST_COLOR_G ); - channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", PlaYUVerFrame::HIST_COLOR_B ); - if( colorSpace == PlaYUVerPixel::COLOR_RGBA ) + channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA ); + channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", CalypFrame::HIST_COLOR_R ); + channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", CalypFrame::HIST_COLOR_G ); + channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", CalypFrame::HIST_COLOR_B ); + if( colorSpace == CLP_COLOR_RGBA ) { - channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", PlaYUVerFrame::HIST_COLOR_A ); + channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", CalypFrame::HIST_COLOR_A ); } - channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", PlaYUVerFrame::HIST_ALL_CHANNELS ); + channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", CalypFrame::HIST_ALL_CHANNELS ); colorsCB->clear(); - colorsCB->addItem( "Red", PlaYUVerFrame::HIST_COLOR_R ); - colorsCB->addItem( "Green", PlaYUVerFrame::HIST_COLOR_G ); - colorsCB->addItem( "Blue", PlaYUVerFrame::HIST_COLOR_B ); + colorsCB->addItem( "Red", CalypFrame::HIST_COLOR_R ); + colorsCB->addItem( "Green", CalypFrame::HIST_COLOR_G ); + colorsCB->addItem( "Blue", CalypFrame::HIST_COLOR_B ); colorsCB->setEnabled( false ); colorsCB->setWhatsThis( tr( "

    Select here the main color displayed with Colors Channel mode:" "

    Red: Draw the Red image channel in the foreground.

    " @@ -318,18 +318,18 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame ) colorsCB->show(); colorsLabel->show(); } - else if( colorSpace == PlaYUVerPixel::COLOR_YUV ) + else if( colorSpace == CLP_COLOR_YUV ) { channelCB->clear(); - channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA ); - channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", PlaYUVerFrame::HIST_CHROMA_U ); - channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", PlaYUVerFrame::HIST_CHROMA_V ); - channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", PlaYUVerFrame::HIST_ALL_CHANNELS ); + channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA ); + channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", CalypFrame::HIST_CHROMA_U ); + channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", CalypFrame::HIST_CHROMA_V ); + channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", CalypFrame::HIST_ALL_CHANNELS ); colorsCB->clear(); - colorsCB->addItem( "Luminance", PlaYUVerFrame::HIST_LUMA ); - colorsCB->addItem( "Chroma U", PlaYUVerFrame::HIST_CHROMA_U ); - colorsCB->addItem( "Chroma V", PlaYUVerFrame::HIST_CHROMA_V ); + colorsCB->addItem( "Luminance", CalypFrame::HIST_LUMA ); + colorsCB->addItem( "Chroma U", CalypFrame::HIST_CHROMA_U ); + colorsCB->addItem( "Chroma V", CalypFrame::HIST_CHROMA_V ); colorsCB->setEnabled( false ); colorsCB->setWhatsThis( tr( "

    Select here the main color displayed with Colors Channel mode:" "

    Luminance: DraupdateDataw the Luminance channel in the " @@ -343,7 +343,7 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame ) else { channelCB->clear(); - channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA ); + channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", CalypFrame::HIST_LUMA ); colorsCB->hide(); colorsLabel->hide(); } @@ -356,11 +356,11 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame ) } } -Void FramePropertiesDock::setSelection( const QRect& selectionArea ) +void FramePropertiesDock::setSelection( const QRect& selectionArea ) { if( m_pcFrame ) { - Bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() ); + bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() ); m_cSelectionArea = selectionArea; if( selectionArea.isValid() ) { @@ -376,8 +376,8 @@ Void FramePropertiesDock::setSelection( const QRect& selectionArea ) { delete m_pcSelectedFrame; } - m_pcSelectedFrame = new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), - selectionArea.height() ); + m_pcSelectedFrame = new CalypFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), + selectionArea.height() ); } updateDataHistogram(); selectionImageButton->click(); @@ -392,7 +392,7 @@ Void FramePropertiesDock::setSelection( const QRect& selectionArea ) } } -Void FramePropertiesDock::updateDataHistogram() +void FramePropertiesDock::updateDataHistogram() { if( m_pcFrame && isVisible() ) { @@ -424,18 +424,18 @@ Void FramePropertiesDock::updateDataHistogram() } } -Void FramePropertiesDock::updateStatistiques() +void FramePropertiesDock::updateStatistiques() { QString value; - Int min = minInterv->value(); - Int max = maxInterv->value(); - Int channel = histogramWidget->m_channelType; + int min = mininterv->value(); + int max = maxinterv->value(); + int channel = histogramWidget->m_channelType; - if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS ) + if( channel == CalypFrame::HIST_ALL_CHANNELS ) channel = colorsCB->itemData( colorsCB->currentIndex() ).toInt(); - PlaYUVerFrame* frame; + CalypFrame* frame; if( histogramWidget->m_renderingType == HistogramWidget::FullImageHistogram ) frame = histogramWidget->m_fullImage; @@ -468,7 +468,7 @@ Void FramePropertiesDock::updateStatistiques() } } -Void FramePropertiesDock::stopHistogram() +void FramePropertiesDock::stopHistogram() { histogramWidget->stopHistogramComputation(); } @@ -477,7 +477,7 @@ Void FramePropertiesDock::stopHistogram() // SLOTS //////////////////////////////////////////////////////////////////////////////// -Void FramePropertiesDock::slotRefreshOptions( int range ) +void FramePropertiesDock::slotRefreshOptions( int range ) { if( !isVisible() ) return; @@ -500,17 +500,17 @@ Void FramePropertiesDock::slotRefreshOptions( int range ) } } -Void FramePropertiesDock::slotHistogramComputationFailed() +void FramePropertiesDock::slotHistogramComputationFailed() { m_pcFrame = NULL; } -Void FramePropertiesDock::slotChannelChanged( Int index ) +void FramePropertiesDock::slotChannelChanged( int index ) { - Int channel = channelCB->itemData( index ).toInt(); + int channel = channelCB->itemData( index ).toInt(); histogramWidget->m_channelType = channel; - if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS ) + if( channel == CalypFrame::HIST_ALL_CHANNELS ) colorsCB->setEnabled( true ); else colorsCB->setEnabled( false ); @@ -518,72 +518,72 @@ Void FramePropertiesDock::slotChannelChanged( Int index ) updateStatistiques(); } -Void FramePropertiesDock::slotScaleChanged( Int scale ) +void FramePropertiesDock::slotScaleChanged( int scale ) { histogramWidget->m_scaleType = scale; histogramWidget->update(); } -Void FramePropertiesDock::slotColorsChanged( Int index ) +void FramePropertiesDock::slotColorsChanged( int index ) { - Int color = colorsCB->itemData( index ).toInt(); + int color = colorsCB->itemData( index ).toInt(); histogramWidget->m_colorType = color; histogramWidget->update(); updateStatistiques(); } -Void FramePropertiesDock::slotRenderingChanged( Int rendering ) +void FramePropertiesDock::slotRenderingChanged( int rendering ) { histogramWidget->m_renderingType = rendering; histogramWidget->update(); updateStatistiques(); } -Void FramePropertiesDock::slotMinValueChanged( Int min ) +void FramePropertiesDock::slotMinValueChanged( int min ) { // Called when user changes values of spin box. // Communicate the change to histogram widget. // make the one control "push" the other - if( min == maxInterv->value() + 1 ) - maxInterv->setValue( min ); + if( min == maxinterv->value() + 1 ) + maxinterv->setValue( min ); - maxInterv->setMinimum( min - 1 ); + maxinterv->setMinimum( min - 1 ); histogramWidget->slotMinValueChanged( min ); updateStatistiques(); } -Void FramePropertiesDock::slotMaxValueChanged( Int max ) +void FramePropertiesDock::slotMaxValueChanged( int max ) { - if( max == minInterv->value() - 1 ) - minInterv->setValue( max ); + if( max == mininterv->value() - 1 ) + mininterv->setValue( max ); - minInterv->setMaximum( max + 1 ); + mininterv->setMaximum( max + 1 ); histogramWidget->slotMaxValueChanged( max ); updateStatistiques(); } -Void FramePropertiesDock::slotUpdateInterval( Int min, Int max ) +void FramePropertiesDock::slotUpdateinterval( int min, int max ) { // Called when value is set from within histogram widget. // Block signals to prevent slotMinValueChanged and // slotMaxValueChanged being called. - minInterv->blockSignals( true ); - minInterv->setMaximum( max + 1 ); - minInterv->setValue( min ); - minInterv->blockSignals( false ); + mininterv->blockSignals( true ); + mininterv->setMaximum( max + 1 ); + mininterv->setValue( min ); + mininterv->blockSignals( false ); - maxInterv->blockSignals( true ); - maxInterv->setMinimum( min - 1 ); - maxInterv->setValue( max ); - maxInterv->blockSignals( false ); + maxinterv->blockSignals( true ); + maxinterv->setMinimum( min - 1 ); + maxinterv->setValue( max ); + maxinterv->blockSignals( false ); updateStatistiques(); } -Void FramePropertiesDock::slotUpdateIntervRange( Int range ) +void FramePropertiesDock::slotUpdateintervRange( int range ) { - maxInterv->blockSignals( true ); - maxInterv->setMaximum( range ); - maxInterv->blockSignals( false ); + maxinterv->blockSignals( true ); + maxinterv->setMaximum( range ); + maxinterv->blockSignals( false ); } diff --git a/app/FramePropertiesDock.h b/app/docks/FramePropertiesDock.h similarity index 77% rename from app/FramePropertiesDock.h rename to app/docks/FramePropertiesDock.h index af8472d..f6ca275 100644 --- a/app/FramePropertiesDock.h +++ b/app/docks/FramePropertiesDock.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,11 +25,11 @@ #ifndef __FRAMEPROPERTIESDOCK_H__ #define __FRAMEPROPERTIESDOCK_H__ +#include "CommonDefs.h" #include "HistogramWidget.h" -#include "PlaYUVerAppDefs.h" #include "config.h" -#include "lib/PlaYUVerFrame.h" -#include "lib/PlaYUVerStream.h" +#include "lib/CalypFrame.h" +#include "lib/CalypStream.h" #include @@ -37,22 +37,22 @@ class FramePropertiesDock : public QWidget { Q_OBJECT public: - FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ); + FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch ); ~FramePropertiesDock(); QSize sizeHint() const; - Void setFrame( PlaYUVerFrame* m_pcFrame ); - Void setSelection( const QRect& selectionArea ); - Void reset(); - Void stopHistogram(); + void setFrame( CalypFrame* m_pcFrame ); + void setSelection( const QRect& selectionArea ); + void reset(); + void stopHistogram(); private: - PlaYUVerFrame* m_pcFrame; - PlaYUVerFrame* m_pcSelectedFrame; - Int m_iLastFrameType; + CalypFrame* m_pcFrame; + CalypFrame* m_pcSelectedFrame; + int m_iLastFrameType; - Bool* m_pbIsPlaying; + bool* m_pbIsPlaying; QComboBox* channelCB; QComboBox* colorsCB; @@ -66,8 +66,8 @@ private: QButtonGroup* scaleButtonGroup; QButtonGroup* renderingButtonGroup; - QSpinBox* minInterv; - QSpinBox* maxInterv; + QSpinBox* mininterv; + QSpinBox* maxinterv; QLabel* labelPixelsValue; QLabel* labelCountValue; @@ -83,8 +83,8 @@ private: HistogramWidget* histogramWidget; - Void updateStatistiques(); - Void updateDataHistogram(); + void updateStatistiques(); + void updateDataHistogram(); private Q_SLOTS: void slotRefreshOptions( int range ); @@ -96,8 +96,8 @@ private Q_SLOTS: void slotMinValueChanged( int ); void slotMaxValueChanged( int ); - void slotUpdateInterval( int min, int max ); - void slotUpdateIntervRange( int range ); + void slotUpdateinterval( int min, int max ); + void slotUpdateintervRange( int range ); }; #endif // __FRAMEPROPERTIESDOCK_H__ diff --git a/app/ModuleHandleDock.cpp b/app/docks/ModuleHandleDock.cpp similarity index 86% rename from app/ModuleHandleDock.cpp rename to app/docks/ModuleHandleDock.cpp index f95dea1..7389476 100644 --- a/app/ModuleHandleDock.cpp +++ b/app/docks/ModuleHandleDock.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,15 +24,15 @@ #include "ModuleHandleDock.h" +#include "CalypAppModuleIf.h" #include "ModulesHandle.h" -#include "PlaYUVerAppModuleIf.h" #include #include #include #include -ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf ) +ModuleHandleDock::ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf ) : QWidget( parent ), m_pcCurrModuleIf( moduleIf ) { // ----------------- Dock definition ----------------- @@ -47,7 +47,7 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module labelModulueReturnValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); QGridLayout* modulesPropertiesLayout = new QGridLayout; - Int layout_line = 0; + int layout_line = 0; modulesPropertiesLayout->addWidget( labelModulueValueLabel, layout_line, 0 ); modulesPropertiesLayout->addWidget( labelModulueReturnValue, layout_line, 1 ); layout_line++; @@ -60,18 +60,18 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* module ModuleHandleDock::~ModuleHandleDock() {} -Void ModuleHandleDock::setModulueReturnValue( Double value ) +void ModuleHandleDock::setModulueReturnValue( double value ) { labelModulueReturnValue->clear(); QString strValue = QString( "%1" ).arg( value ); labelModulueReturnValue->setText( strValue ); } -Void ModuleHandleDock::visibilityChangedSlot( bool visiblity ) +void ModuleHandleDock::visibilityChangedSlot( bool visiblity ) { if( !visiblity && m_pcCurrModuleIf ) { - PlaYUVerAppModuleIf* pcCurrentModule = m_pcCurrModuleIf; + CalypAppModuleIf* pcCurrentModule = m_pcCurrModuleIf; m_pcCurrModuleIf = NULL; ModulesHandle::destroyModuleIf( pcCurrentModule ); } diff --git a/app/ModuleHandleDock.h b/app/docks/ModuleHandleDock.h similarity index 83% rename from app/ModuleHandleDock.h rename to app/docks/ModuleHandleDock.h index 1591dd1..c854edc 100644 --- a/app/ModuleHandleDock.h +++ b/app/docks/ModuleHandleDock.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,7 +25,7 @@ #ifndef __MODULEHANDLEDOCK_H__ #define __MODULEHANDLEDOCK_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" #include @@ -33,23 +33,23 @@ class QLabel; -class PlaYUVerAppModuleIf; +class CalypAppModuleIf; class ModuleHandleDock : public QWidget { Q_OBJECT public: - ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf ); + ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf ); ~ModuleHandleDock(); - Void setModulueReturnValue( Double value ); + void setModulueReturnValue( double value ); QSize sizeHint() const; private: - PlaYUVerAppModuleIf* m_pcCurrModuleIf; + CalypAppModuleIf* m_pcCurrModuleIf; - Bool m_bIsVisible; + bool m_bIsVisible; QLabel* labelModulueValueLabel; QLabel* labelModulueReturnValue; diff --git a/app/QualityMeasurementSidebar.cpp b/app/docks/QualityMeasurementSidebar.cpp similarity index 71% rename from app/QualityMeasurementSidebar.cpp rename to app/docks/QualityMeasurementSidebar.cpp index b2ced4d..0b5e9cf 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/docks/QualityMeasurementSidebar.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,12 +24,12 @@ #include "QualityMeasurementSidebar.h" -#include "PlaYUVerSubWindowHandle.h" +#include "SubWindowHandle.h" #include "VideoSubWindow.h" #include -QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerSubWindowHandle* windowManager ) +QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, SubWindowHandle* windowManager ) : QWidget( parent ), m_pcMainWindowManager( windowManager ), m_pcCurrentVideoSubWindow( NULL ) { // Side bar area ----------------------------------------------------- @@ -44,9 +44,9 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); m_comboBoxMetric = new QComboBox; - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ ) { - m_comboBoxMetric->insertItem( i, PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); + m_comboBoxMetric->insertItem( i, CalypFrame::supportedQualityMetricsList()[i].c_str() ); } m_comboBoxMetric->setSizeAdjustPolicy( QComboBox::AdjustToContents ); m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); @@ -64,28 +64,28 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft ); mainLayout->addWidget( m_comboBoxRef, 1, 1, 1, 2, Qt::AlignLeft ); - m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" ); - m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - m_ppcLabelQualityValue[LUMA] = new QLabel; - m_ppcLabelQualityValue[LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + m_ppcLabelQualityLabel[CLP_LUMA] = new QLabel( "PSNR Y:" ); + m_ppcLabelQualityLabel[CLP_LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[CLP_LUMA] = new QLabel; + m_ppcLabelQualityValue[CLP_LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - m_ppcLabelQualityLabel[CHROMA_U] = new QLabel( "PSNR U:" ); - m_ppcLabelQualityLabel[CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - m_ppcLabelQualityValue[CHROMA_U] = new QLabel; - m_ppcLabelQualityValue[CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + m_ppcLabelQualityLabel[CLP_CHROMA_U] = new QLabel( "PSNR U:" ); + m_ppcLabelQualityLabel[CLP_CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[CLP_CHROMA_U] = new QLabel; + m_ppcLabelQualityValue[CLP_CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); - m_ppcLabelQualityLabel[CHROMA_V] = new QLabel( "PSNR V:" ); - m_ppcLabelQualityLabel[CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - m_ppcLabelQualityValue[CHROMA_V] = new QLabel; - m_ppcLabelQualityValue[CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + m_ppcLabelQualityLabel[CLP_CHROMA_V] = new QLabel( "PSNR V:" ); + m_ppcLabelQualityLabel[CLP_CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[CLP_CHROMA_V] = new QLabel; + m_ppcLabelQualityValue[CLP_CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); QGridLayout* qualityResultsLayout = new QGridLayout; - qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[LUMA], 0, 0 ); - qualityResultsLayout->addWidget( m_ppcLabelQualityValue[LUMA], 0, 1 ); - qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_U], 1, 0 ); - qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_U], 1, 1 ); - qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 ); - qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_LUMA], 0, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_LUMA], 0, 1 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_CHROMA_U], 1, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_CHROMA_U], 1, 1 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CLP_CHROMA_V], 2, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CLP_CHROMA_V], 2, 1 ); // QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) ); QGroupBox* statisticsGroup = new QGroupBox; @@ -114,14 +114,14 @@ QSize QualityMeasurementSidebar::sizeHint() const return currSize; } -Void QualityMeasurementSidebar::updateSideBar( Bool hasSubWindow ) +void QualityMeasurementSidebar::updateSideBar( bool hasSubWindow ) { if( !hasSubWindow ) m_comboBoxRef->clear(); setEnabled( hasSubWindow ); } -Void QualityMeasurementSidebar::updateSubWindowList() +void QualityMeasurementSidebar::updateSubWindowList() { QString currSubWindowName; m_pcWindowListNames.clear(); @@ -129,7 +129,7 @@ Void QualityMeasurementSidebar::updateSubWindowList() VideoSubWindow* pcVideoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + for( int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); if( m_pcCurrentVideoSubWindow == pcVideoSubWindow ) @@ -154,19 +154,19 @@ Void QualityMeasurementSidebar::updateSubWindowList() { if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() ) { - Int index = m_pcVideoWindowList.indexOf( refSubWindow ); + int index = m_pcVideoWindowList.indexOf( refSubWindow ); m_comboBoxRef->setCurrentIndex( index ); } } // m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents ); } -Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow ) +void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow ) { m_pcCurrentVideoSubWindow = subWindow; if( m_pcCurrentVideoSubWindow ) { - Int index = -1; + int index = -1; if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() ) { index = m_pcVideoWindowList.indexOf( refSubWindow ); @@ -177,7 +177,7 @@ Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow* subWindow ) } } -Void QualityMeasurementSidebar::updateSidebarData() +void QualityMeasurementSidebar::updateSidebarData() { QString zeroValue( "0.0000" ); if( m_pcCurrentVideoSubWindow ) @@ -185,11 +185,11 @@ Void QualityMeasurementSidebar::updateSidebarData() VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow(); if( refSubWindow ) { - PlaYUVerFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); - PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame(); - Double quality; + CalypFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); + CalypFrame* refFrame = refSubWindow->getCurrFrame(); + double quality; QString value; - UInt component = 0; + unsigned int component = 0; for( ; component < currFrame->getNumberChannels(); component++ ) { quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component ); @@ -207,23 +207,23 @@ Void QualityMeasurementSidebar::updateSidebarData() m_comboBoxRef->setCurrentIndex( -1 ); } } - for( Int component = 0; component < 3; component++ ) + for( int component = 0; component < 3; component++ ) { m_ppcLabelQualityValue[component]->setText( zeroValue ); } } -Void QualityMeasurementSidebar::updateQualityMetric( Int idx ) +void QualityMeasurementSidebar::updateQualityMetric( int idx ) { m_comboBoxMetric->setCurrentIndex( idx ); - QString labelQuality( PlaYUVerFrame::supportedQualityMetricsList()[idx].c_str() ); - m_ppcLabelQualityLabel[LUMA]->setText( labelQuality + " Y" ); - m_ppcLabelQualityLabel[CHROMA_U]->setText( labelQuality + " U" ); - m_ppcLabelQualityLabel[CHROMA_V]->setText( labelQuality + " V" ); + QString labelQuality( CalypFrame::supportedQualityMetricsList()[idx].c_str() ); + m_ppcLabelQualityLabel[CLP_LUMA]->setText( labelQuality + " Y" ); + m_ppcLabelQualityLabel[CLP_CHROMA_U]->setText( labelQuality + " U" ); + m_ppcLabelQualityLabel[CLP_CHROMA_V]->setText( labelQuality + " V" ); updateSidebarData(); } -Void QualityMeasurementSidebar::slotReferenceChanged( Int index ) +void QualityMeasurementSidebar::slotReferenceChanged( int index ) { if( index > -1 && m_pcCurrentVideoSubWindow ) { @@ -245,7 +245,7 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index ) } } -Void QualityMeasurementSidebar::slotQualityMetricChanged( Int idx ) +void QualityMeasurementSidebar::slotQualityMetricChanged( int idx ) { emit signalQualityMetricChanged( idx ); // updateQualityMetric( idx ); diff --git a/app/QualityMeasurementSidebar.h b/app/docks/QualityMeasurementSidebar.h similarity index 80% rename from app/QualityMeasurementSidebar.h rename to app/docks/QualityMeasurementSidebar.h index db3668a..77e7691 100644 --- a/app/QualityMeasurementSidebar.h +++ b/app/docks/QualityMeasurementSidebar.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,35 +25,35 @@ #ifndef __QUALITYMEASUREMENTSIDEBAR_H__ #define __QUALITYMEASUREMENTSIDEBAR_H__ +#include "CommonDefs.h" #include "HistogramWidget.h" -#include "PlaYUVerAppDefs.h" #include "config.h" -#include "lib/PlaYUVerFrame.h" -#include "lib/PlaYUVerStream.h" +#include "lib/CalypFrame.h" +#include "lib/CalypStream.h" #include -class PlaYUVerSubWindowHandle; +class SubWindowHandle; class VideoSubWindow; class QualityMeasurementSidebar : public QWidget { Q_OBJECT public: - QualityMeasurementSidebar( QWidget*, PlaYUVerSubWindowHandle* ); + QualityMeasurementSidebar( QWidget*, SubWindowHandle* ); ~QualityMeasurementSidebar(); QSize sizeHint() const; - Void updateSideBar( Bool hasSubWindow ); + void updateSideBar( bool hasSubWindow ); - Void updateSubWindowList(); - Void updateCurrentWindow( VideoSubWindow* ); - Void updateSidebarData(); - Void updateQualityMetric( Int ); + void updateSubWindowList(); + void updateCurrentWindow( VideoSubWindow* ); + void updateSidebarData(); + void updateQualityMetric( int ); private: - PlaYUVerSubWindowHandle* m_pcMainWindowManager; + SubWindowHandle* m_pcMainWindowManager; QVector m_pcVideoWindowList; QStringList m_pcWindowListNames; diff --git a/app/external/CMakeLists.txt b/app/external/CMakeLists.txt index 11967aa..9e28baf 100644 --- a/app/external/CMakeLists.txt +++ b/app/external/CMakeLists.txt @@ -1,5 +1,5 @@ ### -### CMakeLists for playuver app external component +### CMakeLists for calyp external components ### ADD_SUBDIRECTORY( qcustomplot ) diff --git a/app/external/qcustomplot/qcustomplot.cpp b/app/external/qcustomplot/qcustomplot.cpp index b882a76..154576a 100644 --- a/app/external/qcustomplot/qcustomplot.cpp +++ b/app/external/qcustomplot/qcustomplot.cpp @@ -25,6 +25,7 @@ #include "qcustomplot.h" + /* including file 'src/vector2d.cpp', size 7340 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -107,8 +108,9 @@ /*! Creates a QCPVector2D object and initializes the x and y coordinates to 0. */ -QCPVector2D::QCPVector2D() - : mX( 0 ), mY( 0 ) +QCPVector2D::QCPVector2D() : + mX(0), + mY(0) { } @@ -116,8 +118,9 @@ QCPVector2D::QCPVector2D() Creates a QCPVector2D object and initializes the \a x and \a y coordinates with the specified values. */ -QCPVector2D::QCPVector2D( double x, double y ) - : mX( x ), mY( y ) +QCPVector2D::QCPVector2D(double x, double y) : + mX(x), + mY(y) { } @@ -125,8 +128,9 @@ QCPVector2D::QCPVector2D( double x, double y ) Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified \a point. */ -QCPVector2D::QCPVector2D( const QPoint& point ) - : mX( point.x() ), mY( point.y() ) +QCPVector2D::QCPVector2D(const QPoint &point) : + mX(point.x()), + mY(point.y()) { } @@ -134,8 +138,9 @@ QCPVector2D::QCPVector2D( const QPoint& point ) Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified \a point. */ -QCPVector2D::QCPVector2D( const QPointF& point ) - : mX( point.x() ), mY( point.y() ) +QCPVector2D::QCPVector2D(const QPointF &point) : + mX(point.x()), + mY(point.y()) { } @@ -158,7 +163,7 @@ void QCPVector2D::normalize() */ QCPVector2D QCPVector2D::normalized() const { - QCPVector2D result( mX, mY ); + QCPVector2D result(mX, mY); result.normalize(); return result; } @@ -170,22 +175,21 @@ QCPVector2D QCPVector2D::normalized() const \see distanceToStraightLine */ -double QCPVector2D::distanceSquaredToLine( const QCPVector2D& start, const QCPVector2D& end ) const +double QCPVector2D::distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const { - QCPVector2D v( end - start ); + QCPVector2D v(end-start); double vLengthSqr = v.lengthSquared(); - if( !qFuzzyIsNull( vLengthSqr ) ) + if (!qFuzzyIsNull(vLengthSqr)) { - double mu = v.dot( *this - start ) / vLengthSqr; - if( mu < 0 ) - return ( *this - start ).lengthSquared(); - else if( mu > 1 ) - return ( *this - end ).lengthSquared(); + double mu = v.dot(*this-start)/vLengthSqr; + if (mu < 0) + return (*this-start).lengthSquared(); + else if (mu > 1) + return (*this-end).lengthSquared(); else - return ( ( start + mu * v ) - *this ).lengthSquared(); - } - else - return ( *this - start ).lengthSquared(); + return ((start + mu*v)-*this).lengthSquared(); + } else + return (*this-start).lengthSquared(); } /*! \overload @@ -195,9 +199,9 @@ double QCPVector2D::distanceSquaredToLine( const QCPVector2D& start, const QCPVe \see distanceToStraightLine */ -double QCPVector2D::distanceSquaredToLine( const QLineF& line ) const +double QCPVector2D::distanceSquaredToLine(const QLineF &line) const { - return distanceSquaredToLine( QCPVector2D( line.p1() ), QCPVector2D( line.p2() ) ); + return distanceSquaredToLine(QCPVector2D(line.p1()), QCPVector2D(line.p2())); } /*! @@ -206,16 +210,16 @@ double QCPVector2D::distanceSquaredToLine( const QLineF& line ) const \see distanceSquaredToLine */ -double QCPVector2D::distanceToStraightLine( const QCPVector2D& base, const QCPVector2D& direction ) const +double QCPVector2D::distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const { - return qAbs( ( *this - base ).dot( direction.perpendicular() ) ) / direction.length(); + return qAbs((*this-base).dot(direction.perpendicular()))/direction.length(); } /*! Scales this vector by the given \a factor, i.e. the x and y components are multiplied by \a factor. */ -QCPVector2D& QCPVector2D::operator*=( double factor ) +QCPVector2D &QCPVector2D::operator*=(double factor) { mX *= factor; mY *= factor; @@ -226,7 +230,7 @@ QCPVector2D& QCPVector2D::operator*=( double factor ) Scales this vector by the given \a divisor, i.e. the x and y components are divided by \a divisor. */ -QCPVector2D& QCPVector2D::operator/=( double divisor ) +QCPVector2D &QCPVector2D::operator/=(double divisor) { mX /= divisor; mY /= divisor; @@ -236,7 +240,7 @@ QCPVector2D& QCPVector2D::operator/=( double divisor ) /*! Adds the given \a vector to this vector component-wise. */ -QCPVector2D& QCPVector2D::operator+=( const QCPVector2D& vector ) +QCPVector2D &QCPVector2D::operator+=(const QCPVector2D &vector) { mX += vector.mX; mY += vector.mY; @@ -246,7 +250,7 @@ QCPVector2D& QCPVector2D::operator+=( const QCPVector2D& vector ) /*! subtracts the given \a vector from this vector component-wise. */ -QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector ) +QCPVector2D &QCPVector2D::operator-=(const QCPVector2D &vector) { mX -= vector.mX; mY -= vector.mY; @@ -254,6 +258,7 @@ QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector ) } /* end of 'src/vector2d.cpp' */ + /* including file 'src/painter.cpp', size 8670 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -277,8 +282,10 @@ QCPVector2D& QCPVector2D::operator-=( const QCPVector2D& vector ) /*! Creates a new QCPPainter instance and sets default values */ -QCPPainter::QCPPainter() - : QPainter(), mModes( pmDefault ), mIsAntialiasing( false ) +QCPPainter::QCPPainter() : + QPainter(), + mModes(pmDefault), + mIsAntialiasing(false) { // don't setRenderHint(QPainter::NonCosmeticDefautPen) here, because painter isn't active yet and // a call to begin() will follow @@ -290,12 +297,14 @@ QCPPainter::QCPPainter() Like \ref begin, this method sets QPainter::NonCosmeticDefaultPen in Qt versions before Qt5. */ -QCPPainter::QCPPainter( QPaintDevice* device ) - : QPainter( device ), mModes( pmDefault ), mIsAntialiasing( false ) +QCPPainter::QCPPainter(QPaintDevice *device) : + QPainter(device), + mModes(pmDefault), + mIsAntialiasing(false) { -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. - if( isActive() ) - setRenderHint( QPainter::NonCosmeticDefaultPen ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. + if (isActive()) + setRenderHint(QPainter::NonCosmeticDefaultPen); #endif } @@ -305,10 +314,10 @@ QCPPainter::QCPPainter( QPaintDevice* device ) \note this function hides the non-virtual base class implementation. */ -void QCPPainter::setPen( const QPen& pen ) +void QCPPainter::setPen(const QPen &pen) { - QPainter::setPen( pen ); - if( mModes.testFlag( pmNonCosmetic ) ) + QPainter::setPen(pen); + if (mModes.testFlag(pmNonCosmetic)) makeNonCosmetic(); } @@ -319,10 +328,10 @@ void QCPPainter::setPen( const QPen& pen ) \note this function hides the non-virtual base class implementation. */ -void QCPPainter::setPen( const QColor& color ) +void QCPPainter::setPen(const QColor &color) { - QPainter::setPen( color ); - if( mModes.testFlag( pmNonCosmetic ) ) + QPainter::setPen(color); + if (mModes.testFlag(pmNonCosmetic)) makeNonCosmetic(); } @@ -333,10 +342,10 @@ void QCPPainter::setPen( const QColor& color ) \note this function hides the non-virtual base class implementation. */ -void QCPPainter::setPen( Qt::PenStyle penStyle ) +void QCPPainter::setPen(Qt::PenStyle penStyle) { - QPainter::setPen( penStyle ); - if( mModes.testFlag( pmNonCosmetic ) ) + QPainter::setPen(penStyle); + if (mModes.testFlag(pmNonCosmetic)) makeNonCosmetic(); } @@ -348,12 +357,12 @@ void QCPPainter::setPen( Qt::PenStyle penStyle ) \note this function hides the non-virtual base class implementation. */ -void QCPPainter::drawLine( const QLineF& line ) +void QCPPainter::drawLine(const QLineF &line) { - if( mIsAntialiasing || mModes.testFlag( pmVectorized ) ) - QPainter::drawLine( line ); + if (mIsAntialiasing || mModes.testFlag(pmVectorized)) + QPainter::drawLine(line); else - QPainter::drawLine( line.toLine() ); + QPainter::drawLine(line.toLine()); } /*! @@ -362,18 +371,18 @@ void QCPPainter::drawLine( const QLineF& line ) antialiased and non-antialiased painting (Since Qt < 5.0 uses slightly different coordinate systems for AA/Non-AA painting). */ -void QCPPainter::setAntialiasing( bool enabled ) +void QCPPainter::setAntialiasing(bool enabled) { - setRenderHint( QPainter::Antialiasing, enabled ); - if( mIsAntialiasing != enabled ) + setRenderHint(QPainter::Antialiasing, enabled); + if (mIsAntialiasing != enabled) { mIsAntialiasing = enabled; - if( !mModes.testFlag( pmVectorized ) ) // antialiasing half-pixel shift only needed for rasterized outputs + if (!mModes.testFlag(pmVectorized)) // antialiasing half-pixel shift only needed for rasterized outputs { - if( mIsAntialiasing ) - translate( 0.5, 0.5 ); + if (mIsAntialiasing) + translate(0.5, 0.5); else - translate( -0.5, -0.5 ); + translate(-0.5, -0.5); } } } @@ -382,7 +391,7 @@ void QCPPainter::setAntialiasing( bool enabled ) Sets the mode of the painter. This controls whether the painter shall adjust its fixes/workarounds optimized for certain output devices. */ -void QCPPainter::setModes( QCPPainter::PainterModes modes ) +void QCPPainter::setModes(QCPPainter::PainterModes modes) { mModes = modes; } @@ -398,12 +407,12 @@ void QCPPainter::setModes( QCPPainter::PainterModes modes ) \note this function hides the non-virtual base class implementation. */ -bool QCPPainter::begin( QPaintDevice* device ) +bool QCPPainter::begin(QPaintDevice *device) { - bool result = QPainter::begin( device ); -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. - if( result ) - setRenderHint( QPainter::NonCosmeticDefaultPen ); + bool result = QPainter::begin(device); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. + if (result) + setRenderHint(QPainter::NonCosmeticDefaultPen); #endif return result; } @@ -413,11 +422,11 @@ bool QCPPainter::begin( QPaintDevice* device ) Sets the mode of the painter. This controls whether the painter shall adjust its fixes/workarounds optimized for certain output devices. */ -void QCPPainter::setMode( QCPPainter::PainterMode mode, bool enabled ) +void QCPPainter::setMode(QCPPainter::PainterMode mode, bool enabled) { - if( !enabled && mModes.testFlag( mode ) ) + if (!enabled && mModes.testFlag(mode)) mModes &= ~mode; - else if( enabled && !mModes.testFlag( mode ) ) + else if (enabled && !mModes.testFlag(mode)) mModes |= mode; } @@ -431,7 +440,7 @@ void QCPPainter::setMode( QCPPainter::PainterMode mode, bool enabled ) */ void QCPPainter::save() { - mAntialiasingStack.push( mIsAntialiasing ); + mAntialiasingStack.push(mIsAntialiasing); QPainter::save(); } @@ -445,7 +454,7 @@ void QCPPainter::save() */ void QCPPainter::restore() { - if( !mAntialiasingStack.isEmpty() ) + if (!mAntialiasingStack.isEmpty()) mIsAntialiasing = mAntialiasingStack.pop(); else qDebug() << Q_FUNC_INFO << "Unbalanced save/restore"; @@ -458,15 +467,16 @@ void QCPPainter::restore() */ void QCPPainter::makeNonCosmetic() { - if( qFuzzyIsNull( pen().widthF() ) ) + if (qFuzzyIsNull(pen().widthF())) { QPen p = pen(); - p.setWidth( 1 ); - QPainter::setPen( p ); + p.setWidth(1); + QPainter::setPen(p); } } /* end of 'src/painter.cpp' */ + /* including file 'src/paintbuffer.cpp', size 18502 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -557,8 +567,10 @@ void QCPPainter::makeNonCosmetic() Subclasses must call their \ref reallocateBuffer implementation in their respective constructors. */ -QCPAbstractPaintBuffer::QCPAbstractPaintBuffer( const QSize& size, double devicePixelRatio ) - : mSize( size ), mDevicePixelRatio( devicePixelRatio ), mInvalidated( true ) +QCPAbstractPaintBuffer::QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio) : + mSize(size), + mDevicePixelRatio(devicePixelRatio), + mInvalidated(true) { } @@ -574,9 +586,9 @@ QCPAbstractPaintBuffer::~QCPAbstractPaintBuffer() If \a size is already the current buffer size, this method does nothing. */ -void QCPAbstractPaintBuffer::setSize( const QSize& size ) +void QCPAbstractPaintBuffer::setSize(const QSize &size) { - if( mSize != size ) + if (mSize != size) { mSize = size; reallocateBuffer(); @@ -598,7 +610,7 @@ void QCPAbstractPaintBuffer::setSize( const QSize& size ) Under normal circumstances, it is not necessary to manually call this method. */ -void QCPAbstractPaintBuffer::setInvalidated( bool invalidated ) +void QCPAbstractPaintBuffer::setInvalidated(bool invalidated) { mInvalidated = invalidated; } @@ -612,9 +624,9 @@ void QCPAbstractPaintBuffer::setInvalidated( bool invalidated ) \note This method is only available for Qt versions 5.4 and higher. */ -void QCPAbstractPaintBuffer::setDevicePixelRatio( double ratio ) +void QCPAbstractPaintBuffer::setDevicePixelRatio(double ratio) { - if( !qFuzzyCompare( ratio, mDevicePixelRatio ) ) + if (!qFuzzyCompare(ratio, mDevicePixelRatio)) { #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED mDevicePixelRatio = ratio; @@ -641,8 +653,8 @@ void QCPAbstractPaintBuffer::setDevicePixelRatio( double ratio ) Creates a pixmap paint buffer instancen with the specified \a size and \a devicePixelRatio, if applicable. */ -QCPPaintBufferPixmap::QCPPaintBufferPixmap( const QSize& size, double devicePixelRatio ) - : QCPAbstractPaintBuffer( size, devicePixelRatio ) +QCPPaintBufferPixmap::QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio) : + QCPAbstractPaintBuffer(size, devicePixelRatio) { QCPPaintBufferPixmap::reallocateBuffer(); } @@ -652,49 +664,49 @@ QCPPaintBufferPixmap::~QCPPaintBufferPixmap() } /* inherits documentation from base class */ -QCPPainter* QCPPaintBufferPixmap::startPainting() +QCPPainter *QCPPaintBufferPixmap::startPainting() { - QCPPainter* result = new QCPPainter( &mBuffer ); - result->setRenderHint( QPainter::HighQualityAntialiasing ); + QCPPainter *result = new QCPPainter(&mBuffer); + result->setRenderHint(QPainter::HighQualityAntialiasing); return result; } /* inherits documentation from base class */ -void QCPPaintBufferPixmap::draw( QCPPainter* painter ) const +void QCPPaintBufferPixmap::draw(QCPPainter *painter) const { - if( painter && painter->isActive() ) - painter->drawPixmap( 0, 0, mBuffer ); + if (painter && painter->isActive()) + painter->drawPixmap(0, 0, mBuffer); else qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed"; } /* inherits documentation from base class */ -void QCPPaintBufferPixmap::clear( const QColor& color ) +void QCPPaintBufferPixmap::clear(const QColor &color) { - mBuffer.fill( color ); + mBuffer.fill(color); } /* inherits documentation from base class */ void QCPPaintBufferPixmap::reallocateBuffer() { setInvalidated(); - if( !qFuzzyCompare( 1.0, mDevicePixelRatio ) ) + if (!qFuzzyCompare(1.0, mDevicePixelRatio)) { #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED - mBuffer = QPixmap( mSize * mDevicePixelRatio ); - mBuffer.setDevicePixelRatio( mDevicePixelRatio ); + mBuffer = QPixmap(mSize*mDevicePixelRatio); + mBuffer.setDevicePixelRatio(mDevicePixelRatio); #else qDebug() << Q_FUNC_INFO << "Device pixel ratios not supported for Qt versions before 5.4"; mDevicePixelRatio = 1.0; - mBuffer = QPixmap( mSize ); + mBuffer = QPixmap(mSize); #endif - } - else + } else { - mBuffer = QPixmap( mSize ); + mBuffer = QPixmap(mSize); } } + #ifdef QCP_OPENGL_PBUFFER //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPPaintBufferGlPbuffer @@ -719,74 +731,76 @@ void QCPPaintBufferPixmap::reallocateBuffer() result in higher quality antialiasing. If the specified \a multisamples value exceeds the capability of the graphics hardware, the highest supported multisampling is used. */ -QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer( const QSize& size, double devicePixelRatio, int multisamples ) - : QCPAbstractPaintBuffer( size, devicePixelRatio ), mGlPBuffer( 0 ), mMultisamples( qMax( 0, multisamples ) ) +QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples) : + QCPAbstractPaintBuffer(size, devicePixelRatio), + mGlPBuffer(0), + mMultisamples(qMax(0, multisamples)) { QCPPaintBufferGlPbuffer::reallocateBuffer(); } QCPPaintBufferGlPbuffer::~QCPPaintBufferGlPbuffer() { - if( mGlPBuffer ) + if (mGlPBuffer) delete mGlPBuffer; } /* inherits documentation from base class */ -QCPPainter* QCPPaintBufferGlPbuffer::startPainting() +QCPPainter *QCPPaintBufferGlPbuffer::startPainting() { - if( !mGlPBuffer->isValid() ) + if (!mGlPBuffer->isValid()) { qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?"; return 0; } - - QCPPainter* result = new QCPPainter( mGlPBuffer ); - result->setRenderHint( QPainter::HighQualityAntialiasing ); + + QCPPainter *result = new QCPPainter(mGlPBuffer); + result->setRenderHint(QPainter::HighQualityAntialiasing); return result; } /* inherits documentation from base class */ -void QCPPaintBufferGlPbuffer::draw( QCPPainter* painter ) const +void QCPPaintBufferGlPbuffer::draw(QCPPainter *painter) const { - if( !painter || !painter->isActive() ) + if (!painter || !painter->isActive()) { qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed"; return; } - if( !mGlPBuffer->isValid() ) + if (!mGlPBuffer->isValid()) { qDebug() << Q_FUNC_INFO << "OpenGL pbuffer isn't valid, reallocateBuffer was not called?"; return; } - painter->drawImage( 0, 0, mGlPBuffer->toImage() ); + painter->drawImage(0, 0, mGlPBuffer->toImage()); } /* inherits documentation from base class */ -void QCPPaintBufferGlPbuffer::clear( const QColor& color ) +void QCPPaintBufferGlPbuffer::clear(const QColor &color) { - if( mGlPBuffer->isValid() ) + if (mGlPBuffer->isValid()) { mGlPBuffer->makeCurrent(); - glClearColor( color.redF(), color.greenF(), color.blueF(), color.alphaF() ); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF()); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mGlPBuffer->doneCurrent(); - } - else + } else qDebug() << Q_FUNC_INFO << "OpenGL pbuffer invalid or context not current"; } /* inherits documentation from base class */ void QCPPaintBufferGlPbuffer::reallocateBuffer() { - if( mGlPBuffer ) + if (mGlPBuffer) delete mGlPBuffer; - + QGLFormat format; - format.setAlpha( true ); - format.setSamples( mMultisamples ); - mGlPBuffer = new QGLPixelBuffer( mSize, format ); + format.setAlpha(true); + format.setSamples(mMultisamples); + mGlPBuffer = new QGLPixelBuffer(mSize, format); } -#endif // QCP_OPENGL_PBUFFER +#endif // QCP_OPENGL_PBUFFER + #ifdef QCP_OPENGL_FBO //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -813,84 +827,87 @@ void QCPPaintBufferGlPbuffer::reallocateBuffer() QCustomPlot::setupOpenGl and the context and paint device are managed by the parent QCustomPlot instance. */ -QCPPaintBufferGlFbo::QCPPaintBufferGlFbo( const QSize& size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice ) - : QCPAbstractPaintBuffer( size, devicePixelRatio ), mGlContext( glContext ), mGlPaintDevice( glPaintDevice ), mGlFrameBuffer( 0 ) +QCPPaintBufferGlFbo::QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice) : + QCPAbstractPaintBuffer(size, devicePixelRatio), + mGlContext(glContext), + mGlPaintDevice(glPaintDevice), + mGlFrameBuffer(0) { QCPPaintBufferGlFbo::reallocateBuffer(); } QCPPaintBufferGlFbo::~QCPPaintBufferGlFbo() { - if( mGlFrameBuffer ) + if (mGlFrameBuffer) delete mGlFrameBuffer; } /* inherits documentation from base class */ -QCPPainter* QCPPaintBufferGlFbo::startPainting() +QCPPainter *QCPPaintBufferGlFbo::startPainting() { - if( mGlPaintDevice.isNull() ) + if (mGlPaintDevice.isNull()) { qDebug() << Q_FUNC_INFO << "OpenGL paint device doesn't exist"; return 0; } - if( !mGlFrameBuffer ) + if (!mGlFrameBuffer) { qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?"; return 0; } - - if( QOpenGLContext::currentContext() != mGlContext.data() ) - mGlContext.data()->makeCurrent( mGlContext.data()->surface() ); + + if (QOpenGLContext::currentContext() != mGlContext.data()) + mGlContext.data()->makeCurrent(mGlContext.data()->surface()); mGlFrameBuffer->bind(); - QCPPainter* result = new QCPPainter( mGlPaintDevice.data() ); - result->setRenderHint( QPainter::HighQualityAntialiasing ); + QCPPainter *result = new QCPPainter(mGlPaintDevice.data()); + result->setRenderHint(QPainter::HighQualityAntialiasing); return result; } /* inherits documentation from base class */ void QCPPaintBufferGlFbo::donePainting() { - if( mGlFrameBuffer && mGlFrameBuffer->isBound() ) + if (mGlFrameBuffer && mGlFrameBuffer->isBound()) mGlFrameBuffer->release(); else qDebug() << Q_FUNC_INFO << "Either OpenGL frame buffer not valid or was not bound"; } /* inherits documentation from base class */ -void QCPPaintBufferGlFbo::draw( QCPPainter* painter ) const +void QCPPaintBufferGlFbo::draw(QCPPainter *painter) const { - if( !painter || !painter->isActive() ) + if (!painter || !painter->isActive()) { qDebug() << Q_FUNC_INFO << "invalid or inactive painter passed"; return; } - if( !mGlFrameBuffer ) + if (!mGlFrameBuffer) { qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?"; return; } - painter->drawImage( 0, 0, mGlFrameBuffer->toImage() ); + painter->drawImage(0, 0, mGlFrameBuffer->toImage()); } /* inherits documentation from base class */ -void QCPPaintBufferGlFbo::clear( const QColor& color ) +void QCPPaintBufferGlFbo::clear(const QColor &color) { - if( mGlContext.isNull() ) + if (mGlContext.isNull()) { qDebug() << Q_FUNC_INFO << "OpenGL context doesn't exist"; return; } - if( !mGlFrameBuffer ) + if (!mGlFrameBuffer) { qDebug() << Q_FUNC_INFO << "OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?"; return; } - - if( QOpenGLContext::currentContext() != mGlContext.data() ) - mGlContext.data()->makeCurrent( mGlContext.data()->surface() ); + + if (QOpenGLContext::currentContext() != mGlContext.data()) + mGlContext.data()->makeCurrent(mGlContext.data()->surface()); mGlFrameBuffer->bind(); - glClearColor( color.redF(), color.greenF(), color.blueF(), color.alphaF() ); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF()); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mGlFrameBuffer->release(); } @@ -898,40 +915,41 @@ void QCPPaintBufferGlFbo::clear( const QColor& color ) void QCPPaintBufferGlFbo::reallocateBuffer() { // release and delete possibly existing framebuffer: - if( mGlFrameBuffer ) + if (mGlFrameBuffer) { - if( mGlFrameBuffer->isBound() ) + if (mGlFrameBuffer->isBound()) mGlFrameBuffer->release(); delete mGlFrameBuffer; mGlFrameBuffer = 0; } - - if( mGlContext.isNull() ) + + if (mGlContext.isNull()) { qDebug() << Q_FUNC_INFO << "OpenGL context doesn't exist"; return; } - if( mGlPaintDevice.isNull() ) + if (mGlPaintDevice.isNull()) { qDebug() << Q_FUNC_INFO << "OpenGL paint device doesn't exist"; return; } - + // create new fbo with appropriate size: - mGlContext.data()->makeCurrent( mGlContext.data()->surface() ); + mGlContext.data()->makeCurrent(mGlContext.data()->surface()); QOpenGLFramebufferObjectFormat frameBufferFormat; - frameBufferFormat.setSamples( mGlContext.data()->format().samples() ); - frameBufferFormat.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil ); - mGlFrameBuffer = new QOpenGLFramebufferObject( mSize * mDevicePixelRatio, frameBufferFormat ); - if( mGlPaintDevice.data()->size() != mSize * mDevicePixelRatio ) - mGlPaintDevice.data()->setSize( mSize * mDevicePixelRatio ); + frameBufferFormat.setSamples(mGlContext.data()->format().samples()); + frameBufferFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + mGlFrameBuffer = new QOpenGLFramebufferObject(mSize*mDevicePixelRatio, frameBufferFormat); + if (mGlPaintDevice.data()->size() != mSize*mDevicePixelRatio) + mGlPaintDevice.data()->setSize(mSize*mDevicePixelRatio); #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED - mGlPaintDevice.data()->setDevicePixelRatio( mDevicePixelRatio ); + mGlPaintDevice.data()->setDevicePixelRatio(mDevicePixelRatio); #endif } -#endif // QCP_OPENGL_FBO +#endif // QCP_OPENGL_FBO /* end of 'src/paintbuffer.cpp' */ + /* including file 'src/layer.cpp', size 37064 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1021,10 +1039,13 @@ void QCPPaintBufferGlFbo::reallocateBuffer() \warning It is not checked that \a layerName is actually a unique layer name in \a parentPlot. This check is only performed by \ref QCustomPlot::addLayer. */ -QCPLayer::QCPLayer( QCustomPlot* parentPlot, const QString& layerName ) - : QObject( parentPlot ), mParentPlot( parentPlot ), mName( layerName ), mIndex( -1 ), // will be set to a proper value by the QCustomPlot layer creation function - mVisible( true ) - , mMode( lmLogical ) +QCPLayer::QCPLayer(QCustomPlot *parentPlot, const QString &layerName) : + QObject(parentPlot), + mParentPlot(parentPlot), + mName(layerName), + mIndex(-1), // will be set to a proper value by the QCustomPlot layer creation function + mVisible(true), + mMode(lmLogical) { // Note: no need to make sure layerName is unique, because layer // management is done with QCustomPlot functions. @@ -1036,11 +1057,11 @@ QCPLayer::~QCPLayer() // then invalid layer once they get deleted/moved themselves. This only happens when layers are deleted // directly, like in the QCustomPlot destructor. (The regular layer removal procedure for the user is to // call QCustomPlot::removeLayer, which moves all layerables off this layer before deleting it.) - - while( !mChildren.isEmpty() ) - mChildren.last()->setLayer( 0 ); // removes itself from mChildren via removeChild() - - if( mParentPlot->currentLayer() == this ) + + while (!mChildren.isEmpty()) + mChildren.last()->setLayer(0); // removes itself from mChildren via removeChild() + + if (mParentPlot->currentLayer() == this) qDebug() << Q_FUNC_INFO << "The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand."; } @@ -1052,7 +1073,7 @@ QCPLayer::~QCPLayer() QCPLayerable::setVisible), but the \ref QCPLayerable::realVisibility of each layerable takes the visibility of the parent layer into account. */ -void QCPLayer::setVisible( bool visible ) +void QCPLayer::setVisible(bool visible) { mVisible = visible; } @@ -1078,12 +1099,12 @@ void QCPLayer::setVisible( bool visible ) \see replot */ -void QCPLayer::setMode( QCPLayer::LayerMode mode ) +void QCPLayer::setMode(QCPLayer::LayerMode mode) { - if( mMode != mode ) + if (mMode != mode) { mMode = mode; - if( !mPaintBuffer.isNull() ) + if (!mPaintBuffer.isNull()) mPaintBuffer.data()->setInvalidated(); } } @@ -1094,16 +1115,16 @@ void QCPLayer::setMode( QCPLayer::LayerMode mode ) \see replot, drawToPaintBuffer */ -void QCPLayer::draw( QCPPainter* painter ) +void QCPLayer::draw(QCPPainter *painter) { - foreach( QCPLayerable* child, mChildren ) + foreach (QCPLayerable *child, mChildren) { - if( child->realVisibility() ) + if (child->realVisibility()) { painter->save(); - painter->setClipRect( child->clipRect().translated( 0, -1 ) ); - child->applyDefaultAntialiasingHint( painter ); - child->draw( painter ); + painter->setClipRect(child->clipRect().translated(0, -1)); + child->applyDefaultAntialiasingHint(painter); + child->draw(painter); painter->restore(); } } @@ -1119,21 +1140,19 @@ void QCPLayer::draw( QCPPainter* painter ) */ void QCPLayer::drawToPaintBuffer() { - if( !mPaintBuffer.isNull() ) + if (!mPaintBuffer.isNull()) { - if( QCPPainter* painter = mPaintBuffer.data()->startPainting() ) + if (QCPPainter *painter = mPaintBuffer.data()->startPainting()) { - if( painter->isActive() ) - draw( painter ); + if (painter->isActive()) + draw(painter); else qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter"; delete painter; mPaintBuffer.data()->donePainting(); - } - else + } else qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter"; - } - else + } else qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer"; } @@ -1152,19 +1171,17 @@ void QCPLayer::drawToPaintBuffer() */ void QCPLayer::replot() { - if( mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers() ) + if (mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers()) { - if( !mPaintBuffer.isNull() ) + if (!mPaintBuffer.isNull()) { - mPaintBuffer.data()->clear( Qt::transparent ); + mPaintBuffer.data()->clear(Qt::transparent); drawToPaintBuffer(); - mPaintBuffer.data()->setInvalidated( false ); + mPaintBuffer.data()->setInvalidated(false); mParentPlot->update(); - } - else + } else qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer"; - } - else if( mMode == lmLogical ) + } else if (mMode == lmLogical) mParentPlot->replot(); } @@ -1178,19 +1195,18 @@ void QCPLayer::replot() \see removeChild */ -void QCPLayer::addChild( QCPLayerable* layerable, bool prepend ) +void QCPLayer::addChild(QCPLayerable *layerable, bool prepend) { - if( !mChildren.contains( layerable ) ) + if (!mChildren.contains(layerable)) { - if( prepend ) - mChildren.prepend( layerable ); + if (prepend) + mChildren.prepend(layerable); else - mChildren.append( layerable ); - if( !mPaintBuffer.isNull() ) + mChildren.append(layerable); + if (!mPaintBuffer.isNull()) mPaintBuffer.data()->setInvalidated(); - } - else - qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast( layerable ); + } else + qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast(layerable); } /*! \internal @@ -1202,17 +1218,17 @@ void QCPLayer::addChild( QCPLayerable* layerable, bool prepend ) \see addChild */ -void QCPLayer::removeChild( QCPLayerable* layerable ) +void QCPLayer::removeChild(QCPLayerable *layerable) { - if( mChildren.removeOne( layerable ) ) + if (mChildren.removeOne(layerable)) { - if( !mPaintBuffer.isNull() ) + if (!mPaintBuffer.isNull()) mPaintBuffer.data()->setInvalidated(); - } - else - qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast( layerable ); + } else + qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast(layerable); } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLayerable //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1320,23 +1336,28 @@ void QCPLayer::removeChild( QCPLayerable* layerable ) plot does. It is not uncommon to set the QObject-parent to something else in the constructors of QCPLayerable subclasses, to guarantee a working destruction hierarchy. */ -QCPLayerable::QCPLayerable( QCustomPlot* plot, QString targetLayer, QCPLayerable* parentLayerable ) - : QObject( plot ), mVisible( true ), mParentPlot( plot ), mParentLayerable( parentLayerable ), mLayer( 0 ), mAntialiased( true ) +QCPLayerable::QCPLayerable(QCustomPlot *plot, QString targetLayer, QCPLayerable *parentLayerable) : + QObject(plot), + mVisible(true), + mParentPlot(plot), + mParentLayerable(parentLayerable), + mLayer(0), + mAntialiased(true) { - if( mParentPlot ) + if (mParentPlot) { - if( targetLayer.isEmpty() ) - setLayer( mParentPlot->currentLayer() ); - else if( !setLayer( targetLayer ) ) + if (targetLayer.isEmpty()) + setLayer(mParentPlot->currentLayer()); + else if (!setLayer(targetLayer)) qDebug() << Q_FUNC_INFO << "setting QCPlayerable initial layer to" << targetLayer << "failed."; } } QCPLayerable::~QCPLayerable() { - if( mLayer ) + if (mLayer) { - mLayer->removeChild( this ); + mLayer->removeChild(this); mLayer = 0; } } @@ -1346,7 +1367,7 @@ QCPLayerable::~QCPLayerable() on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible. */ -void QCPLayerable::setVisible( bool on ) +void QCPLayerable::setVisible(bool on) { mVisible = on; } @@ -1360,9 +1381,9 @@ void QCPLayerable::setVisible( bool on ) Returns true if the layer of this layerable was successfully changed to \a layer. */ -bool QCPLayerable::setLayer( QCPLayer* layer ) +bool QCPLayerable::setLayer(QCPLayer *layer) { - return moveToLayer( layer, false ); + return moveToLayer(layer, false); } /*! \overload @@ -1370,18 +1391,17 @@ bool QCPLayerable::setLayer( QCPLayer* layer ) Returns true on success, i.e. if \a layerName is a valid layer name. */ -bool QCPLayerable::setLayer( const QString& layerName ) +bool QCPLayerable::setLayer(const QString &layerName) { - if( !mParentPlot ) + if (!mParentPlot) { qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set"; return false; } - if( QCPLayer* layer = mParentPlot->layer( layerName ) ) + if (QCPLayer *layer = mParentPlot->layer(layerName)) { - return setLayer( layer ); - } - else + return setLayer(layer); + } else { qDebug() << Q_FUNC_INFO << "there is no layer with name" << layerName; return false; @@ -1394,7 +1414,7 @@ bool QCPLayerable::setLayer( const QString& layerName ) Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. */ -void QCPLayerable::setAntialiased( bool enabled ) +void QCPLayerable::setAntialiased(bool enabled) { mAntialiased = enabled; } @@ -1411,7 +1431,7 @@ void QCPLayerable::setAntialiased( bool enabled ) */ bool QCPLayerable::realVisibility() const { - return mVisible && ( !mLayer || mLayer->visible() ) && ( !mParentLayerable || mParentLayerable.data()->realVisibility() ); + return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility()); } /*! @@ -1448,11 +1468,11 @@ bool QCPLayerable::realVisibility() const \see selectEvent, deselectEvent, mousePressEvent, wheelEvent, QCustomPlot::setInteractions */ -double QCPLayerable::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( pos ) - Q_UNUSED( onlySelectable ) - Q_UNUSED( details ) + Q_UNUSED(pos) + Q_UNUSED(onlySelectable) + Q_UNUSED(details) return -1.0; } @@ -1473,19 +1493,19 @@ double QCPLayerable::selectTest( const QPointF& pos, bool onlySelectable, QVaria so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does). */ -void QCPLayerable::initializeParentPlot( QCustomPlot* parentPlot ) +void QCPLayerable::initializeParentPlot(QCustomPlot *parentPlot) { - if( mParentPlot ) + if (mParentPlot) { qDebug() << Q_FUNC_INFO << "called with mParentPlot already initialized"; return; } - - if( !parentPlot ) + + if (!parentPlot) qDebug() << Q_FUNC_INFO << "called with parentPlot zero"; - + mParentPlot = parentPlot; - parentPlotInitialized( mParentPlot ); + parentPlotInitialized(mParentPlot); } /*! \internal @@ -1499,7 +1519,7 @@ void QCPLayerable::initializeParentPlot( QCustomPlot* parentPlot ) \see realVisibility */ -void QCPLayerable::setParentLayerable( QCPLayerable* parentLayerable ) +void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable) { mParentLayerable = parentLayerable; } @@ -1512,27 +1532,27 @@ void QCPLayerable::setParentLayerable( QCPLayerable* parentLayerable ) Returns true on success, i.e. if \a layer is a valid layer. */ -bool QCPLayerable::moveToLayer( QCPLayer* layer, bool prepend ) +bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend) { - if( layer && !mParentPlot ) + if (layer && !mParentPlot) { qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set"; return false; } - if( layer && layer->parentPlot() != mParentPlot ) + if (layer && layer->parentPlot() != mParentPlot) { qDebug() << Q_FUNC_INFO << "layer" << layer->name() << "is not in same QCustomPlot as this layerable"; return false; } - - QCPLayer* oldLayer = mLayer; - if( mLayer ) - mLayer->removeChild( this ); + + QCPLayer *oldLayer = mLayer; + if (mLayer) + mLayer->removeChild(this); mLayer = layer; - if( mLayer ) - mLayer->addChild( this, prepend ); - if( mLayer != oldLayer ) - emit layerChanged( mLayer ); + if (mLayer) + mLayer->addChild(this, prepend); + if (mLayer != oldLayer) + emit layerChanged(mLayer); return true; } @@ -1543,14 +1563,14 @@ bool QCPLayerable::moveToLayer( QCPLayer* layer, bool prepend ) QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via \a overrideElement. */ -void QCPLayerable::applyAntialiasingHint( QCPPainter* painter, bool localAntialiased, QCP::AntialiasedElement overrideElement ) const +void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const { - if( mParentPlot && mParentPlot->notAntialiasedElements().testFlag( overrideElement ) ) - painter->setAntialiasing( false ); - else if( mParentPlot && mParentPlot->antialiasedElements().testFlag( overrideElement ) ) - painter->setAntialiasing( true ); + if (mParentPlot && mParentPlot->notAntialiasedElements().testFlag(overrideElement)) + painter->setAntialiasing(false); + else if (mParentPlot && mParentPlot->antialiasedElements().testFlag(overrideElement)) + painter->setAntialiasing(true); else - painter->setAntialiasing( localAntialiased ); + painter->setAntialiasing(localAntialiased); } /*! \internal @@ -1569,8 +1589,10 @@ void QCPLayerable::applyAntialiasingHint( QCPPainter* painter, bool localAntiali \see initializeParentPlot */ -void QCPLayerable::parentPlotInitialized( QCustomPlot* parentPlot ){ - Q_UNUSED( parentPlot )} +void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) +{ + Q_UNUSED(parentPlot) +} /*! \internal @@ -1599,7 +1621,7 @@ QCP::Interaction QCPLayerable::selectionCategory() const */ QRect QCPLayerable::clipRect() const { - if( mParentPlot ) + if (mParentPlot) return mParentPlot->viewport(); else return QRect(); @@ -1633,12 +1655,12 @@ QRect QCPLayerable::clipRect() const \see selectTest, deselectEvent */ -void QCPLayerable::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - Q_UNUSED( additive ) - Q_UNUSED( details ) - Q_UNUSED( selectionStateChanged ) + Q_UNUSED(event) + Q_UNUSED(additive) + Q_UNUSED(details) + Q_UNUSED(selectionStateChanged) } /*! \internal @@ -1653,9 +1675,9 @@ void QCPLayerable::selectEvent( QMouseEvent* event, bool additive, const QVarian \see selectTest, selectEvent */ -void QCPLayerable::deselectEvent( bool* selectionStateChanged ) +void QCPLayerable::deselectEvent(bool *selectionStateChanged) { - Q_UNUSED( selectionStateChanged ) + Q_UNUSED(selectionStateChanged) } /*! @@ -1683,9 +1705,9 @@ void QCPLayerable::deselectEvent( bool* selectionStateChanged ) \see mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent */ -void QCPLayerable::mousePressEvent( QMouseEvent* event, const QVariant& details ) +void QCPLayerable::mousePressEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) + Q_UNUSED(details) event->ignore(); } @@ -1701,9 +1723,9 @@ void QCPLayerable::mousePressEvent( QMouseEvent* event, const QVariant& details \see mousePressEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent */ -void QCPLayerable::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPLayerable::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) { - Q_UNUSED( startPos ) + Q_UNUSED(startPos) event->ignore(); } @@ -1719,9 +1741,9 @@ void QCPLayerable::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) \see mousePressEvent, mouseMoveEvent, mouseDoubleClickEvent, wheelEvent */ -void QCPLayerable::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPLayerable::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) { - Q_UNUSED( startPos ) + Q_UNUSED(startPos) event->ignore(); } @@ -1751,9 +1773,9 @@ void QCPLayerable::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPo \see mousePressEvent, mouseMoveEvent, mouseReleaseEvent, wheelEvent */ -void QCPLayerable::mouseDoubleClickEvent( QMouseEvent* event, const QVariant& details ) +void QCPLayerable::mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) + Q_UNUSED(details) event->ignore(); } @@ -1774,12 +1796,13 @@ void QCPLayerable::mouseDoubleClickEvent( QMouseEvent* event, const QVariant& de \see mousePressEvent, mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent */ -void QCPLayerable::wheelEvent( QWheelEvent* event ) +void QCPLayerable::wheelEvent(QWheelEvent *event) { event->ignore(); } /* end of 'src/layer.cpp' */ + /* including file 'src/axis/range.cpp', size 12221 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1869,8 +1892,9 @@ const double QCPRange::maxRange = 1e250; /*! Constructs a range with \a lower and \a upper set to zero. */ -QCPRange::QCPRange() - : lower( 0 ), upper( 0 ) +QCPRange::QCPRange() : + lower(0), + upper(0) { } @@ -1881,8 +1905,9 @@ QCPRange::QCPRange() The resulting range will be normalized (see \ref normalize), so if \a lower is not numerically smaller than \a upper, they will be swapped. */ -QCPRange::QCPRange( double lower, double upper ) - : lower( lower ), upper( upper ) +QCPRange::QCPRange(double lower, double upper) : + lower(lower), + upper(upper) { normalize(); } @@ -1899,11 +1924,11 @@ QCPRange::QCPRange( double lower, double upper ) \see expanded */ -void QCPRange::expand( const QCPRange& otherRange ) +void QCPRange::expand(const QCPRange &otherRange) { - if( lower > otherRange.lower || qIsNaN( lower ) ) + if (lower > otherRange.lower || qIsNaN(lower)) lower = otherRange.lower; - if( upper < otherRange.upper || qIsNaN( upper ) ) + if (upper < otherRange.upper || qIsNaN(upper)) upper = otherRange.upper; } @@ -1919,14 +1944,15 @@ void QCPRange::expand( const QCPRange& otherRange ) \see expand */ -void QCPRange::expand( double includeCoord ) +void QCPRange::expand(double includeCoord) { - if( lower > includeCoord || qIsNaN( lower ) ) + if (lower > includeCoord || qIsNaN(lower)) lower = includeCoord; - if( upper < includeCoord || qIsNaN( upper ) ) + if (upper < includeCoord || qIsNaN(upper)) upper = includeCoord; } + /*! \overload Returns an expanded range that contains this and \a otherRange. It is assumed that both this @@ -1937,10 +1963,10 @@ void QCPRange::expand( double includeCoord ) \see expand */ -QCPRange QCPRange::expanded( const QCPRange& otherRange ) const +QCPRange QCPRange::expanded(const QCPRange &otherRange) const { QCPRange result = *this; - result.expand( otherRange ); + result.expand(otherRange); return result; } @@ -1954,10 +1980,10 @@ QCPRange QCPRange::expanded( const QCPRange& otherRange ) const \see expand */ -QCPRange QCPRange::expanded( double includeCoord ) const +QCPRange QCPRange::expanded(double includeCoord) const { QCPRange result = *this; - result.expand( includeCoord ); + result.expand(includeCoord); return result; } @@ -1969,27 +1995,26 @@ QCPRange QCPRange::expanded( double includeCoord ) const QCPRange::maxRange. If it shall only be bounded at the upper side, set \a lowerBound to -\ref QCPRange::maxRange. */ -QCPRange QCPRange::bounded( double lowerBound, double upperBound ) const +QCPRange QCPRange::bounded(double lowerBound, double upperBound) const { - if( lowerBound > upperBound ) - qSwap( lowerBound, upperBound ); - - QCPRange result( lower, upper ); - if( result.lower < lowerBound ) + if (lowerBound > upperBound) + qSwap(lowerBound, upperBound); + + QCPRange result(lower, upper); + if (result.lower < lowerBound) { result.lower = lowerBound; result.upper = lowerBound + size(); - if( result.upper > upperBound || qFuzzyCompare( size(), upperBound - lowerBound ) ) + if (result.upper > upperBound || qFuzzyCompare(size(), upperBound-lowerBound)) result.upper = upperBound; - } - else if( result.upper > upperBound ) + } else if (result.upper > upperBound) { result.upper = upperBound; result.lower = upperBound - size(); - if( result.lower < lowerBound || qFuzzyCompare( size(), upperBound - lowerBound ) ) + if (result.lower < lowerBound || qFuzzyCompare(size(), upperBound-lowerBound)) result.lower = lowerBound; } - + return result; } @@ -2008,44 +2033,42 @@ QCPRange QCPRange::bounded( double lowerBound, double upperBound ) const QCPRange QCPRange::sanitizedForLogScale() const { double rangeFac = 1e-3; - QCPRange sanitizedRange( lower, upper ); + QCPRange sanitizedRange(lower, upper); sanitizedRange.normalize(); // can't have range spanning negative and positive values in log plot, so change range to fix it //if (qFuzzyCompare(sanitizedRange.lower+1, 1) && !qFuzzyCompare(sanitizedRange.upper+1, 1)) - if( sanitizedRange.lower == 0.0 && sanitizedRange.upper != 0.0 ) + if (sanitizedRange.lower == 0.0 && sanitizedRange.upper != 0.0) { // case lower is 0 - if( rangeFac < sanitizedRange.upper * rangeFac ) + if (rangeFac < sanitizedRange.upper*rangeFac) sanitizedRange.lower = rangeFac; else - sanitizedRange.lower = sanitizedRange.upper * rangeFac; - } //else if (!qFuzzyCompare(lower+1, 1) && qFuzzyCompare(upper+1, 1)) - else if( sanitizedRange.lower != 0.0 && sanitizedRange.upper == 0.0 ) + sanitizedRange.lower = sanitizedRange.upper*rangeFac; + } //else if (!qFuzzyCompare(lower+1, 1) && qFuzzyCompare(upper+1, 1)) + else if (sanitizedRange.lower != 0.0 && sanitizedRange.upper == 0.0) { // case upper is 0 - if( -rangeFac > sanitizedRange.lower * rangeFac ) + if (-rangeFac > sanitizedRange.lower*rangeFac) sanitizedRange.upper = -rangeFac; else - sanitizedRange.upper = sanitizedRange.lower * rangeFac; - } - else if( sanitizedRange.lower < 0 && sanitizedRange.upper > 0 ) + sanitizedRange.upper = sanitizedRange.lower*rangeFac; + } else if (sanitizedRange.lower < 0 && sanitizedRange.upper > 0) { // find out whether negative or positive interval is wider to decide which sign domain will be chosen - if( -sanitizedRange.lower > sanitizedRange.upper ) + if (-sanitizedRange.lower > sanitizedRange.upper) { // negative is wider, do same as in case upper is 0 - if( -rangeFac > sanitizedRange.lower * rangeFac ) + if (-rangeFac > sanitizedRange.lower*rangeFac) sanitizedRange.upper = -rangeFac; else - sanitizedRange.upper = sanitizedRange.lower * rangeFac; - } - else + sanitizedRange.upper = sanitizedRange.lower*rangeFac; + } else { // positive is wider, do same as in case lower is 0 - if( rangeFac < sanitizedRange.upper * rangeFac ) + if (rangeFac < sanitizedRange.upper*rangeFac) sanitizedRange.lower = rangeFac; else - sanitizedRange.lower = sanitizedRange.upper * rangeFac; + sanitizedRange.lower = sanitizedRange.upper*rangeFac; } } // due to normalization, case lower>0 && upper<0 should never occur, because that implies upper -maxRange && - upper < maxRange && - qAbs( lower - upper ) > minRange && - qAbs( lower - upper ) < maxRange && - !( lower > 0 && qIsInf( upper / lower ) ) && - !( upper < 0 && qIsInf( lower / upper ) ) ); + return (lower > -maxRange && + upper < maxRange && + qAbs(lower-upper) > minRange && + qAbs(lower-upper) < maxRange && + !(lower > 0 && qIsInf(upper/lower)) && + !(upper < 0 && qIsInf(lower/upper))); } /*! @@ -2090,17 +2113,18 @@ bool QCPRange::validRange( double lower, double upper ) \li range size above minRange \li range size below maxRange */ -bool QCPRange::validRange( const QCPRange& range ) +bool QCPRange::validRange(const QCPRange &range) { - return ( range.lower > -maxRange && - range.upper < maxRange && - qAbs( range.lower - range.upper ) > minRange && - qAbs( range.lower - range.upper ) < maxRange && - !( range.lower > 0 && qIsInf( range.upper / range.lower ) ) && - !( range.upper < 0 && qIsInf( range.lower / range.upper ) ) ); + return (range.lower > -maxRange && + range.upper < maxRange && + qAbs(range.lower-range.upper) > minRange && + qAbs(range.lower-range.upper) < maxRange && + !(range.lower > 0 && qIsInf(range.upper/range.lower)) && + !(range.upper < 0 && qIsInf(range.lower/range.upper))); } /* end of 'src/axis/range.cpp' */ + /* including file 'src/selection.cpp', size 21906 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -2198,8 +2222,9 @@ bool QCPRange::validRange( const QCPRange& range ) /*! Creates an empty QCPDataRange, with begin and end set to 0. */ -QCPDataRange::QCPDataRange() - : mBegin( 0 ), mEnd( 0 ) +QCPDataRange::QCPDataRange() : + mBegin(0), + mEnd(0) { } @@ -2208,8 +2233,9 @@ QCPDataRange::QCPDataRange() No checks or corrections are made to ensure the resulting range is valid (\ref isValid). */ -QCPDataRange::QCPDataRange( int begin, int end ) - : mBegin( begin ), mEnd( end ) +QCPDataRange::QCPDataRange(int begin, int end) : + mBegin(begin), + mEnd(end) { } @@ -2222,15 +2248,15 @@ QCPDataRange::QCPDataRange( int begin, int end ) to the respective boundary side of \a other, at which this range is residing. (\ref intersection would just return a range with begin and end set to 0.) */ -QCPDataRange QCPDataRange::bounded( const QCPDataRange& other ) const +QCPDataRange QCPDataRange::bounded(const QCPDataRange &other) const { - QCPDataRange result( intersection( other ) ); - if( result.isEmpty() ) // no intersection, preserve respective bounding side of otherRange as both begin and end of return value + QCPDataRange result(intersection(other)); + if (result.isEmpty()) // no intersection, preserve respective bounding side of otherRange as both begin and end of return value { - if( mEnd <= other.mBegin ) - result = QCPDataRange( other.mBegin, other.mBegin ); + if (mEnd <= other.mBegin) + result = QCPDataRange(other.mBegin, other.mBegin); else - result = QCPDataRange( other.mEnd, other.mEnd ); + result = QCPDataRange(other.mEnd, other.mEnd); } return result; } @@ -2238,9 +2264,9 @@ QCPDataRange QCPDataRange::bounded( const QCPDataRange& other ) const /*! Returns a data range that contains both this data range as well as \a other. */ -QCPDataRange QCPDataRange::expanded( const QCPDataRange& other ) const +QCPDataRange QCPDataRange::expanded(const QCPDataRange &other) const { - return QCPDataRange( qMin( mBegin, other.mBegin ), qMax( mEnd, other.mEnd ) ); + return QCPDataRange(qMin(mBegin, other.mBegin), qMax(mEnd, other.mEnd)); } /*! @@ -2253,10 +2279,10 @@ QCPDataRange QCPDataRange::expanded( const QCPDataRange& other ) const \see QCPDataSelection::intersection */ -QCPDataRange QCPDataRange::intersection( const QCPDataRange& other ) const +QCPDataRange QCPDataRange::intersection(const QCPDataRange &other) const { - QCPDataRange result( qMax( mBegin, other.mBegin ), qMin( mEnd, other.mEnd ) ); - if( result.isValid() ) + QCPDataRange result(qMax(mBegin, other.mBegin), qMin(mEnd, other.mEnd)); + if (result.isValid()) return result; else return QCPDataRange(); @@ -2267,10 +2293,10 @@ QCPDataRange QCPDataRange::intersection( const QCPDataRange& other ) const \see intersection, contains */ -bool QCPDataRange::intersects( const QCPDataRange& other ) const +bool QCPDataRange::intersects(const QCPDataRange &other) const { - return !( ( mBegin > other.mBegin && mBegin >= other.mEnd ) || - ( mEnd <= other.mBegin && mEnd < other.mEnd ) ); + return !( (mBegin > other.mBegin && mBegin >= other.mEnd) || + (mEnd <= other.mBegin && mEnd < other.mEnd) ); } /*! @@ -2278,11 +2304,13 @@ bool QCPDataRange::intersects( const QCPDataRange& other ) const \see intersects */ -bool QCPDataRange::contains( const QCPDataRange& other ) const +bool QCPDataRange::contains(const QCPDataRange &other) const { return mBegin <= other.mBegin && mEnd >= other.mEnd; } + + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPDataSelection //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2359,9 +2387,9 @@ QCPDataSelection::QCPDataSelection() /*! Creates a QCPDataSelection containing the provided \a range. */ -QCPDataSelection::QCPDataSelection( const QCPDataRange& range ) +QCPDataSelection::QCPDataSelection(const QCPDataRange &range) { - mDataRanges.append( range ); + mDataRanges.append(range); } /*! @@ -2371,13 +2399,13 @@ QCPDataSelection::QCPDataSelection( const QCPDataRange& range ) Note that both data selections must be in simplified state (the usual state of the selection, see \ref simplify) for this operator to return correct results. */ -bool QCPDataSelection::operator==( const QCPDataSelection& other ) const +bool QCPDataSelection::operator==(const QCPDataSelection &other) const { - if( mDataRanges.size() != other.mDataRanges.size() ) + if (mDataRanges.size() != other.mDataRanges.size()) return false; - for( int i = 0; i < mDataRanges.size(); ++i ) + for (int i=0; i= other.end() ) - break; // since data ranges are sorted after the simplify() call, no ranges which contain other will come after this - - if( thisEnd > other.begin() ) // ranges which don't fulfill this are entirely before other and can be ignored + const int thisBegin = mDataRanges.at(i).begin(); + const int thisEnd = mDataRanges.at(i).end(); + if (thisBegin >= other.end()) + break; // since data ranges are sorted after the simplify() call, no ranges which contain other will come after this + + if (thisEnd > other.begin()) // ranges which don't fulfill this are entirely before other and can be ignored { - if( thisBegin >= other.begin() ) // range leading segment is encompassed + if (thisBegin >= other.begin()) // range leading segment is encompassed { - if( thisEnd <= other.end() ) // range fully encompassed, remove completely + if (thisEnd <= other.end()) // range fully encompassed, remove completely { - mDataRanges.removeAt( i ); + mDataRanges.removeAt(i); continue; - } - else // only leading segment is encompassed, trim accordingly - mDataRanges[i].setBegin( other.end() ); - } - else // leading segment is not encompassed + } else // only leading segment is encompassed, trim accordingly + mDataRanges[i].setBegin(other.end()); + } else // leading segment is not encompassed { - if( thisEnd <= other.end() ) // only trailing segment is encompassed, trim accordingly + if (thisEnd <= other.end()) // only trailing segment is encompassed, trim accordingly { - mDataRanges[i].setEnd( other.begin() ); - } - else // other lies inside this range, so split range + mDataRanges[i].setEnd(other.begin()); + } else // other lies inside this range, so split range { - mDataRanges[i].setEnd( other.begin() ); - mDataRanges.insert( i + 1, QCPDataRange( other.end(), thisEnd ) ); - break; // since data ranges are sorted (and don't overlap) after simplify() call, we're done here + mDataRanges[i].setEnd(other.begin()); + mDataRanges.insert(i+1, QCPDataRange(other.end(), thisEnd)); + break; // since data ranges are sorted (and don't overlap) after simplify() call, we're done here } } } ++i; } - + return *this; } @@ -2471,8 +2496,8 @@ QCPDataSelection& QCPDataSelection::operator-=( const QCPDataRange& other ) int QCPDataSelection::dataPointCount() const { int result = 0; - for( int i = 0; i < mDataRanges.size(); ++i ) - result += mDataRanges.at( i ).length(); + for (int i=0; i= 0 && index < mDataRanges.size() ) + if (index >= 0 && index < mDataRanges.size()) { - return mDataRanges.at( index ); - } - else + return mDataRanges.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of range:" << index; return QCPDataRange(); @@ -2503,10 +2527,10 @@ QCPDataRange QCPDataSelection::dataRange( int index ) const */ QCPDataRange QCPDataSelection::span() const { - if( isEmpty() ) + if (isEmpty()) return QCPDataRange(); else - return QCPDataRange( mDataRanges.first().begin(), mDataRanges.last().end() ); + return QCPDataRange(mDataRanges.first().begin(), mDataRanges.last().end()); } /*! @@ -2515,10 +2539,10 @@ QCPDataRange QCPDataSelection::span() const performance if adding a very large amount of data ranges successively. In this case, make sure to call \ref simplify manually, after the operation. */ -void QCPDataSelection::addDataRange( const QCPDataRange& dataRange, bool simplify ) +void QCPDataSelection::addDataRange(const QCPDataRange &dataRange, bool simplify) { - mDataRanges.append( dataRange ); - if( simplify ) + mDataRanges.append(dataRange); + if (simplify) this->simplify(); } @@ -2544,27 +2568,26 @@ void QCPDataSelection::clear() void QCPDataSelection::simplify() { // remove any empty ranges: - for( int i = mDataRanges.size() - 1; i >= 0; --i ) + for (int i=mDataRanges.size()-1; i>=0; --i) { - if( mDataRanges.at( i ).isEmpty() ) - mDataRanges.removeAt( i ); + if (mDataRanges.at(i).isEmpty()) + mDataRanges.removeAt(i); } - if( mDataRanges.isEmpty() ) + if (mDataRanges.isEmpty()) return; - + // sort ranges by starting value, ascending: - std::sort( mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin ); - + std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin); + // join overlapping/contiguous ranges: int i = 1; - while( i < mDataRanges.size() ) + while (i < mDataRanges.size()) { - if( mDataRanges.at( i - 1 ).end() >= mDataRanges.at( i ).begin() ) // range i overlaps/joins with i-1, so expand range i-1 appropriately and remove range i from list + if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin()) // range i overlaps/joins with i-1, so expand range i-1 appropriately and remove range i from list { - mDataRanges[i - 1].setEnd( qMax( mDataRanges.at( i - 1 ).end(), mDataRanges.at( i ).end() ) ); - mDataRanges.removeAt( i ); - } - else + mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end())); + mDataRanges.removeAt(i); + } else ++i; } } @@ -2579,43 +2602,43 @@ void QCPDataSelection::simplify() \see QCP::SelectionType */ -void QCPDataSelection::enforceType( QCP::SelectionType type ) +void QCPDataSelection::enforceType(QCP::SelectionType type) { simplify(); - switch( type ) + switch (type) { - case QCP::stNone: - { - mDataRanges.clear(); - break; - } - case QCP::stWhole: - { - // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods) - break; - } - case QCP::stSingleData: - { - // reduce all data ranges to the single first data point: - if( !mDataRanges.isEmpty() ) + case QCP::stNone: { - if( mDataRanges.size() > 1 ) - mDataRanges = QList() << mDataRanges.first(); - if( mDataRanges.first().length() > 1 ) - mDataRanges.first().setEnd( mDataRanges.first().begin() + 1 ); + mDataRanges.clear(); + break; + } + case QCP::stWhole: + { + // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods) + break; + } + case QCP::stSingleData: + { + // reduce all data ranges to the single first data point: + if (!mDataRanges.isEmpty()) + { + if (mDataRanges.size() > 1) + mDataRanges = QList() << mDataRanges.first(); + if (mDataRanges.first().length() > 1) + mDataRanges.first().setEnd(mDataRanges.first().begin()+1); + } + break; + } + case QCP::stDataRange: + { + mDataRanges = QList() << span(); + break; + } + case QCP::stMultipleDataRanges: + { + // this is the selection type that allows all concievable combinations of ranges, so do nothing + break; } - break; - } - case QCP::stDataRange: - { - mDataRanges = QList() << span(); - break; - } - case QCP::stMultipleDataRanges: - { - // this is the selection type that allows all concievable combinations of ranges, so do nothing - break; - } } } @@ -2625,21 +2648,20 @@ void QCPDataSelection::enforceType( QCP::SelectionType type ) \see QCPDataRange::contains */ -bool QCPDataSelection::contains( const QCPDataSelection& other ) const +bool QCPDataSelection::contains(const QCPDataSelection &other) const { - if( other.isEmpty() ) - return false; - + if (other.isEmpty()) return false; + int otherIndex = 0; int thisIndex = 0; - while( thisIndex < mDataRanges.size() && otherIndex < other.mDataRanges.size() ) + while (thisIndex < mDataRanges.size() && otherIndex < other.mDataRanges.size()) { - if( mDataRanges.at( thisIndex ).contains( other.mDataRanges.at( otherIndex ) ) ) + if (mDataRanges.at(thisIndex).contains(other.mDataRanges.at(otherIndex))) ++otherIndex; else ++thisIndex; } - return thisIndex < mDataRanges.size(); // if thisIndex ran all the way to the end to find a containing range for the current otherIndex, other is not contained in this + return thisIndex < mDataRanges.size(); // if thisIndex ran all the way to the end to find a containing range for the current otherIndex, other is not contained in this } /*! @@ -2650,11 +2672,11 @@ bool QCPDataSelection::contains( const QCPDataSelection& other ) const using \ref QCPDataContainer::dataRange as \a other. One can then safely iterate over the returned data selection without exceeding the data container's bounds. */ -QCPDataSelection QCPDataSelection::intersection( const QCPDataRange& other ) const +QCPDataSelection QCPDataSelection::intersection(const QCPDataRange &other) const { QCPDataSelection result; - for( int i = 0; i < mDataRanges.size(); ++i ) - result.addDataRange( mDataRanges.at( i ).intersection( other ), false ); + for (int i=0; iorientation() == Qt::Horizontal ) - return QCPRange( axis->pixelToCoord( mRect.left() ), axis->pixelToCoord( mRect.left() + mRect.width() ) ); + if (axis->orientation() == Qt::Horizontal) + return QCPRange(axis->pixelToCoord(mRect.left()), axis->pixelToCoord(mRect.left()+mRect.width())); else - return QCPRange( axis->pixelToCoord( mRect.top() + mRect.height() ), axis->pixelToCoord( mRect.top() ) ); - } - else + return QCPRange(axis->pixelToCoord(mRect.top()+mRect.height()), axis->pixelToCoord(mRect.top())); + } else { qDebug() << Q_FUNC_INFO << "called with axis zero"; return QCPRange(); @@ -2822,7 +2847,7 @@ QCPRange QCPSelectionRect::range( const QCPAxis* axis ) const \see setBrush */ -void QCPSelectionRect::setPen( const QPen& pen ) +void QCPSelectionRect::setPen(const QPen &pen) { mPen = pen; } @@ -2833,7 +2858,7 @@ void QCPSelectionRect::setPen( const QPen& pen ) \see setPen */ -void QCPSelectionRect::setBrush( const QBrush& brush ) +void QCPSelectionRect::setBrush(const QBrush &brush) { mBrush = brush; } @@ -2844,10 +2869,10 @@ void QCPSelectionRect::setBrush( const QBrush& brush ) */ void QCPSelectionRect::cancel() { - if( mActive ) + if (mActive) { mActive = false; - emit canceled( mRect, 0 ); + emit canceled(mRect, 0); } } @@ -2857,11 +2882,11 @@ void QCPSelectionRect::cancel() The default implementation sets the selection rect to active, initializes the selection rect geometry and emits the \ref started signal. */ -void QCPSelectionRect::startSelection( QMouseEvent* event ) +void QCPSelectionRect::startSelection(QMouseEvent *event) { mActive = true; - mRect = QRect( event->pos(), event->pos() ); - emit started( event ); + mRect = QRect(event->pos(), event->pos()); + emit started(event); } /*! \internal @@ -2870,10 +2895,10 @@ void QCPSelectionRect::startSelection( QMouseEvent* event ) to update its geometry. The default implementation updates the rect and emits the \ref changed signal. */ -void QCPSelectionRect::moveSelection( QMouseEvent* event ) +void QCPSelectionRect::moveSelection(QMouseEvent *event) { - mRect.setBottomRight( event->pos() ); - emit changed( mRect, event ); + mRect.setBottomRight(event->pos()); + emit changed(mRect, event); layer()->replot(); } @@ -2883,11 +2908,11 @@ void QCPSelectionRect::moveSelection( QMouseEvent* event ) finished by the user releasing the mouse button. The default implementation deactivates the selection rect and emits the \ref accepted signal. */ -void QCPSelectionRect::endSelection( QMouseEvent* event ) +void QCPSelectionRect::endSelection(QMouseEvent *event) { - mRect.setBottomRight( event->pos() ); + mRect.setBottomRight(event->pos()); mActive = false; - emit accepted( mRect, event ); + emit accepted(mRect, event); } /*! \internal @@ -2896,19 +2921,19 @@ void QCPSelectionRect::endSelection( QMouseEvent* event ) rect interaction is active. The default implementation allows to \ref cancel the interaction by hitting the escape key. */ -void QCPSelectionRect::keyPressEvent( QKeyEvent* event ) +void QCPSelectionRect::keyPressEvent(QKeyEvent *event) { - if( event->key() == Qt::Key_Escape && mActive ) + if (event->key() == Qt::Key_Escape && mActive) { mActive = false; - emit canceled( mRect, event ); + emit canceled(mRect, event); } } /* inherits documentation from base class */ -void QCPSelectionRect::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPSelectionRect::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeOther ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeOther); } /*! \internal @@ -2917,17 +2942,18 @@ void QCPSelectionRect::applyDefaultAntialiasingHint( QCPPainter* painter ) const \seebaseclassmethod */ -void QCPSelectionRect::draw( QCPPainter* painter ) +void QCPSelectionRect::draw(QCPPainter *painter) { - if( mActive ) + if (mActive) { - painter->setPen( mPen ); - painter->setBrush( mBrush ); - painter->drawRect( mRect ); + painter->setPen(mPen); + painter->setBrush(mBrush); + painter->drawRect(mRect); } } /* end of 'src/selectionrect.cpp' */ + /* including file 'src/layout.cpp', size 79064 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -2979,13 +3005,14 @@ void QCPSelectionRect::draw( QCPPainter* painter ) /*! Creates a new QCPMarginGroup instance in \a parentPlot. */ -QCPMarginGroup::QCPMarginGroup( QCustomPlot* parentPlot ) - : QObject( parentPlot ), mParentPlot( parentPlot ) +QCPMarginGroup::QCPMarginGroup(QCustomPlot *parentPlot) : + QObject(parentPlot), + mParentPlot(parentPlot) { - mChildren.insert( QCP::msLeft, QList() ); - mChildren.insert( QCP::msRight, QList() ); - mChildren.insert( QCP::msTop, QList() ); - mChildren.insert( QCP::msBottom, QList() ); + mChildren.insert(QCP::msLeft, QList()); + mChildren.insert(QCP::msRight, QList()); + mChildren.insert(QCP::msTop, QList()); + mChildren.insert(QCP::msBottom, QList()); } QCPMarginGroup::~QCPMarginGroup() @@ -2999,11 +3026,11 @@ QCPMarginGroup::~QCPMarginGroup() */ bool QCPMarginGroup::isEmpty() const { - QHashIterator > it( mChildren ); - while( it.hasNext() ) + QHashIterator > it(mChildren); + while (it.hasNext()) { it.next(); - if( !it.value().isEmpty() ) + if (!it.value().isEmpty()) return false; } return true; @@ -3016,13 +3043,13 @@ bool QCPMarginGroup::isEmpty() const void QCPMarginGroup::clear() { // make all children remove themselves from this margin group: - QHashIterator > it( mChildren ); - while( it.hasNext() ) + QHashIterator > it(mChildren); + while (it.hasNext()) { it.next(); const QList elements = it.value(); - for( int i = elements.size() - 1; i >= 0; --i ) - elements.at( i )->setMarginGroup( it.key(), 0 ); // removes itself from mChildren via removeChild + for (int i=elements.size()-1; i>=0; --i) + elements.at(i)->setMarginGroup(it.key(), 0); // removes itself from mChildren via removeChild } } @@ -3036,17 +3063,17 @@ void QCPMarginGroup::clear() group, and choosing the largest returned value. (QCPLayoutElement::minimumMargins is taken into account, too.) */ -int QCPMarginGroup::commonMargin( QCP::MarginSide side ) const +int QCPMarginGroup::commonMargin(QCP::MarginSide side) const { // query all automatic margins of the layout elements in this margin group side and find maximum: int result = 0; - const QList elements = mChildren.value( side ); - for( int i = 0; i < elements.size(); ++i ) + const QList elements = mChildren.value(side); + for (int i=0; iautoMargins().testFlag( side ) ) + if (!elements.at(i)->autoMargins().testFlag(side)) continue; - int m = qMax( elements.at( i )->calculateAutoMargin( side ), QCP::getMarginValue( elements.at( i )->minimumMargins(), side ) ); - if( m > result ) + int m = qMax(elements.at(i)->calculateAutoMargin(side), QCP::getMarginValue(elements.at(i)->minimumMargins(), side)); + if (m > result) result = m; } return result; @@ -3058,12 +3085,12 @@ int QCPMarginGroup::commonMargin( QCP::MarginSide side ) const This function does not modify the margin group property of \a element. */ -void QCPMarginGroup::addChild( QCP::MarginSide side, QCPLayoutElement* element ) +void QCPMarginGroup::addChild(QCP::MarginSide side, QCPLayoutElement *element) { - if( !mChildren[side].contains( element ) ) - mChildren[side].append( element ); + if (!mChildren[side].contains(element)) + mChildren[side].append(element); else - qDebug() << Q_FUNC_INFO << "element is already child of this margin group side" << reinterpret_cast( element ); + qDebug() << Q_FUNC_INFO << "element is already child of this margin group side" << reinterpret_cast(element); } /*! \internal @@ -3072,12 +3099,13 @@ void QCPMarginGroup::addChild( QCP::MarginSide side, QCPLayoutElement* element ) This function does not modify the margin group property of \a element. */ -void QCPMarginGroup::removeChild( QCP::MarginSide side, QCPLayoutElement* element ) +void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element) { - if( !mChildren[side].removeOne( element ) ) - qDebug() << Q_FUNC_INFO << "element is not child of this margin group side" << reinterpret_cast( element ); + if (!mChildren[side].removeOne(element)) + qDebug() << Q_FUNC_INFO << "element is not child of this margin group side" << reinterpret_cast(element); } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLayoutElement //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3144,26 +3172,26 @@ void QCPMarginGroup::removeChild( QCP::MarginSide side, QCPLayoutElement* elemen /*! Creates an instance of QCPLayoutElement and sets default values. */ -QCPLayoutElement::QCPLayoutElement( QCustomPlot* parentPlot ) - : QCPLayerable( parentPlot ), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout) - mParentLayout( 0 ) - , mMinimumSize() - , mMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX ) - , mSizeConstraintRect( scrInnerRect ) - , mRect( 0, 0, 0, 0 ) - , mOuterRect( 0, 0, 0, 0 ) - , mMargins( 0, 0, 0, 0 ) - , mMinimumMargins( 0, 0, 0, 0 ) - , mAutoMargins( QCP::msAll ) +QCPLayoutElement::QCPLayoutElement(QCustomPlot *parentPlot) : + QCPLayerable(parentPlot), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout) + mParentLayout(0), + mMinimumSize(), + mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX), + mSizeConstraintRect(scrInnerRect), + mRect(0, 0, 0, 0), + mOuterRect(0, 0, 0, 0), + mMargins(0, 0, 0, 0), + mMinimumMargins(0, 0, 0, 0), + mAutoMargins(QCP::msAll) { } QCPLayoutElement::~QCPLayoutElement() { - setMarginGroup( QCP::msAll, 0 ); // unregister at margin groups, if there are any + setMarginGroup(QCP::msAll, 0); // unregister at margin groups, if there are any // unregister at layout: - if( qobject_cast( mParentLayout ) ) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor - mParentLayout->take( this ); + if (qobject_cast(mParentLayout)) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor + mParentLayout->take(this); } /*! @@ -3177,12 +3205,12 @@ QCPLayoutElement::~QCPLayoutElement() \see rect */ -void QCPLayoutElement::setOuterRect( const QRect& rect ) +void QCPLayoutElement::setOuterRect(const QRect &rect) { - if( mOuterRect != rect ) + if (mOuterRect != rect) { mOuterRect = rect; - mRect = mOuterRect.adjusted( mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom() ); + mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom()); } } @@ -3197,12 +3225,12 @@ void QCPLayoutElement::setOuterRect( const QRect& rect ) \see setAutoMargins */ -void QCPLayoutElement::setMargins( const QMargins& margins ) +void QCPLayoutElement::setMargins(const QMargins &margins) { - if( mMargins != margins ) + if (mMargins != margins) { mMargins = margins; - mRect = mOuterRect.adjusted( mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom() ); + mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom()); } } @@ -3215,9 +3243,9 @@ void QCPLayoutElement::setMargins( const QMargins& margins ) \see setAutoMargins */ -void QCPLayoutElement::setMinimumMargins( const QMargins& margins ) +void QCPLayoutElement::setMinimumMargins(const QMargins &margins) { - if( mMinimumMargins != margins ) + if (mMinimumMargins != margins) { mMinimumMargins = margins; } @@ -3233,7 +3261,7 @@ void QCPLayoutElement::setMinimumMargins( const QMargins& margins ) \see setMinimumMargins, setMargins, QCP::MarginSide */ -void QCPLayoutElement::setAutoMargins( QCP::MarginSides sides ) +void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides) { mAutoMargins = sides; } @@ -3250,12 +3278,12 @@ void QCPLayoutElement::setAutoMargins( QCP::MarginSides sides ) Whether this constraint applies to the inner or the outer rect can be specified with \ref setSizeConstraintRect (see \ref rect and \ref outerRect). */ -void QCPLayoutElement::setMinimumSize( const QSize& size ) +void QCPLayoutElement::setMinimumSize(const QSize &size) { - if( mMinimumSize != size ) + if (mMinimumSize != size) { mMinimumSize = size; - if( mParentLayout ) + if (mParentLayout) mParentLayout->sizeConstraintsChanged(); } } @@ -3267,9 +3295,9 @@ void QCPLayoutElement::setMinimumSize( const QSize& size ) Whether this constraint applies to the inner or the outer rect can be specified with \ref setSizeConstraintRect (see \ref rect and \ref outerRect). */ -void QCPLayoutElement::setMinimumSize( int width, int height ) +void QCPLayoutElement::setMinimumSize(int width, int height) { - setMinimumSize( QSize( width, height ) ); + setMinimumSize(QSize(width, height)); } /*! @@ -3279,12 +3307,12 @@ void QCPLayoutElement::setMinimumSize( int width, int height ) Whether this constraint applies to the inner or the outer rect can be specified with \ref setSizeConstraintRect (see \ref rect and \ref outerRect). */ -void QCPLayoutElement::setMaximumSize( const QSize& size ) +void QCPLayoutElement::setMaximumSize(const QSize &size) { - if( mMaximumSize != size ) + if (mMaximumSize != size) { mMaximumSize = size; - if( mParentLayout ) + if (mParentLayout) mParentLayout->sizeConstraintsChanged(); } } @@ -3296,9 +3324,9 @@ void QCPLayoutElement::setMaximumSize( const QSize& size ) Whether this constraint applies to the inner or the outer rect can be specified with \ref setSizeConstraintRect (see \ref rect and \ref outerRect). */ -void QCPLayoutElement::setMaximumSize( int width, int height ) +void QCPLayoutElement::setMaximumSize(int width, int height) { - setMaximumSize( QSize( width, height ) ); + setMaximumSize(QSize(width, height)); } /*! @@ -3310,12 +3338,12 @@ void QCPLayoutElement::setMaximumSize( int width, int height ) \see setMinimumSize, setMaximumSize */ -void QCPLayoutElement::setSizeConstraintRect( SizeConstraintRect constraintRect ) +void QCPLayoutElement::setSizeConstraintRect(SizeConstraintRect constraintRect) { - if( mSizeConstraintRect != constraintRect ) + if (mSizeConstraintRect != constraintRect) { mSizeConstraintRect = constraintRect; - if( mParentLayout ) + if (mParentLayout) mParentLayout->sizeConstraintsChanged(); } } @@ -3333,35 +3361,30 @@ void QCPLayoutElement::setSizeConstraintRect( SizeConstraintRect constraintRect \see QCP::MarginSide */ -void QCPLayoutElement::setMarginGroup( QCP::MarginSides sides, QCPMarginGroup* group ) +void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group) { QVector sideVector; - if( sides.testFlag( QCP::msLeft ) ) - sideVector.append( QCP::msLeft ); - if( sides.testFlag( QCP::msRight ) ) - sideVector.append( QCP::msRight ); - if( sides.testFlag( QCP::msTop ) ) - sideVector.append( QCP::msTop ); - if( sides.testFlag( QCP::msBottom ) ) - sideVector.append( QCP::msBottom ); - - for( int i = 0; i < sideVector.size(); ++i ) + if (sides.testFlag(QCP::msLeft)) sideVector.append(QCP::msLeft); + if (sides.testFlag(QCP::msRight)) sideVector.append(QCP::msRight); + if (sides.testFlag(QCP::msTop)) sideVector.append(QCP::msTop); + if (sides.testFlag(QCP::msBottom)) sideVector.append(QCP::msBottom); + + for (int i=0; iremoveChild( side, this ); - - if( !group ) // if setting to 0, remove hash entry. Else set hash entry to new group and register there + QCPMarginGroup *oldGroup = marginGroup(side); + if (oldGroup) // unregister at old group + oldGroup->removeChild(side, this); + + if (!group) // if setting to 0, remove hash entry. Else set hash entry to new group and register there { - mMarginGroups.remove( side ); - } - else // setting to a new group + mMarginGroups.remove(side); + } else // setting to a new group { mMarginGroups[side] = group; - group->addChild( side, this ); + group->addChild(side, this); } } } @@ -3379,29 +3402,29 @@ void QCPLayoutElement::setMarginGroup( QCP::MarginSides sides, QCPMarginGroup* g The default implementation executes the automatic margin mechanism in the \ref upMargins phase. Subclasses should make sure to call the base class implementation. */ -void QCPLayoutElement::update( UpdatePhase phase ) +void QCPLayoutElement::update(UpdatePhase phase) { - if( phase == upMargins ) + if (phase == upMargins) { - if( mAutoMargins != QCP::msNone ) + if (mAutoMargins != QCP::msNone) { // set the margins of this layout element according to automatic margin calculation, either directly or via a margin group: QMargins newMargins = mMargins; QList allMarginSides = QList() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom; - foreach( QCP::MarginSide side, allMarginSides ) + foreach (QCP::MarginSide side, allMarginSides) { - if( mAutoMargins.testFlag( side ) ) // this side's margin shall be calculated automatically + if (mAutoMargins.testFlag(side)) // this side's margin shall be calculated automatically { - if( mMarginGroups.contains( side ) ) - QCP::setMarginValue( newMargins, side, mMarginGroups[side]->commonMargin( side ) ); // this side is part of a margin group, so get the margin value from that group + if (mMarginGroups.contains(side)) + QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group else - QCP::setMarginValue( newMargins, side, calculateAutoMargin( side ) ); // this side is not part of a group, so calculate the value directly + QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly // apply minimum margin restrictions: - if( QCP::getMarginValue( newMargins, side ) < QCP::getMarginValue( mMinimumMargins, side ) ) - QCP::setMarginValue( newMargins, side, QCP::getMarginValue( mMinimumMargins, side ) ); + if (QCP::getMarginValue(newMargins, side) < QCP::getMarginValue(mMinimumMargins, side)) + QCP::setMarginValue(newMargins, side, QCP::getMarginValue(mMinimumMargins, side)); } } - setMargins( newMargins ); + setMargins(newMargins); } } } @@ -3422,7 +3445,7 @@ void QCPLayoutElement::update( UpdatePhase phase ) */ QSize QCPLayoutElement::minimumOuterSizeHint() const { - return QSize( mMargins.left() + mMargins.right(), mMargins.top() + mMargins.bottom() ); + return QSize(mMargins.left()+mMargins.right(), mMargins.top()+mMargins.bottom()); } /*! @@ -3441,7 +3464,7 @@ QSize QCPLayoutElement::minimumOuterSizeHint() const */ QSize QCPLayoutElement::maximumOuterSizeHint() const { - return QSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX ); + return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); } /*! @@ -3451,9 +3474,9 @@ QSize QCPLayoutElement::maximumOuterSizeHint() const \warning There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.) */ -QList QCPLayoutElement::elements( bool recursive ) const +QList QCPLayoutElement::elements(bool recursive) const { - Q_UNUSED( recursive ) + Q_UNUSED(recursive) return QList(); } @@ -3468,24 +3491,23 @@ QList QCPLayoutElement::elements( bool recursive ) const QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour. */ -double QCPLayoutElement::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - - if( onlySelectable ) + Q_UNUSED(details) + + if (onlySelectable) return -1; - - if( QRectF( mOuterRect ).contains( pos ) ) + + if (QRectF(mOuterRect).contains(pos)) { - if( mParentPlot ) - return mParentPlot->selectionTolerance() * 0.99; + if (mParentPlot) + return mParentPlot->selectionTolerance()*0.99; else { qDebug() << Q_FUNC_INFO << "parent plot not defined"; return -1; } - } - else + } else return -1; } @@ -3494,12 +3516,12 @@ double QCPLayoutElement::selectTest( const QPointF& pos, bool onlySelectable, QV propagates the parent plot initialization to all child elements, by calling \ref QCPLayerable::initializeParentPlot on them. */ -void QCPLayoutElement::parentPlotInitialized( QCustomPlot* parentPlot ) +void QCPLayoutElement::parentPlotInitialized(QCustomPlot *parentPlot) { - foreach( QCPLayoutElement* el, elements( false ) ) + foreach (QCPLayoutElement* el, elements(false)) { - if( !el->parentPlot() ) - el->initializeParentPlot( parentPlot ); + if (!el->parentPlot()) + el->initializeParentPlot(parentPlot); } } @@ -3512,9 +3534,9 @@ void QCPLayoutElement::parentPlotInitialized( QCustomPlot* parentPlot ) The default implementation just returns the respective manual margin (\ref setMargins) or the minimum margin, whichever is larger. */ -int QCPLayoutElement::calculateAutoMargin( QCP::MarginSide side ) +int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side) { - return qMax( QCP::getMarginValue( mMargins, side ), QCP::getMarginValue( mMinimumMargins, side ) ); + return qMax(QCP::getMarginValue(mMargins, side), QCP::getMarginValue(mMinimumMargins, side)); } /*! \internal @@ -3622,39 +3644,39 @@ QCPLayout::QCPLayout() For details about this method and the update phases, see the documentation of \ref QCPLayoutElement::update. */ -void QCPLayout::update( UpdatePhase phase ) +void QCPLayout::update(UpdatePhase phase) { - QCPLayoutElement::update( phase ); - + QCPLayoutElement::update(phase); + // set child element rects according to layout: - if( phase == upLayout ) + if (phase == upLayout) updateLayout(); - + // propagate update call to child elements: const int elCount = elementCount(); - for( int i = 0; i < elCount; ++i ) + for (int i=0; iupdate( phase ); + if (QCPLayoutElement *el = elementAt(i)) + el->update(phase); } } /* inherits documentation from base class */ -QList QCPLayout::elements( bool recursive ) const +QList QCPLayout::elements(bool recursive) const { const int c = elementCount(); QList result; -#if QT_VERSION >= QT_VERSION_CHECK( 4, 7, 0 ) - result.reserve( c ); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + result.reserve(c); #endif - for( int i = 0; i < c; ++i ) - result.append( elementAt( i ) ); - if( recursive ) + for (int i=0; ielements( recursive ); + if (result.at(i)) + result << result.at(i)->elements(recursive); } } return result; @@ -3682,14 +3704,13 @@ void QCPLayout::simplify() \see remove, takeAt */ -bool QCPLayout::removeAt( int index ) +bool QCPLayout::removeAt(int index) { - if( QCPLayoutElement* el = takeAt( index ) ) + if (QCPLayoutElement *el = takeAt(index)) { delete el; return true; - } - else + } else return false; } @@ -3704,14 +3725,13 @@ bool QCPLayout::removeAt( int index ) \see removeAt, take */ -bool QCPLayout::remove( QCPLayoutElement* element ) +bool QCPLayout::remove(QCPLayoutElement *element) { - if( take( element ) ) + if (take(element)) { delete element; return true; - } - else + } else return false; } @@ -3723,10 +3743,10 @@ bool QCPLayout::remove( QCPLayoutElement* element ) */ void QCPLayout::clear() { - for( int i = elementCount() - 1; i >= 0; --i ) + for (int i=elementCount()-1; i>=0; --i) { - if( elementAt( i ) ) - removeAt( i ); + if (elementAt(i)) + removeAt(i); } simplify(); } @@ -3741,9 +3761,9 @@ void QCPLayout::clear() */ void QCPLayout::sizeConstraintsChanged() const { - if( QWidget* w = qobject_cast( parent() ) ) + if (QWidget *w = qobject_cast(parent())) w->updateGeometry(); - else if( QCPLayout* l = qobject_cast( parent() ) ) + else if (QCPLayout *l = qobject_cast(parent())) l->sizeConstraintsChanged(); } @@ -3763,6 +3783,7 @@ void QCPLayout::updateLayout() { } + /*! \internal Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the @@ -3775,18 +3796,17 @@ void QCPLayout::updateLayout() method only changes properties in \a el. The removal from the old layout and the insertion into the new layout must be done additionally. */ -void QCPLayout::adoptElement( QCPLayoutElement* el ) +void QCPLayout::adoptElement(QCPLayoutElement *el) { - if( el ) + if (el) { el->mParentLayout = this; - el->setParentLayerable( this ); - el->setParent( this ); - if( !el->parentPlot() ) - el->initializeParentPlot( mParentPlot ); + el->setParentLayerable(this); + el->setParent(this); + if (!el->parentPlot()) + el->initializeParentPlot(mParentPlot); el->layoutChanged(); - } - else + } else qDebug() << Q_FUNC_INFO << "Null element passed"; } @@ -3800,16 +3820,15 @@ void QCPLayout::adoptElement( QCPLayoutElement* el ) take or \ref takeAt). Note that this method only changes properties in \a el. The removal from the old layout must be done additionally. */ -void QCPLayout::releaseElement( QCPLayoutElement* el ) +void QCPLayout::releaseElement(QCPLayoutElement *el) { - if( el ) + if (el) { el->mParentLayout = 0; - el->setParentLayerable( 0 ); - el->setParent( mParentPlot ); + el->setParentLayerable(0); + el->setParent(mParentPlot); // Note: Don't initializeParentPlot(0) here, because layout element will stay in same parent plot - } - else + } else qDebug() << Q_FUNC_INFO << "Null element passed"; } @@ -3842,53 +3861,53 @@ void QCPLayout::releaseElement( QCPLayoutElement* el ) The return value is a QVector containing the section sizes. */ -QVector QCPLayout::getSectionSizes( QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize ) const +QVector QCPLayout::getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const { - if( maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size() ) + if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size()) { qDebug() << Q_FUNC_INFO << "Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors; return QVector(); } - if( stretchFactors.isEmpty() ) + if (stretchFactors.isEmpty()) return QVector(); int sectionCount = stretchFactors.size(); - QVector sectionSizes( sectionCount ); + QVector sectionSizes(sectionCount); // if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections): int minSizeSum = 0; - for( int i = 0; i < sectionCount; ++i ) - minSizeSum += minSizes.at( i ); - if( totalSize < minSizeSum ) + for (int i=0; i minimumLockedSections; QList unfinishedSections; - for( int i = 0; i < sectionCount; ++i ) - unfinishedSections.append( i ); + for (int i=0; i QCPLayout::getSectionSizes( QVector maxSizes, QVector min // check if that maximum is actually within the bounds of the total size (i.e. can we stretch all remaining sections so far that the found section // actually hits its maximum, without exceeding the total size when we add up all sections) double stretchFactorSum = 0; - for( int i = 0; i < unfinishedSections.size(); ++i ) - stretchFactorSum += stretchFactors.at( unfinishedSections.at( i ) ); - double nextMaxLimit = freeSize / stretchFactorSum; - if( nextMax < nextMaxLimit ) // next maximum is actually hit, move forward to that point and fix the size of that section + for (int i=0; i result( sectionCount ); - for( int i = 0; i < sectionCount; ++i ) - result[i] = qRound( sectionSizes.at( i ) ); + + QVector result(sectionCount); + for (int i=0; i QCPLayout::getSectionSizes( QVector maxSizes, QVector min QCPLayoutElement::setSizeConstraintRect), as well as the minimum size hint, if no manual minimum size was set (\ref QCPLayoutElement::minimumOuterSizeHint). */ -QSize QCPLayout::getFinalMinimumOuterSize( const QCPLayoutElement* el ) +QSize QCPLayout::getFinalMinimumOuterSize(const QCPLayoutElement *el) { QSize minOuterHint = el->minimumOuterSizeHint(); - QSize minOuter = el->minimumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset minimum of 0) - if( minOuter.width() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect ) + QSize minOuter = el->minimumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset minimum of 0) + if (minOuter.width() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect) minOuter.rwidth() += el->margins().left() + el->margins().right(); - if( minOuter.height() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect ) + if (minOuter.height() > 0 && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect) minOuter.rheight() += el->margins().top() + el->margins().bottom(); - - return QSize( minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(), - minOuter.height() > 0 ? minOuter.height() : minOuterHint.height() ); - ; + + return QSize(minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(), + minOuter.height() > 0 ? minOuter.height() : minOuterHint.height());; } /*! \internal @@ -3994,19 +4011,20 @@ QSize QCPLayout::getFinalMinimumOuterSize( const QCPLayoutElement* el ) QCPLayoutElement::setSizeConstraintRect), as well as the maximum size hint, if no manual maximum size was set (\ref QCPLayoutElement::maximumOuterSizeHint). */ -QSize QCPLayout::getFinalMaximumOuterSize( const QCPLayoutElement* el ) +QSize QCPLayout::getFinalMaximumOuterSize(const QCPLayoutElement *el) { QSize maxOuterHint = el->maximumOuterSizeHint(); - QSize maxOuter = el->maximumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset maximum of QWIDGETSIZE_MAX) - if( maxOuter.width() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect ) + QSize maxOuter = el->maximumSize(); // depending on sizeConstraitRect this might be with respect to inner rect, so possibly add margins in next four lines (preserving unset maximum of QWIDGETSIZE_MAX) + if (maxOuter.width() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect) maxOuter.rwidth() += el->margins().left() + el->margins().right(); - if( maxOuter.height() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect ) + if (maxOuter.height() < QWIDGETSIZE_MAX && el->sizeConstraintRect() == QCPLayoutElement::scrInnerRect) maxOuter.rheight() += el->margins().top() + el->margins().bottom(); - - return QSize( maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(), - maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height() ); + + return QSize(maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(), + maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height()); } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLayoutGrid //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4052,8 +4070,11 @@ QSize QCPLayout::getFinalMaximumOuterSize( const QCPLayoutElement* el ) /*! Creates an instance of QCPLayoutGrid and sets default values. */ -QCPLayoutGrid::QCPLayoutGrid() - : mColumnSpacing( 5 ), mRowSpacing( 5 ), mWrap( 0 ), mFillOrder( foRowsFirst ) +QCPLayoutGrid::QCPLayoutGrid() : + mColumnSpacing(5), + mRowSpacing(5), + mWrap(0), + mFillOrder(foRowsFirst) { } @@ -4072,25 +4093,24 @@ QCPLayoutGrid::~QCPLayoutGrid() \see addElement, hasElement */ -QCPLayoutElement* QCPLayoutGrid::element( int row, int column ) const +QCPLayoutElement *QCPLayoutGrid::element(int row, int column) const { - if( row >= 0 && row < mElements.size() ) + if (row >= 0 && row < mElements.size()) { - if( column >= 0 && column < mElements.first().size() ) + if (column >= 0 && column < mElements.first().size()) { - if( QCPLayoutElement* result = mElements.at( row ).at( column ) ) + if (QCPLayoutElement *result = mElements.at(row).at(column)) return result; else qDebug() << Q_FUNC_INFO << "Requested cell is empty. Row:" << row << "Column:" << column; - } - else + } else qDebug() << Q_FUNC_INFO << "Invalid column. Row:" << row << "Column:" << column; - } - else + } else qDebug() << Q_FUNC_INFO << "Invalid row. Row:" << row << "Column:" << column; return 0; } + /*! \overload Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it @@ -4105,19 +4125,18 @@ QCPLayoutElement* QCPLayoutGrid::element( int row, int column ) const \see element, hasElement, take, remove */ -bool QCPLayoutGrid::addElement( int row, int column, QCPLayoutElement* element ) +bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element) { - if( !hasElement( row, column ) ) + if (!hasElement(row, column)) { - if( element && element->layout() ) // remove from old layout first - element->layout()->take( element ); - expandTo( row + 1, column + 1 ); + if (element && element->layout()) // remove from old layout first + element->layout()->take(element); + expandTo(row+1, column+1); mElements[row][column] = element; - if( element ) - adoptElement( element ); + if (element) + adoptElement(element); return true; - } - else + } else qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column; return false; } @@ -4132,35 +4151,34 @@ bool QCPLayoutGrid::addElement( int row, int column, QCPLayoutElement* element ) \see setFillOrder, setWrap, element, hasElement, take, remove */ -bool QCPLayoutGrid::addElement( QCPLayoutElement* element ) +bool QCPLayoutGrid::addElement(QCPLayoutElement *element) { int rowIndex = 0; int colIndex = 0; - if( mFillOrder == foColumnsFirst ) + if (mFillOrder == foColumnsFirst) { - while( hasElement( rowIndex, colIndex ) ) + while (hasElement(rowIndex, colIndex)) { ++colIndex; - if( colIndex >= mWrap && mWrap > 0 ) + if (colIndex >= mWrap && mWrap > 0) { colIndex = 0; ++rowIndex; } } - } - else + } else { - while( hasElement( rowIndex, colIndex ) ) + while (hasElement(rowIndex, colIndex)) { ++rowIndex; - if( rowIndex >= mWrap && mWrap > 0 ) + if (rowIndex >= mWrap && mWrap > 0) { rowIndex = 0; ++colIndex; } } } - return addElement( rowIndex, colIndex, element ); + return addElement(rowIndex, colIndex, element); } /*! @@ -4169,10 +4187,10 @@ bool QCPLayoutGrid::addElement( QCPLayoutElement* element ) \see element */ -bool QCPLayoutGrid::hasElement( int row, int column ) +bool QCPLayoutGrid::hasElement(int row, int column) { - if( row >= 0 && row < rowCount() && column >= 0 && column < columnCount() ) - return mElements.at( row ).at( column ); + if (row >= 0 && row < rowCount() && column >= 0 && column < columnCount()) + return mElements.at(row).at(column); else return false; } @@ -4189,16 +4207,15 @@ bool QCPLayoutGrid::hasElement( int row, int column ) \see setColumnStretchFactors, setRowStretchFactor */ -void QCPLayoutGrid::setColumnStretchFactor( int column, double factor ) +void QCPLayoutGrid::setColumnStretchFactor(int column, double factor) { - if( column >= 0 && column < columnCount() ) + if (column >= 0 && column < columnCount()) { - if( factor > 0 ) + if (factor > 0) mColumnStretchFactors[column] = factor; else qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor; - } - else + } else qDebug() << Q_FUNC_INFO << "Invalid column:" << column; } @@ -4214,21 +4231,20 @@ void QCPLayoutGrid::setColumnStretchFactor( int column, double factor ) \see setColumnStretchFactor, setRowStretchFactors */ -void QCPLayoutGrid::setColumnStretchFactors( const QList& factors ) +void QCPLayoutGrid::setColumnStretchFactors(const QList &factors) { - if( factors.size() == mColumnStretchFactors.size() ) + if (factors.size() == mColumnStretchFactors.size()) { mColumnStretchFactors = factors; - for( int i = 0; i < mColumnStretchFactors.size(); ++i ) + for (int i=0; i& factors ) \see setColumnStretchFactors, setRowStretchFactor */ -void QCPLayoutGrid::setRowStretchFactor( int row, double factor ) +void QCPLayoutGrid::setRowStretchFactor(int row, double factor) { - if( row >= 0 && row < rowCount() ) + if (row >= 0 && row < rowCount()) { - if( factor > 0 ) + if (factor > 0) mRowStretchFactors[row] = factor; else qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor; - } - else + } else qDebug() << Q_FUNC_INFO << "Invalid row:" << row; } @@ -4269,21 +4284,20 @@ void QCPLayoutGrid::setRowStretchFactor( int row, double factor ) \see setRowStretchFactor, setColumnStretchFactors */ -void QCPLayoutGrid::setRowStretchFactors( const QList& factors ) +void QCPLayoutGrid::setRowStretchFactors(const QList &factors) { - if( factors.size() == mRowStretchFactors.size() ) + if (factors.size() == mRowStretchFactors.size()) { mRowStretchFactors = factors; - for( int i = 0; i < mRowStretchFactors.size(); ++i ) + for (int i=0; i& factors ) \see setRowSpacing */ -void QCPLayoutGrid::setColumnSpacing( int pixels ) +void QCPLayoutGrid::setColumnSpacing(int pixels) { mColumnSpacing = pixels; } @@ -4302,7 +4316,7 @@ void QCPLayoutGrid::setColumnSpacing( int pixels ) \see setColumnSpacing */ -void QCPLayoutGrid::setRowSpacing( int pixels ) +void QCPLayoutGrid::setRowSpacing(int pixels) { mRowSpacing = pixels; } @@ -4324,9 +4338,9 @@ void QCPLayoutGrid::setRowSpacing( int pixels ) \see setFillOrder */ -void QCPLayoutGrid::setWrap( int count ) +void QCPLayoutGrid::setWrap(int count) { - mWrap = qMax( 0, count ); + mWrap = qMax(0, count); } /*! @@ -4353,28 +4367,28 @@ void QCPLayoutGrid::setWrap( int count ) \see setWrap, addElement(QCPLayoutElement*) */ -void QCPLayoutGrid::setFillOrder( FillOrder order, bool rearrange ) +void QCPLayoutGrid::setFillOrder(FillOrder order, bool rearrange) { // if rearranging, take all elements via linear index of old fill order: const int elCount = elementCount(); QVector tempElements; - if( rearrange ) + if (rearrange) { - tempElements.reserve( elCount ); - for( int i = 0; i < elCount; ++i ) + tempElements.reserve(elCount); + for (int i=0; i() ); - mRowStretchFactors.append( 1 ); + mElements.append(QList()); + mRowStretchFactors.append(1); } // go through rows and expand columns as necessary: - int newColCount = qMax( columnCount(), newColumnCount ); - for( int i = 0; i < rowCount(); ++i ) + int newColCount = qMax(columnCount(), newColumnCount); + for (int i=0; i rowCount() ) + if (newIndex > rowCount()) newIndex = rowCount(); - - mRowStretchFactors.insert( newIndex, 1 ); + + mRowStretchFactors.insert(newIndex, 1); QList newRow; - for( int col = 0; col < columnCount(); ++col ) - newRow.append( (QCPLayoutElement*)0 ); - mElements.insert( newIndex, newRow ); + for (int col=0; col columnCount() ) + if (newIndex > columnCount()) newIndex = columnCount(); - - mColumnStretchFactors.insert( newIndex, 1 ); - for( int row = 0; row < rowCount(); ++row ) - mElements[row].insert( newIndex, (QCPLayoutElement*)0 ); + + mColumnStretchFactors.insert(newIndex, 1); + for (int row=0; row= 0 && row < rowCount() ) + if (row >= 0 && row < rowCount()) { - if( column >= 0 && column < columnCount() ) + if (column >= 0 && column < columnCount()) { - switch( mFillOrder ) + switch (mFillOrder) { - case foRowsFirst: - return column * rowCount() + row; - case foColumnsFirst: - return row * columnCount() + column; + case foRowsFirst: return column*rowCount() + row; + case foColumnsFirst: return row*columnCount() + column; } - } - else + } else qDebug() << Q_FUNC_INFO << "row index out of bounds:" << row; - } - else + } else qDebug() << Q_FUNC_INFO << "column index out of bounds:" << column; return 0; } @@ -4512,34 +4522,34 @@ int QCPLayoutGrid::rowColToIndex( int row, int column ) const \see rowColToIndex */ -void QCPLayoutGrid::indexToRowCol( int index, int& row, int& column ) const +void QCPLayoutGrid::indexToRowCol(int index, int &row, int &column) const { row = -1; column = -1; const int nCols = columnCount(); const int nRows = rowCount(); - if( nCols == 0 || nRows == 0 ) + if (nCols == 0 || nRows == 0) return; - if( index < 0 || index >= elementCount() ) + if (index < 0 || index >= elementCount()) { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return; } - - switch( mFillOrder ) + + switch (mFillOrder) { - case foRowsFirst: - { - column = index / nRows; - row = index % nRows; - break; - } - case foColumnsFirst: - { - row = index / nCols; - column = index % nCols; - break; - } + case foRowsFirst: + { + column = index / nRows; + row = index % nRows; + break; + } + case foColumnsFirst: + { + row = index / nCols; + column = index % nCols; + break; + } } } @@ -4547,27 +4557,27 @@ void QCPLayoutGrid::indexToRowCol( int index, int& row, int& column ) const void QCPLayoutGrid::updateLayout() { QVector minColWidths, minRowHeights, maxColWidths, maxRowHeights; - getMinimumRowColSizes( &minColWidths, &minRowHeights ); - getMaximumRowColSizes( &maxColWidths, &maxRowHeights ); - - int totalRowSpacing = ( rowCount() - 1 ) * mRowSpacing; - int totalColSpacing = ( columnCount() - 1 ) * mColumnSpacing; - QVector colWidths = getSectionSizes( maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width() - totalColSpacing ); - QVector rowHeights = getSectionSizes( maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height() - totalRowSpacing ); - + getMinimumRowColSizes(&minColWidths, &minRowHeights); + getMaximumRowColSizes(&maxColWidths, &maxRowHeights); + + int totalRowSpacing = (rowCount()-1) * mRowSpacing; + int totalColSpacing = (columnCount()-1) * mColumnSpacing; + QVector colWidths = getSectionSizes(maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width()-totalColSpacing); + QVector rowHeights = getSectionSizes(maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height()-totalRowSpacing); + // go through cells and set rects accordingly: int yOffset = mRect.top(); - for( int row = 0; row < rowCount(); ++row ) + for (int row=0; row 0 ) - yOffset += rowHeights.at( row - 1 ) + mRowSpacing; + if (row > 0) + yOffset += rowHeights.at(row-1)+mRowSpacing; int xOffset = mRect.left(); - for( int col = 0; col < columnCount(); ++col ) + for (int col=0; col 0 ) - xOffset += colWidths.at( col - 1 ) + mColumnSpacing; - if( mElements.at( row ).at( col ) ) - mElements.at( row ).at( col )->setOuterRect( QRect( xOffset, yOffset, colWidths.at( col ), rowHeights.at( row ) ) ); + if (col > 0) + xOffset += colWidths.at(col-1)+mColumnSpacing; + if (mElements.at(row).at(col)) + mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row))); } } } @@ -4580,15 +4590,14 @@ void QCPLayoutGrid::updateLayout() \see rowColToIndex */ -QCPLayoutElement* QCPLayoutGrid::elementAt( int index ) const +QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const { - if( index >= 0 && index < elementCount() ) + if (index >= 0 && index < elementCount()) { int row, col; - indexToRowCol( index, row, col ); - return mElements.at( row ).at( col ); - } - else + indexToRowCol(index, row, col); + return mElements.at(row).at(col); + } else return 0; } @@ -4600,17 +4609,16 @@ QCPLayoutElement* QCPLayoutGrid::elementAt( int index ) const \see rowColToIndex */ -QCPLayoutElement* QCPLayoutGrid::takeAt( int index ) +QCPLayoutElement *QCPLayoutGrid::takeAt(int index) { - if( QCPLayoutElement* el = elementAt( index ) ) + if (QCPLayoutElement *el = elementAt(index)) { - releaseElement( el ); + releaseElement(el); int row, col; - indexToRowCol( index, row, col ); + indexToRowCol(index, row, col); mElements[row][col] = 0; return el; - } - else + } else { qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index; return 0; @@ -4618,41 +4626,40 @@ QCPLayoutElement* QCPLayoutGrid::takeAt( int index ) } /* inherits documentation from base class */ -bool QCPLayoutGrid::take( QCPLayoutElement* element ) +bool QCPLayoutGrid::take(QCPLayoutElement *element) { - if( element ) + if (element) { - for( int i = 0; i < elementCount(); ++i ) + for (int i=0; i QCPLayoutGrid::elements( bool recursive ) const +QList QCPLayoutGrid::elements(bool recursive) const { QList result; const int elCount = elementCount(); -#if QT_VERSION >= QT_VERSION_CHECK( 4, 7, 0 ) - result.reserve( elCount ); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + result.reserve(elCount); #endif - for( int i = 0; i < elCount; ++i ) - result.append( elementAt( i ) ); - if( recursive ) + for (int i=0; ielements( recursive ); + if (result.at(i)) + result << result.at(i)->elements(recursive); } } return result; @@ -4664,43 +4671,43 @@ QList QCPLayoutGrid::elements( bool recursive ) const void QCPLayoutGrid::simplify() { // remove rows with only empty cells: - for( int row = rowCount() - 1; row >= 0; --row ) + for (int row=rowCount()-1; row>=0; --row) { bool hasElements = false; - for( int col = 0; col < columnCount(); ++col ) + for (int col=0; col= 0; --col ) + for (int col=columnCount()-1; col>=0; --col) { bool hasElements = false; - for( int row = 0; row < rowCount(); ++row ) + for (int row=0; row minColWidths, minRowHeights; - getMinimumRowColSizes( &minColWidths, &minRowHeights ); - QSize result( 0, 0 ); - for( int i = 0; i < minColWidths.size(); ++i ) - result.rwidth() += minColWidths.at( i ); - for( int i = 0; i < minRowHeights.size(); ++i ) - result.rheight() += minRowHeights.at( i ); - result.rwidth() += qMax( 0, columnCount() - 1 ) * mColumnSpacing; - result.rheight() += qMax( 0, rowCount() - 1 ) * mRowSpacing; - result.rwidth() += mMargins.left() + mMargins.right(); - result.rheight() += mMargins.top() + mMargins.bottom(); + getMinimumRowColSizes(&minColWidths, &minRowHeights); + QSize result(0, 0); + for (int i=0; i maxColWidths, maxRowHeights; - getMaximumRowColSizes( &maxColWidths, &maxRowHeights ); - - QSize result( 0, 0 ); - for( int i = 0; i < maxColWidths.size(); ++i ) - result.setWidth( qMin( result.width() + maxColWidths.at( i ), QWIDGETSIZE_MAX ) ); - for( int i = 0; i < maxRowHeights.size(); ++i ) - result.setHeight( qMin( result.height() + maxRowHeights.at( i ), QWIDGETSIZE_MAX ) ); - result.rwidth() += qMax( 0, columnCount() - 1 ) * mColumnSpacing; - result.rheight() += qMax( 0, rowCount() - 1 ) * mRowSpacing; - result.rwidth() += mMargins.left() + mMargins.right(); - result.rheight() += mMargins.top() + mMargins.bottom(); - if( result.height() > QWIDGETSIZE_MAX ) - result.setHeight( QWIDGETSIZE_MAX ); - if( result.width() > QWIDGETSIZE_MAX ) - result.setWidth( QWIDGETSIZE_MAX ); + getMaximumRowColSizes(&maxColWidths, &maxRowHeights); + + QSize result(0, 0); + for (int i=0; i QWIDGETSIZE_MAX) + result.setHeight(QWIDGETSIZE_MAX); + if (result.width() > QWIDGETSIZE_MAX) + result.setWidth(QWIDGETSIZE_MAX); return result; } @@ -4757,21 +4764,21 @@ QSize QCPLayoutGrid::maximumOuterSizeHint() const \see getMaximumRowColSizes */ -void QCPLayoutGrid::getMinimumRowColSizes( QVector* minColWidths, QVector* minRowHeights ) const +void QCPLayoutGrid::getMinimumRowColSizes(QVector *minColWidths, QVector *minRowHeights) const { - *minColWidths = QVector( columnCount(), 0 ); - *minRowHeights = QVector( rowCount(), 0 ); - for( int row = 0; row < rowCount(); ++row ) + *minColWidths = QVector(columnCount(), 0); + *minRowHeights = QVector(rowCount(), 0); + for (int row=0; rowat( col ) < minSize.width() ) - ( *minColWidths )[col] = minSize.width(); - if( minRowHeights->at( row ) < minSize.height() ) - ( *minRowHeights )[row] = minSize.height(); + QSize minSize = getFinalMinimumOuterSize(el); + if (minColWidths->at(col) < minSize.width()) + (*minColWidths)[col] = minSize.width(); + if (minRowHeights->at(row) < minSize.height()) + (*minRowHeights)[row] = minSize.height(); } } } @@ -4790,26 +4797,27 @@ void QCPLayoutGrid::getMinimumRowColSizes( QVector* minColWidths, QVector* maxColWidths, QVector* maxRowHeights ) const +void QCPLayoutGrid::getMaximumRowColSizes(QVector *maxColWidths, QVector *maxRowHeights) const { - *maxColWidths = QVector( columnCount(), QWIDGETSIZE_MAX ); - *maxRowHeights = QVector( rowCount(), QWIDGETSIZE_MAX ); - for( int row = 0; row < rowCount(); ++row ) + *maxColWidths = QVector(columnCount(), QWIDGETSIZE_MAX); + *maxRowHeights = QVector(rowCount(), QWIDGETSIZE_MAX); + for (int row=0; rowat( col ) > maxSize.width() ) - ( *maxColWidths )[col] = maxSize.width(); - if( maxRowHeights->at( row ) > maxSize.height() ) - ( *maxRowHeights )[row] = maxSize.height(); + QSize maxSize = getFinalMaximumOuterSize(el); + if (maxColWidths->at(col) > maxSize.width()) + (*maxColWidths)[col] = maxSize.width(); + if (maxRowHeights->at(row) > maxSize.height()) + (*maxRowHeights)[row] = maxSize.height(); } } } } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLayoutInset //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4858,10 +4866,10 @@ QCPLayoutInset::~QCPLayoutInset() /*! Returns the placement type of the element with the specified \a index. */ -QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement( int index ) const +QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement(int index) const { - if( elementAt( index ) ) - return mInsetPlacement.at( index ); + if (elementAt(index)) + return mInsetPlacement.at(index); else { qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4873,10 +4881,10 @@ QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement( int index ) const Returns the alignment of the element with the specified \a index. The alignment only has a meaning, if the inset placement (\ref setInsetPlacement) is \ref ipBorderAligned. */ -Qt::Alignment QCPLayoutInset::insetAlignment( int index ) const +Qt::Alignment QCPLayoutInset::insetAlignment(int index) const { - if( elementAt( index ) ) - return mInsetAlignment.at( index ); + if (elementAt(index)) + return mInsetAlignment.at(index); else { qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4888,10 +4896,10 @@ Qt::Alignment QCPLayoutInset::insetAlignment( int index ) const Returns the rect of the element with the specified \a index. The rect only has a meaning, if the inset placement (\ref setInsetPlacement) is \ref ipFree. */ -QRectF QCPLayoutInset::insetRect( int index ) const +QRectF QCPLayoutInset::insetRect(int index) const { - if( elementAt( index ) ) - return mInsetRect.at( index ); + if (elementAt(index)) + return mInsetRect.at(index); else { qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4904,9 +4912,9 @@ QRectF QCPLayoutInset::insetRect( int index ) const \see InsetPlacement */ -void QCPLayoutInset::setInsetPlacement( int index, QCPLayoutInset::InsetPlacement placement ) +void QCPLayoutInset::setInsetPlacement(int index, QCPLayoutInset::InsetPlacement placement) { - if( elementAt( index ) ) + if (elementAt(index)) mInsetPlacement[index] = placement; else qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4920,9 +4928,9 @@ void QCPLayoutInset::setInsetPlacement( int index, QCPLayoutInset::InsetPlacemen Qt::AlignHCenter, Qt::AlighRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom. Any other alignment flags will be ignored. */ -void QCPLayoutInset::setInsetAlignment( int index, Qt::Alignment alignment ) +void QCPLayoutInset::setInsetAlignment(int index, Qt::Alignment alignment) { - if( elementAt( index ) ) + if (elementAt(index)) mInsetAlignment[index] = alignment; else qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4939,9 +4947,9 @@ void QCPLayoutInset::setInsetAlignment( int index, Qt::Alignment alignment ) Note that the minimum and maximum sizes of the embedded element (\ref QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize) are enforced. */ -void QCPLayoutInset::setInsetRect( int index, const QRectF& rect ) +void QCPLayoutInset::setInsetRect(int index, const QRectF &rect) { - if( elementAt( index ) ) + if (elementAt(index)) mInsetRect[index] = rect; else qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; @@ -4950,45 +4958,38 @@ void QCPLayoutInset::setInsetRect( int index, const QRectF& rect ) /* inherits documentation from base class */ void QCPLayoutInset::updateLayout() { - for( int i = 0; i < mElements.size(); ++i ) + for (int i=0; i finalMaxSize.width() ) - insetRect.setWidth( finalMaxSize.width() ); - if( insetRect.size().height() > finalMaxSize.height() ) - insetRect.setHeight( finalMaxSize.height() ); - } - else if( mInsetPlacement.at( i ) == ipBorderAligned ) + insetRect = QRect(rect().x()+rect().width()*mInsetRect.at(i).x(), + rect().y()+rect().height()*mInsetRect.at(i).y(), + rect().width()*mInsetRect.at(i).width(), + rect().height()*mInsetRect.at(i).height()); + if (insetRect.size().width() < finalMinSize.width()) + insetRect.setWidth(finalMinSize.width()); + if (insetRect.size().height() < finalMinSize.height()) + insetRect.setHeight(finalMinSize.height()); + if (insetRect.size().width() > finalMaxSize.width()) + insetRect.setWidth(finalMaxSize.width()); + if (insetRect.size().height() > finalMaxSize.height()) + insetRect.setHeight(finalMaxSize.height()); + } else if (mInsetPlacement.at(i) == ipBorderAligned) { - insetRect.setSize( finalMinSize ); - Qt::Alignment al = mInsetAlignment.at( i ); - if( al.testFlag( Qt::AlignLeft ) ) - insetRect.moveLeft( rect().x() ); - else if( al.testFlag( Qt::AlignRight ) ) - insetRect.moveRight( rect().x() + rect().width() ); - else - insetRect.moveLeft( rect().x() + rect().width() * 0.5 - finalMinSize.width() * 0.5 ); // default to Qt::AlignHCenter - if( al.testFlag( Qt::AlignTop ) ) - insetRect.moveTop( rect().y() ); - else if( al.testFlag( Qt::AlignBottom ) ) - insetRect.moveBottom( rect().y() + rect().height() ); - else - insetRect.moveTop( rect().y() + rect().height() * 0.5 - finalMinSize.height() * 0.5 ); // default to Qt::AlignVCenter + insetRect.setSize(finalMinSize); + Qt::Alignment al = mInsetAlignment.at(i); + if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(rect().x()); + else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(rect().x()+rect().width()); + else insetRect.moveLeft(rect().x()+rect().width()*0.5-finalMinSize.width()*0.5); // default to Qt::AlignHCenter + if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(rect().y()); + else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(rect().y()+rect().height()); + else insetRect.moveTop(rect().y()+rect().height()*0.5-finalMinSize.height()*0.5); // default to Qt::AlignVCenter } - mElements.at( i )->setOuterRect( insetRect ); + mElements.at(i)->setOuterRect(insetRect); } } @@ -4999,27 +5000,26 @@ int QCPLayoutInset::elementCount() const } /* inherits documentation from base class */ -QCPLayoutElement* QCPLayoutInset::elementAt( int index ) const +QCPLayoutElement *QCPLayoutInset::elementAt(int index) const { - if( index >= 0 && index < mElements.size() ) - return mElements.at( index ); + if (index >= 0 && index < mElements.size()) + return mElements.at(index); else return 0; } /* inherits documentation from base class */ -QCPLayoutElement* QCPLayoutInset::takeAt( int index ) +QCPLayoutElement *QCPLayoutInset::takeAt(int index) { - if( QCPLayoutElement* el = elementAt( index ) ) + if (QCPLayoutElement *el = elementAt(index)) { - releaseElement( el ); - mElements.removeAt( index ); - mInsetPlacement.removeAt( index ); - mInsetAlignment.removeAt( index ); - mInsetRect.removeAt( index ); + releaseElement(el); + mElements.removeAt(index); + mInsetPlacement.removeAt(index); + mInsetAlignment.removeAt(index); + mInsetRect.removeAt(index); return el; - } - else + } else { qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index; return 0; @@ -5027,21 +5027,20 @@ QCPLayoutElement* QCPLayoutInset::takeAt( int index ) } /* inherits documentation from base class */ -bool QCPLayoutInset::take( QCPLayoutElement* element ) +bool QCPLayoutInset::take(QCPLayoutElement *element) { - if( element ) + if (element) { - for( int i = 0; i < elementCount(); ++i ) + for (int i=0; irealVisibility() && mElements.at( i )->selectTest( pos, onlySelectable ) >= 0 ) - return mParentPlot->selectionTolerance() * 0.99; + if (mElements.at(i)->realVisibility() && mElements.at(i)->selectTest(pos, onlySelectable) >= 0) + return mParentPlot->selectionTolerance()*0.99; } return -1; } @@ -5082,19 +5081,18 @@ double QCPLayoutInset::selectTest( const QPointF& pos, bool onlySelectable, QVar \see addElement(QCPLayoutElement *element, const QRectF &rect) */ -void QCPLayoutInset::addElement( QCPLayoutElement* element, Qt::Alignment alignment ) +void QCPLayoutInset::addElement(QCPLayoutElement *element, Qt::Alignment alignment) { - if( element ) + if (element) { - if( element->layout() ) // remove from old layout first - element->layout()->take( element ); - mElements.append( element ); - mInsetPlacement.append( ipBorderAligned ); - mInsetAlignment.append( alignment ); - mInsetRect.append( QRectF( 0.6, 0.6, 0.4, 0.4 ) ); - adoptElement( element ); - } - else + if (element->layout()) // remove from old layout first + element->layout()->take(element); + mElements.append(element); + mInsetPlacement.append(ipBorderAligned); + mInsetAlignment.append(alignment); + mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4)); + adoptElement(element); + } else qDebug() << Q_FUNC_INFO << "Can't add null element"; } @@ -5109,23 +5107,23 @@ void QCPLayoutInset::addElement( QCPLayoutElement* element, Qt::Alignment alignm \see addElement(QCPLayoutElement *element, Qt::Alignment alignment) */ -void QCPLayoutInset::addElement( QCPLayoutElement* element, const QRectF& rect ) +void QCPLayoutInset::addElement(QCPLayoutElement *element, const QRectF &rect) { - if( element ) + if (element) { - if( element->layout() ) // remove from old layout first - element->layout()->take( element ); - mElements.append( element ); - mInsetPlacement.append( ipFree ); - mInsetAlignment.append( Qt::AlignRight | Qt::AlignTop ); - mInsetRect.append( rect ); - adoptElement( element ); - } - else + if (element->layout()) // remove from old layout first + element->layout()->take(element); + mElements.append(element); + mInsetPlacement.append(ipFree); + mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop); + mInsetRect.append(rect); + adoptElement(element); + } else qDebug() << Q_FUNC_INFO << "Can't add null element"; } /* end of 'src/layout.cpp' */ + /* including file 'src/lineending.cpp', size 11536 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5156,23 +5154,29 @@ void QCPLayoutInset::addElement( QCPLayoutElement* element, const QRectF& rect ) /*! Creates a QCPLineEnding instance with default values (style \ref esNone). */ -QCPLineEnding::QCPLineEnding() - : mStyle( esNone ), mWidth( 8 ), mLength( 10 ), mInverted( false ) +QCPLineEnding::QCPLineEnding() : + mStyle(esNone), + mWidth(8), + mLength(10), + mInverted(false) { } /*! Creates a QCPLineEnding instance with the specified values. */ -QCPLineEnding::QCPLineEnding( QCPLineEnding::EndingStyle style, double width, double length, bool inverted ) - : mStyle( style ), mWidth( width ), mLength( length ), mInverted( inverted ) +QCPLineEnding::QCPLineEnding(QCPLineEnding::EndingStyle style, double width, double length, bool inverted) : + mStyle(style), + mWidth(width), + mLength(length), + mInverted(inverted) { } /*! Sets the style of the ending decoration. */ -void QCPLineEnding::setStyle( QCPLineEnding::EndingStyle style ) +void QCPLineEnding::setStyle(QCPLineEnding::EndingStyle style) { mStyle = style; } @@ -5183,7 +5187,7 @@ void QCPLineEnding::setStyle( QCPLineEnding::EndingStyle style ) \see setLength */ -void QCPLineEnding::setWidth( double width ) +void QCPLineEnding::setWidth(double width) { mWidth = width; } @@ -5194,7 +5198,7 @@ void QCPLineEnding::setWidth( double width ) \see setWidth */ -void QCPLineEnding::setLength( double length ) +void QCPLineEnding::setLength(double length) { mLength = length; } @@ -5207,7 +5211,7 @@ void QCPLineEnding::setLength( double length ) discs, this doesn't make a difference. However, asymmetric styles like \ref esHalfBar are affected by it, which can be used to control to which side the half bar points to. */ -void QCPLineEnding::setInverted( bool inverted ) +void QCPLineEnding::setInverted(bool inverted) { mInverted = inverted; } @@ -5223,23 +5227,24 @@ void QCPLineEnding::setInverted( bool inverted ) */ double QCPLineEnding::boundingDistance() const { - switch( mStyle ) + switch (mStyle) { - case esNone: - return 0; + case esNone: + return 0; + + case esFlatArrow: + case esSpikeArrow: + case esLineArrow: + case esSkewedBar: + return qSqrt(mWidth*mWidth+mLength*mLength); // items that have width and length + + case esDisc: + case esSquare: + case esDiamond: + case esBar: + case esHalfBar: + return mWidth*1.42; // items that only have a width -> width*sqrt(2) - case esFlatArrow: - case esSpikeArrow: - case esLineArrow: - case esSkewedBar: - return qSqrt( mWidth * mWidth + mLength * mLength ); // items that have width and length - - case esDisc: - case esSquare: - case esDiamond: - case esBar: - case esHalfBar: - return mWidth * 1.42; // items that only have a width -> width*sqrt(2) } return 0; } @@ -5257,25 +5262,25 @@ double QCPLineEnding::boundingDistance() const */ double QCPLineEnding::realLength() const { - switch( mStyle ) + switch (mStyle) { - case esNone: - case esLineArrow: - case esSkewedBar: - case esBar: - case esHalfBar: - return 0; - - case esFlatArrow: - return mLength; - - case esDisc: - case esSquare: - case esDiamond: - return mWidth * 0.5; - - case esSpikeArrow: - return mLength * 0.8; + case esNone: + case esLineArrow: + case esSkewedBar: + case esBar: + case esHalfBar: + return 0; + + case esFlatArrow: + return mLength; + + case esDisc: + case esSquare: + case esDiamond: + return mWidth*0.5; + + case esSpikeArrow: + return mLength*0.8; } return 0; } @@ -5285,121 +5290,124 @@ double QCPLineEnding::realLength() const Draws the line ending with the specified \a painter at the position \a pos. The direction of the line ending is controlled with \a dir. */ -void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, const QCPVector2D& dir ) const +void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const { - if( mStyle == esNone ) + if (mStyle == esNone) return; - - QCPVector2D lengthVec = dir.normalized() * mLength * ( mInverted ? -1 : 1 ); - if( lengthVec.isNull() ) - lengthVec = QCPVector2D( 1, 0 ); - QCPVector2D widthVec = dir.normalized().perpendicular() * mWidth * 0.5 * ( mInverted ? -1 : 1 ); - + + QCPVector2D lengthVec = dir.normalized() * mLength*(mInverted ? -1 : 1); + if (lengthVec.isNull()) + lengthVec = QCPVector2D(1, 0); + QCPVector2D widthVec = dir.normalized().perpendicular() * mWidth*0.5*(mInverted ? -1 : 1); + QPen penBackup = painter->pen(); QBrush brushBackup = painter->brush(); QPen miterPen = penBackup; - miterPen.setJoinStyle( Qt::MiterJoin ); // to make arrow heads spikey - QBrush brush( painter->pen().color(), Qt::SolidPattern ); - switch( mStyle ) + miterPen.setJoinStyle(Qt::MiterJoin); // to make arrow heads spikey + QBrush brush(painter->pen().color(), Qt::SolidPattern); + switch (mStyle) { - case esNone: - break; - case esFlatArrow: - { - QPointF points[3] = {pos.toPointF(), - ( pos - lengthVec + widthVec ).toPointF(), - ( pos - lengthVec - widthVec ).toPointF()}; - painter->setPen( miterPen ); - painter->setBrush( brush ); - painter->drawConvexPolygon( points, 3 ); - painter->setBrush( brushBackup ); - painter->setPen( penBackup ); - break; - } - case esSpikeArrow: - { - QPointF points[4] = {pos.toPointF(), - ( pos - lengthVec + widthVec ).toPointF(), - ( pos - lengthVec * 0.8 ).toPointF(), - ( pos - lengthVec - widthVec ).toPointF()}; - painter->setPen( miterPen ); - painter->setBrush( brush ); - painter->drawConvexPolygon( points, 4 ); - painter->setBrush( brushBackup ); - painter->setPen( penBackup ); - break; - } - case esLineArrow: - { - QPointF points[3] = {( pos - lengthVec + widthVec ).toPointF(), - pos.toPointF(), - ( pos - lengthVec - widthVec ).toPointF()}; - painter->setPen( miterPen ); - painter->drawPolyline( points, 3 ); - painter->setPen( penBackup ); - break; - } - case esDisc: - { - painter->setBrush( brush ); - painter->drawEllipse( pos.toPointF(), mWidth * 0.5, mWidth * 0.5 ); - painter->setBrush( brushBackup ); - break; - } - case esSquare: - { - QCPVector2D widthVecPerp = widthVec.perpendicular(); - QPointF points[4] = {( pos - widthVecPerp + widthVec ).toPointF(), - ( pos - widthVecPerp - widthVec ).toPointF(), - ( pos + widthVecPerp - widthVec ).toPointF(), - ( pos + widthVecPerp + widthVec ).toPointF()}; - painter->setPen( miterPen ); - painter->setBrush( brush ); - painter->drawConvexPolygon( points, 4 ); - painter->setBrush( brushBackup ); - painter->setPen( penBackup ); - break; - } - case esDiamond: - { - QCPVector2D widthVecPerp = widthVec.perpendicular(); - QPointF points[4] = {( pos - widthVecPerp ).toPointF(), - ( pos - widthVec ).toPointF(), - ( pos + widthVecPerp ).toPointF(), - ( pos + widthVec ).toPointF()}; - painter->setPen( miterPen ); - painter->setBrush( brush ); - painter->drawConvexPolygon( points, 4 ); - painter->setBrush( brushBackup ); - painter->setPen( penBackup ); - break; - } - case esBar: - { - painter->drawLine( ( pos + widthVec ).toPointF(), ( pos - widthVec ).toPointF() ); - break; - } - case esHalfBar: - { - painter->drawLine( ( pos + widthVec ).toPointF(), pos.toPointF() ); - break; - } - case esSkewedBar: - { - if( qFuzzyIsNull( painter->pen().widthF() ) && !painter->modes().testFlag( QCPPainter::pmNonCosmetic ) ) + case esNone: break; + case esFlatArrow: { - // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line - painter->drawLine( ( pos + widthVec + lengthVec * 0.2 * ( mInverted ? -1 : 1 ) ).toPointF(), - ( pos - widthVec - lengthVec * 0.2 * ( mInverted ? -1 : 1 ) ).toPointF() ); + QPointF points[3] = {pos.toPointF(), + (pos-lengthVec+widthVec).toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 3); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; } - else + case esSpikeArrow: { - // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly - painter->drawLine( ( pos + widthVec + lengthVec * 0.2 * ( mInverted ? -1 : 1 ) + dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f ).toPointF(), - ( pos - widthVec - lengthVec * 0.2 * ( mInverted ? -1 : 1 ) + dir.normalized() * qMax( 1.0f, (float)painter->pen().widthF() ) * 0.5f ).toPointF() ); + QPointF points[4] = {pos.toPointF(), + (pos-lengthVec+widthVec).toPointF(), + (pos-lengthVec*0.8).toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esLineArrow: + { + QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(), + pos.toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->drawPolyline(points, 3); + painter->setPen(penBackup); + break; + } + case esDisc: + { + painter->setBrush(brush); + painter->drawEllipse(pos.toPointF(), mWidth*0.5, mWidth*0.5); + painter->setBrush(brushBackup); + break; + } + case esSquare: + { + QCPVector2D widthVecPerp = widthVec.perpendicular(); + QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(), + (pos-widthVecPerp-widthVec).toPointF(), + (pos+widthVecPerp-widthVec).toPointF(), + (pos+widthVecPerp+widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esDiamond: + { + QCPVector2D widthVecPerp = widthVec.perpendicular(); + QPointF points[4] = {(pos-widthVecPerp).toPointF(), + (pos-widthVec).toPointF(), + (pos+widthVecPerp).toPointF(), + (pos+widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esBar: + { + painter->drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF()); + break; + } + case esHalfBar: + { + painter->drawLine((pos+widthVec).toPointF(), pos.toPointF()); + break; + } + case esSkewedBar: + { + if (qFuzzyIsNull(painter->pen().widthF()) && !painter->modes().testFlag(QCPPainter::pmNonCosmetic)) + { + // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line + painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)).toPointF(), + (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)).toPointF()); + } else + { + // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly + painter->drawLine((pos+widthVec+lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF(), + (pos-widthVec-lengthVec*0.2*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF()); + } + break; } - break; - } } } @@ -5408,12 +5416,13 @@ void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, const QCP Draws the line ending. The direction is controlled with the \a angle parameter in radians. */ -void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, double angle ) const +void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, double angle) const { - draw( painter, pos, QCPVector2D( qCos( angle ), qSin( angle ) ) ); + draw(painter, pos, QCPVector2D(qCos(angle), qSin(angle))); } /* end of 'src/lineending.cpp' */ + /* including file 'src/axis/axisticker.cpp', size 18664 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5477,20 +5486,23 @@ void QCPLineEnding::draw( QCPPainter* painter, const QCPVector2D& pos, double an Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTicker::QCPAxisTicker() - : mTickStepStrategy( tssReadability ), mTickCount( 5 ), mTickOrigin( 0 ) +QCPAxisTicker::QCPAxisTicker() : + mTickStepStrategy(tssReadability), + mTickCount(5), + mTickOrigin(0) { } QCPAxisTicker::~QCPAxisTicker() { + } /*! Sets which strategy the axis ticker follows when choosing the size of the tick step. For the available strategies, see \ref TickStepStrategy. */ -void QCPAxisTicker::setTickStepStrategy( QCPAxisTicker::TickStepStrategy strategy ) +void QCPAxisTicker::setTickStepStrategy(QCPAxisTicker::TickStepStrategy strategy) { mTickStepStrategy = strategy; } @@ -5503,9 +5515,9 @@ void QCPAxisTicker::setTickStepStrategy( QCPAxisTicker::TickStepStrategy strateg Whether the readability has priority over meeting the requested \a count can be specified with \ref setTickStepStrategy. */ -void QCPAxisTicker::setTickCount( int count ) +void QCPAxisTicker::setTickCount(int count) { - if( count > 0 ) + if (count > 0) mTickCount = count; else qDebug() << Q_FUNC_INFO << "tick count must be greater than zero:" << count; @@ -5519,7 +5531,7 @@ void QCPAxisTicker::setTickCount( int count ) step is five. If \a origin is now set to 1 instead, the correspondingly generated ticks would be {-4, 1, 6, 11, 16,...}. */ -void QCPAxisTicker::setTickOrigin( double origin ) +void QCPAxisTicker::setTickOrigin(double origin) { mTickOrigin = origin; } @@ -5537,30 +5549,29 @@ void QCPAxisTicker::setTickOrigin( double origin ) and are respectively filled with sub tick coordinates, and tick label strings belonging to \a ticks by index. */ -void QCPAxisTicker::generate( const QCPRange& range, const QLocale& locale, QChar formatChar, int precision, QVector& ticks, QVector* subTicks, QVector* tickLabels ) +void QCPAxisTicker::generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector &ticks, QVector *subTicks, QVector *tickLabels) { // generate (major) ticks: - double tickStep = getTickStep( range ); - ticks = createTickVector( tickStep, range ); - trimTicks( range, ticks, true ); // trim ticks to visible range plus one outer tick on each side (incase a subclass createTickVector creates more) - + double tickStep = getTickStep(range); + ticks = createTickVector(tickStep, range); + trimTicks(range, ticks, true); // trim ticks to visible range plus one outer tick on each side (incase a subclass createTickVector creates more) + // generate sub ticks between major ticks: - if( subTicks ) + if (subTicks) { - if( ticks.size() > 0 ) + if (ticks.size() > 0) { - *subTicks = createSubTickVector( getSubTickCount( tickStep ), ticks ); - trimTicks( range, *subTicks, false ); - } - else + *subTicks = createSubTickVector(getSubTickCount(tickStep), ticks); + trimTicks(range, *subTicks, false); + } else *subTicks = QVector(); } - + // finally trim also outliers (no further clipping happens in axis drawing): - trimTicks( range, ticks, false ); + trimTicks(range, ticks, false); // generate labels for visible ticks if requested: - if( tickLabels ) - *tickLabels = createLabelVector( ticks, locale, formatChar, precision ); + if (tickLabels) + *tickLabels = createLabelVector(ticks, locale, formatChar, precision); } /*! \internal @@ -5573,10 +5584,10 @@ void QCPAxisTicker::generate( const QCPRange& range, const QLocale& locale, QCha implementation, it should reimplement this method. See \ref cleanMantissa for a possible helper function. */ -double QCPAxisTicker::getTickStep( const QCPRange& range ) +double QCPAxisTicker::getTickStep(const QCPRange &range) { - double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - return cleanMantissa( exactStep ); + double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + return cleanMantissa(exactStep); } /*! \internal @@ -5586,92 +5597,55 @@ double QCPAxisTicker::getTickStep( const QCPRange& range ) Note that a returned sub tick count of e.g. 4 will split each tick interval into 5 sections. */ -int QCPAxisTicker::getSubTickCount( double tickStep ) +int QCPAxisTicker::getSubTickCount(double tickStep) { - int result = 1; // default to 1, if no proper value can be found - + int result = 1; // default to 1, if no proper value can be found + // separate integer and fractional part of mantissa: double epsilon = 0.01; double intPartf; int intPart; - double fracPart = modf( getMantissa( tickStep ), &intPartf ); + double fracPart = modf(getMantissa(tickStep), &intPartf); intPart = intPartf; - + // handle cases with (almost) integer mantissa: - if( fracPart < epsilon || 1.0 - fracPart < epsilon ) + if (fracPart < epsilon || 1.0-fracPart < epsilon) { - if( 1.0 - fracPart < epsilon ) + if (1.0-fracPart < epsilon) ++intPart; - switch( intPart ) + switch (intPart) { - case 1: - result = 4; - break; // 1.0 -> 0.2 substep - case 2: - result = 3; - break; // 2.0 -> 0.5 substep - case 3: - result = 2; - break; // 3.0 -> 1.0 substep - case 4: - result = 3; - break; // 4.0 -> 1.0 substep - case 5: - result = 4; - break; // 5.0 -> 1.0 substep - case 6: - result = 2; - break; // 6.0 -> 2.0 substep - case 7: - result = 6; - break; // 7.0 -> 1.0 substep - case 8: - result = 3; - break; // 8.0 -> 2.0 substep - case 9: - result = 2; - break; // 9.0 -> 3.0 substep + case 1: result = 4; break; // 1.0 -> 0.2 substep + case 2: result = 3; break; // 2.0 -> 0.5 substep + case 3: result = 2; break; // 3.0 -> 1.0 substep + case 4: result = 3; break; // 4.0 -> 1.0 substep + case 5: result = 4; break; // 5.0 -> 1.0 substep + case 6: result = 2; break; // 6.0 -> 2.0 substep + case 7: result = 6; break; // 7.0 -> 1.0 substep + case 8: result = 3; break; // 8.0 -> 2.0 substep + case 9: result = 2; break; // 9.0 -> 3.0 substep } - } - else + } else { // handle cases with significantly fractional mantissa: - if( qAbs( fracPart - 0.5 ) < epsilon ) // *.5 mantissa + if (qAbs(fracPart-0.5) < epsilon) // *.5 mantissa { - switch( intPart ) + switch (intPart) { - case 1: - result = 2; - break; // 1.5 -> 0.5 substep - case 2: - result = 4; - break; // 2.5 -> 0.5 substep - case 3: - result = 4; - break; // 3.5 -> 0.7 substep - case 4: - result = 2; - break; // 4.5 -> 1.5 substep - case 5: - result = 4; - break; // 5.5 -> 1.1 substep (won't occur with default getTickStep from here on) - case 6: - result = 4; - break; // 6.5 -> 1.3 substep - case 7: - result = 2; - break; // 7.5 -> 2.5 substep - case 8: - result = 4; - break; // 8.5 -> 1.7 substep - case 9: - result = 4; - break; // 9.5 -> 1.9 substep + case 1: result = 2; break; // 1.5 -> 0.5 substep + case 2: result = 4; break; // 2.5 -> 0.5 substep + case 3: result = 4; break; // 3.5 -> 0.7 substep + case 4: result = 2; break; // 4.5 -> 1.5 substep + case 5: result = 4; break; // 5.5 -> 1.1 substep (won't occur with default getTickStep from here on) + case 6: result = 4; break; // 6.5 -> 1.3 substep + case 7: result = 2; break; // 7.5 -> 2.5 substep + case 8: result = 4; break; // 8.5 -> 1.7 substep + case 9: result = 4; break; // 9.5 -> 1.9 substep } } // if mantissa fraction isn't 0.0 or 0.5, don't bother finding good sub tick marks, leave default } - + return result; } @@ -5686,9 +5660,9 @@ int QCPAxisTicker::getSubTickCount( double tickStep ) be formatted accordingly using multiplication symbol and superscript during rendering of the label automatically. */ -QString QCPAxisTicker::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) +QString QCPAxisTicker::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) { - return locale.toString( tick, formatChar.toLatin1(), precision ); + return locale.toString(tick, formatChar.toLatin1(), precision); } /*! \internal @@ -5700,18 +5674,18 @@ QString QCPAxisTicker::getTickLabel( double tick, const QLocale& locale, QChar f reimplement this method. Depending on the purpose of the subclass it doesn't necessarily need to base its result on \a subTickCount or \a ticks. */ -QVector QCPAxisTicker::createSubTickVector( int subTickCount, const QVector& ticks ) +QVector QCPAxisTicker::createSubTickVector(int subTickCount, const QVector &ticks) { QVector result; - if( subTickCount <= 0 || ticks.size() < 2 ) + if (subTickCount <= 0 || ticks.size() < 2) return result; - - result.reserve( ( ticks.size() - 1 ) * subTickCount ); - for( int i = 1; i < ticks.size(); ++i ) + + result.reserve((ticks.size()-1)*subTickCount); + for (int i=1; i QCPAxisTicker::createSubTickVector( int subTickCount, const QVec result on \a tickStep, e.g. when the ticks are spaced unequally like in the case of QCPAxisTickerLog. */ -QVector QCPAxisTicker::createTickVector( double tickStep, const QCPRange& range ) +QVector QCPAxisTicker::createTickVector(double tickStep, const QCPRange &range) { QVector result; // Generate tick positions according to tickStep: - qint64 firstStep = floor( ( range.lower - mTickOrigin ) / tickStep ); // do not use qFloor here, or we'll lose 64 bit precision - qint64 lastStep = ceil( ( range.upper - mTickOrigin ) / tickStep ); // do not use qCeil here, or we'll lose 64 bit precision - int tickcount = lastStep - firstStep + 1; - if( tickcount < 0 ) - tickcount = 0; - result.resize( tickcount ); - for( int i = 0; i < tickcount; ++i ) - result[i] = mTickOrigin + ( firstStep + i ) * tickStep; + qint64 firstStep = floor((range.lower-mTickOrigin)/tickStep); // do not use qFloor here, or we'll lose 64 bit precision + qint64 lastStep = ceil((range.upper-mTickOrigin)/tickStep); // do not use qCeil here, or we'll lose 64 bit precision + int tickcount = lastStep-firstStep+1; + if (tickcount < 0) tickcount = 0; + result.resize(tickcount); + for (int i=0; i QCPAxisTicker::createTickVector( double tickStep, const QCPRange It is possible but uncommon for QCPAxisTicker subclasses to reimplement this method, as reimplementing \ref getTickLabel often achieves the intended result easier. */ -QVector QCPAxisTicker::createLabelVector( const QVector& ticks, const QLocale& locale, QChar formatChar, int precision ) +QVector QCPAxisTicker::createLabelVector(const QVector &ticks, const QLocale &locale, QChar formatChar, int precision) { QVector result; - result.reserve( ticks.size() ); - for( int i = 0; i < ticks.size(); ++i ) - result.append( getTickLabel( ticks.at( i ), locale, formatChar, precision ) ); + result.reserve(ticks.size()); + for (int i=0; i QCPAxisTicker::createLabelVector( const QVector& ticks, The passed \a ticks must be sorted in ascending order. */ -void QCPAxisTicker::trimTicks( const QCPRange& range, QVector& ticks, bool keepOneOutlier ) const +void QCPAxisTicker::trimTicks(const QCPRange &range, QVector &ticks, bool keepOneOutlier) const { bool lowFound = false; bool highFound = false; int lowIndex = 0; int highIndex = -1; - - for( int i = 0; i < ticks.size(); ++i ) + + for (int i=0; i < ticks.size(); ++i) { - if( ticks.at( i ) >= range.lower ) + if (ticks.at(i) >= range.lower) { lowFound = true; lowIndex = i; break; } } - for( int i = ticks.size() - 1; i >= 0; --i ) + for (int i=ticks.size()-1; i >= 0; --i) { - if( ticks.at( i ) <= range.upper ) + if (ticks.at(i) <= range.upper) { highFound = true; highIndex = i; break; } } - - if( highFound && lowFound ) + + if (highFound && lowFound) { - int trimFront = qMax( 0, lowIndex - ( keepOneOutlier ? 1 : 0 ) ); - int trimBack = qMax( 0, ticks.size() - ( keepOneOutlier ? 2 : 1 ) - highIndex ); - if( trimFront > 0 || trimBack > 0 ) - ticks = ticks.mid( trimFront, ticks.size() - trimFront - trimBack ); - } - else // all ticks are either all below or all above the range + int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0)); + int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex); + if (trimFront > 0 || trimBack > 0) + ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack); + } else // all ticks are either all below or all above the range ticks.clear(); } @@ -5814,17 +5786,17 @@ void QCPAxisTicker::trimTicks( const QCPRange& range, QVector& ticks, bo This method assumes \a candidates is not empty and sorted in ascending order. */ -double QCPAxisTicker::pickClosest( double target, const QVector& candidates ) const +double QCPAxisTicker::pickClosest(double target, const QVector &candidates) const { - if( candidates.size() == 1 ) + if (candidates.size() == 1) return candidates.first(); - QVector::const_iterator it = std::lower_bound( candidates.constBegin(), candidates.constEnd(), target ); - if( it == candidates.constEnd() ) - return *( it - 1 ); - else if( it == candidates.constBegin() ) + QVector::const_iterator it = std::lower_bound(candidates.constBegin(), candidates.constEnd(), target); + if (it == candidates.constEnd()) + return *(it-1); + else if (it == candidates.constBegin()) return *it; else - return target - *( it - 1 ) < *it - target ? *( it - 1 ) : *it; + return target-*(it-1) < *it-target ? *(it-1) : *it; } /*! \internal @@ -5834,12 +5806,11 @@ double QCPAxisTicker::pickClosest( double target, const QVector& candida For example, an input of 142.6 will return a mantissa of 1.426 and a magnitude of 100. */ -double QCPAxisTicker::getMantissa( double input, double* magnitude ) const +double QCPAxisTicker::getMantissa(double input, double *magnitude) const { - const double mag = qPow( 10.0, qFloor( qLn( input ) / qLn( 10.0 ) ) ); - if( magnitude ) - *magnitude = mag; - return input / mag; + const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0))); + if (magnitude) *magnitude = mag; + return input/mag; } /*! \internal @@ -5848,29 +5819,30 @@ double QCPAxisTicker::getMantissa( double input, double* magnitude ) const strongly the mantissa is altered, and thus how strong the result deviates from the original \a input, depends on the current tick step strategy (see \ref setTickStepStrategy). */ -double QCPAxisTicker::cleanMantissa( double input ) const +double QCPAxisTicker::cleanMantissa(double input) const { double magnitude; - const double mantissa = getMantissa( input, &magnitude ); - switch( mTickStepStrategy ) + const double mantissa = getMantissa(input, &magnitude); + switch (mTickStepStrategy) { - case tssReadability: - { - return pickClosest( mantissa, QVector() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0 ) * magnitude; - } - case tssMeetTickCount: - { - // this gives effectively a mantissa of 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0 - if( mantissa <= 5.0 ) - return (int)( mantissa * 2 ) / 2.0 * magnitude; // round digit after decimal point to 0.5 - else - return (int)( mantissa / 2.0 ) * 2.0 * magnitude; // round to first digit in multiples of 2 - } + case tssReadability: + { + return pickClosest(mantissa, QVector() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude; + } + case tssMeetTickCount: + { + // this gives effectively a mantissa of 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0 + if (mantissa <= 5.0) + return (int)(mantissa*2)/2.0*magnitude; // round digit after decimal point to 0.5 + else + return (int)(mantissa/2.0)*2.0*magnitude; // round to first digit in multiples of 2 + } } return input; } /* end of 'src/axis/axisticker.cpp' */ + /* including file 'src/axis/axistickerdatetime.cpp', size 14443 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5917,10 +5889,12 @@ double QCPAxisTicker::cleanMantissa( double input ) const Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerDateTime::QCPAxisTickerDateTime() - : mDateTimeFormat( QLatin1String( "hh:mm:ss\ndd.MM.yy" ) ), mDateTimeSpec( Qt::LocalTime ), mDateStrategy( dsNone ) +QCPAxisTickerDateTime::QCPAxisTickerDateTime() : + mDateTimeFormat(QLatin1String("hh:mm:ss\ndd.MM.yy")), + mDateTimeSpec(Qt::LocalTime), + mDateStrategy(dsNone) { - setTickCount( 4 ); + setTickCount(4); } /*! @@ -5931,7 +5905,7 @@ QCPAxisTickerDateTime::QCPAxisTickerDateTime() \see setDateTimeSpec */ -void QCPAxisTickerDateTime::setDateTimeFormat( const QString& format ) +void QCPAxisTickerDateTime::setDateTimeFormat(const QString &format) { mDateTimeFormat = format; } @@ -5946,7 +5920,7 @@ void QCPAxisTickerDateTime::setDateTimeFormat( const QString& format ) \see setDateTimeFormat */ -void QCPAxisTickerDateTime::setDateTimeSpec( Qt::TimeSpec spec ) +void QCPAxisTickerDateTime::setDateTimeSpec(Qt::TimeSpec spec) { mDateTimeSpec = spec; } @@ -5960,9 +5934,9 @@ void QCPAxisTickerDateTime::setDateTimeSpec( Qt::TimeSpec spec ) example, If you pass 15. July, 9:45 to this method and the tick interval happens to be one tick per year, the ticks will end up on 15. July at 9:45 of every year. */ -void QCPAxisTickerDateTime::setTickOrigin( double origin ) +void QCPAxisTickerDateTime::setTickOrigin(double origin) { - QCPAxisTicker::setTickOrigin( origin ); + QCPAxisTicker::setTickOrigin(origin); } /*! @@ -5972,9 +5946,9 @@ void QCPAxisTickerDateTime::setTickOrigin( double origin ) example, If you pass 15. July, 9:45 to this method and the tick interval happens to be one tick per year, the ticks will end up on 15. July at 9:45 of every year. */ -void QCPAxisTickerDateTime::setTickOrigin( const QDateTime& origin ) +void QCPAxisTickerDateTime::setTickOrigin(const QDateTime &origin) { - setTickOrigin( dateTimeToKey( origin ) ); + setTickOrigin(dateTimeToKey(origin)); } /*! \internal @@ -5990,30 +5964,28 @@ void QCPAxisTickerDateTime::setTickOrigin( const QDateTime& origin ) \seebaseclassmethod */ -double QCPAxisTickerDateTime::getTickStep( const QCPRange& range ) +double QCPAxisTickerDateTime::getTickStep(const QCPRange &range) { - double result = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - + double result = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + mDateStrategy = dsNone; - if( result < 1 ) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds + if (result < 1) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds { - result = cleanMantissa( result ); - } - else if( result < 86400 * 30.4375 * 12 ) // below a year + result = cleanMantissa(result); + } else if (result < 86400*30.4375*12) // below a year { - result = pickClosest( result, QVector() - << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5 * 60 << 5 * 60 << 10 * 60 << 15 * 60 << 30 * 60 << 60 * 60 // second, minute, hour range - << 3600 * 2 << 3600 * 3 << 3600 * 6 << 3600 * 12 << 3600 * 24 // hour to day range - << 86400 * 2 << 86400 * 5 << 86400 * 7 << 86400 * 14 << 86400 * 30.4375 << 86400 * 30.4375 * 2 << 86400 * 30.4375 * 3 << 86400 * 30.4375 * 6 << 86400 * 30.4375 * 12 ); // day, week, month range (avg. days per month includes leap years) - if( result > 86400 * 30.4375 - 1 ) // month tick intervals or larger + result = pickClosest(result, QVector() + << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5*60 << 5*60 << 10*60 << 15*60 << 30*60 << 60*60 // second, minute, hour range + << 3600*2 << 3600*3 << 3600*6 << 3600*12 << 3600*24 // hour to day range + << 86400*2 << 86400*5 << 86400*7 << 86400*14 << 86400*30.4375 << 86400*30.4375*2 << 86400*30.4375*3 << 86400*30.4375*6 << 86400*30.4375*12); // day, week, month range (avg. days per month includes leap years) + if (result > 86400*30.4375-1) // month tick intervals or larger mDateStrategy = dsUniformDayInMonth; - else if( result > 3600 * 24 - 1 ) // day tick intervals or larger + else if (result > 3600*24-1) // day tick intervals or larger mDateStrategy = dsUniformTimeInDay; - } - else // more than a year, go back to normal clean mantissa algorithm but in units of years + } else // more than a year, go back to normal clean mantissa algorithm but in units of years { - const double secondsPerYear = 86400 * 30.4375 * 12; // average including leap years - result = cleanMantissa( result / secondsPerYear ) * secondsPerYear; + const double secondsPerYear = 86400*30.4375*12; // average including leap years + result = cleanMantissa(result/secondsPerYear)*secondsPerYear; mDateStrategy = dsUniformDayInMonth; } return result; @@ -6026,68 +5998,30 @@ double QCPAxisTickerDateTime::getTickStep( const QCPRange& range ) \seebaseclassmethod */ -int QCPAxisTickerDateTime::getSubTickCount( double tickStep ) +int QCPAxisTickerDateTime::getSubTickCount(double tickStep) { - int result = QCPAxisTicker::getSubTickCount( tickStep ); - switch( qRound( tickStep ) ) // hand chosen subticks for specific minute/hour/day/week/month range (as specified in getTickStep) + int result = QCPAxisTicker::getSubTickCount(tickStep); + switch (qRound(tickStep)) // hand chosen subticks for specific minute/hour/day/week/month range (as specified in getTickStep) { - case 5 * 60: - result = 4; - break; - case 10 * 60: - result = 1; - break; - case 15 * 60: - result = 2; - break; - case 30 * 60: - result = 1; - break; - case 60 * 60: - result = 3; - break; - case 3600 * 2: - result = 3; - break; - case 3600 * 3: - result = 2; - break; - case 3600 * 6: - result = 1; - break; - case 3600 * 12: - result = 3; - break; - case 3600 * 24: - result = 3; - break; - case 86400 * 2: - result = 1; - break; - case 86400 * 5: - result = 4; - break; - case 86400 * 7: - result = 6; - break; - case 86400 * 14: - result = 1; - break; - case(int)( 86400 * 30.4375 + 0.5 ): - result = 3; - break; - case(int)( 86400 * 30.4375 * 2 + 0.5 ): - result = 1; - break; - case(int)( 86400 * 30.4375 * 3 + 0.5 ): - result = 2; - break; - case(int)( 86400 * 30.4375 * 6 + 0.5 ): - result = 5; - break; - case(int)( 86400 * 30.4375 * 12 + 0.5 ): - result = 3; - break; + case 5*60: result = 4; break; + case 10*60: result = 1; break; + case 15*60: result = 2; break; + case 30*60: result = 1; break; + case 60*60: result = 3; break; + case 3600*2: result = 3; break; + case 3600*3: result = 2; break; + case 3600*6: result = 1; break; + case 3600*12: result = 3; break; + case 3600*24: result = 3; break; + case 86400*2: result = 1; break; + case 86400*5: result = 4; break; + case 86400*7: result = 6; break; + case 86400*14: result = 1; break; + case (int)(86400*30.4375+0.5): result = 3; break; + case (int)(86400*30.4375*2+0.5): result = 1; break; + case (int)(86400*30.4375*3+0.5): result = 2; break; + case (int)(86400*30.4375*6+0.5): result = 5; break; + case (int)(86400*30.4375*12+0.5): result = 3; break; } return result; } @@ -6099,11 +6033,11 @@ int QCPAxisTickerDateTime::getSubTickCount( double tickStep ) \seebaseclassmethod */ -QString QCPAxisTickerDateTime::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) +QString QCPAxisTickerDateTime::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) { - Q_UNUSED( precision ) - Q_UNUSED( formatChar ) - return locale.toString( keyToDateTime( tick ).toTimeSpec( mDateTimeSpec ), mDateTimeFormat ); + Q_UNUSED(precision) + Q_UNUSED(formatChar) + return locale.toString(keyToDateTime(tick).toTimeSpec(mDateTimeSpec), mDateTimeFormat); } /*! \internal @@ -6113,37 +6047,36 @@ QString QCPAxisTickerDateTime::getTickLabel( double tick, const QLocale& locale, \seebaseclassmethod */ -QVector QCPAxisTickerDateTime::createTickVector( double tickStep, const QCPRange& range ) +QVector QCPAxisTickerDateTime::createTickVector(double tickStep, const QCPRange &range) { - QVector result = QCPAxisTicker::createTickVector( tickStep, range ); - if( !result.isEmpty() ) + QVector result = QCPAxisTicker::createTickVector(tickStep, range); + if (!result.isEmpty()) { - if( mDateStrategy == dsUniformTimeInDay ) + if (mDateStrategy == dsUniformTimeInDay) { - QDateTime uniformDateTime = keyToDateTime( mTickOrigin ); // the time of this datetime will be set for all other ticks, if possible + QDateTime uniformDateTime = keyToDateTime(mTickOrigin); // the time of this datetime will be set for all other ticks, if possible QDateTime tickDateTime; - for( int i = 0; i < result.size(); ++i ) + for (int i=0; i 15 ) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day - tickDateTime = tickDateTime.addMonths( -1 ); - tickDateTime.setDate( QDate( tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay ) ); - result[i] = dateTimeToKey( tickDateTime ); + tickDateTime = keyToDateTime(result.at(i)); + tickDateTime.setTime(uniformDateTime.time()); + int thisUniformDay = uniformDateTime.date().day() <= tickDateTime.date().daysInMonth() ? uniformDateTime.date().day() : tickDateTime.date().daysInMonth(); // don't exceed month (e.g. try to set day 31 in February) + if (thisUniformDay-tickDateTime.date().day() < -15) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day + tickDateTime = tickDateTime.addMonths(1); + else if (thisUniformDay-tickDateTime.date().day() > 15) // with leap years involved, date month may jump backwards or forwards, and needs to be corrected before setting day + tickDateTime = tickDateTime.addMonths(-1); + tickDateTime.setDate(QDate(tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay)); + result[i] = dateTimeToKey(tickDateTime); } } } @@ -6159,13 +6092,13 @@ QVector QCPAxisTickerDateTime::createTickVector( double tickStep, const \see dateTimeToKey */ -QDateTime QCPAxisTickerDateTime::keyToDateTime( double key ) +QDateTime QCPAxisTickerDateTime::keyToDateTime(double key) { -#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 ) - return QDateTime::fromTime_t( key ).addMSecs( ( key - (qint64)key ) * 1000 ); -#else - return QDateTime::fromMSecsSinceEpoch( key * 1000.0 ); -#endif +# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) + return QDateTime::fromTime_t(key).addMSecs((key-(qint64)key)*1000); +# else + return QDateTime::fromMSecsSinceEpoch(key*1000.0); +# endif } /*! \overload @@ -6179,13 +6112,13 @@ QDateTime QCPAxisTickerDateTime::keyToDateTime( double key ) \see keyToDateTime */ -double QCPAxisTickerDateTime::dateTimeToKey( const QDateTime dateTime ) +double QCPAxisTickerDateTime::dateTimeToKey(const QDateTime dateTime) { -#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 ) - return dateTime.toTime_t() + dateTime.time().msec() / 1000.0; -#else - return dateTime.toMSecsSinceEpoch() / 1000.0; -#endif +# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) + return dateTime.toTime_t()+dateTime.time().msec()/1000.0; +# else + return dateTime.toMSecsSinceEpoch()/1000.0; +# endif } /*! \overload @@ -6196,16 +6129,17 @@ double QCPAxisTickerDateTime::dateTimeToKey( const QDateTime dateTime ) \see keyToDateTime */ -double QCPAxisTickerDateTime::dateTimeToKey( const QDate date ) +double QCPAxisTickerDateTime::dateTimeToKey(const QDate date) { -#if QT_VERSION < QT_VERSION_CHECK( 4, 7, 0 ) - return QDateTime( date ).toTime_t(); -#else - return QDateTime( date ).toMSecsSinceEpoch() / 1000.0; -#endif +# if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) + return QDateTime(date).toTime_t(); +# else + return QDateTime(date).toMSecsSinceEpoch()/1000.0; +# endif } /* end of 'src/axis/axistickerdatetime.cpp' */ + /* including file 'src/axis/axistickertime.cpp', size 11747 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6252,21 +6186,23 @@ double QCPAxisTickerDateTime::dateTimeToKey( const QDate date ) Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerTime::QCPAxisTickerTime() - : mTimeFormat( QLatin1String( "%h:%m:%s" ) ), mSmallestUnit( tuSeconds ), mBiggestUnit( tuHours ) +QCPAxisTickerTime::QCPAxisTickerTime() : + mTimeFormat(QLatin1String("%h:%m:%s")), + mSmallestUnit(tuSeconds), + mBiggestUnit(tuHours) { - setTickCount( 4 ); + setTickCount(4); mFieldWidth[tuMilliseconds] = 3; mFieldWidth[tuSeconds] = 2; mFieldWidth[tuMinutes] = 2; mFieldWidth[tuHours] = 2; mFieldWidth[tuDays] = 1; - - mFormatPattern[tuMilliseconds] = QLatin1String( "%z" ); - mFormatPattern[tuSeconds] = QLatin1String( "%s" ); - mFormatPattern[tuMinutes] = QLatin1String( "%m" ); - mFormatPattern[tuHours] = QLatin1String( "%h" ); - mFormatPattern[tuDays] = QLatin1String( "%d" ); + + mFormatPattern[tuMilliseconds] = QLatin1String("%z"); + mFormatPattern[tuSeconds] = QLatin1String("%s"); + mFormatPattern[tuMinutes] = QLatin1String("%m"); + mFormatPattern[tuHours] = QLatin1String("%h"); + mFormatPattern[tuDays] = QLatin1String("%d"); } /*! @@ -6287,21 +6223,21 @@ QCPAxisTickerTime::QCPAxisTickerTime() other hand %%h is available, the minutes will wrap around to zero after 59 and the time will carry to the hour digit. */ -void QCPAxisTickerTime::setTimeFormat( const QString& format ) +void QCPAxisTickerTime::setTimeFormat(const QString &format) { mTimeFormat = format; - + // determine smallest and biggest unit in format, to optimize unit replacement and allow biggest // unit to consume remaining time of a tick value and grow beyond its modulo (e.g. min > 59) mSmallestUnit = tuMilliseconds; mBiggestUnit = tuMilliseconds; bool hasSmallest = false; - for( int i = tuMilliseconds; i <= tuDays; ++i ) + for (int i = tuMilliseconds; i <= tuDays; ++i) { - TimeUnit unit = static_cast( i ); - if( mTimeFormat.contains( mFormatPattern.value( unit ) ) ) + TimeUnit unit = static_cast(i); + if (mTimeFormat.contains(mFormatPattern.value(unit))) { - if( !hasSmallest ) + if (!hasSmallest) { mSmallestUnit = unit; hasSmallest = true; @@ -6318,9 +6254,9 @@ void QCPAxisTickerTime::setTimeFormat( const QString& format ) \see setTimeFormat */ -void QCPAxisTickerTime::setFieldWidth( QCPAxisTickerTime::TimeUnit unit, int width ) +void QCPAxisTickerTime::setFieldWidth(QCPAxisTickerTime::TimeUnit unit, int width) { - mFieldWidth[unit] = qMax( width, 1 ); + mFieldWidth[unit] = qMax(width, 1); } /*! \internal @@ -6332,49 +6268,47 @@ void QCPAxisTickerTime::setFieldWidth( QCPAxisTickerTime::TimeUnit unit, int wid \seebaseclassmethod */ -double QCPAxisTickerTime::getTickStep( const QCPRange& range ) +double QCPAxisTickerTime::getTickStep(const QCPRange &range) { - double result = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - - if( result < 1 ) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds + double result = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + + if (result < 1) // ideal tick step is below 1 second -> use normal clean mantissa algorithm in units of seconds { - if( mSmallestUnit == tuMilliseconds ) - result = qMax( cleanMantissa( result ), 0.001 ); // smallest tick step is 1 millisecond - else // have no milliseconds available in format, so stick with 1 second tickstep + if (mSmallestUnit == tuMilliseconds) + result = qMax(cleanMantissa(result), 0.001); // smallest tick step is 1 millisecond + else // have no milliseconds available in format, so stick with 1 second tickstep result = 1.0; - } - else if( result < 3600 * 24 ) // below a day + } else if (result < 3600*24) // below a day { // the filling of availableSteps seems a bit contorted but it fills in a sorted fashion and thus saves a post-fill sorting run QVector availableSteps; // seconds range: - if( mSmallestUnit <= tuSeconds ) + if (mSmallestUnit <= tuSeconds) availableSteps << 1; - if( mSmallestUnit == tuMilliseconds ) - availableSteps << 2.5; // only allow half second steps if milliseconds are there to display it - else if( mSmallestUnit == tuSeconds ) + if (mSmallestUnit == tuMilliseconds) + availableSteps << 2.5; // only allow half second steps if milliseconds are there to display it + else if (mSmallestUnit == tuSeconds) availableSteps << 2; - if( mSmallestUnit <= tuSeconds ) + if (mSmallestUnit <= tuSeconds) availableSteps << 5 << 10 << 15 << 30; // minutes range: - if( mSmallestUnit <= tuMinutes ) - availableSteps << 1 * 60; - if( mSmallestUnit <= tuSeconds ) - availableSteps << 2.5 * 60; // only allow half minute steps if seconds are there to display it - else if( mSmallestUnit == tuMinutes ) - availableSteps << 2 * 60; - if( mSmallestUnit <= tuMinutes ) - availableSteps << 5 * 60 << 10 * 60 << 15 * 60 << 30 * 60; + if (mSmallestUnit <= tuMinutes) + availableSteps << 1*60; + if (mSmallestUnit <= tuSeconds) + availableSteps << 2.5*60; // only allow half minute steps if seconds are there to display it + else if (mSmallestUnit == tuMinutes) + availableSteps << 2*60; + if (mSmallestUnit <= tuMinutes) + availableSteps << 5*60 << 10*60 << 15*60 << 30*60; // hours range: - if( mSmallestUnit <= tuHours ) - availableSteps << 1 * 3600 << 2 * 3600 << 3 * 3600 << 6 * 3600 << 12 * 3600 << 24 * 3600; + if (mSmallestUnit <= tuHours) + availableSteps << 1*3600 << 2*3600 << 3*3600 << 6*3600 << 12*3600 << 24*3600; // pick available step that is most appropriate to approximate ideal step: - result = pickClosest( result, availableSteps ); - } - else // more than a day, go back to normal clean mantissa algorithm but in units of days + result = pickClosest(result, availableSteps); + } else // more than a day, go back to normal clean mantissa algorithm but in units of days { - const double secondsPerDay = 3600 * 24; - result = cleanMantissa( result / secondsPerDay ) * secondsPerDay; + const double secondsPerDay = 3600*24; + result = cleanMantissa(result/secondsPerDay)*secondsPerDay; } return result; } @@ -6385,41 +6319,21 @@ double QCPAxisTickerTime::getTickStep( const QCPRange& range ) \seebaseclassmethod */ -int QCPAxisTickerTime::getSubTickCount( double tickStep ) +int QCPAxisTickerTime::getSubTickCount(double tickStep) { - int result = QCPAxisTicker::getSubTickCount( tickStep ); - switch( qRound( tickStep ) ) // hand chosen subticks for specific minute/hour/day range (as specified in getTickStep) + int result = QCPAxisTicker::getSubTickCount(tickStep); + switch (qRound(tickStep)) // hand chosen subticks for specific minute/hour/day range (as specified in getTickStep) { - case 5 * 60: - result = 4; - break; - case 10 * 60: - result = 1; - break; - case 15 * 60: - result = 2; - break; - case 30 * 60: - result = 1; - break; - case 60 * 60: - result = 3; - break; - case 3600 * 2: - result = 3; - break; - case 3600 * 3: - result = 2; - break; - case 3600 * 6: - result = 1; - break; - case 3600 * 12: - result = 3; - break; - case 3600 * 24: - result = 3; - break; + case 5*60: result = 4; break; + case 10*60: result = 1; break; + case 15*60: result = 2; break; + case 30*60: result = 1; break; + case 60*60: result = 3; break; + case 3600*2: result = 3; break; + case 3600*3: result = 2; break; + case 3600*6: result = 1; break; + case 3600*12: result = 3; break; + case 3600*24: result = 3; break; } return result; } @@ -6431,32 +6345,31 @@ int QCPAxisTickerTime::getSubTickCount( double tickStep ) \seebaseclassmethod */ -QString QCPAxisTickerTime::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) +QString QCPAxisTickerTime::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) { - Q_UNUSED( precision ) - Q_UNUSED( formatChar ) - Q_UNUSED( locale ) + Q_UNUSED(precision) + Q_UNUSED(formatChar) + Q_UNUSED(locale) bool negative = tick < 0; - if( negative ) - tick *= -1; - double values[tuDays + 1]; // contains the msec/sec/min/... value with its respective modulo (e.g. minute 0..59) - double restValues[tuDays + 1]; // contains the msec/sec/min/... value as if it's the largest available unit and thus consumes the remaining time - - restValues[tuMilliseconds] = tick * 1000; - values[tuMilliseconds] = modf( restValues[tuMilliseconds] / 1000, &restValues[tuSeconds] ) * 1000; - values[tuSeconds] = modf( restValues[tuSeconds] / 60, &restValues[tuMinutes] ) * 60; - values[tuMinutes] = modf( restValues[tuMinutes] / 60, &restValues[tuHours] ) * 60; - values[tuHours] = modf( restValues[tuHours] / 24, &restValues[tuDays] ) * 24; + if (negative) tick *= -1; + double values[tuDays+1]; // contains the msec/sec/min/... value with its respective modulo (e.g. minute 0..59) + double restValues[tuDays+1]; // contains the msec/sec/min/... value as if it's the largest available unit and thus consumes the remaining time + + restValues[tuMilliseconds] = tick*1000; + values[tuMilliseconds] = modf(restValues[tuMilliseconds]/1000, &restValues[tuSeconds])*1000; + values[tuSeconds] = modf(restValues[tuSeconds]/60, &restValues[tuMinutes])*60; + values[tuMinutes] = modf(restValues[tuMinutes]/60, &restValues[tuHours])*60; + values[tuHours] = modf(restValues[tuHours]/24, &restValues[tuDays])*24; // no need to set values[tuDays] because days are always a rest value (there is no higher unit so it consumes all remaining time) - + QString result = mTimeFormat; - for( int i = mSmallestUnit; i <= mBiggestUnit; ++i ) + for (int i = mSmallestUnit; i <= mBiggestUnit; ++i) { - TimeUnit iUnit = static_cast( i ); - replaceUnit( result, iUnit, qRound( iUnit == mBiggestUnit ? restValues[iUnit] : values[iUnit] ) ); + TimeUnit iUnit = static_cast(i); + replaceUnit(result, iUnit, qRound(iUnit == mBiggestUnit ? restValues[iUnit] : values[iUnit])); } - if( negative ) - result.prepend( QLatin1Char( '-' ) ); + if (negative) + result.prepend(QLatin1Char('-')); return result; } @@ -6465,16 +6378,17 @@ QString QCPAxisTickerTime::getTickLabel( double tick, const QLocale& locale, QCh Replaces all occurrences of the format pattern belonging to \a unit in \a text with the specified \a value, using the field width as specified with \ref setFieldWidth for the \a unit. */ -void QCPAxisTickerTime::replaceUnit( QString& text, QCPAxisTickerTime::TimeUnit unit, int value ) const +void QCPAxisTickerTime::replaceUnit(QString &text, QCPAxisTickerTime::TimeUnit unit, int value) const { - QString valueStr = QString::number( value ); - while( valueStr.size() < mFieldWidth.value( unit ) ) - valueStr.prepend( QLatin1Char( '0' ) ); - - text.replace( mFormatPattern.value( unit ), valueStr ); + QString valueStr = QString::number(value); + while (valueStr.size() < mFieldWidth.value(unit)) + valueStr.prepend(QLatin1Char('0')); + + text.replace(mFormatPattern.value(unit), valueStr); } /* end of 'src/axis/axistickertime.cpp' */ + /* including file 'src/axis/axistickerfixed.cpp', size 5583 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6505,8 +6419,9 @@ void QCPAxisTickerTime::replaceUnit( QString& text, QCPAxisTickerTime::TimeUnit Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerFixed::QCPAxisTickerFixed() - : mTickStep( 1.0 ), mScaleStrategy( ssNone ) +QCPAxisTickerFixed::QCPAxisTickerFixed() : + mTickStep(1.0), + mScaleStrategy(ssNone) { } @@ -6519,9 +6434,9 @@ QCPAxisTickerFixed::QCPAxisTickerFixed() step. This will enable the ticker to reduce the number of ticks to a reasonable amount (see \ref setTickCount). */ -void QCPAxisTickerFixed::setTickStep( double step ) +void QCPAxisTickerFixed::setTickStep(double step) { - if( step > 0 ) + if (step > 0) mTickStep = step; else qDebug() << Q_FUNC_INFO << "tick step must be greater than zero:" << step; @@ -6534,7 +6449,7 @@ void QCPAxisTickerFixed::setTickStep( double step ) The default strategy is \ref ssNone, which means the tick step is absolutely fixed. */ -void QCPAxisTickerFixed::setScaleStrategy( QCPAxisTickerFixed::ScaleStrategy strategy ) +void QCPAxisTickerFixed::setScaleStrategy(QCPAxisTickerFixed::ScaleStrategy strategy) { mScaleStrategy = strategy; } @@ -6549,32 +6464,33 @@ void QCPAxisTickerFixed::setScaleStrategy( QCPAxisTickerFixed::ScaleStrategy str \seebaseclassmethod */ -double QCPAxisTickerFixed::getTickStep( const QCPRange& range ) +double QCPAxisTickerFixed::getTickStep(const QCPRange &range) { - switch( mScaleStrategy ) + switch (mScaleStrategy) { - case ssNone: - { - return mTickStep; - } - case ssMultiples: - { - double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - if( exactStep < mTickStep ) + case ssNone: + { return mTickStep; - else - return ( qint64 )( cleanMantissa( exactStep / mTickStep ) + 0.5 ) * mTickStep; - } - case ssPowers: - { - double exactStep = range.size() / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - return qPow( mTickStep, (int)( qLn( exactStep ) / qLn( mTickStep ) + 0.5 ) ); - } + } + case ssMultiples: + { + double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + if (exactStep < mTickStep) + return mTickStep; + else + return (qint64)(cleanMantissa(exactStep/mTickStep)+0.5)*mTickStep; + } + case ssPowers: + { + double exactStep = range.size()/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + return qPow(mTickStep, (int)(qLn(exactStep)/qLn(mTickStep)+0.5)); + } } return mTickStep; } /* end of 'src/axis/axistickerfixed.cpp' */ + /* including file 'src/axis/axistickertext.cpp', size 8653 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6618,8 +6534,8 @@ double QCPAxisTickerFixed::getTickStep( const QCPRange& range ) Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerText::QCPAxisTickerText() - : mSubTickCount( 0 ) +QCPAxisTickerText::QCPAxisTickerText() : + mSubTickCount(0) { } @@ -6633,7 +6549,7 @@ QCPAxisTickerText::QCPAxisTickerText() \see addTicks, addTick, clear */ -void QCPAxisTickerText::setTicks( const QMap& ticks ) +void QCPAxisTickerText::setTicks(const QMap &ticks) { mTicks = ticks; } @@ -6646,10 +6562,10 @@ void QCPAxisTickerText::setTicks( const QMap& ticks ) \see addTicks, addTick, clear */ -void QCPAxisTickerText::setTicks( const QVector& positions, const QVector labels ) +void QCPAxisTickerText::setTicks(const QVector &positions, const QVector labels) { clear(); - addTicks( positions, labels ); + addTicks(positions, labels); } /*! @@ -6657,9 +6573,9 @@ void QCPAxisTickerText::setTicks( const QVector& positions, const QVecto automatic sub tick count calculation. So if sub ticks are needed, they must be configured with this method. */ -void QCPAxisTickerText::setSubTickCount( int subTicks ) +void QCPAxisTickerText::setSubTickCount(int subTicks) { - if( subTicks >= 0 ) + if (subTicks >= 0) mSubTickCount = subTicks; else qDebug() << Q_FUNC_INFO << "sub tick count can't be negative:" << subTicks; @@ -6684,9 +6600,9 @@ void QCPAxisTickerText::clear() \see addTicks, setTicks, clear */ -void QCPAxisTickerText::addTick( double position, QString label ) +void QCPAxisTickerText::addTick(double position, QString label) { - mTicks.insert( position, label ); + mTicks.insert(position, label); } /*! \overload @@ -6699,9 +6615,9 @@ void QCPAxisTickerText::addTick( double position, QString label ) \see addTick, setTicks, clear */ -void QCPAxisTickerText::addTicks( const QMap& ticks ) +void QCPAxisTickerText::addTicks(const QMap &ticks) { - mTicks.unite( ticks ); + mTicks.unite(ticks); } /*! \overload @@ -6715,13 +6631,13 @@ void QCPAxisTickerText::addTicks( const QMap& ticks ) \see addTick, setTicks, clear */ -void QCPAxisTickerText::addTicks( const QVector& positions, const QVector& labels ) +void QCPAxisTickerText::addTicks(const QVector &positions, const QVector &labels) { - if( positions.size() != labels.size() ) + if (positions.size() != labels.size()) qDebug() << Q_FUNC_INFO << "passed unequal length vectors for positions and labels:" << positions.size() << labels.size(); - int n = qMin( positions.size(), labels.size() ); - for( int i = 0; i < n; ++i ) - mTicks.insert( positions.at( i ), labels.at( i ) ); + int n = qMin(positions.size(), labels.size()); + for (int i=0; i& positions, const QVecto \seebaseclassmethod */ -double QCPAxisTickerText::getTickStep( const QCPRange& range ) +double QCPAxisTickerText::getTickStep(const QCPRange &range) { // text axis ticker has manual tick positions, so doesn't need this method - Q_UNUSED( range ) + Q_UNUSED(range) return 1.0; } @@ -6741,9 +6657,9 @@ double QCPAxisTickerText::getTickStep( const QCPRange& range ) \seebaseclassmethod */ -int QCPAxisTickerText::getSubTickCount( double tickStep ) +int QCPAxisTickerText::getSubTickCount(double tickStep) { - Q_UNUSED( tickStep ) + Q_UNUSED(tickStep) return mSubTickCount; } @@ -6753,12 +6669,12 @@ int QCPAxisTickerText::getSubTickCount( double tickStep ) \seebaseclassmethod */ -QString QCPAxisTickerText::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) +QString QCPAxisTickerText::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) { - Q_UNUSED( locale ) - Q_UNUSED( formatChar ) - Q_UNUSED( precision ) - return mTicks.value( tick ); + Q_UNUSED(locale) + Q_UNUSED(formatChar) + Q_UNUSED(precision) + return mTicks.value(tick); } /*! @@ -6768,27 +6684,26 @@ QString QCPAxisTickerText::getTickLabel( double tick, const QLocale& locale, QCh \seebaseclassmethod */ -QVector QCPAxisTickerText::createTickVector( double tickStep, const QCPRange& range ) +QVector QCPAxisTickerText::createTickVector(double tickStep, const QCPRange &range) { - Q_UNUSED( tickStep ) + Q_UNUSED(tickStep) QVector result; - if( mTicks.isEmpty() ) + if (mTicks.isEmpty()) return result; - - QMap::const_iterator start = mTicks.lowerBound( range.lower ); - QMap::const_iterator end = mTicks.upperBound( range.upper ); + + QMap::const_iterator start = mTicks.lowerBound(range.lower); + QMap::const_iterator end = mTicks.upperBound(range.upper); // this method should try to give one tick outside of range so proper subticks can be generated: - if( start != mTicks.constBegin() ) - --start; - if( end != mTicks.constEnd() ) - ++end; - for( QMap::const_iterator it = start; it != end; ++it ) - result.append( it.key() ); - + if (start != mTicks.constBegin()) --start; + if (end != mTicks.constEnd()) ++end; + for (QMap::const_iterator it = start; it != end; ++it) + result.append(it.key()); + return result; } /* end of 'src/axis/axistickertext.cpp' */ + /* including file 'src/axis/axistickerpi.cpp', size 11170 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6815,10 +6730,14 @@ QVector QCPAxisTickerText::createTickVector( double tickStep, const QCPR Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerPi::QCPAxisTickerPi() - : mPiSymbol( QLatin1String( " " ) + QChar( 0x03C0 ) ), mPiValue( M_PI ), mPeriodicity( 0 ), mFractionStyle( fsUnicodeFractions ), mPiTickStep( 0 ) +QCPAxisTickerPi::QCPAxisTickerPi() : + mPiSymbol(QLatin1String(" ")+QChar(0x03C0)), + mPiValue(M_PI), + mPeriodicity(0), + mFractionStyle(fsUnicodeFractions), + mPiTickStep(0) { - setTickCount( 4 ); + setTickCount(4); } /*! @@ -6828,7 +6747,7 @@ QCPAxisTickerPi::QCPAxisTickerPi() If a space shall appear between the number and the symbol, make sure the space is contained in \a symbol. */ -void QCPAxisTickerPi::setPiSymbol( QString symbol ) +void QCPAxisTickerPi::setPiSymbol(QString symbol) { mPiSymbol = symbol; } @@ -6839,7 +6758,7 @@ void QCPAxisTickerPi::setPiSymbol( QString symbol ) This will be used to place the appropriate fractions of the symbol at the respective axis coordinates. */ -void QCPAxisTickerPi::setPiValue( double pi ) +void QCPAxisTickerPi::setPiValue(double pi) { mPiValue = pi; } @@ -6852,16 +6771,16 @@ void QCPAxisTickerPi::setPiValue( double pi ) For example, an axis that identifies 0 with 2pi would set \a multiplesOfPi to two. */ -void QCPAxisTickerPi::setPeriodicity( int multiplesOfPi ) +void QCPAxisTickerPi::setPeriodicity(int multiplesOfPi) { - mPeriodicity = qAbs( multiplesOfPi ); + mPeriodicity = qAbs(multiplesOfPi); } /*! Sets how the numerical/fractional part preceding the symbolic constant is displayed in tick labels. See \ref FractionStyle for the various options. */ -void QCPAxisTickerPi::setFractionStyle( QCPAxisTickerPi::FractionStyle style ) +void QCPAxisTickerPi::setFractionStyle(QCPAxisTickerPi::FractionStyle style) { mFractionStyle = style; } @@ -6874,11 +6793,11 @@ void QCPAxisTickerPi::setFractionStyle( QCPAxisTickerPi::FractionStyle style ) \seebaseclassmethod */ -double QCPAxisTickerPi::getTickStep( const QCPRange& range ) +double QCPAxisTickerPi::getTickStep(const QCPRange &range) { - mPiTickStep = range.size() / mPiValue / (double)( mTickCount + 1e-10 ); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers - mPiTickStep = cleanMantissa( mPiTickStep ); - return mPiTickStep * mPiValue; + mPiTickStep = range.size()/mPiValue/(double)(mTickCount+1e-10); // mTickCount ticks on average, the small addition is to prevent jitter on exact integers + mPiTickStep = cleanMantissa(mPiTickStep); + return mPiTickStep*mPiValue; } /*! \internal @@ -6889,9 +6808,9 @@ double QCPAxisTickerPi::getTickStep( const QCPRange& range ) \seebaseclassmethod */ -int QCPAxisTickerPi::getSubTickCount( double tickStep ) +int QCPAxisTickerPi::getSubTickCount(double tickStep) { - return QCPAxisTicker::getSubTickCount( tickStep / mPiValue ); + return QCPAxisTicker::getSubTickCount(tickStep/mPiValue); } /*! \internal @@ -6902,33 +6821,32 @@ int QCPAxisTickerPi::getSubTickCount( double tickStep ) \seebaseclassmethod */ -QString QCPAxisTickerPi::getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) +QString QCPAxisTickerPi::getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) { - double tickInPis = tick / mPiValue; - if( mPeriodicity > 0 ) - tickInPis = fmod( tickInPis, mPeriodicity ); - - if( mFractionStyle != fsFloatingPoint && mPiTickStep > 0.09 && mPiTickStep < 50 ) + double tickInPis = tick/mPiValue; + if (mPeriodicity > 0) + tickInPis = fmod(tickInPis, mPeriodicity); + + if (mFractionStyle != fsFloatingPoint && mPiTickStep > 0.09 && mPiTickStep < 50) { // simply construct fraction from decimal like 1.234 -> 1234/1000 and then simplify fraction, smaller digits are irrelevant due to mPiTickStep conditional above int denominator = 1000; - int numerator = qRound( tickInPis * denominator ); - simplifyFraction( numerator, denominator ); - if( qAbs( numerator ) == 1 && denominator == 1 ) - return ( numerator < 0 ? QLatin1String( "-" ) : QLatin1String( "" ) ) + mPiSymbol.trimmed(); - else if( numerator == 0 ) - return QLatin1String( "0" ); + int numerator = qRound(tickInPis*denominator); + simplifyFraction(numerator, denominator); + if (qAbs(numerator) == 1 && denominator == 1) + return (numerator < 0 ? QLatin1String("-") : QLatin1String("")) + mPiSymbol.trimmed(); + else if (numerator == 0) + return QLatin1String("0"); else - return fractionToString( numerator, denominator ) + mPiSymbol; - } - else + return fractionToString(numerator, denominator) + mPiSymbol; + } else { - if( qFuzzyIsNull( tickInPis ) ) - return QLatin1String( "0" ); - else if( qFuzzyCompare( qAbs( tickInPis ), 1.0 ) ) - return ( tickInPis < 0 ? QLatin1String( "-" ) : QLatin1String( "" ) ) + mPiSymbol.trimmed(); + if (qFuzzyIsNull(tickInPis)) + return QLatin1String("0"); + else if (qFuzzyCompare(qAbs(tickInPis), 1.0)) + return (tickInPis < 0 ? QLatin1String("-") : QLatin1String("")) + mPiSymbol.trimmed(); else - return QCPAxisTicker::getTickLabel( tickInPis, locale, formatChar, precision ) + mPiSymbol; + return QCPAxisTicker::getTickLabel(tickInPis, locale, formatChar, precision) + mPiSymbol; } } @@ -6938,14 +6856,14 @@ QString QCPAxisTickerPi::getTickLabel( double tick, const QLocale& locale, QChar the fraction is in irreducible form, i.e. numerator and denominator don't share any common factors which could be cancelled. */ -void QCPAxisTickerPi::simplifyFraction( int& numerator, int& denominator ) const +void QCPAxisTickerPi::simplifyFraction(int &numerator, int &denominator) const { - if( numerator == 0 || denominator == 0 ) + if (numerator == 0 || denominator == 0) return; - + int num = numerator; int denom = denominator; - while( denom != 0 ) // euclidean gcd algorithm + while (denom != 0) // euclidean gcd algorithm { int oldDenom = denom; denom = num % denom; @@ -6965,50 +6883,47 @@ void QCPAxisTickerPi::simplifyFraction( int& numerator, int& denominator ) const simplifies the passed fraction to an irreducible form using \ref simplifyFraction and factors out any integer parts of the fraction (e.g. "10/4" becomes "2 1/2"). */ -QString QCPAxisTickerPi::fractionToString( int numerator, int denominator ) const +QString QCPAxisTickerPi::fractionToString(int numerator, int denominator) const { - if( denominator == 0 ) + if (denominator == 0) { qDebug() << Q_FUNC_INFO << "called with zero denominator"; return QString(); } - if( mFractionStyle == fsFloatingPoint ) // should never be the case when calling this function + if (mFractionStyle == fsFloatingPoint) // should never be the case when calling this function { qDebug() << Q_FUNC_INFO << "shouldn't be called with fraction style fsDecimal"; - return QString::number( numerator / (double)denominator ); // failsafe + return QString::number(numerator/(double)denominator); // failsafe } - int sign = numerator * denominator < 0 ? -1 : 1; - numerator = qAbs( numerator ); - denominator = qAbs( denominator ); - - if( denominator == 1 ) + int sign = numerator*denominator < 0 ? -1 : 1; + numerator = qAbs(numerator); + denominator = qAbs(denominator); + + if (denominator == 1) { - return QString::number( sign * numerator ); - } - else + return QString::number(sign*numerator); + } else { - int integerPart = numerator / denominator; - int remainder = numerator % denominator; - if( remainder == 0 ) + int integerPart = numerator/denominator; + int remainder = numerator%denominator; + if (remainder == 0) { - return QString::number( sign * integerPart ); - } - else + return QString::number(sign*integerPart); + } else { - if( mFractionStyle == fsAsciiFractions ) + if (mFractionStyle == fsAsciiFractions) { - return QString( QLatin1String( "%1%2%3/%4" ) ) - .arg( sign == -1 ? QLatin1String( "-" ) : QLatin1String( "" ) ) - .arg( integerPart > 0 ? QString::number( integerPart ) + QLatin1String( " " ) : QLatin1String( "" ) ) - .arg( remainder ) - .arg( denominator ); - } - else if( mFractionStyle == fsUnicodeFractions ) + return QString(QLatin1String("%1%2%3/%4")) + .arg(sign == -1 ? QLatin1String("-") : QLatin1String("")) + .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String("")) + .arg(remainder) + .arg(denominator); + } else if (mFractionStyle == fsUnicodeFractions) { - return QString( QLatin1String( "%1%2%3" ) ) - .arg( sign == -1 ? QLatin1String( "-" ) : QLatin1String( "" ) ) - .arg( integerPart > 0 ? QString::number( integerPart ) : QLatin1String( "" ) ) - .arg( unicodeFraction( remainder, denominator ) ); + return QString(QLatin1String("%1%2%3")) + .arg(sign == -1 ? QLatin1String("-") : QLatin1String("")) + .arg(integerPart > 0 ? QString::number(integerPart) : QLatin1String("")) + .arg(unicodeFraction(remainder, denominator)); } } } @@ -7024,9 +6939,9 @@ QString QCPAxisTickerPi::fractionToString( int numerator, int denominator ) cons This method doesn't use the single-character common fractions but builds each fraction from a superscript unicode number, the unicode fraction character, and a subscript unicode number. */ -QString QCPAxisTickerPi::unicodeFraction( int numerator, int denominator ) const +QString QCPAxisTickerPi::unicodeFraction(int numerator, int denominator) const { - return unicodeSuperscript( numerator ) + QChar( 0x2044 ) + unicodeSubscript( denominator ); + return unicodeSuperscript(numerator)+QChar(0x2044)+unicodeSubscript(denominator); } /*! \internal @@ -7034,37 +6949,21 @@ QString QCPAxisTickerPi::unicodeFraction( int numerator, int denominator ) const Returns the unicode string representing \a number as superscript. This is used to build unicode fractions in \ref unicodeFraction. */ -QString QCPAxisTickerPi::unicodeSuperscript( int number ) const +QString QCPAxisTickerPi::unicodeSuperscript(int number) const { - if( number == 0 ) - return QString( QChar( 0x2070 ) ); - + if (number == 0) + return QString(QChar(0x2070)); + QString result; - while( number > 0 ) + while (number > 0) { - const int digit = number % 10; - switch( digit ) + const int digit = number%10; + switch (digit) { - case 1: - { - result.prepend( QChar( 0x00B9 ) ); - break; - } - case 2: - { - result.prepend( QChar( 0x00B2 ) ); - break; - } - case 3: - { - result.prepend( QChar( 0x00B3 ) ); - break; - } - default: - { - result.prepend( QChar( 0x2070 + digit ) ); - break; - } + case 1: { result.prepend(QChar(0x00B9)); break; } + case 2: { result.prepend(QChar(0x00B2)); break; } + case 3: { result.prepend(QChar(0x00B3)); break; } + default: { result.prepend(QChar(0x2070+digit)); break; } } number /= 10; } @@ -7076,21 +6975,22 @@ QString QCPAxisTickerPi::unicodeSuperscript( int number ) const Returns the unicode string representing \a number as subscript. This is used to build unicode fractions in \ref unicodeFraction. */ -QString QCPAxisTickerPi::unicodeSubscript( int number ) const +QString QCPAxisTickerPi::unicodeSubscript(int number) const { - if( number == 0 ) - return QString( QChar( 0x2080 ) ); - + if (number == 0) + return QString(QChar(0x2080)); + QString result; - while( number > 0 ) + while (number > 0) { - result.prepend( QChar( 0x2080 + number % 10 ) ); + result.prepend(QChar(0x2080+number%10)); number /= 10; } return result; } /* end of 'src/axis/axistickerpi.cpp' */ + /* including file 'src/axis/axistickerlog.cpp', size 7106 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -7121,9 +7021,10 @@ QString QCPAxisTickerPi::unicodeSubscript( int number ) const Constructs the ticker and sets reasonable default values. Axis tickers are commonly created managed by a QSharedPointer, which then can be passed to QCPAxis::setTicker. */ -QCPAxisTickerLog::QCPAxisTickerLog() - : mLogBase( 10.0 ), mSubTickCount( 8 ), // generates 10 intervals - mLogBaseLnInv( 1.0 / qLn( mLogBase ) ) +QCPAxisTickerLog::QCPAxisTickerLog() : + mLogBase(10.0), + mSubTickCount(8), // generates 10 intervals + mLogBaseLnInv(1.0/qLn(mLogBase)) { } @@ -7131,14 +7032,13 @@ QCPAxisTickerLog::QCPAxisTickerLog() Sets the logarithm base used for tick coordinate generation. The ticks will be placed at integer powers of \a base. */ -void QCPAxisTickerLog::setLogBase( double base ) +void QCPAxisTickerLog::setLogBase(double base) { - if( base > 0 ) + if (base > 0) { mLogBase = base; - mLogBaseLnInv = 1.0 / qLn( mLogBase ); - } - else + mLogBaseLnInv = 1.0/qLn(mLogBase); + } else qDebug() << Q_FUNC_INFO << "log base has to be greater than zero:" << base; } @@ -7152,9 +7052,9 @@ void QCPAxisTickerLog::setLogBase( double base ) ticks (the default). This means e.g. between the ticks 10 and 100 there will be eight ticks, namely at 20, 30, 40, 50, 60, 70, 80 and 90. */ -void QCPAxisTickerLog::setSubTickCount( int subTicks ) +void QCPAxisTickerLog::setSubTickCount(int subTicks) { - if( subTicks >= 0 ) + if (subTicks >= 0) mSubTickCount = subTicks; else qDebug() << Q_FUNC_INFO << "sub tick count can't be negative:" << subTicks; @@ -7167,10 +7067,10 @@ void QCPAxisTickerLog::setSubTickCount( int subTicks ) \seebaseclassmethod */ -double QCPAxisTickerLog::getTickStep( const QCPRange& range ) +double QCPAxisTickerLog::getTickStep(const QCPRange &range) { // Logarithmic axis ticker has unequal tick spacing, so doesn't need this method - Q_UNUSED( range ) + Q_UNUSED(range) return 1.0; } @@ -7181,9 +7081,9 @@ double QCPAxisTickerLog::getTickStep( const QCPRange& range ) \seebaseclassmethod */ -int QCPAxisTickerLog::getSubTickCount( double tickStep ) +int QCPAxisTickerLog::getSubTickCount(double tickStep) { - Q_UNUSED( tickStep ) + Q_UNUSED(tickStep) return mSubTickCount; } @@ -7196,46 +7096,46 @@ int QCPAxisTickerLog::getSubTickCount( double tickStep ) \seebaseclassmethod */ -QVector QCPAxisTickerLog::createTickVector( double tickStep, const QCPRange& range ) +QVector QCPAxisTickerLog::createTickVector(double tickStep, const QCPRange &range) { - Q_UNUSED( tickStep ) + Q_UNUSED(tickStep) QVector result; - if( range.lower > 0 && range.upper > 0 ) // positive range + if (range.lower > 0 && range.upper > 0) // positive range { - double exactPowerStep = qLn( range.upper / range.lower ) * mLogBaseLnInv / (double)( mTickCount + 1e-10 ); - double newLogBase = qPow( mLogBase, qMax( (int)cleanMantissa( exactPowerStep ), 1 ) ); - double currentTick = qPow( newLogBase, qFloor( qLn( range.lower ) / qLn( newLogBase ) ) ); - result.append( currentTick ); - while( currentTick < range.upper && currentTick > 0 ) // currentMag might be zero for ranges ~1e-300, just cancel in that case + double exactPowerStep = qLn(range.upper/range.lower)*mLogBaseLnInv/(double)(mTickCount+1e-10); + double newLogBase = qPow(mLogBase, qMax((int)cleanMantissa(exactPowerStep), 1)); + double currentTick = qPow(newLogBase, qFloor(qLn(range.lower)/qLn(newLogBase))); + result.append(currentTick); + while (currentTick < range.upper && currentTick > 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case { currentTick *= newLogBase; - result.append( currentTick ); + result.append(currentTick); } - } - else if( range.lower < 0 && range.upper < 0 ) // negative range + } else if (range.lower < 0 && range.upper < 0) // negative range { - double exactPowerStep = qLn( range.lower / range.upper ) * mLogBaseLnInv / (double)( mTickCount + 1e-10 ); - double newLogBase = qPow( mLogBase, qMax( (int)cleanMantissa( exactPowerStep ), 1 ) ); - double currentTick = -qPow( newLogBase, qCeil( qLn( -range.lower ) / qLn( newLogBase ) ) ); - result.append( currentTick ); - while( currentTick < range.upper && currentTick < 0 ) // currentMag might be zero for ranges ~1e-300, just cancel in that case + double exactPowerStep = qLn(range.lower/range.upper)*mLogBaseLnInv/(double)(mTickCount+1e-10); + double newLogBase = qPow(mLogBase, qMax((int)cleanMantissa(exactPowerStep), 1)); + double currentTick = -qPow(newLogBase, qCeil(qLn(-range.lower)/qLn(newLogBase))); + result.append(currentTick); + while (currentTick < range.upper && currentTick < 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case { currentTick /= newLogBase; - result.append( currentTick ); + result.append(currentTick); } - } - else // invalid range for logarithmic scale, because lower and upper have different sign + } else // invalid range for logarithmic scale, because lower and upper have different sign { qDebug() << Q_FUNC_INFO << "Invalid range for logarithmic plot: " << range.lower << ".." << range.upper; } - + return result; } /* end of 'src/axis/axistickerlog.cpp' */ + /* including file 'src/axis/axis.cpp', size 99397 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPGrid //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -7258,18 +7158,19 @@ QVector QCPAxisTickerLog::createTickVector( double tickStep, const QCPRa You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid. */ -QCPGrid::QCPGrid( QCPAxis* parentAxis ) - : QCPLayerable( parentAxis->parentPlot(), QString(), parentAxis ), mParentAxis( parentAxis ) +QCPGrid::QCPGrid(QCPAxis *parentAxis) : + QCPLayerable(parentAxis->parentPlot(), QString(), parentAxis), + mParentAxis(parentAxis) { // warning: this is called in QCPAxis constructor, so parentAxis members should not be accessed/called - setParent( parentAxis ); - setPen( QPen( QColor( 200, 200, 200 ), 0, Qt::DotLine ) ); - setSubGridPen( QPen( QColor( 220, 220, 220 ), 0, Qt::DotLine ) ); - setZeroLinePen( QPen( QColor( 200, 200, 200 ), 0, Qt::SolidLine ) ); - setSubGridVisible( false ); - setAntialiased( false ); - setAntialiasedSubGrid( false ); - setAntialiasedZeroLine( false ); + setParent(parentAxis); + setPen(QPen(QColor(200,200,200), 0, Qt::DotLine)); + setSubGridPen(QPen(QColor(220,220,220), 0, Qt::DotLine)); + setZeroLinePen(QPen(QColor(200,200,200), 0, Qt::SolidLine)); + setSubGridVisible(false); + setAntialiased(false); + setAntialiasedSubGrid(false); + setAntialiasedZeroLine(false); } /*! @@ -7277,7 +7178,7 @@ QCPGrid::QCPGrid( QCPAxis* parentAxis ) \see setSubGridPen */ -void QCPGrid::setSubGridVisible( bool visible ) +void QCPGrid::setSubGridVisible(bool visible) { mSubGridVisible = visible; } @@ -7285,7 +7186,7 @@ void QCPGrid::setSubGridVisible( bool visible ) /*! Sets whether sub grid lines are drawn antialiased. */ -void QCPGrid::setAntialiasedSubGrid( bool enabled ) +void QCPGrid::setAntialiasedSubGrid(bool enabled) { mAntialiasedSubGrid = enabled; } @@ -7293,7 +7194,7 @@ void QCPGrid::setAntialiasedSubGrid( bool enabled ) /*! Sets whether zero lines are drawn antialiased. */ -void QCPGrid::setAntialiasedZeroLine( bool enabled ) +void QCPGrid::setAntialiasedZeroLine(bool enabled) { mAntialiasedZeroLine = enabled; } @@ -7301,7 +7202,7 @@ void QCPGrid::setAntialiasedZeroLine( bool enabled ) /*! Sets the pen with which (major) grid lines are drawn. */ -void QCPGrid::setPen( const QPen& pen ) +void QCPGrid::setPen(const QPen &pen) { mPen = pen; } @@ -7309,7 +7210,7 @@ void QCPGrid::setPen( const QPen& pen ) /*! Sets the pen with which sub grid lines are drawn. */ -void QCPGrid::setSubGridPen( const QPen& pen ) +void QCPGrid::setSubGridPen(const QPen &pen) { mSubGridPen = pen; } @@ -7320,7 +7221,7 @@ void QCPGrid::setSubGridPen( const QPen& pen ) Zero lines are lines at value coordinate 0 which may be drawn with a different pen than other grid lines. To disable zero lines and just draw normal grid lines at zero, set \a pen to Qt::NoPen. */ -void QCPGrid::setZeroLinePen( const QPen& pen ) +void QCPGrid::setZeroLinePen(const QPen &pen) { mZeroLinePen = pen; } @@ -7338,9 +7239,9 @@ void QCPGrid::setZeroLinePen( const QPen& pen ) \see setAntialiased */ -void QCPGrid::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPGrid::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeGrid ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeGrid); } /*! \internal @@ -7348,17 +7249,13 @@ void QCPGrid::applyDefaultAntialiasingHint( QCPPainter* painter ) const Draws grid lines and sub grid lines at the positions of (sub) ticks of the parent axis, spanning over the complete axis rect. Also draws the zero line, if appropriate (\ref setZeroLinePen). */ -void QCPGrid::draw( QCPPainter* painter ) +void QCPGrid::draw(QCPPainter *painter) { - if( !mParentAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid parent axis"; - return; - } - - if( mParentAxis->subTicks() && mSubGridVisible ) - drawSubGridLines( painter ); - drawGridLines( painter ); + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + + if (mParentAxis->subTicks() && mSubGridVisible) + drawSubGridLines(painter); + drawGridLines(painter); } /*! \internal @@ -7367,76 +7264,69 @@ void QCPGrid::draw( QCPPainter* painter ) This is a helper function called by \ref draw. */ -void QCPGrid::drawGridLines( QCPPainter* painter ) const +void QCPGrid::drawGridLines(QCPPainter *painter) const { - if( !mParentAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid parent axis"; - return; - } - + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + const int tickCount = mParentAxis->mTickVector.size(); - double t; // helper variable, result of coordinate-to-pixel transforms - if( mParentAxis->orientation() == Qt::Horizontal ) + double t; // helper variable, result of coordinate-to-pixel transforms + if (mParentAxis->orientation() == Qt::Horizontal) { // draw zeroline: int zeroLineIndex = -1; - if( mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0 ) + if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0) { - applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine ); - painter->setPen( mZeroLinePen ); - double epsilon = mParentAxis->range().size() * 1E-6; // for comparing double to zero - for( int i = 0; i < tickCount; ++i ) + applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine); + painter->setPen(mZeroLinePen); + double epsilon = mParentAxis->range().size()*1E-6; // for comparing double to zero + for (int i=0; imTickVector.at( i ) ) < epsilon ) + if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon) { zeroLineIndex = i; - t = mParentAxis->coordToPixel( mParentAxis->mTickVector.at( i ) ); // x - painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) ); + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); break; } } } // draw grid lines: - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - for( int i = 0; i < tickCount; ++i ) + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + for (int i=0; icoordToPixel( mParentAxis->mTickVector.at( i ) ); // x - painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) ); + if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); } - } - else + } else { // draw zeroline: int zeroLineIndex = -1; - if( mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0 ) + if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0) { - applyAntialiasingHint( painter, mAntialiasedZeroLine, QCP::aeZeroLine ); - painter->setPen( mZeroLinePen ); - double epsilon = mParentAxis->mRange.size() * 1E-6; // for comparing double to zero - for( int i = 0; i < tickCount; ++i ) + applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine); + painter->setPen(mZeroLinePen); + double epsilon = mParentAxis->mRange.size()*1E-6; // for comparing double to zero + for (int i=0; imTickVector.at( i ) ) < epsilon ) + if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon) { zeroLineIndex = i; - t = mParentAxis->coordToPixel( mParentAxis->mTickVector.at( i ) ); // y - painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) ); + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); break; } } } // draw grid lines: - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - for( int i = 0; i < tickCount; ++i ) + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + for (int i=0; icoordToPixel( mParentAxis->mTickVector.at( i ) ); // y - painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) ); + if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); } } } @@ -7447,35 +7337,31 @@ void QCPGrid::drawGridLines( QCPPainter* painter ) const This is a helper function called by \ref draw. */ -void QCPGrid::drawSubGridLines( QCPPainter* painter ) const +void QCPGrid::drawSubGridLines(QCPPainter *painter) const { - if( !mParentAxis ) + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + + applyAntialiasingHint(painter, mAntialiasedSubGrid, QCP::aeSubGrid); + double t; // helper variable, result of coordinate-to-pixel transforms + painter->setPen(mSubGridPen); + if (mParentAxis->orientation() == Qt::Horizontal) { - qDebug() << Q_FUNC_INFO << "invalid parent axis"; - return; - } - - applyAntialiasingHint( painter, mAntialiasedSubGrid, QCP::aeSubGrid ); - double t; // helper variable, result of coordinate-to-pixel transforms - painter->setPen( mSubGridPen ); - if( mParentAxis->orientation() == Qt::Horizontal ) - { - for( int i = 0; i < mParentAxis->mSubTickVector.size(); ++i ) + for (int i=0; imSubTickVector.size(); ++i) { - t = mParentAxis->coordToPixel( mParentAxis->mSubTickVector.at( i ) ); // x - painter->drawLine( QLineF( t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top() ) ); + t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); } - } - else + } else { - for( int i = 0; i < mParentAxis->mSubTickVector.size(); ++i ) + for (int i=0; imSubTickVector.size(); ++i) { - t = mParentAxis->coordToPixel( mParentAxis->mSubTickVector.at( i ) ); // y - painter->drawLine( QLineF( mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t ) ); + t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); } } } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxis //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -7610,86 +7496,78 @@ void QCPGrid::drawSubGridLines( QCPPainter* painter ) const them for you with \ref QCPAxisRect::addAxis. If you want to use own QCPAxis-subclasses however, create them manually and then inject them also via \ref QCPAxisRect::addAxis. */ -QCPAxis::QCPAxis( QCPAxisRect* parent, AxisType type ) - : QCPLayerable( parent->parentPlot(), QString(), parent ), - // axis base: - mAxisType( type ) - , mAxisRect( parent ) - , mPadding( 5 ) - , mOrientation( orientation( type ) ) - , mSelectableParts( spAxis | spTickLabels | spAxisLabel ) - , mSelectedParts( spNone ) - , mBasePen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ) - , mSelectedBasePen( QPen( Qt::blue, 2 ) ) - , - // axis label: - mLabel() - , mLabelFont( mParentPlot->font() ) - , mSelectedLabelFont( QFont( mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold ) ) - , mLabelColor( Qt::black ) - , mSelectedLabelColor( Qt::blue ) - , - // tick labels: - mTickLabels( true ) - , mTickLabelFont( mParentPlot->font() ) - , mSelectedTickLabelFont( QFont( mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold ) ) - , mTickLabelColor( Qt::black ) - , mSelectedTickLabelColor( Qt::blue ) - , mNumberPrecision( 6 ) - , mNumberFormatChar( 'g' ) - , mNumberBeautifulPowers( true ) - , - // ticks and subticks: - mTicks( true ) - , mSubTicks( true ) - , mTickPen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ) - , mSelectedTickPen( QPen( Qt::blue, 2 ) ) - , mSubTickPen( QPen( Qt::black, 0, Qt::SolidLine, Qt::SquareCap ) ) - , mSelectedSubTickPen( QPen( Qt::blue, 2 ) ) - , - // scale and range: - mRange( 0, 5 ) - , mRangeReversed( false ) - , mScaleType( stLinear ) - , - // internal members: - mGrid( new QCPGrid( this ) ) - , mAxisPainter( new QCPAxisPainterPrivate( parent->parentPlot() ) ) - , mTicker( new QCPAxisTicker ) - , mCachedMarginValid( false ) - , mCachedMargin( 0 ) +QCPAxis::QCPAxis(QCPAxisRect *parent, AxisType type) : + QCPLayerable(parent->parentPlot(), QString(), parent), + // axis base: + mAxisType(type), + mAxisRect(parent), + mPadding(5), + mOrientation(orientation(type)), + mSelectableParts(spAxis | spTickLabels | spAxisLabel), + mSelectedParts(spNone), + mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedBasePen(QPen(Qt::blue, 2)), + // axis label: + mLabel(), + mLabelFont(mParentPlot->font()), + mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)), + mLabelColor(Qt::black), + mSelectedLabelColor(Qt::blue), + // tick labels: + mTickLabels(true), + mTickLabelFont(mParentPlot->font()), + mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)), + mTickLabelColor(Qt::black), + mSelectedTickLabelColor(Qt::blue), + mNumberPrecision(6), + mNumberFormatChar('g'), + mNumberBeautifulPowers(true), + // ticks and subticks: + mTicks(true), + mSubTicks(true), + mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedTickPen(QPen(Qt::blue, 2)), + mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedSubTickPen(QPen(Qt::blue, 2)), + // scale and range: + mRange(0, 5), + mRangeReversed(false), + mScaleType(stLinear), + // internal members: + mGrid(new QCPGrid(this)), + mAxisPainter(new QCPAxisPainterPrivate(parent->parentPlot())), + mTicker(new QCPAxisTicker), + mCachedMarginValid(false), + mCachedMargin(0) { - setParent( parent ); - mGrid->setVisible( false ); - setAntialiased( false ); - setLayer( mParentPlot->currentLayer() ); // it's actually on that layer already, but we want it in front of the grid, so we place it on there again - - if( type == atTop ) + setParent(parent); + mGrid->setVisible(false); + setAntialiased(false); + setLayer(mParentPlot->currentLayer()); // it's actually on that layer already, but we want it in front of the grid, so we place it on there again + + if (type == atTop) { - setTickLabelPadding( 3 ); - setLabelPadding( 6 ); - } - else if( type == atRight ) + setTickLabelPadding(3); + setLabelPadding(6); + } else if (type == atRight) { - setTickLabelPadding( 7 ); - setLabelPadding( 12 ); - } - else if( type == atBottom ) + setTickLabelPadding(7); + setLabelPadding(12); + } else if (type == atBottom) { - setTickLabelPadding( 3 ); - setLabelPadding( 3 ); - } - else if( type == atLeft ) + setTickLabelPadding(3); + setLabelPadding(3); + } else if (type == atLeft) { - setTickLabelPadding( 5 ); - setLabelPadding( 10 ); + setTickLabelPadding(5); + setLabelPadding(10); } } QCPAxis::~QCPAxis() { delete mAxisPainter; - delete mGrid; // delete grid here instead of via parent ~QObject for better defined deletion order + delete mGrid; // delete grid here instead of via parent ~QObject for better defined deletion order } /* No documentation as it is a property getter */ @@ -7714,12 +7592,12 @@ QCPAxis::LabelSide QCPAxis::tickLabelSide() const QString QCPAxis::numberFormat() const { QString result; - result.append( mNumberFormatChar ); - if( mNumberBeautifulPowers ) + result.append(mNumberFormatChar); + if (mNumberBeautifulPowers) { - result.append( QLatin1Char( 'b' ) ); - if( mAxisPainter->numberMultiplyCross ) - result.append( QLatin1Char( 'c' ) ); + result.append(QLatin1Char('b')); + if (mAxisPainter->numberMultiplyCross) + result.append(QLatin1Char('c')); } return result; } @@ -7782,15 +7660,15 @@ QCPLineEnding QCPAxis::upperEnding() const \ref setNumberPrecision */ -void QCPAxis::setScaleType( QCPAxis::ScaleType type ) +void QCPAxis::setScaleType(QCPAxis::ScaleType type) { - if( mScaleType != type ) + if (mScaleType != type) { mScaleType = type; - if( mScaleType == stLogarithmic ) - setRange( mRange.sanitizedForLogScale() ); + if (mScaleType == stLogarithmic) + setRange(mRange.sanitizedForLogScale()); mCachedMarginValid = false; - emit scaleTypeChanged( mScaleType ); + emit scaleTypeChanged(mScaleType); } } @@ -7802,24 +7680,22 @@ void QCPAxis::setScaleType( QCPAxis::ScaleType type ) To invert the direction of an axis, use \ref setRangeReversed. */ -void QCPAxis::setRange( const QCPRange& range ) +void QCPAxis::setRange(const QCPRange &range) { - if( range.lower == mRange.lower && range.upper == mRange.upper ) - return; - - if( !QCPRange::validRange( range ) ) + if (range.lower == mRange.lower && range.upper == mRange.upper) return; + + if (!QCPRange::validRange(range)) return; QCPRange oldRange = mRange; - if( mScaleType == stLogarithmic ) + if (mScaleType == stLogarithmic) { mRange = range.sanitizedForLogScale(); - } - else + } else { mRange = range.sanitizedForLinScale(); } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! @@ -7832,12 +7708,12 @@ void QCPAxis::setRange( const QCPRange& range ) \see SelectablePart, setSelectedParts */ -void QCPAxis::setSelectableParts( const SelectableParts& selectable ) +void QCPAxis::setSelectableParts(const SelectableParts &selectable) { - if( mSelectableParts != selectable ) + if (mSelectableParts != selectable) { mSelectableParts = selectable; - emit selectableChanged( mSelectableParts ); + emit selectableChanged(mSelectableParts); } } @@ -7856,12 +7732,12 @@ void QCPAxis::setSelectableParts( const SelectableParts& selectable ) \see SelectablePart, setSelectableParts, selectTest, setSelectedBasePen, setSelectedTickPen, setSelectedSubTickPen, setSelectedTickLabelFont, setSelectedLabelFont, setSelectedTickLabelColor, setSelectedLabelColor */ -void QCPAxis::setSelectedParts( const SelectableParts& selected ) +void QCPAxis::setSelectedParts(const SelectableParts &selected) { - if( mSelectedParts != selected ) + if (mSelectedParts != selected) { mSelectedParts = selected; - emit selectionChanged( mSelectedParts ); + emit selectionChanged(mSelectedParts); } } @@ -7874,26 +7750,24 @@ void QCPAxis::setSelectedParts( const SelectableParts& selected ) There is also a slot to set a range, see \ref setRange(const QCPRange &range). */ -void QCPAxis::setRange( double lower, double upper ) +void QCPAxis::setRange(double lower, double upper) { - if( lower == mRange.lower && upper == mRange.upper ) - return; - - if( !QCPRange::validRange( lower, upper ) ) + if (lower == mRange.lower && upper == mRange.upper) return; + + if (!QCPRange::validRange(lower, upper)) return; QCPRange oldRange = mRange; mRange.lower = lower; mRange.upper = upper; - if( mScaleType == stLogarithmic ) + if (mScaleType == stLogarithmic) { mRange = mRange.sanitizedForLogScale(); - } - else + } else { mRange = mRange.sanitizedForLinScale(); } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! @@ -7907,60 +7781,58 @@ void QCPAxis::setRange( double lower, double upper ) or center of the range to be aligned with \a position. Any other values of \a alignment will default to Qt::AlignCenter. */ -void QCPAxis::setRange( double position, double size, Qt::AlignmentFlag alignment ) +void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment) { - if( alignment == Qt::AlignLeft ) - setRange( position, position + size ); - else if( alignment == Qt::AlignRight ) - setRange( position - size, position ); - else // alignment == Qt::AlignCenter - setRange( position - size / 2.0, position + size / 2.0 ); + if (alignment == Qt::AlignLeft) + setRange(position, position+size); + else if (alignment == Qt::AlignRight) + setRange(position-size, position); + else // alignment == Qt::AlignCenter + setRange(position-size/2.0, position+size/2.0); } /*! Sets the lower bound of the axis range. The upper bound is not changed. \see setRange */ -void QCPAxis::setRangeLower( double lower ) +void QCPAxis::setRangeLower(double lower) { - if( mRange.lower == lower ) + if (mRange.lower == lower) return; - + QCPRange oldRange = mRange; mRange.lower = lower; - if( mScaleType == stLogarithmic ) + if (mScaleType == stLogarithmic) { mRange = mRange.sanitizedForLogScale(); - } - else + } else { mRange = mRange.sanitizedForLinScale(); } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! Sets the upper bound of the axis range. The lower bound is not changed. \see setRange */ -void QCPAxis::setRangeUpper( double upper ) +void QCPAxis::setRangeUpper(double upper) { - if( mRange.upper == upper ) + if (mRange.upper == upper) return; - + QCPRange oldRange = mRange; mRange.upper = upper; - if( mScaleType == stLogarithmic ) + if (mScaleType == stLogarithmic) { mRange = mRange.sanitizedForLogScale(); - } - else + } else { mRange = mRange.sanitizedForLinScale(); } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! @@ -7972,7 +7844,7 @@ void QCPAxis::setRangeUpper( double upper ) of the \ref setRange interface will still reference the mathematically smaller number than the \a upper part. */ -void QCPAxis::setRangeReversed( bool reversed ) +void QCPAxis::setRangeReversed(bool reversed) { mRangeReversed = reversed; } @@ -7990,9 +7862,9 @@ void QCPAxis::setRangeReversed( bool reversed ) \see ticker */ -void QCPAxis::setTicker( QSharedPointer ticker ) +void QCPAxis::setTicker(QSharedPointer ticker) { - if( ticker ) + if (ticker) mTicker = ticker; else qDebug() << Q_FUNC_INFO << "can not set 0 as axis ticker"; @@ -8007,9 +7879,9 @@ void QCPAxis::setTicker( QSharedPointer ticker ) \see setSubTicks */ -void QCPAxis::setTicks( bool show ) +void QCPAxis::setTicks(bool show) { - if( mTicks != show ) + if (mTicks != show) { mTicks = show; mCachedMarginValid = false; @@ -8019,13 +7891,13 @@ void QCPAxis::setTicks( bool show ) /*! Sets whether tick labels are displayed. Tick labels are the numbers drawn next to tick marks. */ -void QCPAxis::setTickLabels( bool show ) +void QCPAxis::setTickLabels(bool show) { - if( mTickLabels != show ) + if (mTickLabels != show) { mTickLabels = show; mCachedMarginValid = false; - if( !mTickLabels ) + if (!mTickLabels) mTickVectorLabels.clear(); } } @@ -8034,9 +7906,9 @@ void QCPAxis::setTickLabels( bool show ) Sets the distance between the axis base line (including any outward ticks) and the tick labels. \see setLabelPadding, setPadding */ -void QCPAxis::setTickLabelPadding( int padding ) +void QCPAxis::setTickLabelPadding(int padding) { - if( mAxisPainter->tickLabelPadding != padding ) + if (mAxisPainter->tickLabelPadding != padding) { mAxisPainter->tickLabelPadding = padding; mCachedMarginValid = false; @@ -8048,9 +7920,9 @@ void QCPAxis::setTickLabelPadding( int padding ) \see setTickLabels, setTickLabelColor */ -void QCPAxis::setTickLabelFont( const QFont& font ) +void QCPAxis::setTickLabelFont(const QFont &font) { - if( font != mTickLabelFont ) + if (font != mTickLabelFont) { mTickLabelFont = font; mCachedMarginValid = false; @@ -8062,7 +7934,7 @@ void QCPAxis::setTickLabelFont( const QFont& font ) \see setTickLabels, setTickLabelFont */ -void QCPAxis::setTickLabelColor( const QColor& color ) +void QCPAxis::setTickLabelColor(const QColor &color) { mTickLabelColor = color; } @@ -8076,11 +7948,11 @@ void QCPAxis::setTickLabelColor( const QColor& color ) other angles, the label is drawn with an offset such that it seems to point toward or away from the tick mark. */ -void QCPAxis::setTickLabelRotation( double degrees ) +void QCPAxis::setTickLabelRotation(double degrees) { - if( !qFuzzyIsNull( degrees - mAxisPainter->tickLabelRotation ) ) + if (!qFuzzyIsNull(degrees-mAxisPainter->tickLabelRotation)) { - mAxisPainter->tickLabelRotation = qBound( -90.0, degrees, 90.0 ); + mAxisPainter->tickLabelRotation = qBound(-90.0, degrees, 90.0); mCachedMarginValid = false; } } @@ -8092,7 +7964,7 @@ void QCPAxis::setTickLabelRotation( double degrees ) to be inside the axis rect, to save space. If \a side is set to \ref lsInside, the tick labels appear on the inside are additionally clipped to the axis rect. */ -void QCPAxis::setTickLabelSide( LabelSide side ) +void QCPAxis::setTickLabelSide(LabelSide side) { mAxisPainter->tickLabelSide = side; mCachedMarginValid = false; @@ -8128,59 +8000,55 @@ void QCPAxis::setTickLabelSide( LabelSide side ) \li \c hello illegal format code, since first char is not 'e', 'E', 'f', 'g' or 'G'. Current format code will not be changed. */ -void QCPAxis::setNumberFormat( const QString& formatCode ) +void QCPAxis::setNumberFormat(const QString &formatCode) { - if( formatCode.isEmpty() ) + if (formatCode.isEmpty()) { qDebug() << Q_FUNC_INFO << "Passed formatCode is empty"; return; } mCachedMarginValid = false; - + // interpret first char as number format char: - QString allowedFormatChars( QLatin1String( "eEfgG" ) ); - if( allowedFormatChars.contains( formatCode.at( 0 ) ) ) + QString allowedFormatChars(QLatin1String("eEfgG")); + if (allowedFormatChars.contains(formatCode.at(0))) { - mNumberFormatChar = QLatin1Char( formatCode.at( 0 ).toLatin1() ); - } - else + mNumberFormatChar = QLatin1Char(formatCode.at(0).toLatin1()); + } else { qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode; return; } - if( formatCode.length() < 2 ) + if (formatCode.length() < 2) { mNumberBeautifulPowers = false; mAxisPainter->numberMultiplyCross = false; return; } - + // interpret second char as indicator for beautiful decimal powers: - if( formatCode.at( 1 ) == QLatin1Char( 'b' ) && ( mNumberFormatChar == QLatin1Char( 'e' ) || mNumberFormatChar == QLatin1Char( 'g' ) ) ) + if (formatCode.at(1) == QLatin1Char('b') && (mNumberFormatChar == QLatin1Char('e') || mNumberFormatChar == QLatin1Char('g'))) { mNumberBeautifulPowers = true; - } - else + } else { qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode; return; } - if( formatCode.length() < 3 ) + if (formatCode.length() < 3) { mAxisPainter->numberMultiplyCross = false; return; } - + // interpret third char as indicator for dot or cross multiplication symbol: - if( formatCode.at( 2 ) == QLatin1Char( 'c' ) ) + if (formatCode.at(2) == QLatin1Char('c')) { mAxisPainter->numberMultiplyCross = true; - } - else if( formatCode.at( 2 ) == QLatin1Char( 'd' ) ) + } else if (formatCode.at(2) == QLatin1Char('d')) { mAxisPainter->numberMultiplyCross = false; - } - else + } else { qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode; return; @@ -8192,9 +8060,9 @@ void QCPAxis::setNumberFormat( const QString& formatCode ) for details. The effect of precisions are most notably for number Formats starting with 'e', see \ref setNumberFormat */ -void QCPAxis::setNumberPrecision( int precision ) +void QCPAxis::setNumberPrecision(int precision) { - if( mNumberPrecision != precision ) + if (mNumberPrecision != precision) { mNumberPrecision = precision; mCachedMarginValid = false; @@ -8209,10 +8077,10 @@ void QCPAxis::setNumberPrecision( int precision ) \see setSubTickLength, setTickLengthIn, setTickLengthOut */ -void QCPAxis::setTickLength( int inside, int outside ) +void QCPAxis::setTickLength(int inside, int outside) { - setTickLengthIn( inside ); - setTickLengthOut( outside ); + setTickLengthIn(inside); + setTickLengthOut(outside); } /*! @@ -8221,9 +8089,9 @@ void QCPAxis::setTickLength( int inside, int outside ) \see setTickLengthOut, setTickLength, setSubTickLength */ -void QCPAxis::setTickLengthIn( int inside ) +void QCPAxis::setTickLengthIn(int inside) { - if( mAxisPainter->tickLengthIn != inside ) + if (mAxisPainter->tickLengthIn != inside) { mAxisPainter->tickLengthIn = inside; } @@ -8236,12 +8104,12 @@ void QCPAxis::setTickLengthIn( int inside ) \see setTickLengthIn, setTickLength, setSubTickLength */ -void QCPAxis::setTickLengthOut( int outside ) +void QCPAxis::setTickLengthOut(int outside) { - if( mAxisPainter->tickLengthOut != outside ) + if (mAxisPainter->tickLengthOut != outside) { mAxisPainter->tickLengthOut = outside; - mCachedMarginValid = false; // only outside tick length can change margin + mCachedMarginValid = false; // only outside tick length can change margin } } @@ -8252,9 +8120,9 @@ void QCPAxis::setTickLengthOut( int outside ) \see setTicks */ -void QCPAxis::setSubTicks( bool show ) +void QCPAxis::setSubTicks(bool show) { - if( mSubTicks != show ) + if (mSubTicks != show) { mSubTicks = show; mCachedMarginValid = false; @@ -8269,10 +8137,10 @@ void QCPAxis::setSubTicks( bool show ) \see setTickLength, setSubTickLengthIn, setSubTickLengthOut */ -void QCPAxis::setSubTickLength( int inside, int outside ) +void QCPAxis::setSubTickLength(int inside, int outside) { - setSubTickLengthIn( inside ); - setSubTickLengthOut( outside ); + setSubTickLengthIn(inside); + setSubTickLengthOut(outside); } /*! @@ -8281,9 +8149,9 @@ void QCPAxis::setSubTickLength( int inside, int outside ) \see setSubTickLengthOut, setSubTickLength, setTickLength */ -void QCPAxis::setSubTickLengthIn( int inside ) +void QCPAxis::setSubTickLengthIn(int inside) { - if( mAxisPainter->subTickLengthIn != inside ) + if (mAxisPainter->subTickLengthIn != inside) { mAxisPainter->subTickLengthIn = inside; } @@ -8296,12 +8164,12 @@ void QCPAxis::setSubTickLengthIn( int inside ) \see setSubTickLengthIn, setSubTickLength, setTickLength */ -void QCPAxis::setSubTickLengthOut( int outside ) +void QCPAxis::setSubTickLengthOut(int outside) { - if( mAxisPainter->subTickLengthOut != outside ) + if (mAxisPainter->subTickLengthOut != outside) { mAxisPainter->subTickLengthOut = outside; - mCachedMarginValid = false; // only outside tick length can change margin + mCachedMarginValid = false; // only outside tick length can change margin } } @@ -8310,7 +8178,7 @@ void QCPAxis::setSubTickLengthOut( int outside ) \see setTickPen, setSubTickPen */ -void QCPAxis::setBasePen( const QPen& pen ) +void QCPAxis::setBasePen(const QPen &pen) { mBasePen = pen; } @@ -8320,7 +8188,7 @@ void QCPAxis::setBasePen( const QPen& pen ) \see setTickLength, setBasePen */ -void QCPAxis::setTickPen( const QPen& pen ) +void QCPAxis::setTickPen(const QPen &pen) { mTickPen = pen; } @@ -8330,7 +8198,7 @@ void QCPAxis::setTickPen( const QPen& pen ) \see setSubTickCount, setSubTickLength, setBasePen */ -void QCPAxis::setSubTickPen( const QPen& pen ) +void QCPAxis::setSubTickPen(const QPen &pen) { mSubTickPen = pen; } @@ -8340,9 +8208,9 @@ void QCPAxis::setSubTickPen( const QPen& pen ) \see setLabelColor */ -void QCPAxis::setLabelFont( const QFont& font ) +void QCPAxis::setLabelFont(const QFont &font) { - if( mLabelFont != font ) + if (mLabelFont != font) { mLabelFont = font; mCachedMarginValid = false; @@ -8354,7 +8222,7 @@ void QCPAxis::setLabelFont( const QFont& font ) \see setLabelFont */ -void QCPAxis::setLabelColor( const QColor& color ) +void QCPAxis::setLabelColor(const QColor &color) { mLabelColor = color; } @@ -8363,9 +8231,9 @@ void QCPAxis::setLabelColor( const QColor& color ) Sets the text of the axis label that will be shown below/above or next to the axis, depending on its orientation. To disable axis labels, pass an empty string as \a str. */ -void QCPAxis::setLabel( const QString& str ) +void QCPAxis::setLabel(const QString &str) { - if( mLabel != str ) + if (mLabel != str) { mLabel = str; mCachedMarginValid = false; @@ -8377,9 +8245,9 @@ void QCPAxis::setLabel( const QString& str ) \see setTickLabelPadding, setPadding */ -void QCPAxis::setLabelPadding( int padding ) +void QCPAxis::setLabelPadding(int padding) { - if( mAxisPainter->labelPadding != padding ) + if (mAxisPainter->labelPadding != padding) { mAxisPainter->labelPadding = padding; mCachedMarginValid = false; @@ -8396,9 +8264,9 @@ void QCPAxis::setLabelPadding( int padding ) \see setLabelPadding, setTickLabelPadding */ -void QCPAxis::setPadding( int padding ) +void QCPAxis::setPadding(int padding) { - if( mPadding != padding ) + if (mPadding != padding) { mPadding = padding; mCachedMarginValid = false; @@ -8413,7 +8281,7 @@ void QCPAxis::setPadding( int padding ) offset of the other, outer axes is controlled automatically, to place them at appropriate positions. */ -void QCPAxis::setOffset( int offset ) +void QCPAxis::setOffset(int offset) { mAxisPainter->offset = offset; } @@ -8423,9 +8291,9 @@ void QCPAxis::setOffset( int offset ) \see setTickLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedTickLabelFont( const QFont& font ) +void QCPAxis::setSelectedTickLabelFont(const QFont &font) { - if( font != mSelectedTickLabelFont ) + if (font != mSelectedTickLabelFont) { mSelectedTickLabelFont = font; // don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts @@ -8437,7 +8305,7 @@ void QCPAxis::setSelectedTickLabelFont( const QFont& font ) \see setLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedLabelFont( const QFont& font ) +void QCPAxis::setSelectedLabelFont(const QFont &font) { mSelectedLabelFont = font; // don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts @@ -8448,9 +8316,9 @@ void QCPAxis::setSelectedLabelFont( const QFont& font ) \see setTickLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedTickLabelColor( const QColor& color ) +void QCPAxis::setSelectedTickLabelColor(const QColor &color) { - if( color != mSelectedTickLabelColor ) + if (color != mSelectedTickLabelColor) { mSelectedTickLabelColor = color; } @@ -8461,7 +8329,7 @@ void QCPAxis::setSelectedTickLabelColor( const QColor& color ) \see setLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedLabelColor( const QColor& color ) +void QCPAxis::setSelectedLabelColor(const QColor &color) { mSelectedLabelColor = color; } @@ -8471,7 +8339,7 @@ void QCPAxis::setSelectedLabelColor( const QColor& color ) \see setBasePen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedBasePen( const QPen& pen ) +void QCPAxis::setSelectedBasePen(const QPen &pen) { mSelectedBasePen = pen; } @@ -8481,7 +8349,7 @@ void QCPAxis::setSelectedBasePen( const QPen& pen ) \see setTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedTickPen( const QPen& pen ) +void QCPAxis::setSelectedTickPen(const QPen &pen) { mSelectedTickPen = pen; } @@ -8491,7 +8359,7 @@ void QCPAxis::setSelectedTickPen( const QPen& pen ) \see setSubTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions */ -void QCPAxis::setSelectedSubTickPen( const QPen& pen ) +void QCPAxis::setSelectedSubTickPen(const QPen &pen) { mSelectedSubTickPen = pen; } @@ -8506,7 +8374,7 @@ void QCPAxis::setSelectedSubTickPen( const QPen& pen ) \see setUpperEnding */ -void QCPAxis::setLowerEnding( const QCPLineEnding& ending ) +void QCPAxis::setLowerEnding(const QCPLineEnding &ending) { mAxisPainter->lowerEnding = ending; } @@ -8521,7 +8389,7 @@ void QCPAxis::setLowerEnding( const QCPLineEnding& ending ) \see setLowerEnding */ -void QCPAxis::setUpperEnding( const QCPLineEnding& ending ) +void QCPAxis::setUpperEnding(const QCPLineEnding &ending) { mAxisPainter->upperEnding = ending; } @@ -8533,21 +8401,20 @@ void QCPAxis::setUpperEnding( const QCPLineEnding& ending ) If the scale type is \ref stLogarithmic, the range bounds are multiplied by \a diff. This corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff). */ -void QCPAxis::moveRange( double diff ) +void QCPAxis::moveRange(double diff) { QCPRange oldRange = mRange; - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { mRange.lower += diff; mRange.upper += diff; - } - else // mScaleType == stLogarithmic + } else // mScaleType == stLogarithmic { mRange.lower *= diff; mRange.upper *= diff; } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! @@ -8559,9 +8426,9 @@ void QCPAxis::moveRange( double diff ) If you wish to scale around a different coordinate than the current axis range center, use the overload \ref scaleRange(double factor, double center). */ -void QCPAxis::scaleRange( double factor ) +void QCPAxis::scaleRange(double factor) { - scaleRange( factor, range().center() ); + scaleRange(factor, range().center()); } /*! \overload @@ -8573,32 +8440,30 @@ void QCPAxis::scaleRange( double factor ) \see scaleRange(double factor) */ -void QCPAxis::scaleRange( double factor, double center ) +void QCPAxis::scaleRange(double factor, double center) { QCPRange oldRange = mRange; - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { QCPRange newRange; - newRange.lower = ( mRange.lower - center ) * factor + center; - newRange.upper = ( mRange.upper - center ) * factor + center; - if( QCPRange::validRange( newRange ) ) + newRange.lower = (mRange.lower-center)*factor + center; + newRange.upper = (mRange.upper-center)*factor + center; + if (QCPRange::validRange(newRange)) mRange = newRange.sanitizedForLinScale(); - } - else // mScaleType == stLogarithmic + } else // mScaleType == stLogarithmic { - if( ( mRange.upper < 0 && center < 0 ) || ( mRange.upper > 0 && center > 0 ) ) // make sure center has same sign as range + if ((mRange.upper < 0 && center < 0) || (mRange.upper > 0 && center > 0)) // make sure center has same sign as range { QCPRange newRange; - newRange.lower = qPow( mRange.lower / center, factor ) * center; - newRange.upper = qPow( mRange.upper / center, factor ) * center; - if( QCPRange::validRange( newRange ) ) + newRange.lower = qPow(mRange.lower/center, factor)*center; + newRange.upper = qPow(mRange.upper/center, factor)*center; + if (QCPRange::validRange(newRange)) mRange = newRange.sanitizedForLogScale(); - } - else + } else qDebug() << Q_FUNC_INFO << "Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center; } - emit rangeChanged( mRange ); - emit rangeChanged( mRange, oldRange ); + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); } /*! @@ -8614,22 +8479,22 @@ void QCPAxis::scaleRange( double factor, double center ) won't have the desired effect, since the widget dimensions aren't defined yet, and a resizeEvent will follow. */ -void QCPAxis::setScaleRatio( const QCPAxis* otherAxis, double ratio ) +void QCPAxis::setScaleRatio(const QCPAxis *otherAxis, double ratio) { int otherPixelSize, ownPixelSize; - - if( otherAxis->orientation() == Qt::Horizontal ) + + if (otherAxis->orientation() == Qt::Horizontal) otherPixelSize = otherAxis->axisRect()->width(); else otherPixelSize = otherAxis->axisRect()->height(); - - if( orientation() == Qt::Horizontal ) + + if (orientation() == Qt::Horizontal) ownPixelSize = axisRect()->width(); else ownPixelSize = axisRect()->height(); - - double newRangeSize = ratio * otherAxis->range().size() * ownPixelSize / (double)otherPixelSize; - setRange( range().center(), newRangeSize, Qt::AlignCenter ); + + double newRangeSize = ratio*otherAxis->range().size()*ownPixelSize/(double)otherPixelSize; + setRange(range().center(), newRangeSize, Qt::AlignCenter); } /*! @@ -8638,90 +8503,86 @@ void QCPAxis::setScaleRatio( const QCPAxis* otherAxis, double ratio ) \see QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes */ -void QCPAxis::rescale( bool onlyVisiblePlottables ) +void QCPAxis::rescale(bool onlyVisiblePlottables) { QList p = plottables(); QCPRange newRange; bool haveRange = false; - for( int i = 0; i < p.size(); ++i ) + for (int i=0; irealVisibility() && onlyVisiblePlottables ) + if (!p.at(i)->realVisibility() && onlyVisiblePlottables) continue; QCPRange plottableRange; bool currentFoundRange; QCP::SignDomain signDomain = QCP::sdBoth; - if( mScaleType == stLogarithmic ) - signDomain = ( mRange.upper < 0 ? QCP::sdNegative : QCP::sdPositive ); - if( p.at( i )->keyAxis() == this ) - plottableRange = p.at( i )->getKeyRange( currentFoundRange, signDomain ); + if (mScaleType == stLogarithmic) + signDomain = (mRange.upper < 0 ? QCP::sdNegative : QCP::sdPositive); + if (p.at(i)->keyAxis() == this) + plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain); else - plottableRange = p.at( i )->getValueRange( currentFoundRange, signDomain ); - if( currentFoundRange ) + plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain); + if (currentFoundRange) { - if( !haveRange ) + if (!haveRange) newRange = plottableRange; else - newRange.expand( plottableRange ); + newRange.expand(plottableRange); haveRange = true; } } - if( haveRange ) + if (haveRange) { - if( !QCPRange::validRange( newRange ) ) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable { - double center = ( newRange.lower + newRange.upper ) * 0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason - if( mScaleType == stLinear ) + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mScaleType == stLinear) { - newRange.lower = center - mRange.size() / 2.0; - newRange.upper = center + mRange.size() / 2.0; - } - else // mScaleType == stLogarithmic + newRange.lower = center-mRange.size()/2.0; + newRange.upper = center+mRange.size()/2.0; + } else // mScaleType == stLogarithmic { - newRange.lower = center / qSqrt( mRange.upper / mRange.lower ); - newRange.upper = center * qSqrt( mRange.upper / mRange.lower ); + newRange.lower = center/qSqrt(mRange.upper/mRange.lower); + newRange.upper = center*qSqrt(mRange.upper/mRange.lower); } } - setRange( newRange ); + setRange(newRange); } } /*! Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates. */ -double QCPAxis::pixelToCoord( double value ) const +double QCPAxis::pixelToCoord(double value) const { - if( orientation() == Qt::Horizontal ) + if (orientation() == Qt::Horizontal) { - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { - if( !mRangeReversed ) - return ( value - mAxisRect->left() ) / (double)mAxisRect->width() * mRange.size() + mRange.lower; + if (!mRangeReversed) + return (value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.lower; else - return -( value - mAxisRect->left() ) / (double)mAxisRect->width() * mRange.size() + mRange.upper; - } - else // mScaleType == stLogarithmic + return -(value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.upper; + } else // mScaleType == stLogarithmic { - if( !mRangeReversed ) - return qPow( mRange.upper / mRange.lower, ( value - mAxisRect->left() ) / (double)mAxisRect->width() ) * mRange.lower; + if (!mRangeReversed) + return qPow(mRange.upper/mRange.lower, (value-mAxisRect->left())/(double)mAxisRect->width())*mRange.lower; else - return qPow( mRange.upper / mRange.lower, ( mAxisRect->left() - value ) / (double)mAxisRect->width() ) * mRange.upper; + return qPow(mRange.upper/mRange.lower, (mAxisRect->left()-value)/(double)mAxisRect->width())*mRange.upper; } - } - else // orientation() == Qt::Vertical + } else // orientation() == Qt::Vertical { - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { - if( !mRangeReversed ) - return ( mAxisRect->bottom() - value ) / (double)mAxisRect->height() * mRange.size() + mRange.lower; + if (!mRangeReversed) + return (mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.lower; else - return -( mAxisRect->bottom() - value ) / (double)mAxisRect->height() * mRange.size() + mRange.upper; - } - else // mScaleType == stLogarithmic + return -(mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.upper; + } else // mScaleType == stLogarithmic { - if( !mRangeReversed ) - return qPow( mRange.upper / mRange.lower, ( mAxisRect->bottom() - value ) / (double)mAxisRect->height() ) * mRange.lower; + if (!mRangeReversed) + return qPow(mRange.upper/mRange.lower, (mAxisRect->bottom()-value)/(double)mAxisRect->height())*mRange.lower; else - return qPow( mRange.upper / mRange.lower, ( value - mAxisRect->bottom() ) / (double)mAxisRect->height() ) * mRange.upper; + return qPow(mRange.upper/mRange.lower, (value-mAxisRect->bottom())/(double)mAxisRect->height())*mRange.upper; } } } @@ -8729,53 +8590,50 @@ double QCPAxis::pixelToCoord( double value ) const /*! Transforms \a value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget. */ -double QCPAxis::coordToPixel( double value ) const +double QCPAxis::coordToPixel(double value) const { - if( orientation() == Qt::Horizontal ) + if (orientation() == Qt::Horizontal) { - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { - if( !mRangeReversed ) - return ( value - mRange.lower ) / mRange.size() * mAxisRect->width() + mAxisRect->left(); + if (!mRangeReversed) + return (value-mRange.lower)/mRange.size()*mAxisRect->width()+mAxisRect->left(); else - return ( mRange.upper - value ) / mRange.size() * mAxisRect->width() + mAxisRect->left(); - } - else // mScaleType == stLogarithmic + return (mRange.upper-value)/mRange.size()*mAxisRect->width()+mAxisRect->left(); + } else // mScaleType == stLogarithmic { - if( value >= 0.0 && mRange.upper < 0.0 ) // invalid value for logarithmic scale, just draw it outside visible range - return !mRangeReversed ? mAxisRect->right() + 200 : mAxisRect->left() - 200; - else if( value <= 0.0 && mRange.upper >= 0.0 ) // invalid value for logarithmic scale, just draw it outside visible range - return !mRangeReversed ? mAxisRect->left() - 200 : mAxisRect->right() + 200; + if (value >= 0.0 && mRange.upper < 0.0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->right()+200 : mAxisRect->left()-200; + else if (value <= 0.0 && mRange.upper >= 0.0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->left()-200 : mAxisRect->right()+200; else { - if( !mRangeReversed ) - return qLn( value / mRange.lower ) / qLn( mRange.upper / mRange.lower ) * mAxisRect->width() + mAxisRect->left(); + if (!mRangeReversed) + return qLn(value/mRange.lower)/qLn(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left(); else - return qLn( mRange.upper / value ) / qLn( mRange.upper / mRange.lower ) * mAxisRect->width() + mAxisRect->left(); + return qLn(mRange.upper/value)/qLn(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left(); } } - } - else // orientation() == Qt::Vertical + } else // orientation() == Qt::Vertical { - if( mScaleType == stLinear ) + if (mScaleType == stLinear) { - if( !mRangeReversed ) - return mAxisRect->bottom() - ( value - mRange.lower ) / mRange.size() * mAxisRect->height(); + if (!mRangeReversed) + return mAxisRect->bottom()-(value-mRange.lower)/mRange.size()*mAxisRect->height(); else - return mAxisRect->bottom() - ( mRange.upper - value ) / mRange.size() * mAxisRect->height(); - } - else // mScaleType == stLogarithmic + return mAxisRect->bottom()-(mRange.upper-value)/mRange.size()*mAxisRect->height(); + } else // mScaleType == stLogarithmic { - if( value >= 0.0 && mRange.upper < 0.0 ) // invalid value for logarithmic scale, just draw it outside visible range - return !mRangeReversed ? mAxisRect->top() - 200 : mAxisRect->bottom() + 200; - else if( value <= 0.0 && mRange.upper >= 0.0 ) // invalid value for logarithmic scale, just draw it outside visible range - return !mRangeReversed ? mAxisRect->bottom() + 200 : mAxisRect->top() - 200; + if (value >= 0.0 && mRange.upper < 0.0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->top()-200 : mAxisRect->bottom()+200; + else if (value <= 0.0 && mRange.upper >= 0.0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->bottom()+200 : mAxisRect->top()-200; else { - if( !mRangeReversed ) - return mAxisRect->bottom() - qLn( value / mRange.lower ) / qLn( mRange.upper / mRange.lower ) * mAxisRect->height(); + if (!mRangeReversed) + return mAxisRect->bottom()-qLn(value/mRange.lower)/qLn(mRange.upper/mRange.lower)*mAxisRect->height(); else - return mAxisRect->bottom() - qLn( mRange.upper / value ) / qLn( mRange.upper / mRange.lower ) * mAxisRect->height(); + return mAxisRect->bottom()-qLn(mRange.upper/value)/qLn(mRange.upper/mRange.lower)*mAxisRect->height(); } } } @@ -8790,33 +8648,32 @@ double QCPAxis::coordToPixel( double value ) const \see setSelectedParts, setSelectableParts, QCustomPlot::setInteractions */ -QCPAxis::SelectablePart QCPAxis::getPartAt( const QPointF& pos ) const +QCPAxis::SelectablePart QCPAxis::getPartAt(const QPointF &pos) const { - if( !mVisible ) + if (!mVisible) return spNone; - - if( mAxisPainter->axisSelectionBox().contains( pos.toPoint() ) ) + + if (mAxisPainter->axisSelectionBox().contains(pos.toPoint())) return spAxis; - else if( mAxisPainter->tickLabelsSelectionBox().contains( pos.toPoint() ) ) + else if (mAxisPainter->tickLabelsSelectionBox().contains(pos.toPoint())) return spTickLabels; - else if( mAxisPainter->labelSelectionBox().contains( pos.toPoint() ) ) + else if (mAxisPainter->labelSelectionBox().contains(pos.toPoint())) return spAxisLabel; else return spNone; } /* inherits documentation from base class */ -double QCPAxis::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPAxis::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( !mParentPlot ) + if (!mParentPlot) return -1; + SelectablePart part = getPartAt(pos); + if ((onlySelectable && !mSelectableParts.testFlag(part)) || part == spNone) return -1; - SelectablePart part = getPartAt( pos ); - if( ( onlySelectable && !mSelectableParts.testFlag( part ) ) || part == spNone ) - return -1; - - if( details ) - details->setValue( part ); - return mParentPlot->selectionTolerance() * 0.99; + + if (details) + details->setValue(part); + return mParentPlot->selectionTolerance()*0.99; } /*! @@ -8829,13 +8686,12 @@ double QCPAxis::selectTest( const QPointF& pos, bool onlySelectable, QVariant* d QList QCPAxis::plottables() const { QList result; - if( !mParentPlot ) - return result; - - for( int i = 0; i < mParentPlot->mPlottables.size(); ++i ) + if (!mParentPlot) return result; + + for (int i=0; imPlottables.size(); ++i) { - if( mParentPlot->mPlottables.at( i )->keyAxis() == this || mParentPlot->mPlottables.at( i )->valueAxis() == this ) - result.append( mParentPlot->mPlottables.at( i ) ); + if (mParentPlot->mPlottables.at(i)->keyAxis() == this ||mParentPlot->mPlottables.at(i)->valueAxis() == this) + result.append(mParentPlot->mPlottables.at(i)); } return result; } @@ -8848,13 +8704,12 @@ QList QCPAxis::plottables() const QList QCPAxis::graphs() const { QList result; - if( !mParentPlot ) - return result; - - for( int i = 0; i < mParentPlot->mGraphs.size(); ++i ) + if (!mParentPlot) return result; + + for (int i=0; imGraphs.size(); ++i) { - if( mParentPlot->mGraphs.at( i )->keyAxis() == this || mParentPlot->mGraphs.at( i )->valueAxis() == this ) - result.append( mParentPlot->mGraphs.at( i ) ); + if (mParentPlot->mGraphs.at(i)->keyAxis() == this || mParentPlot->mGraphs.at(i)->valueAxis() == this) + result.append(mParentPlot->mGraphs.at(i)); } return result; } @@ -8868,17 +8723,16 @@ QList QCPAxis::graphs() const QList QCPAxis::items() const { QList result; - if( !mParentPlot ) - return result; - - for( int itemId = 0; itemId < mParentPlot->mItems.size(); ++itemId ) + if (!mParentPlot) return result; + + for (int itemId=0; itemIdmItems.size(); ++itemId) { - QList positions = mParentPlot->mItems.at( itemId )->positions(); - for( int posId = 0; posId < positions.size(); ++posId ) + QList positions = mParentPlot->mItems.at(itemId)->positions(); + for (int posId=0; posIdkeyAxis() == this || positions.at( posId )->valueAxis() == this ) + if (positions.at(posId)->keyAxis() == this || positions.at(posId)->valueAxis() == this) { - result.append( mParentPlot->mItems.at( itemId ) ); + result.append(mParentPlot->mItems.at(itemId)); break; } } @@ -8890,20 +8744,15 @@ QList QCPAxis::items() const Transforms a margin side to the logically corresponding axis type. (QCP::msLeft to QCPAxis::atLeft, QCP::msRight to QCPAxis::atRight, etc.) */ -QCPAxis::AxisType QCPAxis::marginSideToAxisType( QCP::MarginSide side ) +QCPAxis::AxisType QCPAxis::marginSideToAxisType(QCP::MarginSide side) { - switch( side ) + switch (side) { - case QCP::msLeft: - return atLeft; - case QCP::msRight: - return atRight; - case QCP::msTop: - return atTop; - case QCP::msBottom: - return atBottom; - default: - break; + case QCP::msLeft: return atLeft; + case QCP::msRight: return atRight; + case QCP::msTop: return atTop; + case QCP::msBottom: return atBottom; + default: break; } qDebug() << Q_FUNC_INFO << "Invalid margin side passed:" << (int)side; return atLeft; @@ -8912,49 +8761,38 @@ QCPAxis::AxisType QCPAxis::marginSideToAxisType( QCP::MarginSide side ) /*! Returns the axis type that describes the opposite axis of an axis with the specified \a type. */ -QCPAxis::AxisType QCPAxis::opposite( QCPAxis::AxisType type ) +QCPAxis::AxisType QCPAxis::opposite(QCPAxis::AxisType type) { - switch( type ) + switch (type) { - case atLeft: - return atRight; - break; - case atRight: - return atLeft; - break; - case atBottom: - return atTop; - break; - case atTop: - return atBottom; - break; - default: - qDebug() << Q_FUNC_INFO << "invalid axis type"; - return atLeft; - break; + case atLeft: return atRight; break; + case atRight: return atLeft; break; + case atBottom: return atTop; break; + case atTop: return atBottom; break; + default: qDebug() << Q_FUNC_INFO << "invalid axis type"; return atLeft; break; } } /* inherits documentation from base class */ -void QCPAxis::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPAxis::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) + Q_UNUSED(event) SelectablePart part = details.value(); - if( mSelectableParts.testFlag( part ) ) + if (mSelectableParts.testFlag(part)) { SelectableParts selBefore = mSelectedParts; - setSelectedParts( additive ? mSelectedParts ^ part : part ); - if( selectionStateChanged ) + setSelectedParts(additive ? mSelectedParts^part : part); + if (selectionStateChanged) *selectionStateChanged = mSelectedParts != selBefore; } } /* inherits documentation from base class */ -void QCPAxis::deselectEvent( bool* selectionStateChanged ) +void QCPAxis::deselectEvent(bool *selectionStateChanged) { SelectableParts selBefore = mSelectedParts; - setSelectedParts( mSelectedParts & ~mSelectableParts ); - if( selectionStateChanged ) + setSelectedParts(mSelectedParts & ~mSelectableParts); + if (selectionStateChanged) *selectionStateChanged = mSelectedParts != selBefore; } @@ -8973,28 +8811,28 @@ void QCPAxis::deselectEvent( bool* selectionStateChanged ) \note The dragging of possibly multiple axes at once by starting the drag anywhere in the axis rect is handled by the axis rect's mouse event, e.g. \ref QCPAxisRect::mousePressEvent. */ -void QCPAxis::mousePressEvent( QMouseEvent* event, const QVariant& details ) +void QCPAxis::mousePressEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) - if( !mParentPlot->interactions().testFlag( QCP::iRangeDrag ) || - !mAxisRect->rangeDrag().testFlag( orientation() ) || - !mAxisRect->rangeDragAxes( orientation() ).contains( this ) ) + Q_UNUSED(details) + if (!mParentPlot->interactions().testFlag(QCP::iRangeDrag) || + !mAxisRect->rangeDrag().testFlag(orientation()) || + !mAxisRect->rangeDragAxes(orientation()).contains(this)) { event->ignore(); return; } - - if( event->buttons() & Qt::LeftButton ) + + if (event->buttons() & Qt::LeftButton) { mDragging = true; // initialize antialiasing backup in case we start dragging: - if( mParentPlot->noAntialiasingOnDrag() ) + if (mParentPlot->noAntialiasingOnDrag()) { mAADragBackup = mParentPlot->antialiasedElements(); mNotAADragBackup = mParentPlot->notAntialiasedElements(); } // Mouse range dragging interaction: - if( mParentPlot->interactions().testFlag( QCP::iRangeDrag ) ) + if (mParentPlot->interactions().testFlag(QCP::iRangeDrag)) mDragStartRange = mRange; } } @@ -9011,26 +8849,25 @@ void QCPAxis::mousePressEvent( QMouseEvent* event, const QVariant& details ) \see QCPAxis::mousePressEvent */ -void QCPAxis::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPAxis::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) { - if( mDragging ) + if (mDragging) { const double startPixel = orientation() == Qt::Horizontal ? startPos.x() : startPos.y(); const double currentPixel = orientation() == Qt::Horizontal ? event->pos().x() : event->pos().y(); - if( mScaleType == QCPAxis::stLinear ) + if (mScaleType == QCPAxis::stLinear) { - const double diff = pixelToCoord( startPixel ) - pixelToCoord( currentPixel ); - setRange( mDragStartRange.lower + diff, mDragStartRange.upper + diff ); - } - else if( mScaleType == QCPAxis::stLogarithmic ) + const double diff = pixelToCoord(startPixel) - pixelToCoord(currentPixel); + setRange(mDragStartRange.lower+diff, mDragStartRange.upper+diff); + } else if (mScaleType == QCPAxis::stLogarithmic) { - const double diff = pixelToCoord( startPixel ) / pixelToCoord( currentPixel ); - setRange( mDragStartRange.lower * diff, mDragStartRange.upper * diff ); + const double diff = pixelToCoord(startPixel) / pixelToCoord(currentPixel); + setRange(mDragStartRange.lower*diff, mDragStartRange.upper*diff); } - - if( mParentPlot->noAntialiasingOnDrag() ) - mParentPlot->setNotAntialiasedElements( QCP::aeAll ); - mParentPlot->replot( QCustomPlot::rpQueuedReplot ); + + if (mParentPlot->noAntialiasingOnDrag()) + mParentPlot->setNotAntialiasedElements(QCP::aeAll); + mParentPlot->replot(QCustomPlot::rpQueuedReplot); } } @@ -9046,15 +8883,15 @@ void QCPAxis::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) \see QCPAxis::mousePressEvent */ -void QCPAxis::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPAxis::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) { - Q_UNUSED( event ) - Q_UNUSED( startPos ) + Q_UNUSED(event) + Q_UNUSED(startPos) mDragging = false; - if( mParentPlot->noAntialiasingOnDrag() ) + if (mParentPlot->noAntialiasingOnDrag()) { - mParentPlot->setAntialiasedElements( mAADragBackup ); - mParentPlot->setNotAntialiasedElements( mNotAADragBackup ); + mParentPlot->setAntialiasedElements(mAADragBackup); + mParentPlot->setNotAntialiasedElements(mNotAADragBackup); } } @@ -9073,20 +8910,20 @@ void QCPAxis::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) \note The zooming of possibly multiple axes at once by performing the wheel event anywhere in the axis rect is handled by the axis rect's mouse event, e.g. \ref QCPAxisRect::wheelEvent. */ -void QCPAxis::wheelEvent( QWheelEvent* event ) +void QCPAxis::wheelEvent(QWheelEvent *event) { // Mouse range zooming interaction: - if( !mParentPlot->interactions().testFlag( QCP::iRangeZoom ) || - !mAxisRect->rangeZoom().testFlag( orientation() ) || - !mAxisRect->rangeZoomAxes( orientation() ).contains( this ) ) + if (!mParentPlot->interactions().testFlag(QCP::iRangeZoom) || + !mAxisRect->rangeZoom().testFlag(orientation()) || + !mAxisRect->rangeZoomAxes(orientation()).contains(this)) { event->ignore(); return; } - - const double wheelSteps = event->delta() / 120.0; // a single step delta is +/-120 usually - const double factor = qPow( mAxisRect->rangeZoomFactor( orientation() ), wheelSteps ); - scaleRange( factor, pixelToCoord( orientation() == Qt::Horizontal ? event->pos().x() : event->pos().y() ) ); + + const double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually + const double factor = qPow(mAxisRect->rangeZoomFactor(orientation()), wheelSteps); + scaleRange(factor, pixelToCoord(orientation() == Qt::Horizontal ? event->pos().x() : event->pos().y())); mParentPlot->replot(); } @@ -9105,9 +8942,9 @@ void QCPAxis::wheelEvent( QWheelEvent* event ) \see setAntialiased */ -void QCPAxis::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPAxis::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeAxes ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeAxes); } /*! \internal @@ -9116,32 +8953,32 @@ void QCPAxis::applyDefaultAntialiasingHint( QCPPainter* painter ) const \seebaseclassmethod */ -void QCPAxis::draw( QCPPainter* painter ) +void QCPAxis::draw(QCPPainter *painter) { - QVector subTickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter - QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter - QVector tickLabels; // the final vector passed to QCPAxisPainter - tickPositions.reserve( mTickVector.size() ); - tickLabels.reserve( mTickVector.size() ); - subTickPositions.reserve( mSubTickVector.size() ); - - if( mTicks ) + QVector subTickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(mTickVector.size()); + tickLabels.reserve(mTickVector.size()); + subTickPositions.reserve(mSubTickVector.size()); + + if (mTicks) { - for( int i = 0; i < mTickVector.size(); ++i ) + for (int i=0; itype = mAxisType; @@ -9161,7 +8998,7 @@ void QCPAxis::draw( QCPPainter* painter ) mAxisPainter->tickPositions = tickPositions; mAxisPainter->tickLabels = tickLabels; mAxisPainter->subTickPositions = subTickPositions; - mAxisPainter->draw( painter ); + mAxisPainter->draw(painter); } /*! \internal @@ -9174,14 +9011,12 @@ void QCPAxis::draw( QCPPainter* painter ) */ void QCPAxis::setupTickVectors() { - if( !mParentPlot ) - return; - if( ( !mTicks && !mTickLabels && !mGrid->visible() ) || mRange.size() <= 0 ) - return; - + if (!mParentPlot) return; + if ((!mTicks && !mTickLabels && !mGrid->visible()) || mRange.size() <= 0) return; + QVector oldLabels = mTickVectorLabels; - mTicker->generate( mRange, mParentPlot->locale(), mNumberFormatChar, mNumberPrecision, mTickVector, mSubTicks ? &mSubTickVector : 0, mTickLabels ? &mTickVectorLabels : 0 ); - mCachedMarginValid &= mTickVectorLabels == oldLabels; // if labels have changed, margin might have changed, too + mTicker->generate(mRange, mParentPlot->locale(), mNumberFormatChar, mNumberPrecision, mTickVector, mSubTicks ? &mSubTickVector : 0, mTickLabels ? &mTickVectorLabels : 0); + mCachedMarginValid &= mTickVectorLabels == oldLabels; // if labels have changed, margin might have changed, too } /*! \internal @@ -9191,7 +9026,7 @@ void QCPAxis::setupTickVectors() */ QPen QCPAxis::getBasePen() const { - return mSelectedParts.testFlag( spAxis ) ? mSelectedBasePen : mBasePen; + return mSelectedParts.testFlag(spAxis) ? mSelectedBasePen : mBasePen; } /*! \internal @@ -9201,7 +9036,7 @@ QPen QCPAxis::getBasePen() const */ QPen QCPAxis::getTickPen() const { - return mSelectedParts.testFlag( spAxis ) ? mSelectedTickPen : mTickPen; + return mSelectedParts.testFlag(spAxis) ? mSelectedTickPen : mTickPen; } /*! \internal @@ -9211,7 +9046,7 @@ QPen QCPAxis::getTickPen() const */ QPen QCPAxis::getSubTickPen() const { - return mSelectedParts.testFlag( spAxis ) ? mSelectedSubTickPen : mSubTickPen; + return mSelectedParts.testFlag(spAxis) ? mSelectedSubTickPen : mSubTickPen; } /*! \internal @@ -9221,7 +9056,7 @@ QPen QCPAxis::getSubTickPen() const */ QFont QCPAxis::getTickLabelFont() const { - return mSelectedParts.testFlag( spTickLabels ) ? mSelectedTickLabelFont : mTickLabelFont; + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelFont : mTickLabelFont; } /*! \internal @@ -9231,7 +9066,7 @@ QFont QCPAxis::getTickLabelFont() const */ QFont QCPAxis::getLabelFont() const { - return mSelectedParts.testFlag( spAxisLabel ) ? mSelectedLabelFont : mLabelFont; + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelFont : mLabelFont; } /*! \internal @@ -9241,7 +9076,7 @@ QFont QCPAxis::getLabelFont() const */ QColor QCPAxis::getTickLabelColor() const { - return mSelectedParts.testFlag( spTickLabels ) ? mSelectedTickLabelColor : mTickLabelColor; + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelColor : mTickLabelColor; } /*! \internal @@ -9251,7 +9086,7 @@ QColor QCPAxis::getTickLabelColor() const */ QColor QCPAxis::getLabelColor() const { - return mSelectedParts.testFlag( spAxisLabel ) ? mSelectedLabelColor : mLabelColor; + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelColor : mLabelColor; } /*! \internal @@ -9270,27 +9105,27 @@ QColor QCPAxis::getLabelColor() const */ int QCPAxis::calculateMargin() { - if( !mVisible ) // if not visible, directly return 0, don't cache 0 because we can't react to setVisible in QCPAxis + if (!mVisible) // if not visible, directly return 0, don't cache 0 because we can't react to setVisible in QCPAxis return 0; - - if( mCachedMarginValid ) + + if (mCachedMarginValid) return mCachedMargin; - + // run through similar steps as QCPAxis::draw, and calculate margin needed to fit axis and its labels int margin = 0; - - QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter - QVector tickLabels; // the final vector passed to QCPAxisPainter - tickPositions.reserve( mTickVector.size() ); - tickLabels.reserve( mTickVector.size() ); - - if( mTicks ) + + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(mTickVector.size()); + tickLabels.reserve(mTickVector.size()); + + if (mTicks) { - for( int i = 0; i < mTickVector.size(); ++i ) + for (int i=0; isetPen( basePen ); - if( QCPAxis::orientation( type ) == Qt::Horizontal ) - baseLine.setPoints( origin + QPointF( xCor, yCor ), origin + QPointF( axisRect.width() + xCor, yCor ) ); + painter->setPen(basePen); + if (QCPAxis::orientation(type) == Qt::Horizontal) + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(axisRect.width()+xCor, yCor)); else - baseLine.setPoints( origin + QPointF( xCor, yCor ), origin + QPointF( xCor, -axisRect.height() + yCor ) ); - if( reversedEndings ) - baseLine = QLineF( baseLine.p2(), baseLine.p1() ); // won't make a difference for line itself, but for line endings later - painter->drawLine( baseLine ); - + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -axisRect.height()+yCor)); + if (reversedEndings) + baseLine = QLineF(baseLine.p2(), baseLine.p1()); // won't make a difference for line itself, but for line endings later + painter->drawLine(baseLine); + // draw ticks: - if( !tickPositions.isEmpty() ) + if (!tickPositions.isEmpty()) { - painter->setPen( tickPen ); - int tickDir = ( type == QCPAxis::atBottom || type == QCPAxis::atRight ) ? -1 : 1; // direction of ticks ("inward" is right for left axis and left for right axis) - if( QCPAxis::orientation( type ) == Qt::Horizontal ) + painter->setPen(tickPen); + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; // direction of ticks ("inward" is right for left axis and left for right axis) + if (QCPAxis::orientation(type) == Qt::Horizontal) { - for( int i = 0; i < tickPositions.size(); ++i ) - painter->drawLine( QLineF( tickPositions.at( i ) + xCor, origin.y() - tickLengthOut * tickDir + yCor, tickPositions.at( i ) + xCor, origin.y() + tickLengthIn * tickDir + yCor ) ); - } - else + for (int i=0; idrawLine(QLineF(tickPositions.at(i)+xCor, origin.y()-tickLengthOut*tickDir+yCor, tickPositions.at(i)+xCor, origin.y()+tickLengthIn*tickDir+yCor)); + } else { - for( int i = 0; i < tickPositions.size(); ++i ) - painter->drawLine( QLineF( origin.x() - tickLengthOut * tickDir + xCor, tickPositions.at( i ) + yCor, origin.x() + tickLengthIn * tickDir + xCor, tickPositions.at( i ) + yCor ) ); + for (int i=0; idrawLine(QLineF(origin.x()-tickLengthOut*tickDir+xCor, tickPositions.at(i)+yCor, origin.x()+tickLengthIn*tickDir+xCor, tickPositions.at(i)+yCor)); } } - + // draw subticks: - if( !subTickPositions.isEmpty() ) + if (!subTickPositions.isEmpty()) { - painter->setPen( subTickPen ); + painter->setPen(subTickPen); // direction of ticks ("inward" is right for left axis and left for right axis) - int tickDir = ( type == QCPAxis::atBottom || type == QCPAxis::atRight ) ? -1 : 1; - if( QCPAxis::orientation( type ) == Qt::Horizontal ) + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; + if (QCPAxis::orientation(type) == Qt::Horizontal) { - for( int i = 0; i < subTickPositions.size(); ++i ) - painter->drawLine( QLineF( subTickPositions.at( i ) + xCor, origin.y() - subTickLengthOut * tickDir + yCor, subTickPositions.at( i ) + xCor, origin.y() + subTickLengthIn * tickDir + yCor ) ); - } - else + for (int i=0; idrawLine(QLineF(subTickPositions.at(i)+xCor, origin.y()-subTickLengthOut*tickDir+yCor, subTickPositions.at(i)+xCor, origin.y()+subTickLengthIn*tickDir+yCor)); + } else { - for( int i = 0; i < subTickPositions.size(); ++i ) - painter->drawLine( QLineF( origin.x() - subTickLengthOut * tickDir + xCor, subTickPositions.at( i ) + yCor, origin.x() + subTickLengthIn * tickDir + xCor, subTickPositions.at( i ) + yCor ) ); + for (int i=0; idrawLine(QLineF(origin.x()-subTickLengthOut*tickDir+xCor, subTickPositions.at(i)+yCor, origin.x()+subTickLengthIn*tickDir+xCor, subTickPositions.at(i)+yCor)); } } - margin += qMax( 0, qMax( tickLengthOut, subTickLengthOut ) ); - + margin += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + // draw axis base endings: bool antialiasingBackup = painter->antialiasing(); - painter->setAntialiasing( true ); // always want endings to be antialiased, even if base and ticks themselves aren't - painter->setBrush( QBrush( basePen.color() ) ); - QCPVector2D baseLineVector( baseLine.dx(), baseLine.dy() ); - if( lowerEnding.style() != QCPLineEnding::esNone ) - lowerEnding.draw( painter, QCPVector2D( baseLine.p1() ) - baseLineVector.normalized() * lowerEnding.realLength() * ( lowerEnding.inverted() ? -1 : 1 ), -baseLineVector ); - if( upperEnding.style() != QCPLineEnding::esNone ) - upperEnding.draw( painter, QCPVector2D( baseLine.p2() ) + baseLineVector.normalized() * upperEnding.realLength() * ( upperEnding.inverted() ? -1 : 1 ), baseLineVector ); - painter->setAntialiasing( antialiasingBackup ); - + painter->setAntialiasing(true); // always want endings to be antialiased, even if base and ticks themselves aren't + painter->setBrush(QBrush(basePen.color())); + QCPVector2D baseLineVector(baseLine.dx(), baseLine.dy()); + if (lowerEnding.style() != QCPLineEnding::esNone) + lowerEnding.draw(painter, QCPVector2D(baseLine.p1())-baseLineVector.normalized()*lowerEnding.realLength()*(lowerEnding.inverted()?-1:1), -baseLineVector); + if (upperEnding.style() != QCPLineEnding::esNone) + upperEnding.draw(painter, QCPVector2D(baseLine.p2())+baseLineVector.normalized()*upperEnding.realLength()*(upperEnding.inverted()?-1:1), baseLineVector); + painter->setAntialiasing(antialiasingBackup); + // tick labels: QRect oldClipRect; - if( tickLabelSide == QCPAxis::lsInside ) // if using inside labels, clip them to the axis rect + if (tickLabelSide == QCPAxis::lsInside) // if using inside labels, clip them to the axis rect { oldClipRect = painter->clipRegion().boundingRect(); - painter->setClipRect( axisRect ); + painter->setClipRect(axisRect); } - QSize tickLabelsSize( 0, 0 ); // size of largest tick label, for offset calculation of axis label - if( !tickLabels.isEmpty() ) + QSize tickLabelsSize(0, 0); // size of largest tick label, for offset calculation of axis label + if (!tickLabels.isEmpty()) { - if( tickLabelSide == QCPAxis::lsOutside ) + if (tickLabelSide == QCPAxis::lsOutside) margin += tickLabelPadding; - painter->setFont( tickLabelFont ); - painter->setPen( QPen( tickLabelColor ) ); - const int maxLabelIndex = qMin( tickPositions.size(), tickLabels.size() ); + painter->setFont(tickLabelFont); + painter->setPen(QPen(tickLabelColor)); + const int maxLabelIndex = qMin(tickPositions.size(), tickLabels.size()); int distanceToAxis = margin; - if( tickLabelSide == QCPAxis::lsInside ) - distanceToAxis = -( qMax( tickLengthIn, subTickLengthIn ) + tickLabelPadding ); - for( int i = 0; i < maxLabelIndex; ++i ) - placeTickLabel( painter, tickPositions.at( i ), distanceToAxis, tickLabels.at( i ), &tickLabelsSize ); - if( tickLabelSide == QCPAxis::lsOutside ) - margin += ( QCPAxis::orientation( type ) == Qt::Horizontal ) ? tickLabelsSize.height() : tickLabelsSize.width(); + if (tickLabelSide == QCPAxis::lsInside) + distanceToAxis = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding); + for (int i=0; isetClipRect( oldClipRect ); - + if (tickLabelSide == QCPAxis::lsInside) + painter->setClipRect(oldClipRect); + // axis label: QRect labelBounds; - if( !label.isEmpty() ) + if (!label.isEmpty()) { margin += labelPadding; - painter->setFont( labelFont ); - painter->setPen( QPen( labelColor ) ); - labelBounds = painter->fontMetrics().boundingRect( 0, 0, 0, 0, Qt::TextDontClip, label ); - if( type == QCPAxis::atLeft ) + painter->setFont(labelFont); + painter->setPen(QPen(labelColor)); + labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip, label); + if (type == QCPAxis::atLeft) { QTransform oldTransform = painter->transform(); - painter->translate( ( origin.x() - margin - labelBounds.height() ), origin.y() ); - painter->rotate( -90 ); - painter->drawText( 0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label ); - painter->setTransform( oldTransform ); + painter->translate((origin.x()-margin-labelBounds.height()), origin.y()); + painter->rotate(-90); + painter->drawText(0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + painter->setTransform(oldTransform); } - else if( type == QCPAxis::atRight ) + else if (type == QCPAxis::atRight) { QTransform oldTransform = painter->transform(); - painter->translate( ( origin.x() + margin + labelBounds.height() ), origin.y() - axisRect.height() ); - painter->rotate( 90 ); - painter->drawText( 0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label ); - painter->setTransform( oldTransform ); + painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-axisRect.height()); + painter->rotate(90); + painter->drawText(0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + painter->setTransform(oldTransform); } - else if( type == QCPAxis::atTop ) - painter->drawText( origin.x(), origin.y() - margin - labelBounds.height(), axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label ); - else if( type == QCPAxis::atBottom ) - painter->drawText( origin.x(), origin.y() + margin, axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label ); + else if (type == QCPAxis::atTop) + painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(), axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + else if (type == QCPAxis::atBottom) + painter->drawText(origin.x(), origin.y()+margin, axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); } - + // set selection boxes: int selectionTolerance = 0; - if( mParentPlot ) + if (mParentPlot) selectionTolerance = mParentPlot->selectionTolerance(); else qDebug() << Q_FUNC_INFO << "mParentPlot is null"; - int selAxisOutSize = qMax( qMax( tickLengthOut, subTickLengthOut ), selectionTolerance ); + int selAxisOutSize = qMax(qMax(tickLengthOut, subTickLengthOut), selectionTolerance); int selAxisInSize = selectionTolerance; int selTickLabelSize; int selTickLabelOffset; - if( tickLabelSide == QCPAxis::lsOutside ) + if (tickLabelSide == QCPAxis::lsOutside) { - selTickLabelSize = ( QCPAxis::orientation( type ) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width() ); - selTickLabelOffset = qMax( tickLengthOut, subTickLengthOut ) + tickLabelPadding; - } - else + selTickLabelSize = (QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); + selTickLabelOffset = qMax(tickLengthOut, subTickLengthOut)+tickLabelPadding; + } else { - selTickLabelSize = -( QCPAxis::orientation( type ) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width() ); - selTickLabelOffset = -( qMax( tickLengthIn, subTickLengthIn ) + tickLabelPadding ); + selTickLabelSize = -(QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); + selTickLabelOffset = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding); } int selLabelSize = labelBounds.height(); - int selLabelOffset = qMax( tickLengthOut, subTickLengthOut ) + ( !tickLabels.isEmpty() && tickLabelSide == QCPAxis::lsOutside ? tickLabelPadding + selTickLabelSize : 0 ) + labelPadding; - if( type == QCPAxis::atLeft ) + int selLabelOffset = qMax(tickLengthOut, subTickLengthOut)+(!tickLabels.isEmpty() && tickLabelSide == QCPAxis::lsOutside ? tickLabelPadding+selTickLabelSize : 0)+labelPadding; + if (type == QCPAxis::atLeft) { - mAxisSelectionBox.setCoords( origin.x() - selAxisOutSize, axisRect.top(), origin.x() + selAxisInSize, axisRect.bottom() ); - mTickLabelsSelectionBox.setCoords( origin.x() - selTickLabelOffset - selTickLabelSize, axisRect.top(), origin.x() - selTickLabelOffset, axisRect.bottom() ); - mLabelSelectionBox.setCoords( origin.x() - selLabelOffset - selLabelSize, axisRect.top(), origin.x() - selLabelOffset, axisRect.bottom() ); - } - else if( type == QCPAxis::atRight ) + mAxisSelectionBox.setCoords(origin.x()-selAxisOutSize, axisRect.top(), origin.x()+selAxisInSize, axisRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()-selTickLabelOffset-selTickLabelSize, axisRect.top(), origin.x()-selTickLabelOffset, axisRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()-selLabelOffset-selLabelSize, axisRect.top(), origin.x()-selLabelOffset, axisRect.bottom()); + } else if (type == QCPAxis::atRight) { - mAxisSelectionBox.setCoords( origin.x() - selAxisInSize, axisRect.top(), origin.x() + selAxisOutSize, axisRect.bottom() ); - mTickLabelsSelectionBox.setCoords( origin.x() + selTickLabelOffset + selTickLabelSize, axisRect.top(), origin.x() + selTickLabelOffset, axisRect.bottom() ); - mLabelSelectionBox.setCoords( origin.x() + selLabelOffset + selLabelSize, axisRect.top(), origin.x() + selLabelOffset, axisRect.bottom() ); - } - else if( type == QCPAxis::atTop ) + mAxisSelectionBox.setCoords(origin.x()-selAxisInSize, axisRect.top(), origin.x()+selAxisOutSize, axisRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()+selTickLabelOffset+selTickLabelSize, axisRect.top(), origin.x()+selTickLabelOffset, axisRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()+selLabelOffset+selLabelSize, axisRect.top(), origin.x()+selLabelOffset, axisRect.bottom()); + } else if (type == QCPAxis::atTop) { - mAxisSelectionBox.setCoords( axisRect.left(), origin.y() - selAxisOutSize, axisRect.right(), origin.y() + selAxisInSize ); - mTickLabelsSelectionBox.setCoords( axisRect.left(), origin.y() - selTickLabelOffset - selTickLabelSize, axisRect.right(), origin.y() - selTickLabelOffset ); - mLabelSelectionBox.setCoords( axisRect.left(), origin.y() - selLabelOffset - selLabelSize, axisRect.right(), origin.y() - selLabelOffset ); - } - else if( type == QCPAxis::atBottom ) + mAxisSelectionBox.setCoords(axisRect.left(), origin.y()-selAxisOutSize, axisRect.right(), origin.y()+selAxisInSize); + mTickLabelsSelectionBox.setCoords(axisRect.left(), origin.y()-selTickLabelOffset-selTickLabelSize, axisRect.right(), origin.y()-selTickLabelOffset); + mLabelSelectionBox.setCoords(axisRect.left(), origin.y()-selLabelOffset-selLabelSize, axisRect.right(), origin.y()-selLabelOffset); + } else if (type == QCPAxis::atBottom) { - mAxisSelectionBox.setCoords( axisRect.left(), origin.y() - selAxisInSize, axisRect.right(), origin.y() + selAxisOutSize ); - mTickLabelsSelectionBox.setCoords( axisRect.left(), origin.y() + selTickLabelOffset + selTickLabelSize, axisRect.right(), origin.y() + selTickLabelOffset ); - mLabelSelectionBox.setCoords( axisRect.left(), origin.y() + selLabelOffset + selLabelSize, axisRect.right(), origin.y() + selLabelOffset ); + mAxisSelectionBox.setCoords(axisRect.left(), origin.y()-selAxisInSize, axisRect.right(), origin.y()+selAxisOutSize); + mTickLabelsSelectionBox.setCoords(axisRect.left(), origin.y()+selTickLabelOffset+selTickLabelSize, axisRect.right(), origin.y()+selTickLabelOffset); + mLabelSelectionBox.setCoords(axisRect.left(), origin.y()+selLabelOffset+selLabelSize, axisRect.right(), origin.y()+selLabelOffset); } mAxisSelectionBox = mAxisSelectionBox.normalized(); mTickLabelsSelectionBox = mTickLabelsSelectionBox.normalized(); @@ -9568,33 +9405,33 @@ void QCPAxisPainterPrivate::draw( QCPPainter* painter ) int QCPAxisPainterPrivate::size() const { int result = 0; - + // get length of tick marks pointing outwards: - if( !tickPositions.isEmpty() ) - result += qMax( 0, qMax( tickLengthOut, subTickLengthOut ) ); - + if (!tickPositions.isEmpty()) + result += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + // calculate size of tick labels: - if( tickLabelSide == QCPAxis::lsOutside ) + if (tickLabelSide == QCPAxis::lsOutside) { - QSize tickLabelsSize( 0, 0 ); - if( !tickLabels.isEmpty() ) + QSize tickLabelsSize(0, 0); + if (!tickLabels.isEmpty()) { - for( int i = 0; i < tickLabels.size(); ++i ) - getMaxTickLabelSize( tickLabelFont, tickLabels.at( i ), &tickLabelsSize ); - result += QCPAxis::orientation( type ) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width(); - result += tickLabelPadding; + for (int i=0; ibufferDevicePixelRatio() ) ); - result.append( QByteArray::number( tickLabelRotation ) ); - result.append( QByteArray::number( (int)tickLabelSide ) ); - result.append( QByteArray::number( (int)substituteExponent ) ); - result.append( QByteArray::number( (int)numberMultiplyCross ) ); - result.append( tickLabelColor.name().toLatin1() + QByteArray::number( tickLabelColor.alpha(), 16 ) ); - result.append( tickLabelFont.toString().toLatin1() ); + result.append(QByteArray::number(mParentPlot->bufferDevicePixelRatio())); + result.append(QByteArray::number(tickLabelRotation)); + result.append(QByteArray::number((int)tickLabelSide)); + result.append(QByteArray::number((int)substituteExponent)); + result.append(QByteArray::number((int)numberMultiplyCross)); + result.append(tickLabelColor.name().toLatin1()+QByteArray::number(tickLabelColor.alpha(), 16)); + result.append(tickLabelFont.toString().toLatin1()); return result; } @@ -9648,95 +9485,84 @@ QByteArray QCPAxisPainterPrivate::generateLabelParameterHash() const superscripted powers, the font is temporarily made smaller by a fixed factor (see \ref getTickLabelData). */ -void QCPAxisPainterPrivate::placeTickLabel( QCPPainter* painter, double position, int distanceToAxis, const QString& text, QSize* tickLabelsSize ) +void QCPAxisPainterPrivate::placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize) { // warning: if you change anything here, also adapt getMaxTickLabelSize() accordingly! - if( text.isEmpty() ) - return; + if (text.isEmpty()) return; QSize finalSize; QPointF labelAnchor; - switch( type ) + switch (type) { - case QCPAxis::atLeft: - labelAnchor = QPointF( axisRect.left() - distanceToAxis - offset, position ); - break; - case QCPAxis::atRight: - labelAnchor = QPointF( axisRect.right() + distanceToAxis + offset, position ); - break; - case QCPAxis::atTop: - labelAnchor = QPointF( position, axisRect.top() - distanceToAxis - offset ); - break; - case QCPAxis::atBottom: - labelAnchor = QPointF( position, axisRect.bottom() + distanceToAxis + offset ); - break; + case QCPAxis::atLeft: labelAnchor = QPointF(axisRect.left()-distanceToAxis-offset, position); break; + case QCPAxis::atRight: labelAnchor = QPointF(axisRect.right()+distanceToAxis+offset, position); break; + case QCPAxis::atTop: labelAnchor = QPointF(position, axisRect.top()-distanceToAxis-offset); break; + case QCPAxis::atBottom: labelAnchor = QPointF(position, axisRect.bottom()+distanceToAxis+offset); break; } - if( mParentPlot->plottingHints().testFlag( QCP::phCacheLabels ) && !painter->modes().testFlag( QCPPainter::pmNoCaching ) ) // label caching enabled + if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && !painter->modes().testFlag(QCPPainter::pmNoCaching)) // label caching enabled { - CachedLabel* cachedLabel = mLabelCache.take( text ); // attempt to get label from cache - if( !cachedLabel ) // no cached label existed, create it + CachedLabel *cachedLabel = mLabelCache.take(text); // attempt to get label from cache + if (!cachedLabel) // no cached label existed, create it { cachedLabel = new CachedLabel; - TickLabelData labelData = getTickLabelData( painter->font(), text ); - cachedLabel->offset = getTickLabelDrawOffset( labelData ) + labelData.rotatedTotalBounds.topLeft(); - if( !qFuzzyCompare( 1.0, mParentPlot->bufferDevicePixelRatio() ) ) + TickLabelData labelData = getTickLabelData(painter->font(), text); + cachedLabel->offset = getTickLabelDrawOffset(labelData)+labelData.rotatedTotalBounds.topLeft(); + if (!qFuzzyCompare(1.0, mParentPlot->bufferDevicePixelRatio())) { - cachedLabel->pixmap = QPixmap( labelData.rotatedTotalBounds.size() * mParentPlot->bufferDevicePixelRatio() ); + cachedLabel->pixmap = QPixmap(labelData.rotatedTotalBounds.size()*mParentPlot->bufferDevicePixelRatio()); #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED -#ifdef QCP_DEVICEPIXELRATIO_FLOAT - cachedLabel->pixmap.setDevicePixelRatio( mParentPlot->devicePixelRatioF() ); -#else - cachedLabel->pixmap.setDevicePixelRatio( mParentPlot->devicePixelRatio() ); +# ifdef QCP_DEVICEPIXELRATIO_FLOAT + cachedLabel->pixmap.setDevicePixelRatio(mParentPlot->devicePixelRatioF()); +# else + cachedLabel->pixmap.setDevicePixelRatio(mParentPlot->devicePixelRatio()); +# endif #endif -#endif - } - else - cachedLabel->pixmap = QPixmap( labelData.rotatedTotalBounds.size() ); - cachedLabel->pixmap.fill( Qt::transparent ); - QCPPainter cachePainter( &cachedLabel->pixmap ); - cachePainter.setPen( painter->pen() ); - drawTickLabel( &cachePainter, -labelData.rotatedTotalBounds.topLeft().x(), -labelData.rotatedTotalBounds.topLeft().y(), labelData ); + } else + cachedLabel->pixmap = QPixmap(labelData.rotatedTotalBounds.size()); + cachedLabel->pixmap.fill(Qt::transparent); + QCPPainter cachePainter(&cachedLabel->pixmap); + cachePainter.setPen(painter->pen()); + drawTickLabel(&cachePainter, -labelData.rotatedTotalBounds.topLeft().x(), -labelData.rotatedTotalBounds.topLeft().y(), labelData); } // if label would be partly clipped by widget border on sides, don't draw it (only for outside tick labels): bool labelClippedByBorder = false; - if( tickLabelSide == QCPAxis::lsOutside ) + if (tickLabelSide == QCPAxis::lsOutside) { - if( QCPAxis::orientation( type ) == Qt::Horizontal ) - labelClippedByBorder = labelAnchor.x() + cachedLabel->offset.x() + cachedLabel->pixmap.width() / mParentPlot->bufferDevicePixelRatio() > viewportRect.right() || labelAnchor.x() + cachedLabel->offset.x() < viewportRect.left(); + if (QCPAxis::orientation(type) == Qt::Horizontal) + labelClippedByBorder = labelAnchor.x()+cachedLabel->offset.x()+cachedLabel->pixmap.width()/mParentPlot->bufferDevicePixelRatio() > viewportRect.right() || labelAnchor.x()+cachedLabel->offset.x() < viewportRect.left(); else - labelClippedByBorder = labelAnchor.y() + cachedLabel->offset.y() + cachedLabel->pixmap.height() / mParentPlot->bufferDevicePixelRatio() > viewportRect.bottom() || labelAnchor.y() + cachedLabel->offset.y() < viewportRect.top(); + labelClippedByBorder = labelAnchor.y()+cachedLabel->offset.y()+cachedLabel->pixmap.height()/mParentPlot->bufferDevicePixelRatio() > viewportRect.bottom() || labelAnchor.y()+cachedLabel->offset.y() < viewportRect.top(); } - if( !labelClippedByBorder ) + if (!labelClippedByBorder) { - painter->drawPixmap( labelAnchor + cachedLabel->offset, cachedLabel->pixmap ); - finalSize = cachedLabel->pixmap.size() / mParentPlot->bufferDevicePixelRatio(); + painter->drawPixmap(labelAnchor+cachedLabel->offset, cachedLabel->pixmap); + finalSize = cachedLabel->pixmap.size()/mParentPlot->bufferDevicePixelRatio(); } - mLabelCache.insert( text, cachedLabel ); // return label to cache or insert for the first time if newly created - } - else // label caching disabled, draw text directly on surface: + mLabelCache.insert(text, cachedLabel); // return label to cache or insert for the first time if newly created + } else // label caching disabled, draw text directly on surface: { - TickLabelData labelData = getTickLabelData( painter->font(), text ); - QPointF finalPosition = labelAnchor + getTickLabelDrawOffset( labelData ); + TickLabelData labelData = getTickLabelData(painter->font(), text); + QPointF finalPosition = labelAnchor + getTickLabelDrawOffset(labelData); // if label would be partly clipped by widget border on sides, don't draw it (only for outside tick labels): - bool labelClippedByBorder = false; - if( tickLabelSide == QCPAxis::lsOutside ) + bool labelClippedByBorder = false; + if (tickLabelSide == QCPAxis::lsOutside) { - if( QCPAxis::orientation( type ) == Qt::Horizontal ) - labelClippedByBorder = finalPosition.x() + ( labelData.rotatedTotalBounds.width() + labelData.rotatedTotalBounds.left() ) > viewportRect.right() || finalPosition.x() + labelData.rotatedTotalBounds.left() < viewportRect.left(); + if (QCPAxis::orientation(type) == Qt::Horizontal) + labelClippedByBorder = finalPosition.x()+(labelData.rotatedTotalBounds.width()+labelData.rotatedTotalBounds.left()) > viewportRect.right() || finalPosition.x()+labelData.rotatedTotalBounds.left() < viewportRect.left(); else - labelClippedByBorder = finalPosition.y() + ( labelData.rotatedTotalBounds.height() + labelData.rotatedTotalBounds.top() ) > viewportRect.bottom() || finalPosition.y() + labelData.rotatedTotalBounds.top() < viewportRect.top(); + labelClippedByBorder = finalPosition.y()+(labelData.rotatedTotalBounds.height()+labelData.rotatedTotalBounds.top()) > viewportRect.bottom() || finalPosition.y()+labelData.rotatedTotalBounds.top() < viewportRect.top(); } - if( !labelClippedByBorder ) + if (!labelClippedByBorder) { - drawTickLabel( painter, finalPosition.x(), finalPosition.y(), labelData ); + drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData); finalSize = labelData.rotatedTotalBounds.size(); } } - + // expand passed tickLabelsSize if current tick label is larger: - if( finalSize.width() > tickLabelsSize->width() ) - tickLabelsSize->setWidth( finalSize.width() ); - if( finalSize.height() > tickLabelsSize->height() ) - tickLabelsSize->setHeight( finalSize.height() ); + if (finalSize.width() > tickLabelsSize->width()) + tickLabelsSize->setWidth(finalSize.width()); + if (finalSize.height() > tickLabelsSize->height()) + tickLabelsSize->setHeight(finalSize.height()); } /*! \internal @@ -9748,36 +9574,35 @@ void QCPAxisPainterPrivate::placeTickLabel( QCPPainter* painter, double position directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when QCP::phCacheLabels plotting hint is not set. */ -void QCPAxisPainterPrivate::drawTickLabel( QCPPainter* painter, double x, double y, const TickLabelData& labelData ) const +void QCPAxisPainterPrivate::drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const { // backup painter settings that we're about to change: QTransform oldTransform = painter->transform(); QFont oldFont = painter->font(); - + // transform painter to position/rotation: - painter->translate( x, y ); - if( !qFuzzyIsNull( tickLabelRotation ) ) - painter->rotate( tickLabelRotation ); - + painter->translate(x, y); + if (!qFuzzyIsNull(tickLabelRotation)) + painter->rotate(tickLabelRotation); + // draw text: - if( !labelData.expPart.isEmpty() ) // indicator that beautiful powers must be used + if (!labelData.expPart.isEmpty()) // indicator that beautiful powers must be used { - painter->setFont( labelData.baseFont ); - painter->drawText( 0, 0, 0, 0, Qt::TextDontClip, labelData.basePart ); - if( !labelData.suffixPart.isEmpty() ) - painter->drawText( labelData.baseBounds.width() + 1 + labelData.expBounds.width(), 0, 0, 0, Qt::TextDontClip, labelData.suffixPart ); - painter->setFont( labelData.expFont ); - painter->drawText( labelData.baseBounds.width() + 1, 0, labelData.expBounds.width(), labelData.expBounds.height(), Qt::TextDontClip, labelData.expPart ); - } - else + painter->setFont(labelData.baseFont); + painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.basePart); + if (!labelData.suffixPart.isEmpty()) + painter->drawText(labelData.baseBounds.width()+1+labelData.expBounds.width(), 0, 0, 0, Qt::TextDontClip, labelData.suffixPart); + painter->setFont(labelData.expFont); + painter->drawText(labelData.baseBounds.width()+1, 0, labelData.expBounds.width(), labelData.expBounds.height(), Qt::TextDontClip, labelData.expPart); + } else { - painter->setFont( labelData.baseFont ); - painter->drawText( 0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart ); + painter->setFont(labelData.baseFont); + painter->drawText(0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart); } - + // reset painter settings to what it was before: - painter->setTransform( oldTransform ); - painter->setFont( oldFont ); + painter->setTransform(oldTransform); + painter->setFont(oldFont); } /*! \internal @@ -9788,76 +9613,75 @@ void QCPAxisPainterPrivate::drawTickLabel( QCPPainter* painter, double x, double processed by \ref getTickLabelDrawOffset and \ref drawTickLabel. It splits the text into base and exponent if necessary (member substituteExponent) and calculates appropriate bounding boxes. */ -QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData( const QFont& font, const QString& text ) const +QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData(const QFont &font, const QString &text) const { TickLabelData result; - + // determine whether beautiful decimal powers should be used bool useBeautifulPowers = false; - int ePos = -1; // first index of exponent part, text before that will be basePart, text until eLast will be expPart - int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart - if( substituteExponent ) + int ePos = -1; // first index of exponent part, text before that will be basePart, text until eLast will be expPart + int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart + if (substituteExponent) { - ePos = text.indexOf( QLatin1Char( 'e' ) ); - if( ePos > 0 && text.at( ePos - 1 ).isDigit() ) + ePos = text.indexOf(QLatin1Char('e')); + if (ePos > 0 && text.at(ePos-1).isDigit()) { eLast = ePos; - while( eLast + 1 < text.size() && ( text.at( eLast + 1 ) == QLatin1Char( '+' ) || text.at( eLast + 1 ) == QLatin1Char( '-' ) || text.at( eLast + 1 ).isDigit() ) ) + while (eLast+1 < text.size() && (text.at(eLast+1) == QLatin1Char('+') || text.at(eLast+1) == QLatin1Char('-') || text.at(eLast+1).isDigit())) ++eLast; - if( eLast > ePos ) // only if also to right of 'e' is a digit/+/- interpret it as beautifiable power + if (eLast > ePos) // only if also to right of 'e' is a digit/+/- interpret it as beautifiable power useBeautifulPowers = true; } } - + // calculate text bounding rects and do string preparation for beautiful decimal powers: result.baseFont = font; - if( result.baseFont.pointSizeF() > 0 ) // might return -1 if specified with setPixelSize, in that case we can't do correction in next line - result.baseFont.setPointSizeF( result.baseFont.pointSizeF() + 0.05 ); // QFontMetrics.boundingRect has a bug for exact point sizes that make the results oscillate due to internal rounding - if( useBeautifulPowers ) + if (result.baseFont.pointSizeF() > 0) // might return -1 if specified with setPixelSize, in that case we can't do correction in next line + result.baseFont.setPointSizeF(result.baseFont.pointSizeF()+0.05); // QFontMetrics.boundingRect has a bug for exact point sizes that make the results oscillate due to internal rounding + if (useBeautifulPowers) { // split text into parts of number/symbol that will be drawn normally and part that will be drawn as exponent: - result.basePart = text.left( ePos ); - result.suffixPart = text.mid( eLast + 1 ); // also drawn normally but after exponent + result.basePart = text.left(ePos); + result.suffixPart = text.mid(eLast+1); // also drawn normally but after exponent // in log scaling, we want to turn "1*10^n" into "10^n", else add multiplication sign and decimal base: - if( abbreviateDecimalPowers && result.basePart == QLatin1String( "1" ) ) - result.basePart = QLatin1String( "10" ); + if (abbreviateDecimalPowers && result.basePart == QLatin1String("1")) + result.basePart = QLatin1String("10"); else - result.basePart += ( numberMultiplyCross ? QString( QChar( 215 ) ) : QString( QChar( 183 ) ) ) + QLatin1String( "10" ); - result.expPart = text.mid( ePos + 1, eLast - ePos ); + result.basePart += (numberMultiplyCross ? QString(QChar(215)) : QString(QChar(183))) + QLatin1String("10"); + result.expPart = text.mid(ePos+1, eLast-ePos); // clip "+" and leading zeros off expPart: - while( result.expPart.length() > 2 && result.expPart.at( 1 ) == QLatin1Char( '0' ) ) // length > 2 so we leave one zero when numberFormatChar is 'e' - result.expPart.remove( 1, 1 ); - if( !result.expPart.isEmpty() && result.expPart.at( 0 ) == QLatin1Char( '+' ) ) - result.expPart.remove( 0, 1 ); + while (result.expPart.length() > 2 && result.expPart.at(1) == QLatin1Char('0')) // length > 2 so we leave one zero when numberFormatChar is 'e' + result.expPart.remove(1, 1); + if (!result.expPart.isEmpty() && result.expPart.at(0) == QLatin1Char('+')) + result.expPart.remove(0, 1); // prepare smaller font for exponent: result.expFont = font; - if( result.expFont.pointSize() > 0 ) - result.expFont.setPointSize( result.expFont.pointSize() * 0.75 ); + if (result.expFont.pointSize() > 0) + result.expFont.setPointSize(result.expFont.pointSize()*0.75); else - result.expFont.setPixelSize( result.expFont.pixelSize() * 0.75 ); + result.expFont.setPixelSize(result.expFont.pixelSize()*0.75); // calculate bounding rects of base part(s), exponent part and total one: - result.baseBounds = QFontMetrics( result.baseFont ).boundingRect( 0, 0, 0, 0, Qt::TextDontClip, result.basePart ); - result.expBounds = QFontMetrics( result.expFont ).boundingRect( 0, 0, 0, 0, Qt::TextDontClip, result.expPart ); - if( !result.suffixPart.isEmpty() ) - result.suffixBounds = QFontMetrics( result.baseFont ).boundingRect( 0, 0, 0, 0, Qt::TextDontClip, result.suffixPart ); - result.totalBounds = result.baseBounds.adjusted( 0, 0, result.expBounds.width() + result.suffixBounds.width() + 2, 0 ); // +2 consists of the 1 pixel spacing between base and exponent (see drawTickLabel) and an extra pixel to include AA - } - else // useBeautifulPowers == false + result.baseBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip, result.basePart); + result.expBounds = QFontMetrics(result.expFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip, result.expPart); + if (!result.suffixPart.isEmpty()) + result.suffixBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip, result.suffixPart); + result.totalBounds = result.baseBounds.adjusted(0, 0, result.expBounds.width()+result.suffixBounds.width()+2, 0); // +2 consists of the 1 pixel spacing between base and exponent (see drawTickLabel) and an extra pixel to include AA + } else // useBeautifulPowers == false { result.basePart = text; - result.totalBounds = QFontMetrics( result.baseFont ).boundingRect( 0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.basePart ); + result.totalBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.basePart); } - result.totalBounds.moveTopLeft( QPoint( 0, 0 ) ); // want bounding box aligned top left at origin, independent of how it was created, to make further processing simpler - + result.totalBounds.moveTopLeft(QPoint(0, 0)); // want bounding box aligned top left at origin, independent of how it was created, to make further processing simpler + // calculate possibly different bounding rect after rotation: result.rotatedTotalBounds = result.totalBounds; - if( !qFuzzyIsNull( tickLabelRotation ) ) + if (!qFuzzyIsNull(tickLabelRotation)) { QTransform transform; - transform.rotate( tickLabelRotation ); - result.rotatedTotalBounds = transform.mapRect( result.rotatedTotalBounds ); + transform.rotate(tickLabelRotation); + result.rotatedTotalBounds = transform.mapRect(result.rotatedTotalBounds); } - + return result; } @@ -9871,7 +9695,7 @@ QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData( co This function is thus responsible for e.g. centering tick labels under ticks and positioning them appropriately when they are rotated. */ -QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset( const TickLabelData& labelData ) const +QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset(const TickLabelData &labelData) const { /* calculate label offset from base point at tick (non-trivial, for best visual appearance): short @@ -9883,96 +9707,85 @@ QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset( const TickLabelData& labe time, a 45 degree rotated text will "point toward" its tick, as is typical for rotated tick labels. */ - bool doRotation = !qFuzzyIsNull( tickLabelRotation ); - bool flip = qFuzzyCompare( qAbs( tickLabelRotation ), 90.0 ); // perfect +/-90 degree flip. Indicates vertical label centering on vertical axes. - double radians = tickLabelRotation / 180.0 * M_PI; - int x = 0, y = 0; - if( ( type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsOutside ) || ( type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsInside ) ) // Anchor at right side of tick label + bool doRotation = !qFuzzyIsNull(tickLabelRotation); + bool flip = qFuzzyCompare(qAbs(tickLabelRotation), 90.0); // perfect +/-90 degree flip. Indicates vertical label centering on vertical axes. + double radians = tickLabelRotation/180.0*M_PI; + int x=0, y=0; + if ((type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsInside)) // Anchor at right side of tick label { - if( doRotation ) + if (doRotation) { - if( tickLabelRotation > 0 ) + if (tickLabelRotation > 0) { - x = -qCos( radians ) * labelData.totalBounds.width(); - y = flip ? -labelData.totalBounds.width() / 2.0 : -qSin( radians ) * labelData.totalBounds.width() - qCos( radians ) * labelData.totalBounds.height() / 2.0; - } - else + x = -qCos(radians)*labelData.totalBounds.width(); + y = flip ? -labelData.totalBounds.width()/2.0 : -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height()/2.0; + } else { - x = -qCos( -radians ) * labelData.totalBounds.width() - qSin( -radians ) * labelData.totalBounds.height(); - y = flip ? +labelData.totalBounds.width() / 2.0 : +qSin( -radians ) * labelData.totalBounds.width() - qCos( -radians ) * labelData.totalBounds.height() / 2.0; + x = -qCos(-radians)*labelData.totalBounds.width()-qSin(-radians)*labelData.totalBounds.height(); + y = flip ? +labelData.totalBounds.width()/2.0 : +qSin(-radians)*labelData.totalBounds.width()-qCos(-radians)*labelData.totalBounds.height()/2.0; } - } - else + } else { x = -labelData.totalBounds.width(); - y = -labelData.totalBounds.height() / 2.0; + y = -labelData.totalBounds.height()/2.0; } - } - else if( ( type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsOutside ) || ( type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsInside ) ) // Anchor at left side of tick label + } else if ((type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsInside)) // Anchor at left side of tick label { - if( doRotation ) + if (doRotation) { - if( tickLabelRotation > 0 ) + if (tickLabelRotation > 0) { - x = +qSin( radians ) * labelData.totalBounds.height(); - y = flip ? -labelData.totalBounds.width() / 2.0 : -qCos( radians ) * labelData.totalBounds.height() / 2.0; - } - else + x = +qSin(radians)*labelData.totalBounds.height(); + y = flip ? -labelData.totalBounds.width()/2.0 : -qCos(radians)*labelData.totalBounds.height()/2.0; + } else { x = 0; - y = flip ? +labelData.totalBounds.width() / 2.0 : -qCos( -radians ) * labelData.totalBounds.height() / 2.0; + y = flip ? +labelData.totalBounds.width()/2.0 : -qCos(-radians)*labelData.totalBounds.height()/2.0; } - } - else + } else { x = 0; - y = -labelData.totalBounds.height() / 2.0; + y = -labelData.totalBounds.height()/2.0; } - } - else if( ( type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsOutside ) || ( type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsInside ) ) // Anchor at bottom side of tick label + } else if ((type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsInside)) // Anchor at bottom side of tick label { - if( doRotation ) + if (doRotation) { - if( tickLabelRotation > 0 ) + if (tickLabelRotation > 0) { - x = -qCos( radians ) * labelData.totalBounds.width() + qSin( radians ) * labelData.totalBounds.height() / 2.0; - y = -qSin( radians ) * labelData.totalBounds.width() - qCos( radians ) * labelData.totalBounds.height(); - } - else + x = -qCos(radians)*labelData.totalBounds.width()+qSin(radians)*labelData.totalBounds.height()/2.0; + y = -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height(); + } else { - x = -qSin( -radians ) * labelData.totalBounds.height() / 2.0; - y = -qCos( -radians ) * labelData.totalBounds.height(); + x = -qSin(-radians)*labelData.totalBounds.height()/2.0; + y = -qCos(-radians)*labelData.totalBounds.height(); } - } - else + } else { - x = -labelData.totalBounds.width() / 2.0; + x = -labelData.totalBounds.width()/2.0; y = -labelData.totalBounds.height(); } - } - else if( ( type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsOutside ) || ( type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsInside ) ) // Anchor at top side of tick label + } else if ((type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsInside)) // Anchor at top side of tick label { - if( doRotation ) + if (doRotation) { - if( tickLabelRotation > 0 ) + if (tickLabelRotation > 0) { - x = +qSin( radians ) * labelData.totalBounds.height() / 2.0; + x = +qSin(radians)*labelData.totalBounds.height()/2.0; y = 0; - } - else + } else { - x = -qCos( -radians ) * labelData.totalBounds.width() - qSin( -radians ) * labelData.totalBounds.height() / 2.0; - y = +qSin( -radians ) * labelData.totalBounds.width(); + x = -qCos(-radians)*labelData.totalBounds.width()-qSin(-radians)*labelData.totalBounds.height()/2.0; + y = +qSin(-radians)*labelData.totalBounds.width(); } - } - else + } else { - x = -labelData.totalBounds.width() / 2.0; + x = -labelData.totalBounds.width()/2.0; y = 0; } } - - return QPointF( x, y ); + + return QPointF(x, y); } /*! \internal @@ -9982,29 +9795,29 @@ QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset( const TickLabelData& labe margin calculation, the passed \a tickLabelsSize is only expanded, if it's currently set to a smaller width/height. */ -void QCPAxisPainterPrivate::getMaxTickLabelSize( const QFont& font, const QString& text, QSize* tickLabelsSize ) const +void QCPAxisPainterPrivate::getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const { // note: this function must return the same tick label sizes as the placeTickLabel function. QSize finalSize; - if( mParentPlot->plottingHints().testFlag( QCP::phCacheLabels ) && mLabelCache.contains( text ) ) // label caching enabled and have cached label + if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && mLabelCache.contains(text)) // label caching enabled and have cached label { - const CachedLabel* cachedLabel = mLabelCache.object( text ); - finalSize = cachedLabel->pixmap.size() / mParentPlot->bufferDevicePixelRatio(); - } - else // label caching disabled or no label with this text cached: + const CachedLabel *cachedLabel = mLabelCache.object(text); + finalSize = cachedLabel->pixmap.size()/mParentPlot->bufferDevicePixelRatio(); + } else // label caching disabled or no label with this text cached: { - TickLabelData labelData = getTickLabelData( font, text ); + TickLabelData labelData = getTickLabelData(font, text); finalSize = labelData.rotatedTotalBounds.size(); } - + // expand passed tickLabelsSize if current tick label is larger: - if( finalSize.width() > tickLabelsSize->width() ) - tickLabelsSize->setWidth( finalSize.width() ); - if( finalSize.height() > tickLabelsSize->height() ) - tickLabelsSize->setHeight( finalSize.height() ); + if (finalSize.width() > tickLabelsSize->width()) + tickLabelsSize->setWidth(finalSize.width()); + if (finalSize.height() > tickLabelsSize->height()) + tickLabelsSize->setHeight(finalSize.height()); } /* end of 'src/axis/axis.cpp' */ + /* including file 'src/scatterstyle.cpp', size 17450 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -10093,8 +9906,12 @@ void QCPAxisPainterPrivate::getMaxTickLabelSize( const QFont& font, const QStrin Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited from the plottable that uses this scatter style. */ -QCPScatterStyle::QCPScatterStyle() - : mSize( 6 ), mShape( ssNone ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPenDefined( false ) +QCPScatterStyle::QCPScatterStyle() : + mSize(6), + mShape(ssNone), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPenDefined(false) { } @@ -10105,8 +9922,12 @@ QCPScatterStyle::QCPScatterStyle() Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited from the plottable that uses this scatter style. */ -QCPScatterStyle::QCPScatterStyle( ScatterShape shape, double size ) - : mSize( size ), mShape( shape ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPenDefined( false ) +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, double size) : + mSize(size), + mShape(shape), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPenDefined(false) { } @@ -10114,8 +9935,12 @@ QCPScatterStyle::QCPScatterStyle( ScatterShape shape, double size ) Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color, and size to \a size. No brush is defined, i.e. the scatter point will not be filled. */ -QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, double size ) - : mSize( size ), mShape( shape ), mPen( QPen( color ) ), mBrush( Qt::NoBrush ), mPenDefined( true ) +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, double size) : + mSize(size), + mShape(shape), + mPen(QPen(color)), + mBrush(Qt::NoBrush), + mPenDefined(true) { } @@ -10123,8 +9948,12 @@ QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, doubl Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color, the brush color to \a fill (with a solid pattern), and size to \a size. */ -QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, const QColor& fill, double size ) - : mSize( size ), mShape( shape ), mPen( QPen( color ) ), mBrush( QBrush( fill ) ), mPenDefined( true ) +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size) : + mSize(size), + mShape(shape), + mPen(QPen(color)), + mBrush(QBrush(fill)), + mPenDefined(true) { } @@ -10143,8 +9972,12 @@ QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QColor& color, const instead of just Qt::blue, to clearly point out to the compiler that this constructor is wanted. */ -QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QPen& pen, const QBrush& brush, double size ) - : mSize( size ), mShape( shape ), mPen( pen ), mBrush( brush ), mPenDefined( pen.style() != Qt::NoPen ) +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size) : + mSize(size), + mShape(shape), + mPen(pen), + mBrush(brush), + mPenDefined(pen.style() != Qt::NoPen) { } @@ -10152,8 +9985,13 @@ QCPScatterStyle::QCPScatterStyle( ScatterShape shape, const QPen& pen, const QBr Creates a new QCPScatterStyle instance which will show the specified \a pixmap. The scatter shape is set to \ref ssPixmap. */ -QCPScatterStyle::QCPScatterStyle( const QPixmap& pixmap ) - : mSize( 5 ), mShape( ssPixmap ), mPen( Qt::NoPen ), mBrush( Qt::NoBrush ), mPixmap( pixmap ), mPenDefined( false ) +QCPScatterStyle::QCPScatterStyle(const QPixmap &pixmap) : + mSize(5), + mShape(ssPixmap), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPixmap(pixmap), + mPenDefined(false) { } @@ -10166,33 +10004,38 @@ QCPScatterStyle::QCPScatterStyle( const QPixmap& pixmap ) factor of \a size/6.0. Since the default \a size is 6, the custom path will appear in its original size by default. To for example double the size of the path, set \a size to 12. */ -QCPScatterStyle::QCPScatterStyle( const QPainterPath& customPath, const QPen& pen, const QBrush& brush, double size ) - : mSize( size ), mShape( ssCustom ), mPen( pen ), mBrush( brush ), mCustomPath( customPath ), mPenDefined( pen.style() != Qt::NoPen ) +QCPScatterStyle::QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush, double size) : + mSize(size), + mShape(ssCustom), + mPen(pen), + mBrush(brush), + mCustomPath(customPath), + mPenDefined(pen.style() != Qt::NoPen) { } /*! Copies the specified \a properties from the \a other scatter style to this scatter style. */ -void QCPScatterStyle::setFromOther( const QCPScatterStyle& other, ScatterProperties properties ) +void QCPScatterStyle::setFromOther(const QCPScatterStyle &other, ScatterProperties properties) { - if( properties.testFlag( spPen ) ) + if (properties.testFlag(spPen)) { - setPen( other.pen() ); - if( !other.isPenDefined() ) + setPen(other.pen()); + if (!other.isPenDefined()) undefinePen(); } - if( properties.testFlag( spBrush ) ) - setBrush( other.brush() ); - if( properties.testFlag( spSize ) ) - setSize( other.size() ); - if( properties.testFlag( spShape ) ) + if (properties.testFlag(spBrush)) + setBrush(other.brush()); + if (properties.testFlag(spSize)) + setSize(other.size()); + if (properties.testFlag(spShape)) { - setShape( other.shape() ); - if( other.shape() == ssPixmap ) - setPixmap( other.pixmap() ); - else if( other.shape() == ssCustom ) - setCustomPath( other.customPath() ); + setShape(other.shape()); + if (other.shape() == ssPixmap) + setPixmap(other.pixmap()); + else if (other.shape() == ssCustom) + setCustomPath(other.customPath()); } } @@ -10201,7 +10044,7 @@ void QCPScatterStyle::setFromOther( const QCPScatterStyle& other, ScatterPropert \see setShape */ -void QCPScatterStyle::setSize( double size ) +void QCPScatterStyle::setSize(double size) { mSize = size; } @@ -10214,7 +10057,7 @@ void QCPScatterStyle::setSize( double size ) \see setSize */ -void QCPScatterStyle::setShape( QCPScatterStyle::ScatterShape shape ) +void QCPScatterStyle::setShape(QCPScatterStyle::ScatterShape shape) { mShape = shape; } @@ -10228,7 +10071,7 @@ void QCPScatterStyle::setShape( QCPScatterStyle::ScatterShape shape ) \see setBrush */ -void QCPScatterStyle::setPen( const QPen& pen ) +void QCPScatterStyle::setPen(const QPen &pen) { mPenDefined = true; mPen = pen; @@ -10240,7 +10083,7 @@ void QCPScatterStyle::setPen( const QPen& pen ) \see setPen */ -void QCPScatterStyle::setBrush( const QBrush& brush ) +void QCPScatterStyle::setBrush(const QBrush &brush) { mBrush = brush; } @@ -10252,9 +10095,9 @@ void QCPScatterStyle::setBrush( const QBrush& brush ) The scatter shape is automatically set to \ref ssPixmap. */ -void QCPScatterStyle::setPixmap( const QPixmap& pixmap ) +void QCPScatterStyle::setPixmap(const QPixmap &pixmap) { - setShape( ssPixmap ); + setShape(ssPixmap); mPixmap = pixmap; } @@ -10263,9 +10106,9 @@ void QCPScatterStyle::setPixmap( const QPixmap& pixmap ) The scatter shape is automatically set to \ref ssCustom. */ -void QCPScatterStyle::setCustomPath( const QPainterPath& customPath ) +void QCPScatterStyle::setCustomPath(const QPainterPath &customPath) { - setShape( ssCustom ); + setShape(ssCustom); mCustomPath = customPath; } @@ -10289,10 +10132,10 @@ void QCPScatterStyle::undefinePen() \see drawShape */ -void QCPScatterStyle::applyTo( QCPPainter* painter, const QPen& defaultPen ) const +void QCPScatterStyle::applyTo(QCPPainter *painter, const QPen &defaultPen) const { - painter->setPen( mPenDefined ? mPen : defaultPen ); - painter->setBrush( mBrush ); + painter->setPen(mPenDefined ? mPen : defaultPen); + painter->setBrush(mBrush); } /*! @@ -10303,147 +10146,146 @@ void QCPScatterStyle::applyTo( QCPPainter* painter, const QPen& defaultPen ) con \see applyTo */ -void QCPScatterStyle::drawShape( QCPPainter* painter, const QPointF& pos ) const +void QCPScatterStyle::drawShape(QCPPainter *painter, const QPointF &pos) const { - drawShape( painter, pos.x(), pos.y() ); + drawShape(painter, pos.x(), pos.y()); } /*! \overload Draws the scatter shape with \a painter at position \a x and \a y. */ -void QCPScatterStyle::drawShape( QCPPainter* painter, double x, double y ) const +void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const { - double w = mSize / 2.0; - switch( mShape ) + double w = mSize/2.0; + switch (mShape) { - case ssNone: - break; - case ssDot: - { - painter->drawLine( QPointF( x, y ), QPointF( x + 0.0001, y ) ); - break; - } - case ssCross: - { - painter->drawLine( QLineF( x - w, y - w, x + w, y + w ) ); - painter->drawLine( QLineF( x - w, y + w, x + w, y - w ) ); - break; - } - case ssPlus: - { - painter->drawLine( QLineF( x - w, y, x + w, y ) ); - painter->drawLine( QLineF( x, y + w, x, y - w ) ); - break; - } - case ssCircle: - { - painter->drawEllipse( QPointF( x, y ), w, w ); - break; - } - case ssDisc: - { - QBrush b = painter->brush(); - painter->setBrush( painter->pen().color() ); - painter->drawEllipse( QPointF( x, y ), w, w ); - painter->setBrush( b ); - break; - } - case ssSquare: - { - painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) ); - break; - } - case ssDiamond: - { - QPointF lineArray[4] = {QPointF( x - w, y ), - QPointF( x, y - w ), - QPointF( x + w, y ), - QPointF( x, y + w )}; - painter->drawPolygon( lineArray, 4 ); - break; - } - case ssStar: - { - painter->drawLine( QLineF( x - w, y, x + w, y ) ); - painter->drawLine( QLineF( x, y + w, x, y - w ) ); - painter->drawLine( QLineF( x - w * 0.707, y - w * 0.707, x + w * 0.707, y + w * 0.707 ) ); - painter->drawLine( QLineF( x - w * 0.707, y + w * 0.707, x + w * 0.707, y - w * 0.707 ) ); - break; - } - case ssTriangle: - { - QPointF lineArray[3] = {QPointF( x - w, y + 0.755 * w ), - QPointF( x + w, y + 0.755 * w ), - QPointF( x, y - 0.977 * w )}; - painter->drawPolygon( lineArray, 3 ); - break; - } - case ssTriangleInverted: - { - QPointF lineArray[3] = {QPointF( x - w, y - 0.755 * w ), - QPointF( x + w, y - 0.755 * w ), - QPointF( x, y + 0.977 * w )}; - painter->drawPolygon( lineArray, 3 ); - break; - } - case ssCrossSquare: - { - painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) ); - painter->drawLine( QLineF( x - w, y - w, x + w * 0.95, y + w * 0.95 ) ); - painter->drawLine( QLineF( x - w, y + w * 0.95, x + w * 0.95, y - w ) ); - break; - } - case ssPlusSquare: - { - painter->drawRect( QRectF( x - w, y - w, mSize, mSize ) ); - painter->drawLine( QLineF( x - w, y, x + w * 0.95, y ) ); - painter->drawLine( QLineF( x, y + w, x, y - w ) ); - break; - } - case ssCrossCircle: - { - painter->drawEllipse( QPointF( x, y ), w, w ); - painter->drawLine( QLineF( x - w * 0.707, y - w * 0.707, x + w * 0.670, y + w * 0.670 ) ); - painter->drawLine( QLineF( x - w * 0.707, y + w * 0.670, x + w * 0.670, y - w * 0.707 ) ); - break; - } - case ssPlusCircle: - { - painter->drawEllipse( QPointF( x, y ), w, w ); - painter->drawLine( QLineF( x - w, y, x + w, y ) ); - painter->drawLine( QLineF( x, y + w, x, y - w ) ); - break; - } - case ssPeace: - { - painter->drawEllipse( QPointF( x, y ), w, w ); - painter->drawLine( QLineF( x, y - w, x, y + w ) ); - painter->drawLine( QLineF( x, y, x - w * 0.707, y + w * 0.707 ) ); - painter->drawLine( QLineF( x, y, x + w * 0.707, y + w * 0.707 ) ); - break; - } - case ssPixmap: - { - const double widthHalf = mPixmap.width() * 0.5; - const double heightHalf = mPixmap.height() * 0.5; -#if QT_VERSION < QT_VERSION_CHECK( 4, 8, 0 ) - const QRectF clipRect = painter->clipRegion().boundingRect().adjusted( -widthHalf, -heightHalf, widthHalf, heightHalf ); + case ssNone: break; + case ssDot: + { + painter->drawLine(QPointF(x, y), QPointF(x+0.0001, y)); + break; + } + case ssCross: + { + painter->drawLine(QLineF(x-w, y-w, x+w, y+w)); + painter->drawLine(QLineF(x-w, y+w, x+w, y-w)); + break; + } + case ssPlus: + { + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + break; + } + case ssCircle: + { + painter->drawEllipse(QPointF(x , y), w, w); + break; + } + case ssDisc: + { + QBrush b = painter->brush(); + painter->setBrush(painter->pen().color()); + painter->drawEllipse(QPointF(x , y), w, w); + painter->setBrush(b); + break; + } + case ssSquare: + { + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + break; + } + case ssDiamond: + { + QPointF lineArray[4] = {QPointF(x-w, y), + QPointF( x, y-w), + QPointF(x+w, y), + QPointF( x, y+w)}; + painter->drawPolygon(lineArray, 4); + break; + } + case ssStar: + { + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707)); + painter->drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707)); + break; + } + case ssTriangle: + { + QPointF lineArray[3] = {QPointF(x-w, y+0.755*w), + QPointF(x+w, y+0.755*w), + QPointF( x, y-0.977*w)}; + painter->drawPolygon(lineArray, 3); + break; + } + case ssTriangleInverted: + { + QPointF lineArray[3] = {QPointF(x-w, y-0.755*w), + QPointF(x+w, y-0.755*w), + QPointF( x, y+0.977*w)}; + painter->drawPolygon(lineArray, 3); + break; + } + case ssCrossSquare: + { + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + painter->drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95)); + painter->drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w)); + break; + } + case ssPlusSquare: + { + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + painter->drawLine(QLineF(x-w, y, x+w*0.95, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + break; + } + case ssCrossCircle: + { + painter->drawEllipse(QPointF(x, y), w, w); + painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670)); + painter->drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707)); + break; + } + case ssPlusCircle: + { + painter->drawEllipse(QPointF(x, y), w, w); + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + break; + } + case ssPeace: + { + painter->drawEllipse(QPointF(x, y), w, w); + painter->drawLine(QLineF(x, y-w, x, y+w)); + painter->drawLine(QLineF(x, y, x-w*0.707, y+w*0.707)); + painter->drawLine(QLineF(x, y, x+w*0.707, y+w*0.707)); + break; + } + case ssPixmap: + { + const double widthHalf = mPixmap.width()*0.5; + const double heightHalf = mPixmap.height()*0.5; +#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) + const QRectF clipRect = painter->clipRegion().boundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf); #else - const QRectF clipRect = painter->clipBoundingRect().adjusted( -widthHalf, -heightHalf, widthHalf, heightHalf ); + const QRectF clipRect = painter->clipBoundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf); #endif - if( clipRect.contains( x, y ) ) - painter->drawPixmap( x - widthHalf, y - heightHalf, mPixmap ); - break; - } - case ssCustom: - { - QTransform oldTransform = painter->transform(); - painter->translate( x, y ); - painter->scale( mSize / 6.0, mSize / 6.0 ); - painter->drawPath( mCustomPath ); - painter->setTransform( oldTransform ); - break; - } + if (clipRect.contains(x, y)) + painter->drawPixmap(x-widthHalf, y-heightHalf, mPixmap); + break; + } + case ssCustom: + { + QTransform oldTransform = painter->transform(); + painter->translate(x, y); + painter->scale(mSize/6.0, mSize/6.0); + painter->drawPath(mCustomPath); + painter->setTransform(oldTransform); + break; + } } } /* end of 'src/scatterstyle.cpp' */ @@ -10486,8 +10328,12 @@ void QCPScatterStyle::drawShape( QCPPainter* painter, double x, double y ) const /*! Creates a new QCPSelectionDecorator instance with default values */ -QCPSelectionDecorator::QCPSelectionDecorator() - : mPen( QColor( 80, 80, 255 ), 2.5 ), mBrush( Qt::NoBrush ), mScatterStyle(), mUsedScatterProperties( QCPScatterStyle::spNone ), mPlottable( 0 ) +QCPSelectionDecorator::QCPSelectionDecorator() : + mPen(QColor(80, 80, 255), 2.5), + mBrush(Qt::NoBrush), + mScatterStyle(), + mUsedScatterProperties(QCPScatterStyle::spNone), + mPlottable(0) { } @@ -10498,7 +10344,7 @@ QCPSelectionDecorator::~QCPSelectionDecorator() /*! Sets the pen that will be used by the parent plottable to draw selected data segments. */ -void QCPSelectionDecorator::setPen( const QPen& pen ) +void QCPSelectionDecorator::setPen(const QPen &pen) { mPen = pen; } @@ -10506,7 +10352,7 @@ void QCPSelectionDecorator::setPen( const QPen& pen ) /*! Sets the brush that will be used by the parent plottable to draw selected data segments. */ -void QCPSelectionDecorator::setBrush( const QBrush& brush ) +void QCPSelectionDecorator::setBrush(const QBrush &brush) { mBrush = brush; } @@ -10518,10 +10364,10 @@ void QCPSelectionDecorator::setBrush( const QBrush& brush ) \a usedProperties specifies which parts of the passed \a scatterStyle will be used by the plottable. The used properties can also be changed via \ref setUsedScatterProperties. */ -void QCPSelectionDecorator::setScatterStyle( const QCPScatterStyle& scatterStyle, QCPScatterStyle::ScatterProperties usedProperties ) +void QCPSelectionDecorator::setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties) { mScatterStyle = scatterStyle; - setUsedScatterProperties( usedProperties ); + setUsedScatterProperties(usedProperties); } /*! @@ -10531,7 +10377,7 @@ void QCPSelectionDecorator::setScatterStyle( const QCPScatterStyle& scatterStyle \see QCPScatterStyle::ScatterProperty */ -void QCPSelectionDecorator::setUsedScatterProperties( const QCPScatterStyle::ScatterProperties& properties ) +void QCPSelectionDecorator::setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties) { mUsedScatterProperties = properties; } @@ -10541,9 +10387,9 @@ void QCPSelectionDecorator::setUsedScatterProperties( const QCPScatterStyle::Sca \see applyBrush, getFinalScatterStyle */ -void QCPSelectionDecorator::applyPen( QCPPainter* painter ) const +void QCPSelectionDecorator::applyPen(QCPPainter *painter) const { - painter->setPen( mPen ); + painter->setPen(mPen); } /*! @@ -10551,9 +10397,9 @@ void QCPSelectionDecorator::applyPen( QCPPainter* painter ) const \see applyPen, getFinalScatterStyle */ -void QCPSelectionDecorator::applyBrush( QCPPainter* painter ) const +void QCPSelectionDecorator::applyBrush(QCPPainter *painter) const { - painter->setBrush( mBrush ); + painter->setBrush(mBrush); } /*! @@ -10564,17 +10410,17 @@ void QCPSelectionDecorator::applyBrush( QCPPainter* painter ) const \see applyPen, applyBrush, setScatterStyle */ -QCPScatterStyle QCPSelectionDecorator::getFinalScatterStyle( const QCPScatterStyle& unselectedStyle ) const +QCPScatterStyle QCPSelectionDecorator::getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const { - QCPScatterStyle result( unselectedStyle ); - result.setFromOther( mScatterStyle, mUsedScatterProperties ); - + QCPScatterStyle result(unselectedStyle); + result.setFromOther(mScatterStyle, mUsedScatterProperties); + // if style shall inherit pen from plottable (has no own pen defined), give it the selected // plottable pen explicitly, so it doesn't use the unselected plottable pen when used in the // plottable: - if( !result.isPenDefined() ) - result.setPen( mPen ); - + if (!result.isPenDefined()) + result.setPen(mPen); + return result; } @@ -10582,11 +10428,11 @@ QCPScatterStyle QCPSelectionDecorator::getFinalScatterStyle( const QCPScatterSty Copies all properties (e.g. color, fill, scatter style) of the \a other selection decorator to this selection decorator. */ -void QCPSelectionDecorator::copyFrom( const QCPSelectionDecorator* other ) +void QCPSelectionDecorator::copyFrom(const QCPSelectionDecorator *other) { - setPen( other->pen() ); - setBrush( other->brush() ); - setScatterStyle( other->scatterStyle(), other->usedScatterProperties() ); + setPen(other->pen()); + setBrush(other->brush()); + setScatterStyle(other->scatterStyle(), other->usedScatterProperties()); } /*! @@ -10597,10 +10443,10 @@ void QCPSelectionDecorator::copyFrom( const QCPSelectionDecorator* other ) The default base class implementation of \ref QCPSelectionDecorator has no special decoration, so this method does nothing. */ -void QCPSelectionDecorator::drawDecoration( QCPPainter* painter, QCPDataSelection selection ) +void QCPSelectionDecorator::drawDecoration(QCPPainter *painter, QCPDataSelection selection) { - Q_UNUSED( painter ) - Q_UNUSED( selection ) + Q_UNUSED(painter) + Q_UNUSED(selection) } /*! \internal @@ -10612,20 +10458,20 @@ void QCPSelectionDecorator::drawDecoration( QCPPainter* painter, QCPDataSelectio If the selection decorator was already added to a different plottable before, this method aborts the registration and returns false. */ -bool QCPSelectionDecorator::registerWithPlottable( QCPAbstractPlottable* plottable ) +bool QCPSelectionDecorator::registerWithPlottable(QCPAbstractPlottable *plottable) { - if( !mPlottable ) + if (!mPlottable) { mPlottable = plottable; return true; - } - else + } else { - qDebug() << Q_FUNC_INFO << "This selection decorator is already registered with plottable:" << reinterpret_cast( mPlottable ); + qDebug() << Q_FUNC_INFO << "This selection decorator is already registered with plottable:" << reinterpret_cast(mPlottable); return false; } } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractPlottable //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -10841,21 +10687,30 @@ bool QCPSelectionDecorator::registerWithPlottable( QCPAbstractPlottable* plottab You probably want one of the subclasses like \ref QCPGraph or \ref QCPCurve instead. */ -QCPAbstractPlottable::QCPAbstractPlottable( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPLayerable( keyAxis->parentPlot(), QString(), keyAxis->axisRect() ), mName(), mAntialiasedFill( true ), mAntialiasedScatters( true ), mPen( Qt::black ), mBrush( Qt::NoBrush ), mKeyAxis( keyAxis ), mValueAxis( valueAxis ), mSelectable( QCP::stWhole ), mSelectionDecorator( 0 ) +QCPAbstractPlottable::QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPLayerable(keyAxis->parentPlot(), QString(), keyAxis->axisRect()), + mName(), + mAntialiasedFill(true), + mAntialiasedScatters(true), + mPen(Qt::black), + mBrush(Qt::NoBrush), + mKeyAxis(keyAxis), + mValueAxis(valueAxis), + mSelectable(QCP::stWhole), + mSelectionDecorator(0) { - if( keyAxis->parentPlot() != valueAxis->parentPlot() ) + if (keyAxis->parentPlot() != valueAxis->parentPlot()) qDebug() << Q_FUNC_INFO << "Parent plot of keyAxis is not the same as that of valueAxis."; - if( keyAxis->orientation() == valueAxis->orientation() ) + if (keyAxis->orientation() == valueAxis->orientation()) qDebug() << Q_FUNC_INFO << "keyAxis and valueAxis must be orthogonal to each other."; - - mParentPlot->registerPlottable( this ); - setSelectionDecorator( new QCPSelectionDecorator ); + + mParentPlot->registerPlottable(this); + setSelectionDecorator(new QCPSelectionDecorator); } QCPAbstractPlottable::~QCPAbstractPlottable() { - if( mSelectionDecorator ) + if (mSelectionDecorator) { delete mSelectionDecorator; mSelectionDecorator = 0; @@ -10866,7 +10721,7 @@ QCPAbstractPlottable::~QCPAbstractPlottable() The name is the textual representation of this plottable as it is displayed in the legend (\ref QCPLegend). It may contain any UTF-8 characters, including newlines. */ -void QCPAbstractPlottable::setName( const QString& name ) +void QCPAbstractPlottable::setName(const QString &name) { mName = name; } @@ -10877,7 +10732,7 @@ void QCPAbstractPlottable::setName( const QString& name ) Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. */ -void QCPAbstractPlottable::setAntialiasedFill( bool enabled ) +void QCPAbstractPlottable::setAntialiasedFill(bool enabled) { mAntialiasedFill = enabled; } @@ -10888,7 +10743,7 @@ void QCPAbstractPlottable::setAntialiasedFill( bool enabled ) Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref QCustomPlot::setNotAntialiasedElements. */ -void QCPAbstractPlottable::setAntialiasedScatters( bool enabled ) +void QCPAbstractPlottable::setAntialiasedScatters(bool enabled) { mAntialiasedScatters = enabled; } @@ -10901,7 +10756,7 @@ void QCPAbstractPlottable::setAntialiasedScatters( bool enabled ) \see setBrush */ -void QCPAbstractPlottable::setPen( const QPen& pen ) +void QCPAbstractPlottable::setPen(const QPen &pen) { mPen = pen; } @@ -10915,7 +10770,7 @@ void QCPAbstractPlottable::setPen( const QPen& pen ) \see setPen */ -void QCPAbstractPlottable::setBrush( const QBrush& brush ) +void QCPAbstractPlottable::setBrush(const QBrush &brush) { mBrush = brush; } @@ -10931,7 +10786,7 @@ void QCPAbstractPlottable::setBrush( const QBrush& brush ) \see setValueAxis */ -void QCPAbstractPlottable::setKeyAxis( QCPAxis* axis ) +void QCPAbstractPlottable::setKeyAxis(QCPAxis *axis) { mKeyAxis = axis; } @@ -10947,11 +10802,12 @@ void QCPAbstractPlottable::setKeyAxis( QCPAxis* axis ) \see setKeyAxis */ -void QCPAbstractPlottable::setValueAxis( QCPAxis* axis ) +void QCPAbstractPlottable::setValueAxis(QCPAxis *axis) { mValueAxis = axis; } + /*! Sets which data ranges of this plottable are selected. Selected data ranges are drawn differently (e.g. color) in the plot. This can be controlled via the selection decorator (see \ref @@ -10970,14 +10826,14 @@ void QCPAbstractPlottable::setValueAxis( QCPAxis* axis ) \see setSelectable, selectTest */ -void QCPAbstractPlottable::setSelection( QCPDataSelection selection ) +void QCPAbstractPlottable::setSelection(QCPDataSelection selection) { - selection.enforceType( mSelectable ); - if( mSelection != selection ) + selection.enforceType(mSelectable); + if (mSelection != selection) { mSelection = selection; - emit selectionChanged( selected() ); - emit selectionChanged( mSelection ); + emit selectionChanged(selected()); + emit selectionChanged(mSelection); } } @@ -10990,18 +10846,17 @@ void QCPAbstractPlottable::setSelection( QCPDataSelection selection ) The currently set decorator can be accessed via \ref selectionDecorator. */ -void QCPAbstractPlottable::setSelectionDecorator( QCPSelectionDecorator* decorator ) +void QCPAbstractPlottable::setSelectionDecorator(QCPSelectionDecorator *decorator) { - if( decorator ) + if (decorator) { - if( decorator->registerWithPlottable( this ) ) + if (decorator->registerWithPlottable(this)) { - if( mSelectionDecorator ) // delete old decorator if necessary + if (mSelectionDecorator) // delete old decorator if necessary delete mSelectionDecorator; mSelectionDecorator = decorator; } - } - else if( mSelectionDecorator ) // just clear decorator + } else if (mSelectionDecorator) // just clear decorator { delete mSelectionDecorator; mSelectionDecorator = 0; @@ -11018,22 +10873,23 @@ void QCPAbstractPlottable::setSelectionDecorator( QCPSelectionDecorator* decorat \see setSelection, QCP::SelectionType */ -void QCPAbstractPlottable::setSelectable( QCP::SelectionType selectable ) +void QCPAbstractPlottable::setSelectable(QCP::SelectionType selectable) { - if( mSelectable != selectable ) + if (mSelectable != selectable) { mSelectable = selectable; QCPDataSelection oldSelection = mSelection; - mSelection.enforceType( mSelectable ); - emit selectableChanged( mSelectable ); - if( mSelection != oldSelection ) + mSelection.enforceType(mSelectable); + emit selectableChanged(mSelectable); + if (mSelection != oldSelection) { - emit selectionChanged( selected() ); - emit selectionChanged( mSelection ); + emit selectionChanged(selected()); + emit selectionChanged(mSelection); } } } + /*! Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, taking the orientations of the axes associated with this plottable into account (e.g. whether key @@ -11043,25 +10899,20 @@ void QCPAbstractPlottable::setSelectable( QCP::SelectionType selectable ) \see pixelsToCoords, QCPAxis::coordToPixel */ -void QCPAbstractPlottable::coordsToPixels( double key, double value, double& x, double& y ) const +void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, double &y) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - - if( keyAxis->orientation() == Qt::Horizontal ) + x = keyAxis->coordToPixel(key); + y = valueAxis->coordToPixel(value); + } else { - x = keyAxis->coordToPixel( key ); - y = valueAxis->coordToPixel( value ); - } - else - { - y = keyAxis->coordToPixel( key ); - x = valueAxis->coordToPixel( value ); + y = keyAxis->coordToPixel(key); + x = valueAxis->coordToPixel(value); } } @@ -11069,20 +10920,16 @@ void QCPAbstractPlottable::coordsToPixels( double key, double value, double& x, Transforms the given \a key and \a value to pixel coordinates and returns them in a QPointF. */ -const QPointF QCPAbstractPlottable::coordsToPixels( double key, double value ) const +const QPointF QCPAbstractPlottable::coordsToPixels(double key, double value) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QPointF(); - } - - if( keyAxis->orientation() == Qt::Horizontal ) - return QPointF( keyAxis->coordToPixel( key ), valueAxis->coordToPixel( value ) ); + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + if (keyAxis->orientation() == Qt::Horizontal) + return QPointF(keyAxis->coordToPixel(key), valueAxis->coordToPixel(value)); else - return QPointF( valueAxis->coordToPixel( value ), keyAxis->coordToPixel( key ) ); + return QPointF(valueAxis->coordToPixel(value), keyAxis->coordToPixel(key)); } /*! @@ -11094,25 +10941,20 @@ const QPointF QCPAbstractPlottable::coordsToPixels( double key, double value ) c \see coordsToPixels, QCPAxis::coordToPixel */ -void QCPAbstractPlottable::pixelsToCoords( double x, double y, double& key, double& value ) const +void QCPAbstractPlottable::pixelsToCoords(double x, double y, double &key, double &value) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - - if( keyAxis->orientation() == Qt::Horizontal ) + key = keyAxis->pixelToCoord(x); + value = valueAxis->pixelToCoord(y); + } else { - key = keyAxis->pixelToCoord( x ); - value = valueAxis->pixelToCoord( y ); - } - else - { - key = keyAxis->pixelToCoord( y ); - value = valueAxis->pixelToCoord( x ); + key = keyAxis->pixelToCoord(y); + value = valueAxis->pixelToCoord(x); } } @@ -11120,9 +10962,9 @@ void QCPAbstractPlottable::pixelsToCoords( double x, double y, double& key, doub Returns the pixel input \a pixelPos as plot coordinates \a key and \a value. */ -void QCPAbstractPlottable::pixelsToCoords( const QPointF& pixelPos, double& key, double& value ) const +void QCPAbstractPlottable::pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const { - pixelsToCoords( pixelPos.x(), pixelPos.y(), key, value ); + pixelsToCoords(pixelPos.x(), pixelPos.y(), key, value); } /*! @@ -11138,10 +10980,10 @@ void QCPAbstractPlottable::pixelsToCoords( const QPointF& pixelPos, double& key, \see rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale */ -void QCPAbstractPlottable::rescaleAxes( bool onlyEnlarge ) const +void QCPAbstractPlottable::rescaleAxes(bool onlyEnlarge) const { - rescaleKeyAxis( onlyEnlarge ); - rescaleValueAxis( onlyEnlarge ); + rescaleKeyAxis(onlyEnlarge); + rescaleValueAxis(onlyEnlarge); } /*! @@ -11149,40 +10991,35 @@ void QCPAbstractPlottable::rescaleAxes( bool onlyEnlarge ) const See \ref rescaleAxes for detailed behaviour. */ -void QCPAbstractPlottable::rescaleKeyAxis( bool onlyEnlarge ) const +void QCPAbstractPlottable::rescaleKeyAxis(bool onlyEnlarge) const { - QCPAxis* keyAxis = mKeyAxis.data(); - if( !keyAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key axis"; - return; - } - + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + QCP::SignDomain signDomain = QCP::sdBoth; - if( keyAxis->scaleType() == QCPAxis::stLogarithmic ) - signDomain = ( keyAxis->range().upper < 0 ? QCP::sdNegative : QCP::sdPositive ); - + if (keyAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (keyAxis->range().upper < 0 ? QCP::sdNegative : QCP::sdPositive); + bool foundRange; - QCPRange newRange = getKeyRange( foundRange, signDomain ); - if( foundRange ) + QCPRange newRange = getKeyRange(foundRange, signDomain); + if (foundRange) { - if( onlyEnlarge ) - newRange.expand( keyAxis->range() ); - if( !QCPRange::validRange( newRange ) ) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + if (onlyEnlarge) + newRange.expand(keyAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable { - double center = ( newRange.lower + newRange.upper ) * 0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason - if( keyAxis->scaleType() == QCPAxis::stLinear ) + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (keyAxis->scaleType() == QCPAxis::stLinear) { - newRange.lower = center - keyAxis->range().size() / 2.0; - newRange.upper = center + keyAxis->range().size() / 2.0; - } - else // scaleType() == stLogarithmic + newRange.lower = center-keyAxis->range().size()/2.0; + newRange.upper = center+keyAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic { - newRange.lower = center / qSqrt( keyAxis->range().upper / keyAxis->range().lower ); - newRange.upper = center * qSqrt( keyAxis->range().upper / keyAxis->range().lower ); + newRange.lower = center/qSqrt(keyAxis->range().upper/keyAxis->range().lower); + newRange.upper = center*qSqrt(keyAxis->range().upper/keyAxis->range().lower); } } - keyAxis->setRange( newRange ); + keyAxis->setRange(newRange); } } @@ -11196,41 +11033,36 @@ void QCPAbstractPlottable::rescaleKeyAxis( bool onlyEnlarge ) const See \ref rescaleAxes for detailed behaviour. */ -void QCPAbstractPlottable::rescaleValueAxis( bool onlyEnlarge, bool inKeyRange ) const +void QCPAbstractPlottable::rescaleValueAxis(bool onlyEnlarge, bool inKeyRange) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + QCP::SignDomain signDomain = QCP::sdBoth; - if( valueAxis->scaleType() == QCPAxis::stLogarithmic ) - signDomain = ( valueAxis->range().upper < 0 ? QCP::sdNegative : QCP::sdPositive ); - + if (valueAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (valueAxis->range().upper < 0 ? QCP::sdNegative : QCP::sdPositive); + bool foundRange; - QCPRange newRange = getValueRange( foundRange, signDomain, inKeyRange ? keyAxis->range() : QCPRange() ); - if( foundRange ) + QCPRange newRange = getValueRange(foundRange, signDomain, inKeyRange ? keyAxis->range() : QCPRange()); + if (foundRange) { - if( onlyEnlarge ) - newRange.expand( valueAxis->range() ); - if( !QCPRange::validRange( newRange ) ) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + if (onlyEnlarge) + newRange.expand(valueAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable { - double center = ( newRange.lower + newRange.upper ) * 0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason - if( valueAxis->scaleType() == QCPAxis::stLinear ) + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (valueAxis->scaleType() == QCPAxis::stLinear) { - newRange.lower = center - valueAxis->range().size() / 2.0; - newRange.upper = center + valueAxis->range().size() / 2.0; - } - else // scaleType() == stLogarithmic + newRange.lower = center-valueAxis->range().size()/2.0; + newRange.upper = center+valueAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic { - newRange.lower = center / qSqrt( valueAxis->range().upper / valueAxis->range().lower ); - newRange.upper = center * qSqrt( valueAxis->range().upper / valueAxis->range().lower ); + newRange.lower = center/qSqrt(valueAxis->range().upper/valueAxis->range().lower); + newRange.upper = center*qSqrt(valueAxis->range().upper/valueAxis->range().lower); } } - valueAxis->setRange( newRange ); + valueAxis->setRange(newRange); } } @@ -11248,25 +11080,24 @@ void QCPAbstractPlottable::rescaleValueAxis( bool onlyEnlarge, bool inKeyRange ) \see removeFromLegend, QCPLegend::addItem */ -bool QCPAbstractPlottable::addToLegend( QCPLegend* legend ) +bool QCPAbstractPlottable::addToLegend(QCPLegend *legend) { - if( !legend ) + if (!legend) { qDebug() << Q_FUNC_INFO << "passed legend is null"; return false; } - if( legend->parentPlot() != mParentPlot ) + if (legend->parentPlot() != mParentPlot) { qDebug() << Q_FUNC_INFO << "passed legend isn't in the same QCustomPlot as this plottable"; return false; } - - if( !legend->hasItemWithPlottable( this ) ) + + if (!legend->hasItemWithPlottable(this)) { - legend->addItem( new QCPPlottableLegendItem( legend, this ) ); + legend->addItem(new QCPPlottableLegendItem(legend, this)); return true; - } - else + } else return false; } @@ -11278,10 +11109,10 @@ bool QCPAbstractPlottable::addToLegend( QCPLegend* legend ) */ bool QCPAbstractPlottable::addToLegend() { - if( !mParentPlot || !mParentPlot->legend ) + if (!mParentPlot || !mParentPlot->legend) return false; else - return addToLegend( mParentPlot->legend ); + return addToLegend(mParentPlot->legend); } /*! \overload @@ -11294,16 +11125,16 @@ bool QCPAbstractPlottable::addToLegend() \see addToLegend, QCPLegend::removeItem */ -bool QCPAbstractPlottable::removeFromLegend( QCPLegend* legend ) const +bool QCPAbstractPlottable::removeFromLegend(QCPLegend *legend) const { - if( !legend ) + if (!legend) { qDebug() << Q_FUNC_INFO << "passed legend is null"; return false; } - - if( QCPPlottableLegendItem* lip = legend->itemWithPlottable( this ) ) - return legend->removeItem( lip ); + + if (QCPPlottableLegendItem *lip = legend->itemWithPlottable(this)) + return legend->removeItem(lip); else return false; } @@ -11316,16 +11147,16 @@ bool QCPAbstractPlottable::removeFromLegend( QCPLegend* legend ) const */ bool QCPAbstractPlottable::removeFromLegend() const { - if( !mParentPlot || !mParentPlot->legend ) + if (!mParentPlot || !mParentPlot->legend) return false; else - return removeFromLegend( mParentPlot->legend ); + return removeFromLegend(mParentPlot->legend); } /* inherits documentation from base class */ QRect QCPAbstractPlottable::clipRect() const { - if( mKeyAxis && mValueAxis ) + if (mKeyAxis && mValueAxis) return mKeyAxis.data()->axisRect()->rect() & mValueAxis.data()->axisRect()->rect(); else return QRect(); @@ -11352,9 +11183,9 @@ QCP::Interaction QCPAbstractPlottable::selectionCategory() const \see setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint */ -void QCPAbstractPlottable::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPAbstractPlottable::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aePlottables ); + applyAntialiasingHint(painter, mAntialiased, QCP::aePlottables); } /*! \internal @@ -11368,9 +11199,9 @@ void QCPAbstractPlottable::applyDefaultAntialiasingHint( QCPPainter* painter ) c \see setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint */ -void QCPAbstractPlottable::applyFillAntialiasingHint( QCPPainter* painter ) const +void QCPAbstractPlottable::applyFillAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiasedFill, QCP::aeFills ); + applyAntialiasingHint(painter, mAntialiasedFill, QCP::aeFills); } /*! \internal @@ -11384,57 +11215,56 @@ void QCPAbstractPlottable::applyFillAntialiasingHint( QCPPainter* painter ) cons \see setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint */ -void QCPAbstractPlottable::applyScattersAntialiasingHint( QCPPainter* painter ) const +void QCPAbstractPlottable::applyScattersAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiasedScatters, QCP::aeScatters ); + applyAntialiasingHint(painter, mAntialiasedScatters, QCP::aeScatters); } /* inherits documentation from base class */ -void QCPAbstractPlottable::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPAbstractPlottable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - - if( mSelectable != QCP::stNone ) + Q_UNUSED(event) + + if (mSelectable != QCP::stNone) { QCPDataSelection newSelection = details.value(); QCPDataSelection selectionBefore = mSelection; - if( additive ) + if (additive) { - if( mSelectable == QCP::stWhole ) // in whole selection mode, we toggle to no selection even if currently unselected point was hit + if (mSelectable == QCP::stWhole) // in whole selection mode, we toggle to no selection even if currently unselected point was hit { - if( selected() ) - setSelection( QCPDataSelection() ); + if (selected()) + setSelection(QCPDataSelection()); else - setSelection( newSelection ); - } - else // in all other selection modes we toggle selections of homogeneously selected/unselected segments + setSelection(newSelection); + } else // in all other selection modes we toggle selections of homogeneously selected/unselected segments { - if( mSelection.contains( newSelection ) ) // if entire newSelection is already selected, toggle selection - setSelection( mSelection - newSelection ); + if (mSelection.contains(newSelection)) // if entire newSelection is already selected, toggle selection + setSelection(mSelection-newSelection); else - setSelection( mSelection + newSelection ); + setSelection(mSelection+newSelection); } - } - else - setSelection( newSelection ); - if( selectionStateChanged ) + } else + setSelection(newSelection); + if (selectionStateChanged) *selectionStateChanged = mSelection != selectionBefore; } } /* inherits documentation from base class */ -void QCPAbstractPlottable::deselectEvent( bool* selectionStateChanged ) +void QCPAbstractPlottable::deselectEvent(bool *selectionStateChanged) { - if( mSelectable != QCP::stNone ) + if (mSelectable != QCP::stNone) { QCPDataSelection selectionBefore = mSelection; - setSelection( QCPDataSelection() ); - if( selectionStateChanged ) + setSelection(QCPDataSelection()); + if (selectionStateChanged) *selectionStateChanged = mSelection != selectionBefore; } } /* end of 'src/plottable.cpp' */ + /* including file 'src/item.cpp', size 49269 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -11482,23 +11312,26 @@ void QCPAbstractPlottable::deselectEvent( bool* selectionStateChanged ) you want to make a new item subclass. Use \ref QCPAbstractItem::createAnchor instead, as explained in the subclassing section of the QCPAbstractItem documentation. */ -QCPItemAnchor::QCPItemAnchor( QCustomPlot* parentPlot, QCPAbstractItem* parentItem, const QString& name, int anchorId ) - : mName( name ), mParentPlot( parentPlot ), mParentItem( parentItem ), mAnchorId( anchorId ) +QCPItemAnchor::QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId) : + mName(name), + mParentPlot(parentPlot), + mParentItem(parentItem), + mAnchorId(anchorId) { } QCPItemAnchor::~QCPItemAnchor() { // unregister as parent at children: - foreach( QCPItemPosition* child, mChildrenX.toList() ) + foreach (QCPItemPosition *child, mChildrenX.toList()) { - if( child->parentAnchorX() == this ) - child->setParentAnchorX( 0 ); // this acts back on this anchor and child removes itself from mChildrenX + if (child->parentAnchorX() == this) + child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX } - foreach( QCPItemPosition* child, mChildrenY.toList() ) + foreach (QCPItemPosition *child, mChildrenY.toList()) { - if( child->parentAnchorY() == this ) - child->setParentAnchorY( 0 ); // this acts back on this anchor and child removes itself from mChildrenY + if (child->parentAnchorY() == this) + child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY } } @@ -11510,19 +11343,17 @@ QCPItemAnchor::~QCPItemAnchor() */ QPointF QCPItemAnchor::pixelPosition() const { - if( mParentItem ) + if (mParentItem) { - if( mAnchorId > -1 ) + if (mAnchorId > -1) { - return mParentItem->anchorPixelPosition( mAnchorId ); - } - else + return mParentItem->anchorPixelPosition(mAnchorId); + } else { qDebug() << Q_FUNC_INFO << "no valid anchor id set:" << mAnchorId; return QPointF(); } - } - else + } else { qDebug() << Q_FUNC_INFO << "no parent item set"; return QPointF(); @@ -11537,12 +11368,12 @@ QPointF QCPItemAnchor::pixelPosition() const Note that this function does not change the parent setting in \a pos. */ -void QCPItemAnchor::addChildX( QCPItemPosition* pos ) +void QCPItemAnchor::addChildX(QCPItemPosition *pos) { - if( !mChildrenX.contains( pos ) ) - mChildrenX.insert( pos ); + if (!mChildrenX.contains(pos)) + mChildrenX.insert(pos); else - qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast( pos ); + qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast(pos); } /*! \internal @@ -11551,10 +11382,10 @@ void QCPItemAnchor::addChildX( QCPItemPosition* pos ) Note that this function does not change the parent setting in \a pos. */ -void QCPItemAnchor::removeChildX( QCPItemPosition* pos ) +void QCPItemAnchor::removeChildX(QCPItemPosition *pos) { - if( !mChildrenX.remove( pos ) ) - qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast( pos ); + if (!mChildrenX.remove(pos)) + qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast(pos); } /*! \internal @@ -11565,12 +11396,12 @@ void QCPItemAnchor::removeChildX( QCPItemPosition* pos ) Note that this function does not change the parent setting in \a pos. */ -void QCPItemAnchor::addChildY( QCPItemPosition* pos ) +void QCPItemAnchor::addChildY(QCPItemPosition *pos) { - if( !mChildrenY.contains( pos ) ) - mChildrenY.insert( pos ); + if (!mChildrenY.contains(pos)) + mChildrenY.insert(pos); else - qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast( pos ); + qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast(pos); } /*! \internal @@ -11579,12 +11410,13 @@ void QCPItemAnchor::addChildY( QCPItemPosition* pos ) Note that this function does not change the parent setting in \a pos. */ -void QCPItemAnchor::removeChildY( QCPItemPosition* pos ) +void QCPItemAnchor::removeChildY(QCPItemPosition *pos) { - if( !mChildrenY.remove( pos ) ) - qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast( pos ); + if (!mChildrenY.remove(pos)) + qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast(pos); } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPItemPosition //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -11653,8 +11485,14 @@ void QCPItemAnchor::removeChildY( QCPItemPosition* pos ) you want to make a new item subclass. Use \ref QCPAbstractItem::createPosition instead, as explained in the subclassing section of the QCPAbstractItem documentation. */ -QCPItemPosition::QCPItemPosition( QCustomPlot* parentPlot, QCPAbstractItem* parentItem, const QString& name ) - : QCPItemAnchor( parentPlot, parentItem, name ), mPositionTypeX( ptAbsolute ), mPositionTypeY( ptAbsolute ), mKey( 0 ), mValue( 0 ), mParentAnchorX( 0 ), mParentAnchorY( 0 ) +QCPItemPosition::QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name) : + QCPItemAnchor(parentPlot, parentItem, name), + mPositionTypeX(ptAbsolute), + mPositionTypeY(ptAbsolute), + mKey(0), + mValue(0), + mParentAnchorX(0), + mParentAnchorY(0) { } @@ -11663,25 +11501,25 @@ QCPItemPosition::~QCPItemPosition() // unregister as parent at children: // Note: this is done in ~QCPItemAnchor again, but it's important QCPItemPosition does it itself, because only then // the setParentAnchor(0) call the correct QCPItemPosition::pixelPosition function instead of QCPItemAnchor::pixelPosition - foreach( QCPItemPosition* child, mChildrenX.toList() ) + foreach (QCPItemPosition *child, mChildrenX.toList()) { - if( child->parentAnchorX() == this ) - child->setParentAnchorX( 0 ); // this acts back on this anchor and child removes itself from mChildrenX + if (child->parentAnchorX() == this) + child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX } - foreach( QCPItemPosition* child, mChildrenY.toList() ) + foreach (QCPItemPosition *child, mChildrenY.toList()) { - if( child->parentAnchorY() == this ) - child->setParentAnchorY( 0 ); // this acts back on this anchor and child removes itself from mChildrenY + if (child->parentAnchorY() == this) + child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY } // unregister as child in parent: - if( mParentAnchorX ) - mParentAnchorX->removeChildX( this ); - if( mParentAnchorY ) - mParentAnchorY->removeChildY( this ); + if (mParentAnchorX) + mParentAnchorX->removeChildX(this); + if (mParentAnchorY) + mParentAnchorY->removeChildY(this); } /* can't make this a header inline function, because QPointer breaks with forward declared types, see QTBUG-29588 */ -QCPAxisRect* QCPItemPosition::axisRect() const +QCPAxisRect *QCPItemPosition::axisRect() const { return mAxisRect.data(); } @@ -11711,10 +11549,10 @@ QCPAxisRect* QCPItemPosition::axisRect() const This method sets the type for both X and Y directions. It is also possible to set different types for X and Y, see \ref setTypeX, \ref setTypeY. */ -void QCPItemPosition::setType( QCPItemPosition::PositionType type ) +void QCPItemPosition::setType(QCPItemPosition::PositionType type) { - setTypeX( type ); - setTypeY( type ); + setTypeX(type); + setTypeY(type); } /*! @@ -11724,26 +11562,26 @@ void QCPItemPosition::setType( QCPItemPosition::PositionType type ) \see setType, setTypeY */ -void QCPItemPosition::setTypeX( QCPItemPosition::PositionType type ) +void QCPItemPosition::setTypeX(QCPItemPosition::PositionType type) { - if( mPositionTypeX != type ) + if (mPositionTypeX != type) { // if switching from or to coordinate type that isn't valid (e.g. because axes or axis rect // were deleted), don't try to recover the pixelPosition() because it would output a qDebug warning. bool retainPixelPosition = true; - if( ( mPositionTypeX == ptPlotCoords || type == ptPlotCoords ) && ( !mKeyAxis || !mValueAxis ) ) + if ((mPositionTypeX == ptPlotCoords || type == ptPlotCoords) && (!mKeyAxis || !mValueAxis)) retainPixelPosition = false; - if( ( mPositionTypeX == ptAxisRectRatio || type == ptAxisRectRatio ) && ( !mAxisRect ) ) + if ((mPositionTypeX == ptAxisRectRatio || type == ptAxisRectRatio) && (!mAxisRect)) retainPixelPosition = false; - + QPointF pixel; - if( retainPixelPosition ) + if (retainPixelPosition) pixel = pixelPosition(); - + mPositionTypeX = type; - - if( retainPixelPosition ) - setPixelPosition( pixel ); + + if (retainPixelPosition) + setPixelPosition(pixel); } } @@ -11754,26 +11592,26 @@ void QCPItemPosition::setTypeX( QCPItemPosition::PositionType type ) \see setType, setTypeX */ -void QCPItemPosition::setTypeY( QCPItemPosition::PositionType type ) +void QCPItemPosition::setTypeY(QCPItemPosition::PositionType type) { - if( mPositionTypeY != type ) + if (mPositionTypeY != type) { // if switching from or to coordinate type that isn't valid (e.g. because axes or axis rect // were deleted), don't try to recover the pixelPosition() because it would output a qDebug warning. bool retainPixelPosition = true; - if( ( mPositionTypeY == ptPlotCoords || type == ptPlotCoords ) && ( !mKeyAxis || !mValueAxis ) ) + if ((mPositionTypeY == ptPlotCoords || type == ptPlotCoords) && (!mKeyAxis || !mValueAxis)) retainPixelPosition = false; - if( ( mPositionTypeY == ptAxisRectRatio || type == ptAxisRectRatio ) && ( !mAxisRect ) ) + if ((mPositionTypeY == ptAxisRectRatio || type == ptAxisRectRatio) && (!mAxisRect)) retainPixelPosition = false; - + QPointF pixel; - if( retainPixelPosition ) + if (retainPixelPosition) pixel = pixelPosition(); - + mPositionTypeY = type; - - if( retainPixelPosition ) - setPixelPosition( pixel ); + + if (retainPixelPosition) + setPixelPosition(pixel); } } @@ -11795,10 +11633,10 @@ void QCPItemPosition::setTypeY( QCPItemPosition::PositionType type ) This method sets the parent anchor for both X and Y directions. It is also possible to set different parents for X and Y, see \ref setParentAnchorX, \ref setParentAnchorY. */ -bool QCPItemPosition::setParentAnchor( QCPItemAnchor* parentAnchor, bool keepPixelPosition ) +bool QCPItemPosition::setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition) { - bool successX = setParentAnchorX( parentAnchor, keepPixelPosition ); - bool successY = setParentAnchorY( parentAnchor, keepPixelPosition ); + bool successX = setParentAnchorX(parentAnchor, keepPixelPosition); + bool successY = setParentAnchorY(parentAnchor, keepPixelPosition); return successX && successY; } @@ -11809,62 +11647,61 @@ bool QCPItemPosition::setParentAnchor( QCPItemAnchor* parentAnchor, bool keepPix \see setParentAnchor, setParentAnchorY */ -bool QCPItemPosition::setParentAnchorX( QCPItemAnchor* parentAnchor, bool keepPixelPosition ) +bool QCPItemPosition::setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition) { // make sure self is not assigned as parent: - if( parentAnchor == this ) + if (parentAnchor == this) { - qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast(parentAnchor); return false; } // make sure no recursive parent-child-relationships are created: - QCPItemAnchor* currentParent = parentAnchor; - while( currentParent ) + QCPItemAnchor *currentParent = parentAnchor; + while (currentParent) { - if( QCPItemPosition* currentParentPos = currentParent->toQCPItemPosition() ) + if (QCPItemPosition *currentParentPos = currentParent->toQCPItemPosition()) { // is a QCPItemPosition, might have further parent, so keep iterating - if( currentParentPos == this ) + if (currentParentPos == this) { - qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast(parentAnchor); return false; } currentParent = currentParentPos->parentAnchorX(); - } - else + } else { // is a QCPItemAnchor, can't have further parent. Now make sure the parent items aren't the // same, to prevent a position being child of an anchor which itself depends on the position, // because they're both on the same item: - if( currentParent->mParentItem == mParentItem ) + if (currentParent->mParentItem == mParentItem) { - qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast(parentAnchor); return false; } break; } } - + // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute: - if( !mParentAnchorX && mPositionTypeX == ptPlotCoords ) - setTypeX( ptAbsolute ); - + if (!mParentAnchorX && mPositionTypeX == ptPlotCoords) + setTypeX(ptAbsolute); + // save pixel position: QPointF pixelP; - if( keepPixelPosition ) + if (keepPixelPosition) pixelP = pixelPosition(); // unregister at current parent anchor: - if( mParentAnchorX ) - mParentAnchorX->removeChildX( this ); + if (mParentAnchorX) + mParentAnchorX->removeChildX(this); // register at new parent anchor: - if( parentAnchor ) - parentAnchor->addChildX( this ); + if (parentAnchor) + parentAnchor->addChildX(this); mParentAnchorX = parentAnchor; // restore pixel position under new parent: - if( keepPixelPosition ) - setPixelPosition( pixelP ); + if (keepPixelPosition) + setPixelPosition(pixelP); else - setCoords( 0, coords().y() ); + setCoords(0, coords().y()); return true; } @@ -11875,62 +11712,61 @@ bool QCPItemPosition::setParentAnchorX( QCPItemAnchor* parentAnchor, bool keepPi \see setParentAnchor, setParentAnchorX */ -bool QCPItemPosition::setParentAnchorY( QCPItemAnchor* parentAnchor, bool keepPixelPosition ) +bool QCPItemPosition::setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition) { // make sure self is not assigned as parent: - if( parentAnchor == this ) + if (parentAnchor == this) { - qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast(parentAnchor); return false; } // make sure no recursive parent-child-relationships are created: - QCPItemAnchor* currentParent = parentAnchor; - while( currentParent ) + QCPItemAnchor *currentParent = parentAnchor; + while (currentParent) { - if( QCPItemPosition* currentParentPos = currentParent->toQCPItemPosition() ) + if (QCPItemPosition *currentParentPos = currentParent->toQCPItemPosition()) { // is a QCPItemPosition, might have further parent, so keep iterating - if( currentParentPos == this ) + if (currentParentPos == this) { - qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast(parentAnchor); return false; } currentParent = currentParentPos->parentAnchorY(); - } - else + } else { // is a QCPItemAnchor, can't have further parent. Now make sure the parent items aren't the // same, to prevent a position being child of an anchor which itself depends on the position, // because they're both on the same item: - if( currentParent->mParentItem == mParentItem ) + if (currentParent->mParentItem == mParentItem) { - qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast( parentAnchor ); + qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast(parentAnchor); return false; } break; } } - + // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute: - if( !mParentAnchorY && mPositionTypeY == ptPlotCoords ) - setTypeY( ptAbsolute ); - + if (!mParentAnchorY && mPositionTypeY == ptPlotCoords) + setTypeY(ptAbsolute); + // save pixel position: QPointF pixelP; - if( keepPixelPosition ) + if (keepPixelPosition) pixelP = pixelPosition(); // unregister at current parent anchor: - if( mParentAnchorY ) - mParentAnchorY->removeChildY( this ); + if (mParentAnchorY) + mParentAnchorY->removeChildY(this); // register at new parent anchor: - if( parentAnchor ) - parentAnchor->addChildY( this ); + if (parentAnchor) + parentAnchor->addChildY(this); mParentAnchorY = parentAnchor; // restore pixel position under new parent: - if( keepPixelPosition ) - setPixelPosition( pixelP ); + if (keepPixelPosition) + setPixelPosition(pixelP); else - setCoords( coords().x(), 0 ); + setCoords(coords().x(), 0); return true; } @@ -11951,7 +11787,7 @@ bool QCPItemPosition::setParentAnchorY( QCPItemAnchor* parentAnchor, bool keepPi \see setPixelPosition */ -void QCPItemPosition::setCoords( double key, double value ) +void QCPItemPosition::setCoords(double key, double value) { mKey = key; mValue = value; @@ -11962,9 +11798,9 @@ void QCPItemPosition::setCoords( double key, double value ) Sets the coordinates as a QPointF \a pos where pos.x has the meaning of \a key and pos.y the meaning of \a value of the \ref setCoords(double key, double value) method. */ -void QCPItemPosition::setCoords( const QPointF& pos ) +void QCPItemPosition::setCoords(const QPointF &pos) { - setCoords( pos.x(), pos.y() ); + setCoords(pos.x(), pos.y()); } /*! @@ -11976,97 +11812,95 @@ void QCPItemPosition::setCoords( const QPointF& pos ) QPointF QCPItemPosition::pixelPosition() const { QPointF result; - + // determine X: - switch( mPositionTypeX ) + switch (mPositionTypeX) { - case ptAbsolute: - { - result.rx() = mKey; - if( mParentAnchorX ) - result.rx() += mParentAnchorX->pixelPosition().x(); - break; - } - case ptViewportRatio: - { - result.rx() = mKey * mParentPlot->viewport().width(); - if( mParentAnchorX ) - result.rx() += mParentAnchorX->pixelPosition().x(); - else - result.rx() += mParentPlot->viewport().left(); - break; - } - case ptAxisRectRatio: - { - if( mAxisRect ) + case ptAbsolute: { - result.rx() = mKey * mAxisRect.data()->width(); - if( mParentAnchorX ) + result.rx() = mKey; + if (mParentAnchorX) + result.rx() += mParentAnchorX->pixelPosition().x(); + break; + } + case ptViewportRatio: + { + result.rx() = mKey*mParentPlot->viewport().width(); + if (mParentAnchorX) result.rx() += mParentAnchorX->pixelPosition().x(); else - result.rx() += mAxisRect.data()->left(); + result.rx() += mParentPlot->viewport().left(); + break; } - else - qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; - break; - } - case ptPlotCoords: - { - if( mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal ) - result.rx() = mKeyAxis.data()->coordToPixel( mKey ); - else if( mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal ) - result.rx() = mValueAxis.data()->coordToPixel( mValue ); - else - qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; - break; - } - } - - // determine Y: - switch( mPositionTypeY ) - { - case ptAbsolute: - { - result.ry() = mValue; - if( mParentAnchorY ) - result.ry() += mParentAnchorY->pixelPosition().y(); - break; - } - case ptViewportRatio: - { - result.ry() = mValue * mParentPlot->viewport().height(); - if( mParentAnchorY ) - result.ry() += mParentAnchorY->pixelPosition().y(); - else - result.ry() += mParentPlot->viewport().top(); - break; - } - case ptAxisRectRatio: - { - if( mAxisRect ) + case ptAxisRectRatio: { - result.ry() = mValue * mAxisRect.data()->height(); - if( mParentAnchorY ) + if (mAxisRect) + { + result.rx() = mKey*mAxisRect.data()->width(); + if (mParentAnchorX) + result.rx() += mParentAnchorX->pixelPosition().x(); + else + result.rx() += mAxisRect.data()->left(); + } else + qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal) + result.rx() = mKeyAxis.data()->coordToPixel(mKey); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal) + result.rx() = mValueAxis.data()->coordToPixel(mValue); + else + qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; + break; + } + } + + // determine Y: + switch (mPositionTypeY) + { + case ptAbsolute: + { + result.ry() = mValue; + if (mParentAnchorY) + result.ry() += mParentAnchorY->pixelPosition().y(); + break; + } + case ptViewportRatio: + { + result.ry() = mValue*mParentPlot->viewport().height(); + if (mParentAnchorY) result.ry() += mParentAnchorY->pixelPosition().y(); else - result.ry() += mAxisRect.data()->top(); + result.ry() += mParentPlot->viewport().top(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + result.ry() = mValue*mAxisRect.data()->height(); + if (mParentAnchorY) + result.ry() += mParentAnchorY->pixelPosition().y(); + else + result.ry() += mAxisRect.data()->top(); + } else + qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical) + result.ry() = mKeyAxis.data()->coordToPixel(mKey); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical) + result.ry() = mValueAxis.data()->coordToPixel(mValue); + else + qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; + break; } - else - qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; - break; } - case ptPlotCoords: - { - if( mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical ) - result.ry() = mKeyAxis.data()->coordToPixel( mKey ); - else if( mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical ) - result.ry() = mValueAxis.data()->coordToPixel( mValue ); - else - qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; - break; - } - } - + return result; } @@ -12075,7 +11909,7 @@ QPointF QCPItemPosition::pixelPosition() const coordinates set with \ref setCoords relate to. By default they are set to the initial xAxis and yAxis of the QCustomPlot. */ -void QCPItemPosition::setAxes( QCPAxis* keyAxis, QCPAxis* valueAxis ) +void QCPItemPosition::setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis) { mKeyAxis = keyAxis; mValueAxis = valueAxis; @@ -12086,7 +11920,7 @@ void QCPItemPosition::setAxes( QCPAxis* keyAxis, QCPAxis* valueAxis ) coordinates set with \ref setCoords relate to. By default this is set to the main axis rect of the QCustomPlot. */ -void QCPItemPosition::setAxisRect( QCPAxisRect* axisRect ) +void QCPItemPosition::setAxisRect(QCPAxisRect *axisRect) { mAxisRect = axisRect; } @@ -12101,100 +11935,99 @@ void QCPItemPosition::setAxisRect( QCPAxisRect* axisRect ) \see pixelPosition, setCoords */ -void QCPItemPosition::setPixelPosition( const QPointF& pixelPosition ) +void QCPItemPosition::setPixelPosition(const QPointF &pixelPosition) { double x = pixelPosition.x(); double y = pixelPosition.y(); - - switch( mPositionTypeX ) + + switch (mPositionTypeX) { - case ptAbsolute: - { - if( mParentAnchorX ) - x -= mParentAnchorX->pixelPosition().x(); - break; - } - case ptViewportRatio: - { - if( mParentAnchorX ) - x -= mParentAnchorX->pixelPosition().x(); - else - x -= mParentPlot->viewport().left(); - x /= (double)mParentPlot->viewport().width(); - break; - } - case ptAxisRectRatio: - { - if( mAxisRect ) + case ptAbsolute: { - if( mParentAnchorX ) + if (mParentAnchorX) + x -= mParentAnchorX->pixelPosition().x(); + break; + } + case ptViewportRatio: + { + if (mParentAnchorX) x -= mParentAnchorX->pixelPosition().x(); else - x -= mAxisRect.data()->left(); - x /= (double)mAxisRect.data()->width(); + x -= mParentPlot->viewport().left(); + x /= (double)mParentPlot->viewport().width(); + break; } - else - qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; - break; - } - case ptPlotCoords: - { - if( mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal ) - x = mKeyAxis.data()->pixelToCoord( x ); - else if( mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal ) - y = mValueAxis.data()->pixelToCoord( x ); - else - qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; - break; - } - } - - switch( mPositionTypeY ) - { - case ptAbsolute: - { - if( mParentAnchorY ) - y -= mParentAnchorY->pixelPosition().y(); - break; - } - case ptViewportRatio: - { - if( mParentAnchorY ) - y -= mParentAnchorY->pixelPosition().y(); - else - y -= mParentPlot->viewport().top(); - y /= (double)mParentPlot->viewport().height(); - break; - } - case ptAxisRectRatio: - { - if( mAxisRect ) + case ptAxisRectRatio: { - if( mParentAnchorY ) + if (mAxisRect) + { + if (mParentAnchorX) + x -= mParentAnchorX->pixelPosition().x(); + else + x -= mAxisRect.data()->left(); + x /= (double)mAxisRect.data()->width(); + } else + qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal) + x = mKeyAxis.data()->pixelToCoord(x); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal) + y = mValueAxis.data()->pixelToCoord(x); + else + qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; + break; + } + } + + switch (mPositionTypeY) + { + case ptAbsolute: + { + if (mParentAnchorY) + y -= mParentAnchorY->pixelPosition().y(); + break; + } + case ptViewportRatio: + { + if (mParentAnchorY) y -= mParentAnchorY->pixelPosition().y(); else - y -= mAxisRect.data()->top(); - y /= (double)mAxisRect.data()->height(); + y -= mParentPlot->viewport().top(); + y /= (double)mParentPlot->viewport().height(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + if (mParentAnchorY) + y -= mParentAnchorY->pixelPosition().y(); + else + y -= mAxisRect.data()->top(); + y /= (double)mAxisRect.data()->height(); + } else + qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical) + x = mKeyAxis.data()->pixelToCoord(y); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical) + y = mValueAxis.data()->pixelToCoord(y); + else + qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; + break; } - else - qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; - break; } - case ptPlotCoords: - { - if( mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical ) - x = mKeyAxis.data()->pixelToCoord( y ); - else if( mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical ) - y = mValueAxis.data()->pixelToCoord( y ); - else - qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; - break; - } - } - - setCoords( x, y ); + + setCoords(x, y); } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractItem //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -12367,27 +12200,30 @@ void QCPItemPosition::setPixelPosition( const QPointF& pixelPosition ) /*! Base class constructor which initializes base class members. */ -QCPAbstractItem::QCPAbstractItem( QCustomPlot* parentPlot ) - : QCPLayerable( parentPlot ), mClipToAxisRect( false ), mSelectable( true ), mSelected( false ) +QCPAbstractItem::QCPAbstractItem(QCustomPlot *parentPlot) : + QCPLayerable(parentPlot), + mClipToAxisRect(false), + mSelectable(true), + mSelected(false) { - parentPlot->registerItem( this ); - + parentPlot->registerItem(this); + QList rects = parentPlot->axisRects(); - if( rects.size() > 0 ) + if (rects.size() > 0) { - setClipToAxisRect( true ); - setClipAxisRect( rects.first() ); + setClipToAxisRect(true); + setClipAxisRect(rects.first()); } } QCPAbstractItem::~QCPAbstractItem() { // don't delete mPositions because every position is also an anchor and thus in mAnchors - qDeleteAll( mAnchors ); + qDeleteAll(mAnchors); } /* can't make this a header inline function, because QPointer breaks with forward declared types, see QTBUG-29588 */ -QCPAxisRect* QCPAbstractItem::clipAxisRect() const +QCPAxisRect *QCPAbstractItem::clipAxisRect() const { return mClipAxisRect.data(); } @@ -12398,11 +12234,11 @@ QCPAxisRect* QCPAbstractItem::clipAxisRect() const \see setClipAxisRect */ -void QCPAbstractItem::setClipToAxisRect( bool clip ) +void QCPAbstractItem::setClipToAxisRect(bool clip) { mClipToAxisRect = clip; - if( mClipToAxisRect ) - setParentLayerable( mClipAxisRect.data() ); + if (mClipToAxisRect) + setParentLayerable(mClipAxisRect.data()); } /*! @@ -12411,11 +12247,11 @@ void QCPAbstractItem::setClipToAxisRect( bool clip ) \see setClipToAxisRect */ -void QCPAbstractItem::setClipAxisRect( QCPAxisRect* rect ) +void QCPAbstractItem::setClipAxisRect(QCPAxisRect *rect) { mClipAxisRect = rect; - if( mClipToAxisRect ) - setParentLayerable( mClipAxisRect.data() ); + if (mClipToAxisRect) + setParentLayerable(mClipAxisRect.data()); } /*! @@ -12427,12 +12263,12 @@ void QCPAbstractItem::setClipAxisRect( QCPAxisRect* rect ) \see QCustomPlot::setInteractions, setSelected */ -void QCPAbstractItem::setSelectable( bool selectable ) +void QCPAbstractItem::setSelectable(bool selectable) { - if( mSelectable != selectable ) + if (mSelectable != selectable) { mSelectable = selectable; - emit selectableChanged( mSelectable ); + emit selectableChanged(mSelectable); } } @@ -12450,12 +12286,12 @@ void QCPAbstractItem::setSelectable( bool selectable ) \see setSelectable, selectTest */ -void QCPAbstractItem::setSelected( bool selected ) +void QCPAbstractItem::setSelected(bool selected) { - if( mSelected != selected ) + if (mSelected != selected) { mSelected = selected; - emit selectionChanged( mSelected ); + emit selectionChanged(mSelected); } } @@ -12469,12 +12305,12 @@ void QCPAbstractItem::setSelected( bool selected ) \see positions, anchor */ -QCPItemPosition* QCPAbstractItem::position( const QString& name ) const +QCPItemPosition *QCPAbstractItem::position(const QString &name) const { - for( int i = 0; i < mPositions.size(); ++i ) + for (int i=0; iname() == name ) - return mPositions.at( i ); + if (mPositions.at(i)->name() == name) + return mPositions.at(i); } qDebug() << Q_FUNC_INFO << "position with name not found:" << name; return 0; @@ -12490,12 +12326,12 @@ QCPItemPosition* QCPAbstractItem::position( const QString& name ) const \see anchors, position */ -QCPItemAnchor* QCPAbstractItem::anchor( const QString& name ) const +QCPItemAnchor *QCPAbstractItem::anchor(const QString &name) const { - for( int i = 0; i < mAnchors.size(); ++i ) + for (int i=0; iname() == name ) - return mAnchors.at( i ); + if (mAnchors.at(i)->name() == name) + return mAnchors.at(i); } qDebug() << Q_FUNC_INFO << "anchor with name not found:" << name; return 0; @@ -12509,11 +12345,11 @@ QCPItemAnchor* QCPAbstractItem::anchor( const QString& name ) const \see anchor, position */ -bool QCPAbstractItem::hasAnchor( const QString& name ) const +bool QCPAbstractItem::hasAnchor(const QString &name) const { - for( int i = 0; i < mAnchors.size(); ++i ) + for (int i=0; iname() == name ) + if (mAnchors.at(i)->name() == name) return true; } return false; @@ -12530,7 +12366,7 @@ bool QCPAbstractItem::hasAnchor( const QString& name ) const */ QRect QCPAbstractItem::clipRect() const { - if( mClipToAxisRect && mClipAxisRect ) + if (mClipToAxisRect && mClipAxisRect) return mClipAxisRect.data()->rect(); else return mParentPlot->viewport(); @@ -12549,9 +12385,9 @@ QRect QCPAbstractItem::clipRect() const \see setAntialiased */ -void QCPAbstractItem::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPAbstractItem::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeItems ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeItems); } /*! \internal @@ -12567,28 +12403,28 @@ void QCPAbstractItem::applyDefaultAntialiasingHint( QCPPainter* painter ) const rect, in your \ref selectTest reimplementation. Finally, return the minimum (non -1) of all four returned values. */ -double QCPAbstractItem::rectDistance( const QRectF& rect, const QPointF& pos, bool filledRect ) const +double QCPAbstractItem::rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const { double result = -1; // distance to border: QList lines; - lines << QLineF( rect.topLeft(), rect.topRight() ) << QLineF( rect.bottomLeft(), rect.bottomRight() ) - << QLineF( rect.topLeft(), rect.bottomLeft() ) << QLineF( rect.topRight(), rect.bottomRight() ); + lines << QLineF(rect.topLeft(), rect.topRight()) << QLineF(rect.bottomLeft(), rect.bottomRight()) + << QLineF(rect.topLeft(), rect.bottomLeft()) << QLineF(rect.topRight(), rect.bottomRight()); double minDistSqr = std::numeric_limits::max(); - for( int i = 0; i < lines.size(); ++i ) + for (int i=0; i mParentPlot->selectionTolerance() * 0.99 ) + if (filledRect && result > mParentPlot->selectionTolerance()*0.99) { - if( rect.contains( pos ) ) - result = mParentPlot->selectionTolerance() * 0.99; + if (rect.contains(pos)) + result = mParentPlot->selectionTolerance()*0.99; } return result; } @@ -12603,7 +12439,7 @@ double QCPAbstractItem::rectDistance( const QRectF& rect, const QPointF& pos, bo \see createAnchor */ -QPointF QCPAbstractItem::anchorPixelPosition( int anchorId ) const +QPointF QCPAbstractItem::anchorPixelPosition(int anchorId) const { qDebug() << Q_FUNC_INFO << "called on item which shouldn't have any anchors (this method not reimplemented). anchorId" << anchorId; return QPointF(); @@ -12623,18 +12459,18 @@ QPointF QCPAbstractItem::anchorPixelPosition( int anchorId ) const \see createAnchor */ -QCPItemPosition* QCPAbstractItem::createPosition( const QString& name ) +QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) { - if( hasAnchor( name ) ) + if (hasAnchor(name)) qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; - QCPItemPosition* newPosition = new QCPItemPosition( mParentPlot, this, name ); - mPositions.append( newPosition ); - mAnchors.append( newPosition ); // every position is also an anchor - newPosition->setAxes( mParentPlot->xAxis, mParentPlot->yAxis ); - newPosition->setType( QCPItemPosition::ptPlotCoords ); - if( mParentPlot->axisRect() ) - newPosition->setAxisRect( mParentPlot->axisRect() ); - newPosition->setCoords( 0, 0 ); + QCPItemPosition *newPosition = new QCPItemPosition(mParentPlot, this, name); + mPositions.append(newPosition); + mAnchors.append(newPosition); // every position is also an anchor + newPosition->setAxes(mParentPlot->xAxis, mParentPlot->yAxis); + newPosition->setType(QCPItemPosition::ptPlotCoords); + if (mParentPlot->axisRect()) + newPosition->setAxisRect(mParentPlot->axisRect()); + newPosition->setCoords(0, 0); return newPosition; } @@ -12657,37 +12493,37 @@ QCPItemPosition* QCPAbstractItem::createPosition( const QString& name ) \see createPosition */ -QCPItemAnchor* QCPAbstractItem::createAnchor( const QString& name, int anchorId ) +QCPItemAnchor *QCPAbstractItem::createAnchor(const QString &name, int anchorId) { - if( hasAnchor( name ) ) + if (hasAnchor(name)) qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; - QCPItemAnchor* newAnchor = new QCPItemAnchor( mParentPlot, this, name, anchorId ); - mAnchors.append( newAnchor ); + QCPItemAnchor *newAnchor = new QCPItemAnchor(mParentPlot, this, name, anchorId); + mAnchors.append(newAnchor); return newAnchor; } /* inherits documentation from base class */ -void QCPAbstractItem::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPAbstractItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - Q_UNUSED( details ) - if( mSelectable ) + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) { bool selBefore = mSelected; - setSelected( additive ? !mSelected : true ); - if( selectionStateChanged ) + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } /* inherits documentation from base class */ -void QCPAbstractItem::deselectEvent( bool* selectionStateChanged ) +void QCPAbstractItem::deselectEvent(bool *selectionStateChanged) { - if( mSelectable ) + if (mSelectable) { bool selBefore = mSelected; - setSelected( false ); - if( selectionStateChanged ) + setSelected(false); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } @@ -12699,6 +12535,7 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const } /* end of 'src/item.cpp' */ + /* including file 'src/core.cpp', size 125037 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -13008,95 +12845,101 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /*! Constructs a QCustomPlot and sets reasonable default values. */ -QCustomPlot::QCustomPlot( QWidget* parent ) - : QWidget( parent ), xAxis( 0 ), yAxis( 0 ), xAxis2( 0 ), yAxis2( 0 ), legend( 0 ), mBufferDevicePixelRatio( 1.0 ), // will be adapted to primary screen below - mPlotLayout( 0 ) - , mAutoAddPlottableToLegend( true ) - , mAntialiasedElements( QCP::aeNone ) - , mNotAntialiasedElements( QCP::aeNone ) - , mInteractions( 0 ) - , mSelectionTolerance( 8 ) - , mNoAntialiasingOnDrag( false ) - , mBackgroundBrush( Qt::white, Qt::SolidPattern ) - , mBackgroundScaled( true ) - , mBackgroundScaledMode( Qt::KeepAspectRatioByExpanding ) - , mCurrentLayer( 0 ) - , mPlottingHints( QCP::phCacheLabels | QCP::phImmediateRefresh ) - , mMultiSelectModifier( Qt::ControlModifier ) - , mSelectionRectMode( QCP::srmNone ) - , mSelectionRect( 0 ) - , mOpenGl( false ) - , mMouseHasMoved( false ) - , mMouseEventLayerable( 0 ) - , mMouseSignalLayerable( 0 ) - , mReplotting( false ) - , mReplotQueued( false ) - , mOpenGlMultisamples( 16 ) - , mOpenGlAntialiasedElementsBackup( QCP::aeNone ) - , mOpenGlCacheLabelsBackup( true ) +QCustomPlot::QCustomPlot(QWidget *parent) : + QWidget(parent), + xAxis(0), + yAxis(0), + xAxis2(0), + yAxis2(0), + legend(0), + mBufferDevicePixelRatio(1.0), // will be adapted to primary screen below + mPlotLayout(0), + mAutoAddPlottableToLegend(true), + mAntialiasedElements(QCP::aeNone), + mNotAntialiasedElements(QCP::aeNone), + mInteractions(0), + mSelectionTolerance(8), + mNoAntialiasingOnDrag(false), + mBackgroundBrush(Qt::white, Qt::SolidPattern), + mBackgroundScaled(true), + mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), + mCurrentLayer(0), + mPlottingHints(QCP::phCacheLabels|QCP::phImmediateRefresh), + mMultiSelectModifier(Qt::ControlModifier), + mSelectionRectMode(QCP::srmNone), + mSelectionRect(0), + mOpenGl(false), + mMouseHasMoved(false), + mMouseEventLayerable(0), + mMouseSignalLayerable(0), + mReplotting(false), + mReplotQueued(false), + mOpenGlMultisamples(16), + mOpenGlAntialiasedElementsBackup(QCP::aeNone), + mOpenGlCacheLabelsBackup(true) { - setAttribute( Qt::WA_NoMousePropagation ); - setAttribute( Qt::WA_OpaquePaintEvent ); - setFocusPolicy( Qt::ClickFocus ); - setMouseTracking( true ); + setAttribute(Qt::WA_NoMousePropagation); + setAttribute(Qt::WA_OpaquePaintEvent); + setFocusPolicy(Qt::ClickFocus); + setMouseTracking(true); QLocale currentLocale = locale(); - currentLocale.setNumberOptions( QLocale::OmitGroupSeparator ); - setLocale( currentLocale ); + currentLocale.setNumberOptions(QLocale::OmitGroupSeparator); + setLocale(currentLocale); #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED -#ifdef QCP_DEVICEPIXELRATIO_FLOAT - setBufferDevicePixelRatio( QWidget::devicePixelRatioF() ); -#else - setBufferDevicePixelRatio( QWidget::devicePixelRatio() ); +# ifdef QCP_DEVICEPIXELRATIO_FLOAT + setBufferDevicePixelRatio(QWidget::devicePixelRatioF()); +# else + setBufferDevicePixelRatio(QWidget::devicePixelRatio()); +# endif #endif -#endif - + mOpenGlAntialiasedElementsBackup = mAntialiasedElements; - mOpenGlCacheLabelsBackup = mPlottingHints.testFlag( QCP::phCacheLabels ); + mOpenGlCacheLabelsBackup = mPlottingHints.testFlag(QCP::phCacheLabels); // create initial layers: - mLayers.append( new QCPLayer( this, QLatin1String( "background" ) ) ); - mLayers.append( new QCPLayer( this, QLatin1String( "grid" ) ) ); - mLayers.append( new QCPLayer( this, QLatin1String( "main" ) ) ); - mLayers.append( new QCPLayer( this, QLatin1String( "axes" ) ) ); - mLayers.append( new QCPLayer( this, QLatin1String( "legend" ) ) ); - mLayers.append( new QCPLayer( this, QLatin1String( "overlay" ) ) ); + mLayers.append(new QCPLayer(this, QLatin1String("background"))); + mLayers.append(new QCPLayer(this, QLatin1String("grid"))); + mLayers.append(new QCPLayer(this, QLatin1String("main"))); + mLayers.append(new QCPLayer(this, QLatin1String("axes"))); + mLayers.append(new QCPLayer(this, QLatin1String("legend"))); + mLayers.append(new QCPLayer(this, QLatin1String("overlay"))); updateLayerIndices(); - setCurrentLayer( QLatin1String( "main" ) ); - layer( QLatin1String( "overlay" ) )->setMode( QCPLayer::lmBuffered ); - + setCurrentLayer(QLatin1String("main")); + layer(QLatin1String("overlay"))->setMode(QCPLayer::lmBuffered); + // create initial layout, axis rect and legend: mPlotLayout = new QCPLayoutGrid; - mPlotLayout->initializeParentPlot( this ); - mPlotLayout->setParent( this ); // important because if parent is QWidget, QCPLayout::sizeConstraintsChanged will call QWidget::updateGeometry - mPlotLayout->setLayer( QLatin1String( "main" ) ); - QCPAxisRect* defaultAxisRect = new QCPAxisRect( this, true ); - mPlotLayout->addElement( 0, 0, defaultAxisRect ); - xAxis = defaultAxisRect->axis( QCPAxis::atBottom ); - yAxis = defaultAxisRect->axis( QCPAxis::atLeft ); - xAxis2 = defaultAxisRect->axis( QCPAxis::atTop ); - yAxis2 = defaultAxisRect->axis( QCPAxis::atRight ); + mPlotLayout->initializeParentPlot(this); + mPlotLayout->setParent(this); // important because if parent is QWidget, QCPLayout::sizeConstraintsChanged will call QWidget::updateGeometry + mPlotLayout->setLayer(QLatin1String("main")); + QCPAxisRect *defaultAxisRect = new QCPAxisRect(this, true); + mPlotLayout->addElement(0, 0, defaultAxisRect); + xAxis = defaultAxisRect->axis(QCPAxis::atBottom); + yAxis = defaultAxisRect->axis(QCPAxis::atLeft); + xAxis2 = defaultAxisRect->axis(QCPAxis::atTop); + yAxis2 = defaultAxisRect->axis(QCPAxis::atRight); legend = new QCPLegend; - legend->setVisible( false ); - defaultAxisRect->insetLayout()->addElement( legend, Qt::AlignRight | Qt::AlignTop ); - defaultAxisRect->insetLayout()->setMargins( QMargins( 12, 12, 12, 12 ) ); - - defaultAxisRect->setLayer( QLatin1String( "background" ) ); - xAxis->setLayer( QLatin1String( "axes" ) ); - yAxis->setLayer( QLatin1String( "axes" ) ); - xAxis2->setLayer( QLatin1String( "axes" ) ); - yAxis2->setLayer( QLatin1String( "axes" ) ); - xAxis->grid()->setLayer( QLatin1String( "grid" ) ); - yAxis->grid()->setLayer( QLatin1String( "grid" ) ); - xAxis2->grid()->setLayer( QLatin1String( "grid" ) ); - yAxis2->grid()->setLayer( QLatin1String( "grid" ) ); - legend->setLayer( QLatin1String( "legend" ) ); - + legend->setVisible(false); + defaultAxisRect->insetLayout()->addElement(legend, Qt::AlignRight|Qt::AlignTop); + defaultAxisRect->insetLayout()->setMargins(QMargins(12, 12, 12, 12)); + + defaultAxisRect->setLayer(QLatin1String("background")); + xAxis->setLayer(QLatin1String("axes")); + yAxis->setLayer(QLatin1String("axes")); + xAxis2->setLayer(QLatin1String("axes")); + yAxis2->setLayer(QLatin1String("axes")); + xAxis->grid()->setLayer(QLatin1String("grid")); + yAxis->grid()->setLayer(QLatin1String("grid")); + xAxis2->grid()->setLayer(QLatin1String("grid")); + yAxis2->grid()->setLayer(QLatin1String("grid")); + legend->setLayer(QLatin1String("legend")); + // create selection rect instance: - mSelectionRect = new QCPSelectionRect( this ); - mSelectionRect->setLayer( QLatin1String( "overlay" ) ); - - setViewport( rect() ); // needs to be called after mPlotLayout has been created - - replot( rpQueuedReplot ); + mSelectionRect = new QCPSelectionRect(this); + mSelectionRect->setLayer(QLatin1String("overlay")); + + setViewport(rect()); // needs to be called after mPlotLayout has been created + + replot(rpQueuedReplot); } QCustomPlot::~QCustomPlot() @@ -13104,14 +12947,14 @@ QCustomPlot::~QCustomPlot() clearPlottables(); clearItems(); - if( mPlotLayout ) + if (mPlotLayout) { delete mPlotLayout; mPlotLayout = 0; } - + mCurrentLayer = 0; - qDeleteAll( mLayers ); // don't use removeLayer, because it would prevent the last layer to be removed + qDeleteAll(mLayers); // don't use removeLayer, because it would prevent the last layer to be removed mLayers.clear(); } @@ -13132,12 +12975,12 @@ QCustomPlot::~QCustomPlot() \see setNotAntialiasedElements */ -void QCustomPlot::setAntialiasedElements( const QCP::AntialiasedElements& antialiasedElements ) +void QCustomPlot::setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements) { mAntialiasedElements = antialiasedElements; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: - if( ( mNotAntialiasedElements & mAntialiasedElements ) != 0 ) + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mNotAntialiasedElements |= ~mAntialiasedElements; } @@ -13148,15 +12991,15 @@ void QCustomPlot::setAntialiasedElements( const QCP::AntialiasedElements& antial \see setNotAntialiasedElement */ -void QCustomPlot::setAntialiasedElement( QCP::AntialiasedElement antialiasedElement, bool enabled ) +void QCustomPlot::setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled) { - if( !enabled && mAntialiasedElements.testFlag( antialiasedElement ) ) + if (!enabled && mAntialiasedElements.testFlag(antialiasedElement)) mAntialiasedElements &= ~antialiasedElement; - else if( enabled && !mAntialiasedElements.testFlag( antialiasedElement ) ) + else if (enabled && !mAntialiasedElements.testFlag(antialiasedElement)) mAntialiasedElements |= antialiasedElement; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: - if( ( mNotAntialiasedElements & mAntialiasedElements ) != 0 ) + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mNotAntialiasedElements |= ~mAntialiasedElements; } @@ -13178,12 +13021,12 @@ void QCustomPlot::setAntialiasedElement( QCP::AntialiasedElement antialiasedElem \see setAntialiasedElements */ -void QCustomPlot::setNotAntialiasedElements( const QCP::AntialiasedElements& notAntialiasedElements ) +void QCustomPlot::setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements) { mNotAntialiasedElements = notAntialiasedElements; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: - if( ( mNotAntialiasedElements & mAntialiasedElements ) != 0 ) + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mAntialiasedElements |= ~mNotAntialiasedElements; } @@ -13194,15 +13037,15 @@ void QCustomPlot::setNotAntialiasedElements( const QCP::AntialiasedElements& not \see setAntialiasedElement */ -void QCustomPlot::setNotAntialiasedElement( QCP::AntialiasedElement notAntialiasedElement, bool enabled ) +void QCustomPlot::setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled) { - if( !enabled && mNotAntialiasedElements.testFlag( notAntialiasedElement ) ) + if (!enabled && mNotAntialiasedElements.testFlag(notAntialiasedElement)) mNotAntialiasedElements &= ~notAntialiasedElement; - else if( enabled && !mNotAntialiasedElements.testFlag( notAntialiasedElement ) ) + else if (enabled && !mNotAntialiasedElements.testFlag(notAntialiasedElement)) mNotAntialiasedElements |= notAntialiasedElement; - + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: - if( ( mNotAntialiasedElements & mAntialiasedElements ) != 0 ) + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) mAntialiasedElements |= ~mNotAntialiasedElements; } @@ -13212,7 +13055,7 @@ void QCustomPlot::setNotAntialiasedElement( QCP::AntialiasedElement notAntialias \see addGraph, QCPLegend::addItem */ -void QCustomPlot::setAutoAddPlottableToLegend( bool on ) +void QCustomPlot::setAutoAddPlottableToLegend(bool on) { mAutoAddPlottableToLegend = on; } @@ -13271,7 +13114,7 @@ void QCustomPlot::setAutoAddPlottableToLegend( bool on ) \see setInteraction, setSelectionTolerance */ -void QCustomPlot::setInteractions( const QCP::Interactions& interactions ) +void QCustomPlot::setInteractions(const QCP::Interactions &interactions) { mInteractions = interactions; } @@ -13283,11 +13126,11 @@ void QCustomPlot::setInteractions( const QCP::Interactions& interactions ) \see setInteractions */ -void QCustomPlot::setInteraction( const QCP::Interaction& interaction, bool enabled ) +void QCustomPlot::setInteraction(const QCP::Interaction &interaction, bool enabled) { - if( !enabled && mInteractions.testFlag( interaction ) ) + if (!enabled && mInteractions.testFlag(interaction)) mInteractions &= ~interaction; - else if( enabled && !mInteractions.testFlag( interaction ) ) + else if (enabled && !mInteractions.testFlag(interaction)) mInteractions |= interaction; } @@ -13304,7 +13147,7 @@ void QCustomPlot::setInteraction( const QCP::Interaction& interaction, bool enab \see setInteractions, QCPLayerable::selectTest */ -void QCustomPlot::setSelectionTolerance( int pixels ) +void QCustomPlot::setSelectionTolerance(int pixels) { mSelectionTolerance = pixels; } @@ -13318,7 +13161,7 @@ void QCustomPlot::setSelectionTolerance( int pixels ) \see setAntialiasedElements, setNotAntialiasedElements */ -void QCustomPlot::setNoAntialiasingOnDrag( bool enabled ) +void QCustomPlot::setNoAntialiasingOnDrag(bool enabled) { mNoAntialiasingOnDrag = enabled; } @@ -13328,7 +13171,7 @@ void QCustomPlot::setNoAntialiasingOnDrag( bool enabled ) \see setPlottingHint */ -void QCustomPlot::setPlottingHints( const QCP::PlottingHints& hints ) +void QCustomPlot::setPlottingHints(const QCP::PlottingHints &hints) { mPlottingHints = hints; } @@ -13338,16 +13181,16 @@ void QCustomPlot::setPlottingHints( const QCP::PlottingHints& hints ) \see setPlottingHints */ -void QCustomPlot::setPlottingHint( QCP::PlottingHint hint, bool enabled ) +void QCustomPlot::setPlottingHint(QCP::PlottingHint hint, bool enabled) { QCP::PlottingHints newHints = mPlottingHints; - if( !enabled ) + if (!enabled) newHints &= ~hint; else newHints |= hint; - - if( newHints != mPlottingHints ) - setPlottingHints( newHints ); + + if (newHints != mPlottingHints) + setPlottingHints(newHints); } /*! @@ -13360,7 +13203,7 @@ void QCustomPlot::setPlottingHint( QCP::PlottingHint hint, bool enabled ) \see setInteractions */ -void QCustomPlot::setMultiSelectModifier( Qt::KeyboardModifier modifier ) +void QCustomPlot::setMultiSelectModifier(Qt::KeyboardModifier modifier) { mMultiSelectModifier = modifier; } @@ -13385,26 +13228,26 @@ void QCustomPlot::setMultiSelectModifier( Qt::KeyboardModifier modifier ) \see setInteractions, setSelectionRect, QCPSelectionRect */ -void QCustomPlot::setSelectionRectMode( QCP::SelectionRectMode mode ) +void QCustomPlot::setSelectionRectMode(QCP::SelectionRectMode mode) { - if( mSelectionRect ) + if (mSelectionRect) { - if( mode == QCP::srmNone ) - mSelectionRect->cancel(); // when switching to none, we immediately want to abort a potentially active selection rect - + if (mode == QCP::srmNone) + mSelectionRect->cancel(); // when switching to none, we immediately want to abort a potentially active selection rect + // disconnect old connections: - if( mSelectionRectMode == QCP::srmSelect ) - disconnect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectSelection( QRect, QMouseEvent* ) ) ); - else if( mSelectionRectMode == QCP::srmZoom ) - disconnect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectZoom( QRect, QMouseEvent* ) ) ); - + if (mSelectionRectMode == QCP::srmSelect) + disconnect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectSelection(QRect,QMouseEvent*))); + else if (mSelectionRectMode == QCP::srmZoom) + disconnect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectZoom(QRect,QMouseEvent*))); + // establish new ones: - if( mode == QCP::srmSelect ) - connect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectSelection( QRect, QMouseEvent* ) ) ); - else if( mode == QCP::srmZoom ) - connect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectZoom( QRect, QMouseEvent* ) ) ); + if (mode == QCP::srmSelect) + connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectSelection(QRect,QMouseEvent*))); + else if (mode == QCP::srmZoom) + connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectZoom(QRect,QMouseEvent*))); } - + mSelectionRectMode = mode; } @@ -13418,20 +13261,20 @@ void QCustomPlot::setSelectionRectMode( QCP::SelectionRectMode mode ) \see setSelectionRectMode */ -void QCustomPlot::setSelectionRect( QCPSelectionRect* selectionRect ) +void QCustomPlot::setSelectionRect(QCPSelectionRect *selectionRect) { - if( mSelectionRect ) + if (mSelectionRect) delete mSelectionRect; - + mSelectionRect = selectionRect; - - if( mSelectionRect ) + + if (mSelectionRect) { // establish connections with new selection rect: - if( mSelectionRectMode == QCP::srmSelect ) - connect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectSelection( QRect, QMouseEvent* ) ) ); - else if( mSelectionRectMode == QCP::srmZoom ) - connect( mSelectionRect, SIGNAL( accepted( QRect, QMouseEvent* ) ), this, SLOT( processRectZoom( QRect, QMouseEvent* ) ) ); + if (mSelectionRectMode == QCP::srmSelect) + connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectSelection(QRect,QMouseEvent*))); + else if (mSelectionRectMode == QCP::srmZoom) + connect(mSelectionRect, SIGNAL(accepted(QRect,QMouseEvent*)), this, SLOT(processRectZoom(QRect,QMouseEvent*))); } } @@ -13471,42 +13314,40 @@ void QCustomPlot::setSelectionRect( QCPSelectionRect* selectionRect ) QT variable in the qmake project files. For Qt versions 5.0 and higher, QCustomPlot switches to a newer OpenGL interface which is already in the "gui" module. */ -void QCustomPlot::setOpenGl( bool enabled, int multisampling ) +void QCustomPlot::setOpenGl(bool enabled, int multisampling) { - mOpenGlMultisamples = qMax( 0, multisampling ); + mOpenGlMultisamples = qMax(0, multisampling); #ifdef QCUSTOMPLOT_USE_OPENGL mOpenGl = enabled; - if( mOpenGl ) + if (mOpenGl) { - if( setupOpenGl() ) + if (setupOpenGl()) { // backup antialiasing override and labelcaching setting so we can restore upon disabling OpenGL mOpenGlAntialiasedElementsBackup = mAntialiasedElements; - mOpenGlCacheLabelsBackup = mPlottingHints.testFlag( QCP::phCacheLabels ); + mOpenGlCacheLabelsBackup = mPlottingHints.testFlag(QCP::phCacheLabels); // set antialiasing override to antialias all (aligns gl pixel grid properly), and disable label caching (would use software rasterizer for pixmap caches): - setAntialiasedElements( QCP::aeAll ); - setPlottingHint( QCP::phCacheLabels, false ); - } - else + setAntialiasedElements(QCP::aeAll); + setPlottingHint(QCP::phCacheLabels, false); + } else { qDebug() << Q_FUNC_INFO << "Failed to enable OpenGL, continuing plotting without hardware acceleration."; mOpenGl = false; } - } - else + } else { // restore antialiasing override and labelcaching to what it was before enabling OpenGL, if nobody changed it in the meantime: - if( mAntialiasedElements == QCP::aeAll ) - setAntialiasedElements( mOpenGlAntialiasedElementsBackup ); - if( !mPlottingHints.testFlag( QCP::phCacheLabels ) ) - setPlottingHint( QCP::phCacheLabels, mOpenGlCacheLabelsBackup ); + if (mAntialiasedElements == QCP::aeAll) + setAntialiasedElements(mOpenGlAntialiasedElementsBackup); + if (!mPlottingHints.testFlag(QCP::phCacheLabels)) + setPlottingHint(QCP::phCacheLabels, mOpenGlCacheLabelsBackup); freeOpenGl(); } // recreate all paint buffers: mPaintBuffers.clear(); setupPaintBuffers(); #else - Q_UNUSED( enabled ) + Q_UNUSED(enabled) qDebug() << Q_FUNC_INFO << "QCustomPlot can't use OpenGL because QCUSTOMPLOT_USE_OPENGL was not defined during compilation (add 'DEFINES += QCUSTOMPLOT_USE_OPENGL' to your qmake .pro file)"; #endif } @@ -13527,11 +13368,11 @@ void QCustomPlot::setOpenGl( bool enabled, int multisampling ) This function is used to allow arbitrary size exports with \ref toPixmap, \ref savePng, \ref savePdf, etc. by temporarily changing the viewport size. */ -void QCustomPlot::setViewport( const QRect& rect ) +void QCustomPlot::setViewport(const QRect &rect) { mViewport = rect; - if( mPlotLayout ) - mPlotLayout->setOuterRect( mViewport ); + if (mPlotLayout) + mPlotLayout->setOuterRect(mViewport); } /*! @@ -13545,15 +13386,15 @@ void QCustomPlot::setViewport( const QRect& rect ) when QCustomPlot is being used with older Qt versions, outputs an according qDebug message and leaves the internal buffer device pixel ratio at 1.0. */ -void QCustomPlot::setBufferDevicePixelRatio( double ratio ) +void QCustomPlot::setBufferDevicePixelRatio(double ratio) { - if( !qFuzzyCompare( ratio, mBufferDevicePixelRatio ) ) + if (!qFuzzyCompare(ratio, mBufferDevicePixelRatio)) { #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED mBufferDevicePixelRatio = ratio; - for( int i = 0; i < mPaintBuffers.size(); ++i ) - mPaintBuffers.at( i )->setDevicePixelRatio( mBufferDevicePixelRatio ); - // Note: axis label cache has devicePixelRatio as part of cache hash, so no need to manually clear cache here + for (int i=0; isetDevicePixelRatio(mBufferDevicePixelRatio); + // Note: axis label cache has devicePixelRatio as part of cache hash, so no need to manually clear cache here #else qDebug() << Q_FUNC_INFO << "Device pixel ratios not supported for Qt versions before 5.4"; mBufferDevicePixelRatio = 1.0; @@ -13576,7 +13417,7 @@ void QCustomPlot::setBufferDevicePixelRatio( double ratio ) \see setBackgroundScaled, setBackgroundScaledMode */ -void QCustomPlot::setBackground( const QPixmap& pm ) +void QCustomPlot::setBackground(const QPixmap &pm) { mBackgroundPixmap = pm; mScaledBackgroundPixmap = QPixmap(); @@ -13595,7 +13436,7 @@ void QCustomPlot::setBackground( const QPixmap& pm ) \see setBackgroundScaled, setBackgroundScaledMode */ -void QCustomPlot::setBackground( const QBrush& brush ) +void QCustomPlot::setBackground(const QBrush &brush) { mBackgroundBrush = brush; } @@ -13607,7 +13448,7 @@ void QCustomPlot::setBackground( const QBrush& brush ) \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode */ -void QCustomPlot::setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatioMode mode ) +void QCustomPlot::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) { mBackgroundPixmap = pm; mScaledBackgroundPixmap = QPixmap(); @@ -13625,7 +13466,7 @@ void QCustomPlot::setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatio \see setBackground, setBackgroundScaledMode */ -void QCustomPlot::setBackgroundScaled( bool scaled ) +void QCustomPlot::setBackgroundScaled(bool scaled) { mBackgroundScaled = scaled; } @@ -13636,7 +13477,7 @@ void QCustomPlot::setBackgroundScaled( bool scaled ) \see setBackground, setBackgroundScaled */ -void QCustomPlot::setBackgroundScaledMode( Qt::AspectRatioMode mode ) +void QCustomPlot::setBackgroundScaledMode(Qt::AspectRatioMode mode) { mBackgroundScaledMode = mode; } @@ -13649,13 +13490,12 @@ void QCustomPlot::setBackgroundScaledMode( Qt::AspectRatioMode mode ) \see plottableCount */ -QCPAbstractPlottable* QCustomPlot::plottable( int index ) +QCPAbstractPlottable *QCustomPlot::plottable(int index) { - if( index >= 0 && index < mPlottables.size() ) + if (index >= 0 && index < mPlottables.size()) { - return mPlottables.at( index ); - } - else + return mPlottables.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return 0; @@ -13669,13 +13509,12 @@ QCPAbstractPlottable* QCustomPlot::plottable( int index ) \see plottableCount */ -QCPAbstractPlottable* QCustomPlot::plottable() +QCPAbstractPlottable *QCustomPlot::plottable() { - if( !mPlottables.isEmpty() ) + if (!mPlottables.isEmpty()) { return mPlottables.last(); - } - else + } else return 0; } @@ -13687,22 +13526,22 @@ QCPAbstractPlottable* QCustomPlot::plottable() \see clearPlottables */ -bool QCustomPlot::removePlottable( QCPAbstractPlottable* plottable ) +bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) { - if( !mPlottables.contains( plottable ) ) + if (!mPlottables.contains(plottable)) { - qDebug() << Q_FUNC_INFO << "plottable not in list:" << reinterpret_cast( plottable ); + qDebug() << Q_FUNC_INFO << "plottable not in list:" << reinterpret_cast(plottable); return false; } - + // remove plottable from legend: plottable->removeFromLegend(); // special handling for QCPGraphs to maintain the simple graph interface: - if( QCPGraph* graph = qobject_cast( plottable ) ) - mGraphs.removeOne( graph ); + if (QCPGraph *graph = qobject_cast(plottable)) + mGraphs.removeOne(graph); // remove plottable: delete plottable; - mPlottables.removeOne( plottable ); + mPlottables.removeOne(plottable); return true; } @@ -13710,10 +13549,10 @@ bool QCustomPlot::removePlottable( QCPAbstractPlottable* plottable ) Removes and deletes the plottable by its \a index. */ -bool QCustomPlot::removePlottable( int index ) +bool QCustomPlot::removePlottable(int index) { - if( index >= 0 && index < mPlottables.size() ) - return removePlottable( mPlottables[index] ); + if (index >= 0 && index < mPlottables.size()) + return removePlottable(mPlottables[index]); else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; @@ -13732,8 +13571,8 @@ bool QCustomPlot::removePlottable( int index ) int QCustomPlot::clearPlottables() { int c = mPlottables.size(); - for( int i = c - 1; i >= 0; --i ) - removePlottable( mPlottables[i] ); + for (int i=c-1; i >= 0; --i) + removePlottable(mPlottables[i]); return c; } @@ -13757,10 +13596,10 @@ int QCustomPlot::plottableCount() const QList QCustomPlot::selectedPlottables() const { QList result; - foreach( QCPAbstractPlottable* plottable, mPlottables ) + foreach (QCPAbstractPlottable *plottable, mPlottables) { - if( plottable->selected() ) - result.append( plottable ); + if (plottable->selected()) + result.append(plottable); } return result; } @@ -13777,35 +13616,35 @@ QList QCustomPlot::selectedPlottables() const \see itemAt, layoutElementAt */ -QCPAbstractPlottable* QCustomPlot::plottableAt( const QPointF& pos, bool onlySelectable ) const +QCPAbstractPlottable *QCustomPlot::plottableAt(const QPointF &pos, bool onlySelectable) const { - QCPAbstractPlottable* resultPlottable = 0; - double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - - foreach( QCPAbstractPlottable* plottable, mPlottables ) + QCPAbstractPlottable *resultPlottable = 0; + double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value + + foreach (QCPAbstractPlottable *plottable, mPlottables) { - if( onlySelectable && !plottable->selectable() ) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable + if (onlySelectable && !plottable->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable continue; - if( ( plottable->keyAxis()->axisRect()->rect() & plottable->valueAxis()->axisRect()->rect() ).contains( pos.toPoint() ) ) // only consider clicks inside the rect that is spanned by the plottable's key/value axes + if ((plottable->keyAxis()->axisRect()->rect() & plottable->valueAxis()->axisRect()->rect()).contains(pos.toPoint())) // only consider clicks inside the rect that is spanned by the plottable's key/value axes { - double currentDistance = plottable->selectTest( pos, false ); - if( currentDistance >= 0 && currentDistance < resultDistance ) + double currentDistance = plottable->selectTest(pos, false); + if (currentDistance >= 0 && currentDistance < resultDistance) { resultPlottable = plottable; resultDistance = currentDistance; } } } - + return resultPlottable; } /*! Returns whether this QCustomPlot instance contains the \a plottable. */ -bool QCustomPlot::hasPlottable( QCPAbstractPlottable* plottable ) const +bool QCustomPlot::hasPlottable(QCPAbstractPlottable *plottable) const { - return mPlottables.contains( plottable ); + return mPlottables.contains(plottable); } /*! @@ -13816,13 +13655,12 @@ bool QCustomPlot::hasPlottable( QCPAbstractPlottable* plottable ) const \see graphCount, addGraph */ -QCPGraph* QCustomPlot::graph( int index ) const +QCPGraph *QCustomPlot::graph(int index) const { - if( index >= 0 && index < mGraphs.size() ) + if (index >= 0 && index < mGraphs.size()) { - return mGraphs.at( index ); - } - else + return mGraphs.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return 0; @@ -13836,13 +13674,12 @@ QCPGraph* QCustomPlot::graph( int index ) const \see graphCount, addGraph */ -QCPGraph* QCustomPlot::graph() const +QCPGraph *QCustomPlot::graph() const { - if( !mGraphs.isEmpty() ) + if (!mGraphs.isEmpty()) { return mGraphs.last(); - } - else + } else return 0; } @@ -13858,25 +13695,23 @@ QCPGraph* QCustomPlot::graph() const \see graph, graphCount, removeGraph, clearGraphs */ -QCPGraph* QCustomPlot::addGraph( QCPAxis* keyAxis, QCPAxis* valueAxis ) +QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) { - if( !keyAxis ) - keyAxis = xAxis; - if( !valueAxis ) - valueAxis = yAxis; - if( !keyAxis || !valueAxis ) + if (!keyAxis) keyAxis = xAxis; + if (!valueAxis) valueAxis = yAxis; + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)"; return 0; } - if( keyAxis->parentPlot() != this || valueAxis->parentPlot() != this ) + if (keyAxis->parentPlot() != this || valueAxis->parentPlot() != this) { qDebug() << Q_FUNC_INFO << "passed keyAxis or valueAxis doesn't have this QCustomPlot as parent"; return 0; } - - QCPGraph* newGraph = new QCPGraph( keyAxis, valueAxis ); - newGraph->setName( QLatin1String( "Graph " ) + QString::number( mGraphs.size() ) ); + + QCPGraph *newGraph = new QCPGraph(keyAxis, valueAxis); + newGraph->setName(QLatin1String("Graph ")+QString::number(mGraphs.size())); return newGraph; } @@ -13890,19 +13725,19 @@ QCPGraph* QCustomPlot::addGraph( QCPAxis* keyAxis, QCPAxis* valueAxis ) \see clearGraphs */ -bool QCustomPlot::removeGraph( QCPGraph* graph ) +bool QCustomPlot::removeGraph(QCPGraph *graph) { - return removePlottable( graph ); + return removePlottable(graph); } /*! \overload Removes and deletes the graph by its \a index. */ -bool QCustomPlot::removeGraph( int index ) +bool QCustomPlot::removeGraph(int index) { - if( index >= 0 && index < mGraphs.size() ) - return removeGraph( mGraphs[index] ); + if (index >= 0 && index < mGraphs.size()) + return removeGraph(mGraphs[index]); else return false; } @@ -13918,8 +13753,8 @@ bool QCustomPlot::removeGraph( int index ) int QCustomPlot::clearGraphs() { int c = mGraphs.size(); - for( int i = c - 1; i >= 0; --i ) - removeGraph( mGraphs[i] ); + for (int i=c-1; i >= 0; --i) + removeGraph(mGraphs[i]); return c; } @@ -13944,10 +13779,10 @@ int QCustomPlot::graphCount() const QList QCustomPlot::selectedGraphs() const { QList result; - foreach( QCPGraph* graph, mGraphs ) + foreach (QCPGraph *graph, mGraphs) { - if( graph->selected() ) - result.append( graph ); + if (graph->selected()) + result.append(graph); } return result; } @@ -13960,13 +13795,12 @@ QList QCustomPlot::selectedGraphs() const \see itemCount */ -QCPAbstractItem* QCustomPlot::item( int index ) const +QCPAbstractItem *QCustomPlot::item(int index) const { - if( index >= 0 && index < mItems.size() ) + if (index >= 0 && index < mItems.size()) { - return mItems.at( index ); - } - else + return mItems.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return 0; @@ -13980,13 +13814,12 @@ QCPAbstractItem* QCustomPlot::item( int index ) const \see itemCount */ -QCPAbstractItem* QCustomPlot::item() const +QCPAbstractItem *QCustomPlot::item() const { - if( !mItems.isEmpty() ) + if (!mItems.isEmpty()) { return mItems.last(); - } - else + } else return 0; } @@ -13997,17 +13830,16 @@ QCPAbstractItem* QCustomPlot::item() const \see clearItems */ -bool QCustomPlot::removeItem( QCPAbstractItem* item ) +bool QCustomPlot::removeItem(QCPAbstractItem *item) { - if( mItems.contains( item ) ) + if (mItems.contains(item)) { delete item; - mItems.removeOne( item ); + mItems.removeOne(item); return true; - } - else + } else { - qDebug() << Q_FUNC_INFO << "item not in list:" << reinterpret_cast( item ); + qDebug() << Q_FUNC_INFO << "item not in list:" << reinterpret_cast(item); return false; } } @@ -14016,10 +13848,10 @@ bool QCustomPlot::removeItem( QCPAbstractItem* item ) Removes and deletes the item by its \a index. */ -bool QCustomPlot::removeItem( int index ) +bool QCustomPlot::removeItem(int index) { - if( index >= 0 && index < mItems.size() ) - return removeItem( mItems[index] ); + if (index >= 0 && index < mItems.size()) + return removeItem(mItems[index]); else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; @@ -14037,8 +13869,8 @@ bool QCustomPlot::removeItem( int index ) int QCustomPlot::clearItems() { int c = mItems.size(); - for( int i = c - 1; i >= 0; --i ) - removeItem( mItems[i] ); + for (int i=c-1; i >= 0; --i) + removeItem(mItems[i]); return c; } @@ -14060,10 +13892,10 @@ int QCustomPlot::itemCount() const QList QCustomPlot::selectedItems() const { QList result; - foreach( QCPAbstractItem* item, mItems ) + foreach (QCPAbstractItem *item, mItems) { - if( item->selected() ) - result.append( item ); + if (item->selected()) + result.append(item); } return result; } @@ -14081,26 +13913,26 @@ QList QCustomPlot::selectedItems() const \see plottableAt, layoutElementAt */ -QCPAbstractItem* QCustomPlot::itemAt( const QPointF& pos, bool onlySelectable ) const +QCPAbstractItem *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const { - QCPAbstractItem* resultItem = 0; - double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value - - foreach( QCPAbstractItem* item, mItems ) + QCPAbstractItem *resultItem = 0; + double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value + + foreach (QCPAbstractItem *item, mItems) { - if( onlySelectable && !item->selectable() ) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable + if (onlySelectable && !item->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable continue; - if( !item->clipToAxisRect() || item->clipRect().contains( pos.toPoint() ) ) // only consider clicks inside axis cliprect of the item if actually clipped to it + if (!item->clipToAxisRect() || item->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it { - double currentDistance = item->selectTest( pos, false ); - if( currentDistance >= 0 && currentDistance < resultDistance ) + double currentDistance = item->selectTest(pos, false); + if (currentDistance >= 0 && currentDistance < resultDistance) { resultItem = item; resultDistance = currentDistance; } } } - + return resultItem; } @@ -14109,9 +13941,9 @@ QCPAbstractItem* QCustomPlot::itemAt( const QPointF& pos, bool onlySelectable ) \see item */ -bool QCustomPlot::hasItem( QCPAbstractItem* item ) const +bool QCustomPlot::hasItem(QCPAbstractItem *item) const { - return mItems.contains( item ); + return mItems.contains(item); } /*! @@ -14122,11 +13954,11 @@ bool QCustomPlot::hasItem( QCPAbstractItem* item ) const \see addLayer, moveLayer, removeLayer */ -QCPLayer* QCustomPlot::layer( const QString& name ) const +QCPLayer *QCustomPlot::layer(const QString &name) const { - foreach( QCPLayer* layer, mLayers ) + foreach (QCPLayer *layer, mLayers) { - if( layer->name() == name ) + if (layer->name() == name) return layer; } return 0; @@ -14138,13 +13970,12 @@ QCPLayer* QCustomPlot::layer( const QString& name ) const \see addLayer, moveLayer, removeLayer */ -QCPLayer* QCustomPlot::layer( int index ) const +QCPLayer *QCustomPlot::layer(int index) const { - if( index >= 0 && index < mLayers.size() ) + if (index >= 0 && index < mLayers.size()) { - return mLayers.at( index ); - } - else + return mLayers.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return 0; @@ -14154,7 +13985,7 @@ QCPLayer* QCustomPlot::layer( int index ) const /*! Returns the layer that is set as current layer (see \ref setCurrentLayer). */ -QCPLayer* QCustomPlot::currentLayer() const +QCPLayer *QCustomPlot::currentLayer() const { return mCurrentLayer; } @@ -14169,13 +14000,12 @@ QCPLayer* QCustomPlot::currentLayer() const \see addLayer, moveLayer, removeLayer, QCPLayerable::setLayer */ -bool QCustomPlot::setCurrentLayer( const QString& name ) +bool QCustomPlot::setCurrentLayer(const QString &name) { - if( QCPLayer* newCurrentLayer = layer( name ) ) + if (QCPLayer *newCurrentLayer = layer(name)) { - return setCurrentLayer( newCurrentLayer ); - } - else + return setCurrentLayer(newCurrentLayer); + } else { qDebug() << Q_FUNC_INFO << "layer with name doesn't exist:" << name; return false; @@ -14190,14 +14020,14 @@ bool QCustomPlot::setCurrentLayer( const QString& name ) \see addLayer, moveLayer, removeLayer */ -bool QCustomPlot::setCurrentLayer( QCPLayer* layer ) +bool QCustomPlot::setCurrentLayer(QCPLayer *layer) { - if( !mLayers.contains( layer ) ) + if (!mLayers.contains(layer)) { - qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast( layer ); + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); return false; } - + mCurrentLayer = layer; return true; } @@ -14225,25 +14055,25 @@ int QCustomPlot::layerCount() const \see layer, moveLayer, removeLayer */ -bool QCustomPlot::addLayer( const QString& name, QCPLayer* otherLayer, QCustomPlot::LayerInsertMode insertMode ) +bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) { - if( !otherLayer ) + if (!otherLayer) otherLayer = mLayers.last(); - if( !mLayers.contains( otherLayer ) ) + if (!mLayers.contains(otherLayer)) { - qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast( otherLayer ); + qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); return false; } - if( layer( name ) ) + if (layer(name)) { qDebug() << Q_FUNC_INFO << "A layer exists already with the name" << name; return false; } - - QCPLayer* newLayer = new QCPLayer( this, name ); - mLayers.insert( otherLayer->index() + ( insertMode == limAbove ? 1 : 0 ), newLayer ); + + QCPLayer *newLayer = new QCPLayer(this, name); + mLayers.insert(otherLayer->index() + (insertMode==limAbove ? 1:0), newLayer); updateLayerIndices(); - setupPaintBuffers(); // associates new layer with the appropriate paint buffer + setupPaintBuffers(); // associates new layer with the appropriate paint buffer return true; } @@ -14261,43 +14091,42 @@ bool QCustomPlot::addLayer( const QString& name, QCPLayer* otherLayer, QCustomPl \see layer, addLayer, moveLayer */ -bool QCustomPlot::removeLayer( QCPLayer* layer ) +bool QCustomPlot::removeLayer(QCPLayer *layer) { - if( !mLayers.contains( layer ) ) + if (!mLayers.contains(layer)) { - qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast( layer ); + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); return false; } - if( mLayers.size() < 2 ) + if (mLayers.size() < 2) { qDebug() << Q_FUNC_INFO << "can't remove last layer"; return false; } - + // append all children of this layer to layer below (if this is lowest layer, prepend to layer above) int removedIndex = layer->index(); - bool isFirstLayer = removedIndex == 0; - QCPLayer* targetLayer = isFirstLayer ? mLayers.at( removedIndex + 1 ) : mLayers.at( removedIndex - 1 ); + bool isFirstLayer = removedIndex==0; + QCPLayer *targetLayer = isFirstLayer ? mLayers.at(removedIndex+1) : mLayers.at(removedIndex-1); QList children = layer->children(); - if( isFirstLayer ) // prepend in reverse order (so order relative to each other stays the same) + if (isFirstLayer) // prepend in reverse order (so order relative to each other stays the same) { - for( int i = children.size() - 1; i >= 0; --i ) - children.at( i )->moveToLayer( targetLayer, true ); - } - else // append normally + for (int i=children.size()-1; i>=0; --i) + children.at(i)->moveToLayer(targetLayer, true); + } else // append normally { - for( int i = 0; i < children.size(); ++i ) - children.at( i )->moveToLayer( targetLayer, false ); + for (int i=0; imoveToLayer(targetLayer, false); } // if removed layer is current layer, change current layer to layer below/above: - if( layer == mCurrentLayer ) - setCurrentLayer( targetLayer ); + if (layer == mCurrentLayer) + setCurrentLayer(targetLayer); // invalidate the paint buffer that was responsible for this layer: - if( !layer->mPaintBuffer.isNull() ) + if (!layer->mPaintBuffer.isNull()) layer->mPaintBuffer.data()->setInvalidated(); // remove layer: delete layer; - mLayers.removeOne( layer ); + mLayers.removeOne(layer); updateLayerIndices(); return true; } @@ -14311,30 +14140,30 @@ bool QCustomPlot::removeLayer( QCPLayer* layer ) \see layer, addLayer, moveLayer */ -bool QCustomPlot::moveLayer( QCPLayer* layer, QCPLayer* otherLayer, QCustomPlot::LayerInsertMode insertMode ) +bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) { - if( !mLayers.contains( layer ) ) + if (!mLayers.contains(layer)) { - qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast( layer ); + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); return false; } - if( !mLayers.contains( otherLayer ) ) + if (!mLayers.contains(otherLayer)) { - qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast( otherLayer ); + qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); return false; } - - if( layer->index() > otherLayer->index() ) - mLayers.move( layer->index(), otherLayer->index() + ( insertMode == limAbove ? 1 : 0 ) ); - else if( layer->index() < otherLayer->index() ) - mLayers.move( layer->index(), otherLayer->index() + ( insertMode == limAbove ? 0 : -1 ) ); - + + if (layer->index() > otherLayer->index()) + mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 1:0)); + else if (layer->index() < otherLayer->index()) + mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 0:-1)); + // invalidate the paint buffers that are responsible for the layers: - if( !layer->mPaintBuffer.isNull() ) + if (!layer->mPaintBuffer.isNull()) layer->mPaintBuffer.data()->setInvalidated(); - if( !otherLayer->mPaintBuffer.isNull() ) + if (!otherLayer->mPaintBuffer.isNull()) otherLayer->mPaintBuffer.data()->setInvalidated(); - + updateLayerIndices(); return true; } @@ -14362,14 +14191,13 @@ int QCustomPlot::axisRectCount() const \see axisRectCount, axisRects */ -QCPAxisRect* QCustomPlot::axisRect( int index ) const +QCPAxisRect *QCustomPlot::axisRect(int index) const { const QList rectList = axisRects(); - if( index >= 0 && index < rectList.size() ) + if (index >= 0 && index < rectList.size()) { - return rectList.at( index ); - } - else + return rectList.at(index); + } else { qDebug() << Q_FUNC_INFO << "invalid axis rect index" << index; return 0; @@ -14385,22 +14213,22 @@ QList QCustomPlot::axisRects() const { QList result; QStack elementStack; - if( mPlotLayout ) - elementStack.push( mPlotLayout ); - - while( !elementStack.isEmpty() ) + if (mPlotLayout) + elementStack.push(mPlotLayout); + + while (!elementStack.isEmpty()) { - foreach( QCPLayoutElement* element, elementStack.pop()->elements( false ) ) + foreach (QCPLayoutElement *element, elementStack.pop()->elements(false)) { - if( element ) + if (element) { - elementStack.push( element ); - if( QCPAxisRect* ar = qobject_cast( element ) ) - result.append( ar ); + elementStack.push(element); + if (QCPAxisRect *ar = qobject_cast(element)) + result.append(ar); } } } - + return result; } @@ -14413,16 +14241,16 @@ QList QCustomPlot::axisRects() const \see itemAt, plottableAt */ -QCPLayoutElement* QCustomPlot::layoutElementAt( const QPointF& pos ) const +QCPLayoutElement *QCustomPlot::layoutElementAt(const QPointF &pos) const { - QCPLayoutElement* currentElement = mPlotLayout; + QCPLayoutElement *currentElement = mPlotLayout; bool searchSubElements = true; - while( searchSubElements && currentElement ) + while (searchSubElements && currentElement) { searchSubElements = false; - foreach( QCPLayoutElement* subElement, currentElement->elements( false ) ) + foreach (QCPLayoutElement *subElement, currentElement->elements(false)) { - if( subElement && subElement->realVisibility() && subElement->selectTest( pos, false ) >= 0 ) + if (subElement && subElement->realVisibility() && subElement->selectTest(pos, false) >= 0) { currentElement = subElement; searchSubElements = true; @@ -14443,21 +14271,21 @@ QCPLayoutElement* QCustomPlot::layoutElementAt( const QPointF& pos ) const \see layoutElementAt */ -QCPAxisRect* QCustomPlot::axisRectAt( const QPointF& pos ) const +QCPAxisRect *QCustomPlot::axisRectAt(const QPointF &pos) const { - QCPAxisRect* result = 0; - QCPLayoutElement* currentElement = mPlotLayout; + QCPAxisRect *result = 0; + QCPLayoutElement *currentElement = mPlotLayout; bool searchSubElements = true; - while( searchSubElements && currentElement ) + while (searchSubElements && currentElement) { searchSubElements = false; - foreach( QCPLayoutElement* subElement, currentElement->elements( false ) ) + foreach (QCPLayoutElement *subElement, currentElement->elements(false)) { - if( subElement && subElement->realVisibility() && subElement->selectTest( pos, false ) >= 0 ) + if (subElement && subElement->realVisibility() && subElement->selectTest(pos, false) >= 0) { currentElement = subElement; searchSubElements = true; - if( QCPAxisRect* ar = qobject_cast( currentElement ) ) + if (QCPAxisRect *ar = qobject_cast(currentElement)) result = ar; break; } @@ -14476,15 +14304,15 @@ QCPAxisRect* QCustomPlot::axisRectAt( const QPointF& pos ) const QList QCustomPlot::selectedAxes() const { QList result, allAxes; - foreach( QCPAxisRect* rect, axisRects() ) + foreach (QCPAxisRect *rect, axisRects()) allAxes << rect->axes(); - - foreach( QCPAxis* axis, allAxes ) + + foreach (QCPAxis *axis, allAxes) { - if( axis->selectedParts() != QCPAxis::spNone ) - result.append( axis ); + if (axis->selectedParts() != QCPAxis::spNone) + result.append(axis); } - + return result; } @@ -14498,27 +14326,27 @@ QList QCustomPlot::selectedAxes() const QList QCustomPlot::selectedLegends() const { QList result; - + QStack elementStack; - if( mPlotLayout ) - elementStack.push( mPlotLayout ); - - while( !elementStack.isEmpty() ) + if (mPlotLayout) + elementStack.push(mPlotLayout); + + while (!elementStack.isEmpty()) { - foreach( QCPLayoutElement* subElement, elementStack.pop()->elements( false ) ) + foreach (QCPLayoutElement *subElement, elementStack.pop()->elements(false)) { - if( subElement ) + if (subElement) { - elementStack.push( subElement ); - if( QCPLegend* leg = qobject_cast( subElement ) ) + elementStack.push(subElement); + if (QCPLegend *leg = qobject_cast(subElement)) { - if( leg->selectedParts() != QCPLegend::spNone ) - result.append( leg ); + if (leg->selectedParts() != QCPLegend::spNone) + result.append(leg); } } } } - + return result; } @@ -14533,10 +14361,10 @@ QList QCustomPlot::selectedLegends() const */ void QCustomPlot::deselectAll() { - foreach( QCPLayer* layer, mLayers ) + foreach (QCPLayer *layer, mLayers) { - foreach( QCPLayerable* layerable, layer->children() ) - layerable->deselectEvent( 0 ); + foreach (QCPLayerable *layerable, layer->children()) + layerable->deselectEvent(0); } } @@ -14565,37 +14393,37 @@ void QCustomPlot::deselectAll() replot only that specific layer via \ref QCPLayer::replot. See the documentation there for details. */ -void QCustomPlot::replot( QCustomPlot::RefreshPriority refreshPriority ) +void QCustomPlot::replot(QCustomPlot::RefreshPriority refreshPriority) { - if( refreshPriority == QCustomPlot::rpQueuedReplot ) + if (refreshPriority == QCustomPlot::rpQueuedReplot) { - if( !mReplotQueued ) + if (!mReplotQueued) { mReplotQueued = true; - QTimer::singleShot( 0, this, SLOT( replot() ) ); + QTimer::singleShot(0, this, SLOT(replot())); } return; } - - if( mReplotting ) // incase signals loop back to replot slot + + if (mReplotting) // incase signals loop back to replot slot return; mReplotting = true; mReplotQueued = false; emit beforeReplot(); - + updateLayout(); // draw all layered objects (grid, axes, plottables, items, legend,...) into their buffers: setupPaintBuffers(); - foreach( QCPLayer* layer, mLayers ) + foreach (QCPLayer *layer, mLayers) layer->drawToPaintBuffer(); - for( int i = 0; i < mPaintBuffers.size(); ++i ) - mPaintBuffers.at( i )->setInvalidated( false ); - - if( ( refreshPriority == rpRefreshHint && mPlottingHints.testFlag( QCP::phImmediateRefresh ) ) || refreshPriority == rpImmediateRefresh ) + for (int i=0; isetInvalidated(false); + + if ((refreshPriority == rpRefreshHint && mPlottingHints.testFlag(QCP::phImmediateRefresh)) || refreshPriority==rpImmediateRefresh) repaint(); else update(); - + emit afterReplot(); mReplotting = false; } @@ -14608,14 +14436,14 @@ void QCustomPlot::replot( QCustomPlot::RefreshPriority refreshPriority ) \see QCPAbstractPlottable::rescaleAxes, QCPAxis::rescale */ -void QCustomPlot::rescaleAxes( bool onlyVisiblePlottables ) +void QCustomPlot::rescaleAxes(bool onlyVisiblePlottables) { QList allAxes; - foreach( QCPAxisRect* rect, axisRects() ) + foreach (QCPAxisRect *rect, axisRects()) allAxes << rect->axes(); - - foreach( QCPAxis* axis, allAxes ) - axis->rescale( onlyVisiblePlottables ); + + foreach (QCPAxis *axis, allAxes) + axis->rescale(onlyVisiblePlottables); } /*! @@ -14655,67 +14483,66 @@ void QCustomPlot::rescaleAxes( bool onlyVisiblePlottables ) \see savePng, saveBmp, saveJpg, saveRastered */ -bool QCustomPlot::savePdf( const QString& fileName, int width, int height, QCP::ExportPen exportPen, const QString& pdfCreator, const QString& pdfTitle ) +bool QCustomPlot::savePdf(const QString &fileName, int width, int height, QCP::ExportPen exportPen, const QString &pdfCreator, const QString &pdfTitle) { bool success = false; #ifdef QT_NO_PRINTER - Q_UNUSED( fileName ) - Q_UNUSED( exportPen ) - Q_UNUSED( width ) - Q_UNUSED( height ) - Q_UNUSED( pdfCreator ) - Q_UNUSED( pdfTitle ) + Q_UNUSED(fileName) + Q_UNUSED(exportPen) + Q_UNUSED(width) + Q_UNUSED(height) + Q_UNUSED(pdfCreator) + Q_UNUSED(pdfTitle) qDebug() << Q_FUNC_INFO << "Qt was built without printer support (QT_NO_PRINTER). PDF not created."; #else int newWidth, newHeight; - if( width == 0 || height == 0 ) + if (width == 0 || height == 0) { newWidth = this->width(); newHeight = this->height(); - } - else + } else { newWidth = width; newHeight = height; } - - QPrinter printer( QPrinter::ScreenResolution ); - printer.setOutputFileName( fileName ); - printer.setOutputFormat( QPrinter::PdfFormat ); - printer.setColorMode( QPrinter::Color ); - printer.printEngine()->setProperty( QPrintEngine::PPK_Creator, pdfCreator ); - printer.printEngine()->setProperty( QPrintEngine::PPK_DocumentName, pdfTitle ); + + QPrinter printer(QPrinter::ScreenResolution); + printer.setOutputFileName(fileName); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setColorMode(QPrinter::Color); + printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator); + printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle); QRect oldViewport = viewport(); - setViewport( QRect( 0, 0, newWidth, newHeight ) ); -#if QT_VERSION < QT_VERSION_CHECK( 5, 3, 0 ) - printer.setFullPage( true ); - printer.setPaperSize( viewport().size(), QPrinter::DevicePixel ); + setViewport(QRect(0, 0, newWidth, newHeight)); +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) + printer.setFullPage(true); + printer.setPaperSize(viewport().size(), QPrinter::DevicePixel); #else QPageLayout pageLayout; - pageLayout.setMode( QPageLayout::FullPageMode ); - pageLayout.setOrientation( QPageLayout::Portrait ); - pageLayout.setMargins( QMarginsF( 0, 0, 0, 0 ) ); - pageLayout.setPageSize( QPageSize( viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch ) ); - printer.setPageLayout( pageLayout ); + pageLayout.setMode(QPageLayout::FullPageMode); + pageLayout.setOrientation(QPageLayout::Portrait); + pageLayout.setMargins(QMarginsF(0, 0, 0, 0)); + pageLayout.setPageSize(QPageSize(viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch)); + printer.setPageLayout(pageLayout); #endif QCPPainter printpainter; - if( printpainter.begin( &printer ) ) + if (printpainter.begin(&printer)) { - printpainter.setMode( QCPPainter::pmVectorized ); - printpainter.setMode( QCPPainter::pmNoCaching ); - printpainter.setMode( QCPPainter::pmNonCosmetic, exportPen == QCP::epNoCosmetic ); - printpainter.setWindow( mViewport ); - if( mBackgroundBrush.style() != Qt::NoBrush && + printpainter.setMode(QCPPainter::pmVectorized); + printpainter.setMode(QCPPainter::pmNoCaching); + printpainter.setMode(QCPPainter::pmNonCosmetic, exportPen==QCP::epNoCosmetic); + printpainter.setWindow(mViewport); + if (mBackgroundBrush.style() != Qt::NoBrush && mBackgroundBrush.color() != Qt::white && mBackgroundBrush.color() != Qt::transparent && - mBackgroundBrush.color().alpha() > 0 ) // draw pdf background color if not white/transparent - printpainter.fillRect( viewport(), mBackgroundBrush ); - draw( &printpainter ); + mBackgroundBrush.color().alpha() > 0) // draw pdf background color if not white/transparent + printpainter.fillRect(viewport(), mBackgroundBrush); + draw(&printpainter); printpainter.end(); success = true; } - setViewport( oldViewport ); -#endif // QT_NO_PRINTER + setViewport(oldViewport); +#endif // QT_NO_PRINTER return success; } @@ -14764,9 +14591,9 @@ bool QCustomPlot::savePdf( const QString& fileName, int width, int height, QCP:: \see savePdf, saveBmp, saveJpg, saveRastered */ -bool QCustomPlot::savePng( const QString& fileName, int width, int height, double scale, int quality, int resolution, QCP::ResolutionUnit resolutionUnit ) +bool QCustomPlot::savePng(const QString &fileName, int width, int height, double scale, int quality, int resolution, QCP::ResolutionUnit resolutionUnit) { - return saveRastered( fileName, width, height, scale, "PNG", quality, resolution, resolutionUnit ); + return saveRastered(fileName, width, height, scale, "PNG", quality, resolution, resolutionUnit); } /*! @@ -14811,9 +14638,9 @@ bool QCustomPlot::savePng( const QString& fileName, int width, int height, doubl \see savePdf, savePng, saveBmp, saveRastered */ -bool QCustomPlot::saveJpg( const QString& fileName, int width, int height, double scale, int quality, int resolution, QCP::ResolutionUnit resolutionUnit ) +bool QCustomPlot::saveJpg(const QString &fileName, int width, int height, double scale, int quality, int resolution, QCP::ResolutionUnit resolutionUnit) { - return saveRastered( fileName, width, height, scale, "JPG", quality, resolution, resolutionUnit ); + return saveRastered(fileName, width, height, scale, "JPG", quality, resolution, resolutionUnit); } /*! @@ -14855,9 +14682,9 @@ bool QCustomPlot::saveJpg( const QString& fileName, int width, int height, doubl \see savePdf, savePng, saveJpg, saveRastered */ -bool QCustomPlot::saveBmp( const QString& fileName, int width, int height, double scale, int resolution, QCP::ResolutionUnit resolutionUnit ) +bool QCustomPlot::saveBmp(const QString &fileName, int width, int height, double scale, int resolution, QCP::ResolutionUnit resolutionUnit) { - return saveRastered( fileName, width, height, scale, "BMP", -1, resolution, resolutionUnit ); + return saveRastered(fileName, width, height, scale, "BMP", -1, resolution, resolutionUnit); } /*! \internal @@ -14888,18 +14715,18 @@ QSize QCustomPlot::sizeHint() const Event handler for when the QCustomPlot widget needs repainting. This does not cause a \ref replot, but draws the internal buffer on the widget surface. */ -void QCustomPlot::paintEvent( QPaintEvent* event ) +void QCustomPlot::paintEvent(QPaintEvent *event) { - Q_UNUSED( event ); - QCPPainter painter( this ); - if( painter.isActive() ) + Q_UNUSED(event); + QCPPainter painter(this); + if (painter.isActive()) { - painter.setRenderHint( QPainter::HighQualityAntialiasing ); // to make Antialiasing look good if using the OpenGL graphicssystem - if( mBackgroundBrush.style() != Qt::NoBrush ) - painter.fillRect( mViewport, mBackgroundBrush ); - drawBackground( &painter ); - for( int bufferIndex = 0; bufferIndex < mPaintBuffers.size(); ++bufferIndex ) - mPaintBuffers.at( bufferIndex )->draw( &painter ); + painter.setRenderHint(QPainter::HighQualityAntialiasing); // to make Antialiasing look good if using the OpenGL graphicssystem + if (mBackgroundBrush.style() != Qt::NoBrush) + painter.fillRect(mViewport, mBackgroundBrush); + drawBackground(&painter); + for (int bufferIndex = 0; bufferIndex < mPaintBuffers.size(); ++bufferIndex) + mPaintBuffers.at(bufferIndex)->draw(&painter); } } @@ -14908,12 +14735,12 @@ void QCustomPlot::paintEvent( QPaintEvent* event ) Event handler for a resize of the QCustomPlot widget. The viewport (which becomes the outer rect of mPlotLayout) is resized appropriately. Finally a \ref replot is performed. */ -void QCustomPlot::resizeEvent( QResizeEvent* event ) +void QCustomPlot::resizeEvent(QResizeEvent *event) { - Q_UNUSED( event ) + Q_UNUSED(event) // resize and repaint the buffer: - setViewport( rect() ); - replot( rpQueuedRefresh ); // queued refresh is important here, to prevent painting issues in some contexts (e.g. MDI subwindow) + setViewport(rect()); + replot(rpQueuedRefresh); // queued refresh is important here, to prevent painting issues in some contexts (e.g. MDI subwindow) } /*! \internal @@ -14925,48 +14752,47 @@ void QCustomPlot::resizeEvent( QResizeEvent* event ) \see mousePressEvent, mouseReleaseEvent */ -void QCustomPlot::mouseDoubleClickEvent( QMouseEvent* event ) +void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) { - emit mouseDoubleClick( event ); + emit mouseDoubleClick(event); mMouseHasMoved = false; mMousePressPos = event->pos(); - + // determine layerable under the cursor (this event is called instead of the second press event in a double-click): QList details; - QList candidates = layerableListAt( mMousePressPos, false, &details ); - for( int i = 0; i < candidates.size(); ++i ) + QList candidates = layerableListAt(mMousePressPos, false, &details); + for (int i=0; iaccept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list - candidates.at( i )->mouseDoubleClickEvent( event, details.at( i ) ); - if( event->isAccepted() ) + event->accept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list + candidates.at(i)->mouseDoubleClickEvent(event, details.at(i)); + if (event->isAccepted()) { - mMouseEventLayerable = candidates.at( i ); - mMouseEventLayerableDetails = details.at( i ); + mMouseEventLayerable = candidates.at(i); + mMouseEventLayerableDetails = details.at(i); break; } } - + // emit specialized object double click signals: - if( !candidates.isEmpty() ) + if (!candidates.isEmpty()) { - if( QCPAbstractPlottable* ap = qobject_cast( candidates.first() ) ) + if (QCPAbstractPlottable *ap = qobject_cast(candidates.first())) { int dataIndex = 0; - if( !details.first().value().isEmpty() ) + if (!details.first().value().isEmpty()) dataIndex = details.first().value().dataRange().begin(); - emit plottableDoubleClick( ap, dataIndex, event ); - } - else if( QCPAxis* ax = qobject_cast( candidates.first() ) ) - emit axisDoubleClick( ax, details.first().value(), event ); - else if( QCPAbstractItem* ai = qobject_cast( candidates.first() ) ) - emit itemDoubleClick( ai, event ); - else if( QCPLegend* lg = qobject_cast( candidates.first() ) ) - emit legendDoubleClick( lg, 0, event ); - else if( QCPAbstractLegendItem* li = qobject_cast( candidates.first() ) ) - emit legendDoubleClick( li->parentLegend(), li, event ); + emit plottableDoubleClick(ap, dataIndex, event); + } else if (QCPAxis *ax = qobject_cast(candidates.first())) + emit axisDoubleClick(ax, details.first().value(), event); + else if (QCPAbstractItem *ai = qobject_cast(candidates.first())) + emit itemDoubleClick(ai, event); + else if (QCPLegend *lg = qobject_cast(candidates.first())) + emit legendDoubleClick(lg, 0, event); + else if (QCPAbstractLegendItem *li = qobject_cast(candidates.first())) + emit legendDoubleClick(li->parentLegend(), li, event); } - - event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. + + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal @@ -14978,43 +14804,42 @@ void QCustomPlot::mouseDoubleClickEvent( QMouseEvent* event ) \see mouseMoveEvent, mouseReleaseEvent */ -void QCustomPlot::mousePressEvent( QMouseEvent* event ) +void QCustomPlot::mousePressEvent(QMouseEvent *event) { - emit mousePress( event ); + emit mousePress(event); // save some state to tell in releaseEvent whether it was a click: mMouseHasMoved = false; mMousePressPos = event->pos(); - - if( mSelectionRect && mSelectionRectMode != QCP::srmNone ) + + if (mSelectionRect && mSelectionRectMode != QCP::srmNone) { - if( mSelectionRectMode != QCP::srmZoom || qobject_cast( axisRectAt( mMousePressPos ) ) ) // in zoom mode only activate selection rect if on an axis rect - mSelectionRect->startSelection( event ); - } - else + if (mSelectionRectMode != QCP::srmZoom || qobject_cast(axisRectAt(mMousePressPos))) // in zoom mode only activate selection rect if on an axis rect + mSelectionRect->startSelection(event); + } else { // no selection rect interaction, prepare for click signal emission and forward event to layerable under the cursor: QList details; - QList candidates = layerableListAt( mMousePressPos, false, &details ); - if( !candidates.isEmpty() ) + QList candidates = layerableListAt(mMousePressPos, false, &details); + if (!candidates.isEmpty()) { - mMouseSignalLayerable = candidates.first(); // candidate for signal emission is always topmost hit layerable (signal emitted in release event) + mMouseSignalLayerable = candidates.first(); // candidate for signal emission is always topmost hit layerable (signal emitted in release event) mMouseSignalLayerableDetails = details.first(); } // forward event to topmost candidate which accepts the event: - for( int i = 0; i < candidates.size(); ++i ) + for (int i=0; iaccept(); // default impl of QCPLayerable's mouse events call ignore() on the event, in that case propagate to next candidate in list - candidates.at( i )->mousePressEvent( event, details.at( i ) ); - if( event->isAccepted() ) + event->accept(); // default impl of QCPLayerable's mouse events call ignore() on the event, in that case propagate to next candidate in list + candidates.at(i)->mousePressEvent(event, details.at(i)); + if (event->isAccepted()) { - mMouseEventLayerable = candidates.at( i ); - mMouseEventLayerableDetails = details.at( i ); + mMouseEventLayerable = candidates.at(i); + mMouseEventLayerableDetails = details.at(i); break; } } } - - event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. + + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal @@ -15029,19 +14854,19 @@ void QCustomPlot::mousePressEvent( QMouseEvent* event ) \see mousePressEvent, mouseReleaseEvent */ -void QCustomPlot::mouseMoveEvent( QMouseEvent* event ) +void QCustomPlot::mouseMoveEvent(QMouseEvent *event) { - emit mouseMove( event ); - - if( !mMouseHasMoved && ( mMousePressPos - event->pos() ).manhattanLength() > 3 ) - mMouseHasMoved = true; // moved too far from mouse press position, don't handle as click on mouse release - - if( mSelectionRect && mSelectionRect->isActive() ) - mSelectionRect->moveSelection( event ); - else if( mMouseEventLayerable ) // call event of affected layerable: - mMouseEventLayerable->mouseMoveEvent( event, mMousePressPos ); - - event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. + emit mouseMove(event); + + if (!mMouseHasMoved && (mMousePressPos-event->pos()).manhattanLength() > 3) + mMouseHasMoved = true; // moved too far from mouse press position, don't handle as click on mouse release + + if (mSelectionRect && mSelectionRect->isActive()) + mSelectionRect->moveSelection(event); + else if (mMouseEventLayerable) // call event of affected layerable: + mMouseEventLayerable->mouseMoveEvent(event, mMousePressPos); + + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal @@ -15058,55 +14883,53 @@ void QCustomPlot::mouseMoveEvent( QMouseEvent* event ) \see mousePressEvent, mouseMoveEvent */ -void QCustomPlot::mouseReleaseEvent( QMouseEvent* event ) +void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) { - emit mouseRelease( event ); - - if( !mMouseHasMoved ) // mouse hasn't moved (much) between press and release, so handle as click + emit mouseRelease(event); + + if (!mMouseHasMoved) // mouse hasn't moved (much) between press and release, so handle as click { - if( mSelectionRect && mSelectionRect->isActive() ) // a simple click shouldn't successfully finish a selection rect, so cancel it here + if (mSelectionRect && mSelectionRect->isActive()) // a simple click shouldn't successfully finish a selection rect, so cancel it here mSelectionRect->cancel(); - if( event->button() == Qt::LeftButton ) - processPointSelection( event ); - + if (event->button() == Qt::LeftButton) + processPointSelection(event); + // emit specialized click signals of QCustomPlot instance: - if( QCPAbstractPlottable* ap = qobject_cast( mMouseSignalLayerable ) ) + if (QCPAbstractPlottable *ap = qobject_cast(mMouseSignalLayerable)) { int dataIndex = 0; - if( !mMouseSignalLayerableDetails.value().isEmpty() ) + if (!mMouseSignalLayerableDetails.value().isEmpty()) dataIndex = mMouseSignalLayerableDetails.value().dataRange().begin(); - emit plottableClick( ap, dataIndex, event ); - } - else if( QCPAxis* ax = qobject_cast( mMouseSignalLayerable ) ) - emit axisClick( ax, mMouseSignalLayerableDetails.value(), event ); - else if( QCPAbstractItem* ai = qobject_cast( mMouseSignalLayerable ) ) - emit itemClick( ai, event ); - else if( QCPLegend* lg = qobject_cast( mMouseSignalLayerable ) ) - emit legendClick( lg, 0, event ); - else if( QCPAbstractLegendItem* li = qobject_cast( mMouseSignalLayerable ) ) - emit legendClick( li->parentLegend(), li, event ); + emit plottableClick(ap, dataIndex, event); + } else if (QCPAxis *ax = qobject_cast(mMouseSignalLayerable)) + emit axisClick(ax, mMouseSignalLayerableDetails.value(), event); + else if (QCPAbstractItem *ai = qobject_cast(mMouseSignalLayerable)) + emit itemClick(ai, event); + else if (QCPLegend *lg = qobject_cast(mMouseSignalLayerable)) + emit legendClick(lg, 0, event); + else if (QCPAbstractLegendItem *li = qobject_cast(mMouseSignalLayerable)) + emit legendClick(li->parentLegend(), li, event); mMouseSignalLayerable = 0; } - - if( mSelectionRect && mSelectionRect->isActive() ) // Note: if a click was detected above, the selection rect is canceled there + + if (mSelectionRect && mSelectionRect->isActive()) // Note: if a click was detected above, the selection rect is canceled there { // finish selection rect, the appropriate action will be taken via signal-slot connection: - mSelectionRect->endSelection( event ); - } - else + mSelectionRect->endSelection(event); + } else { // call event of affected layerable: - if( mMouseEventLayerable ) + if (mMouseEventLayerable) { - mMouseEventLayerable->mouseReleaseEvent( event, mMousePressPos ); + mMouseEventLayerable->mouseReleaseEvent(event, mMousePressPos); mMouseEventLayerable = 0; } } - - if( noAntialiasingOnDrag() ) - replot( rpQueuedReplot ); - - event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. + + if (noAntialiasingOnDrag()) + replot(rpQueuedReplot); + + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal @@ -15114,19 +14937,19 @@ void QCustomPlot::mouseReleaseEvent( QMouseEvent* event ) Event handler for mouse wheel events. First, the \ref mouseWheel signal is emitted. Then determines the affected layerable and forwards the event to it. */ -void QCustomPlot::wheelEvent( QWheelEvent* event ) +void QCustomPlot::wheelEvent(QWheelEvent *event) { - emit mouseWheel( event ); + emit mouseWheel(event); // forward event to layerable under cursor: - QList candidates = layerableListAt( event->pos(), false ); - for( int i = 0; i < candidates.size(); ++i ) + QList candidates = layerableListAt(event->pos(), false); + for (int i=0; iaccept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list - candidates.at( i )->wheelEvent( event ); - if( event->isAccepted() ) + event->accept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list + candidates.at(i)->wheelEvent(event); + if (event->isAccepted()) break; } - event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. + event->accept(); // in case QCPLayerable reimplementation manipulates event accepted state. In QWidget event system, QCustomPlot wants to accept the event. } /*! \internal @@ -15139,17 +14962,17 @@ void QCustomPlot::wheelEvent( QWheelEvent* event ) \ref setBackground(const QBrush &brush)), this is up to the respective functions calling this method. */ -void QCustomPlot::draw( QCPPainter* painter ) +void QCustomPlot::draw(QCPPainter *painter) { updateLayout(); - + // draw viewport background pixmap: - drawBackground( painter ); + drawBackground(painter); // draw all layered objects (grid, axes, plottables, items, legend,...): - foreach( QCPLayer* layer, mLayers ) - layer->draw( painter ); - + foreach (QCPLayer *layer, mLayers) + layer->draw(painter); + /* Debug code to draw all layout element rects foreach (QCPLayoutElement* el, findChildren()) { @@ -15173,9 +14996,9 @@ void QCustomPlot::draw( QCPPainter* painter ) void QCustomPlot::updateLayout() { // run through layout phases: - mPlotLayout->update( QCPLayoutElement::upPreparation ); - mPlotLayout->update( QCPLayoutElement::upMargins ); - mPlotLayout->update( QCPLayoutElement::upLayout ); + mPlotLayout->update(QCPLayoutElement::upPreparation); + mPlotLayout->update(QCPLayoutElement::upMargins); + mPlotLayout->update(QCPLayoutElement::upLayout); } /*! \internal @@ -15195,25 +15018,24 @@ void QCustomPlot::updateLayout() \see setBackground, setBackgroundScaled, setBackgroundScaledMode */ -void QCustomPlot::drawBackground( QCPPainter* painter ) +void QCustomPlot::drawBackground(QCPPainter *painter) { // Note: background color is handled in individual replot/save functions // draw background pixmap (on top of fill, if brush specified): - if( !mBackgroundPixmap.isNull() ) + if (!mBackgroundPixmap.isNull()) { - if( mBackgroundScaled ) + if (mBackgroundScaled) { // check whether mScaledBackground needs to be updated: - QSize scaledSize( mBackgroundPixmap.size() ); - scaledSize.scale( mViewport.size(), mBackgroundScaledMode ); - if( mScaledBackgroundPixmap.size() != scaledSize ) - mScaledBackgroundPixmap = mBackgroundPixmap.scaled( mViewport.size(), mBackgroundScaledMode, Qt::SmoothTransformation ); - painter->drawPixmap( mViewport.topLeft(), mScaledBackgroundPixmap, QRect( 0, 0, mViewport.width(), mViewport.height() ) & mScaledBackgroundPixmap.rect() ); - } - else + QSize scaledSize(mBackgroundPixmap.size()); + scaledSize.scale(mViewport.size(), mBackgroundScaledMode); + if (mScaledBackgroundPixmap.size() != scaledSize) + mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mViewport.size(), mBackgroundScaledMode, Qt::SmoothTransformation); + painter->drawPixmap(mViewport.topLeft(), mScaledBackgroundPixmap, QRect(0, 0, mViewport.width(), mViewport.height()) & mScaledBackgroundPixmap.rect()); + } else { - painter->drawPixmap( mViewport.topLeft(), mBackgroundPixmap, QRect( 0, 0, mViewport.width(), mViewport.height() ) ); + painter->drawPixmap(mViewport.topLeft(), mBackgroundPixmap, QRect(0, 0, mViewport.width(), mViewport.height())); } } } @@ -15240,39 +15062,38 @@ void QCustomPlot::drawBackground( QCPPainter* painter ) void QCustomPlot::setupPaintBuffers() { int bufferIndex = 0; - if( mPaintBuffers.isEmpty() ) - mPaintBuffers.append( QSharedPointer( createPaintBuffer() ) ); - - for( int layerIndex = 0; layerIndex < mLayers.size(); ++layerIndex ) + if (mPaintBuffers.isEmpty()) + mPaintBuffers.append(QSharedPointer(createPaintBuffer())); + + for (int layerIndex = 0; layerIndex < mLayers.size(); ++layerIndex) { - QCPLayer* layer = mLayers.at( layerIndex ); - if( layer->mode() == QCPLayer::lmLogical ) + QCPLayer *layer = mLayers.at(layerIndex); + if (layer->mode() == QCPLayer::lmLogical) { - layer->mPaintBuffer = mPaintBuffers.at( bufferIndex ).toWeakRef(); - } - else if( layer->mode() == QCPLayer::lmBuffered ) + layer->mPaintBuffer = mPaintBuffers.at(bufferIndex).toWeakRef(); + } else if (layer->mode() == QCPLayer::lmBuffered) { ++bufferIndex; - if( bufferIndex >= mPaintBuffers.size() ) - mPaintBuffers.append( QSharedPointer( createPaintBuffer() ) ); - layer->mPaintBuffer = mPaintBuffers.at( bufferIndex ).toWeakRef(); - if( layerIndex < mLayers.size() - 1 && mLayers.at( layerIndex + 1 )->mode() == QCPLayer::lmLogical ) // not last layer, and next one is logical, so prepare another buffer for next layerables + if (bufferIndex >= mPaintBuffers.size()) + mPaintBuffers.append(QSharedPointer(createPaintBuffer())); + layer->mPaintBuffer = mPaintBuffers.at(bufferIndex).toWeakRef(); + if (layerIndex < mLayers.size()-1 && mLayers.at(layerIndex+1)->mode() == QCPLayer::lmLogical) // not last layer, and next one is logical, so prepare another buffer for next layerables { ++bufferIndex; - if( bufferIndex >= mPaintBuffers.size() ) - mPaintBuffers.append( QSharedPointer( createPaintBuffer() ) ); + if (bufferIndex >= mPaintBuffers.size()) + mPaintBuffers.append(QSharedPointer(createPaintBuffer())); } } } // remove unneeded buffers: - while( mPaintBuffers.size() - 1 > bufferIndex ) + while (mPaintBuffers.size()-1 > bufferIndex) mPaintBuffers.removeLast(); // resize buffers to viewport size and clear contents: - for( int i = 0; i < mPaintBuffers.size(); ++i ) + for (int i=0; isetSize( viewport().size() ); // won't do anything if already correct size - mPaintBuffers.at( i )->clear( Qt::transparent ); - mPaintBuffers.at( i )->setInvalidated(); + mPaintBuffers.at(i)->setSize(viewport().size()); // won't do anything if already correct size + mPaintBuffers.at(i)->clear(Qt::transparent); + mPaintBuffers.at(i)->setInvalidated(); } } @@ -15284,21 +15105,20 @@ void QCustomPlot::setupPaintBuffers() backends (subclasses of \ref QCPAbstractPaintBuffer) are created, initialized with the proper size and device pixel ratio, and returned. */ -QCPAbstractPaintBuffer* QCustomPlot::createPaintBuffer() +QCPAbstractPaintBuffer *QCustomPlot::createPaintBuffer() { - if( mOpenGl ) + if (mOpenGl) { -#if defined( QCP_OPENGL_FBO ) - return new QCPPaintBufferGlFbo( viewport().size(), mBufferDevicePixelRatio, mGlContext, mGlPaintDevice ); -#elif defined( QCP_OPENGL_PBUFFER ) - return new QCPPaintBufferGlPbuffer( viewport().size(), mBufferDevicePixelRatio, mOpenGlMultisamples ); +#if defined(QCP_OPENGL_FBO) + return new QCPPaintBufferGlFbo(viewport().size(), mBufferDevicePixelRatio, mGlContext, mGlPaintDevice); +#elif defined(QCP_OPENGL_PBUFFER) + return new QCPPaintBufferGlPbuffer(viewport().size(), mBufferDevicePixelRatio, mOpenGlMultisamples); #else qDebug() << Q_FUNC_INFO << "OpenGL enabled even though no support for it compiled in, this shouldn't have happened. Falling back to pixmap paint buffer."; - return new QCPPaintBufferPixmap( viewport().size(), mBufferDevicePixelRatio ); + return new QCPPaintBufferPixmap(viewport().size(), mBufferDevicePixelRatio); #endif - } - else - return new QCPPaintBufferPixmap( viewport().size(), mBufferDevicePixelRatio ); + } else + return new QCPPaintBufferPixmap(viewport().size(), mBufferDevicePixelRatio); } /*! @@ -15314,9 +15134,9 @@ QCPAbstractPaintBuffer* QCustomPlot::createPaintBuffer() */ bool QCustomPlot::hasInvalidatedPaintBuffers() { - for( int i = 0; i < mPaintBuffers.size(); ++i ) + for (int i=0; iinvalidated() ) + if (mPaintBuffers.at(i)->invalidated()) return true; } return false; @@ -15340,42 +15160,42 @@ bool QCustomPlot::setupOpenGl() #ifdef QCP_OPENGL_FBO freeOpenGl(); QSurfaceFormat proposedSurfaceFormat; - proposedSurfaceFormat.setSamples( mOpenGlMultisamples ); + proposedSurfaceFormat.setSamples(mOpenGlMultisamples); #ifdef QCP_OPENGL_OFFSCREENSURFACE - QOffscreenSurface* surface = new QOffscreenSurface; + QOffscreenSurface *surface = new QOffscreenSurface; #else - QWindow* surface = new QWindow; - surface->setSurfaceType( QSurface::OpenGLSurface ); + QWindow *surface = new QWindow; + surface->setSurfaceType(QSurface::OpenGLSurface); #endif - surface->setFormat( proposedSurfaceFormat ); + surface->setFormat(proposedSurfaceFormat); surface->create(); - mGlSurface = QSharedPointer( surface ); - mGlContext = QSharedPointer( new QOpenGLContext ); - mGlContext->setFormat( mGlSurface->format() ); - if( !mGlContext->create() ) + mGlSurface = QSharedPointer(surface); + mGlContext = QSharedPointer(new QOpenGLContext); + mGlContext->setFormat(mGlSurface->format()); + if (!mGlContext->create()) { qDebug() << Q_FUNC_INFO << "Failed to create OpenGL context"; mGlContext.clear(); mGlSurface.clear(); return false; } - if( !mGlContext->makeCurrent( mGlSurface.data() ) ) // context needs to be current to create paint device + if (!mGlContext->makeCurrent(mGlSurface.data())) // context needs to be current to create paint device { qDebug() << Q_FUNC_INFO << "Failed to make opengl context current"; mGlContext.clear(); mGlSurface.clear(); return false; } - if( !QOpenGLFramebufferObject::hasOpenGLFramebufferObjects() ) + if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) { qDebug() << Q_FUNC_INFO << "OpenGL of this system doesn't support frame buffer objects"; mGlContext.clear(); mGlSurface.clear(); return false; } - mGlPaintDevice = QSharedPointer( new QOpenGLPaintDevice ); + mGlPaintDevice = QSharedPointer(new QOpenGLPaintDevice); return true; -#elif defined( QCP_OPENGL_PBUFFER ) +#elif defined(QCP_OPENGL_PBUFFER) return QGLFormat::hasOpenGL(); #else return false; @@ -15407,17 +15227,17 @@ void QCustomPlot::freeOpenGl() This method is used by \ref QCPAxisRect::removeAxis to report removed axes to the QCustomPlot so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly. */ -void QCustomPlot::axisRemoved( QCPAxis* axis ) +void QCustomPlot::axisRemoved(QCPAxis *axis) { - if( xAxis == axis ) + if (xAxis == axis) xAxis = 0; - if( xAxis2 == axis ) + if (xAxis2 == axis) xAxis2 = 0; - if( yAxis == axis ) + if (yAxis == axis) yAxis = 0; - if( yAxis2 == axis ) + if (yAxis2 == axis) yAxis2 = 0; - + // Note: No need to take care of range drag axes and range zoom axes, because they are stored in smart pointers } @@ -15426,9 +15246,9 @@ void QCustomPlot::axisRemoved( QCPAxis* axis ) This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so it may clear its QCustomPlot::legend member accordingly. */ -void QCustomPlot::legendRemoved( QCPLegend* legend ) +void QCustomPlot::legendRemoved(QCPLegend *legend) { - if( this->legend == legend ) + if (this->legend == legend) this->legend = 0; } @@ -15449,78 +15269,77 @@ void QCustomPlot::legendRemoved( QCPLegend* legend ) \see processRectZoom */ -void QCustomPlot::processRectSelection( QRect rect, QMouseEvent* event ) +void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event) { bool selectionStateChanged = false; - - if( mInteractions.testFlag( QCP::iSelectPlottables ) ) + + if (mInteractions.testFlag(QCP::iSelectPlottables)) { - QMap > potentialSelections; // map key is number of selected data points, so we have selections sorted by size - QRectF rectF( rect.normalized() ); - if( QCPAxisRect* affectedAxisRect = axisRectAt( rectF.topLeft() ) ) + QMap > potentialSelections; // map key is number of selected data points, so we have selections sorted by size + QRectF rectF(rect.normalized()); + if (QCPAxisRect *affectedAxisRect = axisRectAt(rectF.topLeft())) { // determine plottables that were hit by the rect and thus are candidates for selection: - foreach( QCPAbstractPlottable* plottable, affectedAxisRect->plottables() ) + foreach (QCPAbstractPlottable *plottable, affectedAxisRect->plottables()) { - if( QCPPlottableInterface1D* plottableInterface = plottable->interface1D() ) + if (QCPPlottableInterface1D *plottableInterface = plottable->interface1D()) { - QCPDataSelection dataSel = plottableInterface->selectTestRect( rectF, true ); - if( !dataSel.isEmpty() ) - potentialSelections.insertMulti( dataSel.dataPointCount(), QPair( plottable, dataSel ) ); + QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF, true); + if (!dataSel.isEmpty()) + potentialSelections.insertMulti(dataSel.dataPointCount(), QPair(plottable, dataSel)); } } - - if( !mInteractions.testFlag( QCP::iMultiSelect ) ) + + if (!mInteractions.testFlag(QCP::iMultiSelect)) { // only leave plottable with most selected points in map, since we will only select a single plottable: - if( !potentialSelections.isEmpty() ) + if (!potentialSelections.isEmpty()) { QMap >::iterator it = potentialSelections.begin(); - while( it != potentialSelections.end() - 1 ) // erase all except last element - it = potentialSelections.erase( it ); + while (it != potentialSelections.end()-1) // erase all except last element + it = potentialSelections.erase(it); } } - - bool additive = event->modifiers().testFlag( mMultiSelectModifier ); + + bool additive = event->modifiers().testFlag(mMultiSelectModifier); // deselect all other layerables if not additive selection: - if( !additive ) + if (!additive) { // emit deselection except to those plottables who will be selected afterwards: - foreach( QCPLayer* layer, mLayers ) + foreach (QCPLayer *layer, mLayers) { - foreach( QCPLayerable* layerable, layer->children() ) + foreach (QCPLayerable *layerable, layer->children()) { - if( ( potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable ) && mInteractions.testFlag( layerable->selectionCategory() ) ) + if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) && mInteractions.testFlag(layerable->selectionCategory())) { bool selChanged = false; - layerable->deselectEvent( &selChanged ); + layerable->deselectEvent(&selChanged); selectionStateChanged |= selChanged; } } } } - + // go through selections in reverse (largest selection first) and emit select events: QMap >::const_iterator it = potentialSelections.constEnd(); - while( it != potentialSelections.constBegin() ) + while (it != potentialSelections.constBegin()) { --it; - if( mInteractions.testFlag( it.value().first->selectionCategory() ) ) + if (mInteractions.testFlag(it.value().first->selectionCategory())) { bool selChanged = false; - it.value().first->selectEvent( event, additive, QVariant::fromValue( it.value().second ), &selChanged ); + it.value().first->selectEvent(event, additive, QVariant::fromValue(it.value().second), &selChanged); selectionStateChanged |= selChanged; } } } } - - if( selectionStateChanged ) + + if (selectionStateChanged) { emit selectionChangedByUser(); - replot( rpQueuedReplot ); - } - else if( mSelectionRect ) + replot(rpQueuedReplot); + } else if (mSelectionRect) mSelectionRect->layer()->replot(); } @@ -15535,16 +15354,16 @@ void QCustomPlot::processRectSelection( QRect rect, QMouseEvent* event ) \see processRectSelection */ -void QCustomPlot::processRectZoom( QRect rect, QMouseEvent* event ) +void QCustomPlot::processRectZoom(QRect rect, QMouseEvent *event) { - Q_UNUSED( event ) - if( QCPAxisRect* axisRect = axisRectAt( rect.topLeft() ) ) + Q_UNUSED(event) + if (QCPAxisRect *axisRect = axisRectAt(rect.topLeft())) { - QList affectedAxes = QList() << axisRect->rangeZoomAxes( Qt::Horizontal ) << axisRect->rangeZoomAxes( Qt::Vertical ); - affectedAxes.removeAll( static_cast( 0 ) ); - axisRect->zoom( QRectF( rect ), affectedAxes ); + QList affectedAxes = QList() << axisRect->rangeZoomAxes(Qt::Horizontal) << axisRect->rangeZoomAxes(Qt::Vertical); + affectedAxes.removeAll(static_cast(0)); + axisRect->zoom(QRectF(rect), affectedAxes); } - replot( rpQueuedReplot ); // always replot to make selection rect disappear + replot(rpQueuedReplot); // always replot to make selection rect disappear } /*! \internal @@ -15564,39 +15383,39 @@ void QCustomPlot::processRectZoom( QRect rect, QMouseEvent* event ) \see processRectSelection, QCPLayerable::selectTest */ -void QCustomPlot::processPointSelection( QMouseEvent* event ) +void QCustomPlot::processPointSelection(QMouseEvent *event) { QVariant details; - QCPLayerable* clickedLayerable = layerableAt( event->pos(), true, &details ); + QCPLayerable *clickedLayerable = layerableAt(event->pos(), true, &details); bool selectionStateChanged = false; - bool additive = mInteractions.testFlag( QCP::iMultiSelect ) && event->modifiers().testFlag( mMultiSelectModifier ); + bool additive = mInteractions.testFlag(QCP::iMultiSelect) && event->modifiers().testFlag(mMultiSelectModifier); // deselect all other layerables if not additive selection: - if( !additive ) + if (!additive) { - foreach( QCPLayer* layer, mLayers ) + foreach (QCPLayer *layer, mLayers) { - foreach( QCPLayerable* layerable, layer->children() ) + foreach (QCPLayerable *layerable, layer->children()) { - if( layerable != clickedLayerable && mInteractions.testFlag( layerable->selectionCategory() ) ) + if (layerable != clickedLayerable && mInteractions.testFlag(layerable->selectionCategory())) { bool selChanged = false; - layerable->deselectEvent( &selChanged ); + layerable->deselectEvent(&selChanged); selectionStateChanged |= selChanged; } } } } - if( clickedLayerable && mInteractions.testFlag( clickedLayerable->selectionCategory() ) ) + if (clickedLayerable && mInteractions.testFlag(clickedLayerable->selectionCategory())) { // a layerable was actually clicked, call its selectEvent: bool selChanged = false; - clickedLayerable->selectEvent( event, additive, details, &selChanged ); + clickedLayerable->selectEvent(event, additive, details, &selChanged); selectionStateChanged |= selChanged; } - if( selectionStateChanged ) + if (selectionStateChanged) { emit selectionChangedByUser(); - replot( rpQueuedReplot ); + replot(rpQueuedReplot); } } @@ -15611,25 +15430,25 @@ void QCustomPlot::processPointSelection( QMouseEvent* event ) This method is called automatically in the QCPAbstractPlottable base class constructor. */ -bool QCustomPlot::registerPlottable( QCPAbstractPlottable* plottable ) +bool QCustomPlot::registerPlottable(QCPAbstractPlottable *plottable) { - if( mPlottables.contains( plottable ) ) + if (mPlottables.contains(plottable)) { - qDebug() << Q_FUNC_INFO << "plottable already added to this QCustomPlot:" << reinterpret_cast( plottable ); + qDebug() << Q_FUNC_INFO << "plottable already added to this QCustomPlot:" << reinterpret_cast(plottable); return false; } - if( plottable->parentPlot() != this ) + if (plottable->parentPlot() != this) { - qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast( plottable ); + qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast(plottable); return false; } - - mPlottables.append( plottable ); + + mPlottables.append(plottable); // possibly add plottable to legend: - if( mAutoAddPlottableToLegend ) + if (mAutoAddPlottableToLegend) plottable->addToLegend(); - if( !plottable->layer() ) // usually the layer is already set in the constructor of the plottable (via QCPLayerable constructor) - plottable->setLayer( currentLayer() ); + if (!plottable->layer()) // usually the layer is already set in the constructor of the plottable (via QCPLayerable constructor) + plottable->setLayer(currentLayer()); return true; } @@ -15642,23 +15461,24 @@ bool QCustomPlot::registerPlottable( QCPAbstractPlottable* plottable ) This graph specific registration happens in addition to the call to \ref registerPlottable by the QCPAbstractPlottable base class. */ -bool QCustomPlot::registerGraph( QCPGraph* graph ) +bool QCustomPlot::registerGraph(QCPGraph *graph) { - if( !graph ) + if (!graph) { qDebug() << Q_FUNC_INFO << "passed graph is zero"; return false; } - if( mGraphs.contains( graph ) ) + if (mGraphs.contains(graph)) { qDebug() << Q_FUNC_INFO << "graph already registered with this QCustomPlot"; return false; } - - mGraphs.append( graph ); + + mGraphs.append(graph); return true; } + /*! \internal Registers the specified item with this QCustomPlot. QCustomPlot takes ownership of the item. @@ -15668,22 +15488,22 @@ bool QCustomPlot::registerGraph( QCPGraph* graph ) This method is called automatically in the QCPAbstractItem base class constructor. */ -bool QCustomPlot::registerItem( QCPAbstractItem* item ) +bool QCustomPlot::registerItem(QCPAbstractItem *item) { - if( mItems.contains( item ) ) + if (mItems.contains(item)) { - qDebug() << Q_FUNC_INFO << "item already added to this QCustomPlot:" << reinterpret_cast( item ); + qDebug() << Q_FUNC_INFO << "item already added to this QCustomPlot:" << reinterpret_cast(item); return false; } - if( item->parentPlot() != this ) + if (item->parentPlot() != this) { - qDebug() << Q_FUNC_INFO << "item not created with this QCustomPlot as parent:" << reinterpret_cast( item ); + qDebug() << Q_FUNC_INFO << "item not created with this QCustomPlot as parent:" << reinterpret_cast(item); return false; } - - mItems.append( item ); - if( !item->layer() ) // usually the layer is already set in the constructor of the item (via QCPLayerable constructor) - item->setLayer( currentLayer() ); + + mItems.append(item); + if (!item->layer()) // usually the layer is already set in the constructor of the item (via QCPLayerable constructor) + item->setLayer(currentLayer()); return true; } @@ -15695,8 +15515,8 @@ bool QCustomPlot::registerItem( QCPAbstractItem* item ) */ void QCustomPlot::updateLayerIndices() const { - for( int i = 0; i < mLayers.size(); ++i ) - mLayers.at( i )->mIndex = i; + for (int i=0; imIndex = i; } /*! \internal @@ -15714,13 +15534,13 @@ void QCustomPlot::updateLayerIndices() const \see layerableListAt, layoutElementAt, axisRectAt */ -QCPLayerable* QCustomPlot::layerableAt( const QPointF& pos, bool onlySelectable, QVariant* selectionDetails ) const +QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails) const { QList details; - QList candidates = layerableListAt( pos, onlySelectable, selectionDetails ? &details : 0 ); - if( selectionDetails && !details.isEmpty() ) + QList candidates = layerableListAt(pos, onlySelectable, selectionDetails ? &details : 0); + if (selectionDetails && !details.isEmpty()) *selectionDetails = details.first(); - if( !candidates.isEmpty() ) + if (!candidates.isEmpty()) return candidates.first(); else return 0; @@ -15744,23 +15564,23 @@ QCPLayerable* QCustomPlot::layerableAt( const QPointF& pos, bool onlySelectable, \see layerableAt, layoutElementAt, axisRectAt */ -QList QCustomPlot::layerableListAt( const QPointF& pos, bool onlySelectable, QList* selectionDetails ) const +QList QCustomPlot::layerableListAt(const QPointF &pos, bool onlySelectable, QList *selectionDetails) const { QList result; - for( int layerIndex = mLayers.size() - 1; layerIndex >= 0; --layerIndex ) + for (int layerIndex=mLayers.size()-1; layerIndex>=0; --layerIndex) { - const QList layerables = mLayers.at( layerIndex )->children(); - for( int i = layerables.size() - 1; i >= 0; --i ) + const QList layerables = mLayers.at(layerIndex)->children(); + for (int i=layerables.size()-1; i>=0; --i) { - if( !layerables.at( i )->realVisibility() ) + if (!layerables.at(i)->realVisibility()) continue; QVariant details; - double dist = layerables.at( i )->selectTest( pos, onlySelectable, selectionDetails ? &details : 0 ); - if( dist >= 0 && dist < selectionTolerance() ) + double dist = layerables.at(i)->selectTest(pos, onlySelectable, selectionDetails ? &details : 0); + if (dist >= 0 && dist < selectionTolerance()) { - result.append( layerables.at( i ) ); - if( selectionDetails ) - selectionDetails->append( details ); + result.append(layerables.at(i)); + if (selectionDetails) + selectionDetails->append(details); } } } @@ -15785,27 +15605,21 @@ QList QCustomPlot::layerableListAt( const QPointF& pos, bool only \see saveBmp, saveJpg, savePng, savePdf */ -bool QCustomPlot::saveRastered( const QString& fileName, int width, int height, double scale, const char* format, int quality, int resolution, QCP::ResolutionUnit resolutionUnit ) +bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality, int resolution, QCP::ResolutionUnit resolutionUnit) { - QImage buffer = toPixmap( width, height, scale ).toImage(); - + QImage buffer = toPixmap(width, height, scale).toImage(); + int dotsPerMeter = 0; - switch( resolutionUnit ) + switch (resolutionUnit) { - case QCP::ruDotsPerMeter: - dotsPerMeter = resolution; - break; - case QCP::ruDotsPerCentimeter: - dotsPerMeter = resolution * 100; - break; - case QCP::ruDotsPerInch: - dotsPerMeter = resolution / 0.0254; - break; + case QCP::ruDotsPerMeter: dotsPerMeter = resolution; break; + case QCP::ruDotsPerCentimeter: dotsPerMeter = resolution*100; break; + case QCP::ruDotsPerInch: dotsPerMeter = resolution/0.0254; break; } - buffer.setDotsPerMeterX( dotsPerMeter ); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools - buffer.setDotsPerMeterY( dotsPerMeter ); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools - if( !buffer.isNull() ) - return buffer.save( fileName, format, quality ); + buffer.setDotsPerMeterX(dotsPerMeter); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools + buffer.setDotsPerMeterY(dotsPerMeter); // this is saved together with some image formats, e.g. PNG, and is relevant when opening image in other tools + if (!buffer.isNull()) + return buffer.save(fileName, format, quality); else return false; } @@ -15818,45 +15632,43 @@ bool QCustomPlot::saveRastered( const QString& fileName, int width, int height, \see toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf */ -QPixmap QCustomPlot::toPixmap( int width, int height, double scale ) +QPixmap QCustomPlot::toPixmap(int width, int height, double scale) { // this method is somewhat similar to toPainter. Change something here, and a change in toPainter might be necessary, too. int newWidth, newHeight; - if( width == 0 || height == 0 ) + if (width == 0 || height == 0) { newWidth = this->width(); newHeight = this->height(); - } - else + } else { newWidth = width; newHeight = height; } - int scaledWidth = qRound( scale * newWidth ); - int scaledHeight = qRound( scale * newHeight ); + int scaledWidth = qRound(scale*newWidth); + int scaledHeight = qRound(scale*newHeight); - QPixmap result( scaledWidth, scaledHeight ); - result.fill( mBackgroundBrush.style() == Qt::SolidPattern ? mBackgroundBrush.color() : Qt::transparent ); // if using non-solid pattern, make transparent now and draw brush pattern later + QPixmap result(scaledWidth, scaledHeight); + result.fill(mBackgroundBrush.style() == Qt::SolidPattern ? mBackgroundBrush.color() : Qt::transparent); // if using non-solid pattern, make transparent now and draw brush pattern later QCPPainter painter; - painter.begin( &result ); - if( painter.isActive() ) + painter.begin(&result); + if (painter.isActive()) { QRect oldViewport = viewport(); - setViewport( QRect( 0, 0, newWidth, newHeight ) ); - painter.setMode( QCPPainter::pmNoCaching ); - if( !qFuzzyCompare( scale, 1.0 ) ) + setViewport(QRect(0, 0, newWidth, newHeight)); + painter.setMode(QCPPainter::pmNoCaching); + if (!qFuzzyCompare(scale, 1.0)) { - if( scale > 1.0 ) // for scale < 1 we always want cosmetic pens where possible, because else lines might disappear for very small scales - painter.setMode( QCPPainter::pmNonCosmetic ); - painter.scale( scale, scale ); + if (scale > 1.0) // for scale < 1 we always want cosmetic pens where possible, because else lines might disappear for very small scales + painter.setMode(QCPPainter::pmNonCosmetic); + painter.scale(scale, scale); } - if( mBackgroundBrush.style() != Qt::SolidPattern && mBackgroundBrush.style() != Qt::NoBrush ) // solid fills were done a few lines above with QPixmap::fill - painter.fillRect( mViewport, mBackgroundBrush ); - draw( &painter ); - setViewport( oldViewport ); + if (mBackgroundBrush.style() != Qt::SolidPattern && mBackgroundBrush.style() != Qt::NoBrush) // solid fills were done a few lines above with QPixmap::fill + painter.fillRect(mViewport, mBackgroundBrush); + draw(&painter); + setViewport(oldViewport); painter.end(); - } - else // might happen if pixmap has width or height zero + } else // might happen if pixmap has width or height zero { qDebug() << Q_FUNC_INFO << "Couldn't activate painter on pixmap"; return QPixmap(); @@ -15876,32 +15688,30 @@ QPixmap QCustomPlot::toPixmap( int width, int height, double scale ) \see toPixmap */ -void QCustomPlot::toPainter( QCPPainter* painter, int width, int height ) +void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) { // this method is somewhat similar to toPixmap. Change something here, and a change in toPixmap might be necessary, too. int newWidth, newHeight; - if( width == 0 || height == 0 ) + if (width == 0 || height == 0) { newWidth = this->width(); newHeight = this->height(); - } - else + } else { newWidth = width; newHeight = height; } - if( painter->isActive() ) + if (painter->isActive()) { QRect oldViewport = viewport(); - setViewport( QRect( 0, 0, newWidth, newHeight ) ); - painter->setMode( QCPPainter::pmNoCaching ); - if( mBackgroundBrush.style() != Qt::NoBrush ) // unlike in toPixmap, we can't do QPixmap::fill for Qt::SolidPattern brush style, so we also draw solid fills with fillRect here - painter->fillRect( mViewport, mBackgroundBrush ); - draw( painter ); - setViewport( oldViewport ); - } - else + setViewport(QRect(0, 0, newWidth, newHeight)); + painter->setMode(QCPPainter::pmNoCaching); + if (mBackgroundBrush.style() != Qt::NoBrush) // unlike in toPixmap, we can't do QPixmap::fill for Qt::SolidPattern brush style, so we also draw solid fills with fillRect here + painter->fillRect(mViewport, mBackgroundBrush); + draw(painter); + setViewport(oldViewport); + } else qDebug() << Q_FUNC_INFO << "Passed painter is not active"; } /* end of 'src/core.cpp' */ @@ -15911,6 +15721,7 @@ void QCustomPlot::toPainter( QCPPainter* painter, int width, int height ) /* including file 'src/colorgradient.cpp', size 24646 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPColorGradient //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -15949,10 +15760,13 @@ void QCustomPlot::toPainter( QCPPainter* painter, int width, int height ) The color level count is initialized to 350. */ -QCPColorGradient::QCPColorGradient() - : mLevelCount( 350 ), mColorInterpolation( ciRGB ), mPeriodic( false ), mColorBufferInvalidated( true ) +QCPColorGradient::QCPColorGradient() : + mLevelCount(350), + mColorInterpolation(ciRGB), + mPeriodic(false), + mColorBufferInvalidated(true) { - mColorBuffer.fill( qRgb( 0, 0, 0 ), mLevelCount ); + mColorBuffer.fill(qRgb(0, 0, 0), mLevelCount); } /*! @@ -15961,20 +15775,23 @@ QCPColorGradient::QCPColorGradient() The color level count is initialized to 350. */ -QCPColorGradient::QCPColorGradient( GradientPreset preset ) - : mLevelCount( 350 ), mColorInterpolation( ciRGB ), mPeriodic( false ), mColorBufferInvalidated( true ) +QCPColorGradient::QCPColorGradient(GradientPreset preset) : + mLevelCount(350), + mColorInterpolation(ciRGB), + mPeriodic(false), + mColorBufferInvalidated(true) { - mColorBuffer.fill( qRgb( 0, 0, 0 ), mLevelCount ); - loadPreset( preset ); + mColorBuffer.fill(qRgb(0, 0, 0), mLevelCount); + loadPreset(preset); } /* undocumented operator */ -bool QCPColorGradient::operator==( const QCPColorGradient& other ) const +bool QCPColorGradient::operator==(const QCPColorGradient &other) const { - return ( ( other.mLevelCount == this->mLevelCount ) && - ( other.mColorInterpolation == this->mColorInterpolation ) && - ( other.mPeriodic == this->mPeriodic ) && - ( other.mColorStops == this->mColorStops ) ); + return ((other.mLevelCount == this->mLevelCount) && + (other.mColorInterpolation == this->mColorInterpolation) && + (other.mPeriodic == this->mPeriodic) && + (other.mColorStops == this->mColorStops)); } /*! @@ -15983,14 +15800,14 @@ bool QCPColorGradient::operator==( const QCPColorGradient& other ) const \image html QCPColorGradient-levelcount.png */ -void QCPColorGradient::setLevelCount( int n ) +void QCPColorGradient::setLevelCount(int n) { - if( n < 2 ) + if (n < 2) { qDebug() << Q_FUNC_INFO << "n must be greater or equal 2 but was" << n; n = 2; } - if( n != mLevelCount ) + if (n != mLevelCount) { mLevelCount = n; mColorBufferInvalidated = true; @@ -16008,7 +15825,7 @@ void QCPColorGradient::setLevelCount( int n ) \see clearColorStops */ -void QCPColorGradient::setColorStops( const QMap& colorStops ) +void QCPColorGradient::setColorStops(const QMap &colorStops) { mColorStops = colorStops; mColorBufferInvalidated = true; @@ -16020,9 +15837,9 @@ void QCPColorGradient::setColorStops( const QMap& colorStops ) \see setColorStops, clearColorStops */ -void QCPColorGradient::setColorStopAt( double position, const QColor& color ) +void QCPColorGradient::setColorStopAt(double position, const QColor &color) { - mColorStops.insert( position, color ); + mColorStops.insert(position, color); mColorBufferInvalidated = true; } @@ -16033,9 +15850,9 @@ void QCPColorGradient::setColorStopAt( double position, const QColor& color ) For example, a sweep in RGB space from red to green will have a muddy brown intermediate color, whereas in HSV space the intermediate color is yellow. */ -void QCPColorGradient::setColorInterpolation( QCPColorGradient::ColorInterpolation interpolation ) +void QCPColorGradient::setColorInterpolation(QCPColorGradient::ColorInterpolation interpolation) { - if( interpolation != mColorInterpolation ) + if (interpolation != mColorInterpolation) { mColorInterpolation = interpolation; mColorBufferInvalidated = true; @@ -16057,7 +15874,7 @@ void QCPColorGradient::setColorInterpolation( QCPColorGradient::ColorInterpolati dimension, such as an angle or a phase. If this is not the case, the color encoding might become ambiguous, because multiple different data values are shown as the same color. */ -void QCPColorGradient::setPeriodic( bool enabled ) +void QCPColorGradient::setPeriodic(bool enabled) { mPeriodic = enabled; } @@ -16080,70 +15897,67 @@ void QCPColorGradient::setPeriodic( bool enabled ) The QRgb values that are placed in \a scanLine have their r, g and b components premultiplied with alpha (see QImage::Format_ARGB32_Premultiplied). */ -void QCPColorGradient::colorize( const double* data, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor, bool logarithmic ) +void QCPColorGradient::colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor, bool logarithmic) { // If you change something here, make sure to also adapt color() and the other colorize() overload - if( !data ) + if (!data) { qDebug() << Q_FUNC_INFO << "null pointer given as data"; return; } - if( !scanLine ) + if (!scanLine) { qDebug() << Q_FUNC_INFO << "null pointer given as scanLine"; return; } - if( mColorBufferInvalidated ) + if (mColorBufferInvalidated) updateColorBuffer(); - - if( !logarithmic ) + + if (!logarithmic) { - const double posToIndexFactor = ( mLevelCount - 1 ) / range.size(); - if( mPeriodic ) + const double posToIndexFactor = (mLevelCount-1)/range.size(); + if (mPeriodic) { - for( int i = 0; i < n; ++i ) + for (int i=0; i= mLevelCount ) - index = mLevelCount - 1; - scanLine[i] = mColorBuffer.at( index ); + else if (index >= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); } } - } - else // logarithmic == true + } else // logarithmic == true { - if( mPeriodic ) + if (mPeriodic) { - for( int i = 0; i < n; ++i ) + for (int i=0; i= mLevelCount ) - index = mLevelCount - 1; - scanLine[i] = mColorBuffer.at( index ); + else if (index >= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); } } } @@ -16157,110 +15971,103 @@ void QCPColorGradient::colorize( const double* data, const QCPRange& range, QRgb The QRgb values that are placed in \a scanLine have their r, g and b components premultiplied with alpha (see QImage::Format_ARGB32_Premultiplied). */ -void QCPColorGradient::colorize( const double* data, const unsigned char* alpha, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor, bool logarithmic ) +void QCPColorGradient::colorize(const double *data, const unsigned char *alpha, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor, bool logarithmic) { // If you change something here, make sure to also adapt color() and the other colorize() overload - if( !data ) + if (!data) { qDebug() << Q_FUNC_INFO << "null pointer given as data"; return; } - if( !alpha ) + if (!alpha) { qDebug() << Q_FUNC_INFO << "null pointer given as alpha"; return; } - if( !scanLine ) + if (!scanLine) { qDebug() << Q_FUNC_INFO << "null pointer given as scanLine"; return; } - if( mColorBufferInvalidated ) + if (mColorBufferInvalidated) updateColorBuffer(); - - if( !logarithmic ) + + if (!logarithmic) { - const double posToIndexFactor = ( mLevelCount - 1 ) / range.size(); - if( mPeriodic ) + const double posToIndexFactor = (mLevelCount-1)/range.size(); + if (mPeriodic) { - for( int i = 0; i < n; ++i ) + for (int i=0; i= mLevelCount ) - index = mLevelCount - 1; - if( alpha[dataIndexFactor * i] == 255 ) + else if (index >= mLevelCount) + index = mLevelCount-1; + if (alpha[dataIndexFactor*i] == 255) { - scanLine[i] = mColorBuffer.at( index ); - } - else + scanLine[i] = mColorBuffer.at(index); + } else { - const QRgb rgb = mColorBuffer.at( index ); - const float alphaF = alpha[dataIndexFactor * i] / 255.0f; - scanLine[i] = qRgba( qRed( rgb ) * alphaF, qGreen( rgb ) * alphaF, qBlue( rgb ) * alphaF, qAlpha( rgb ) * alphaF ); + const QRgb rgb = mColorBuffer.at(index); + const float alphaF = alpha[dataIndexFactor*i]/255.0f; + scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF); } } } - } - else // logarithmic == true + } else // logarithmic == true { - if( mPeriodic ) + if (mPeriodic) { - for( int i = 0; i < n; ++i ) + for (int i=0; i= mLevelCount ) - index = mLevelCount - 1; - if( alpha[dataIndexFactor * i] == 255 ) + else if (index >= mLevelCount) + index = mLevelCount-1; + if (alpha[dataIndexFactor*i] == 255) { - scanLine[i] = mColorBuffer.at( index ); - } - else + scanLine[i] = mColorBuffer.at(index); + } else { - const QRgb rgb = mColorBuffer.at( index ); - const float alphaF = alpha[dataIndexFactor * i] / 255.0f; - scanLine[i] = qRgba( qRed( rgb ) * alphaF, qGreen( rgb ) * alphaF, qBlue( rgb ) * alphaF, qAlpha( rgb ) * alphaF ); + const QRgb rgb = mColorBuffer.at(index); + const float alphaF = alpha[dataIndexFactor*i]/255.0f; + scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF); } } } @@ -16279,30 +16086,29 @@ void QCPColorGradient::colorize( const double* data, const unsigned char* alpha, The returned QRgb has its r, g and b components premultiplied with alpha (see QImage::Format_ARGB32_Premultiplied). */ -QRgb QCPColorGradient::color( double position, const QCPRange& range, bool logarithmic ) +QRgb QCPColorGradient::color(double position, const QCPRange &range, bool logarithmic) { // If you change something here, make sure to also adapt ::colorize() - if( mColorBufferInvalidated ) + if (mColorBufferInvalidated) updateColorBuffer(); int index = 0; - if( !logarithmic ) - index = ( position - range.lower ) * ( mLevelCount - 1 ) / range.size(); + if (!logarithmic) + index = (position-range.lower)*(mLevelCount-1)/range.size(); else - index = qLn( position / range.lower ) / qLn( range.upper / range.lower ) * ( mLevelCount - 1 ); - if( mPeriodic ) + index = qLn(position/range.lower)/qLn(range.upper/range.lower)*(mLevelCount-1); + if (mPeriodic) { index = index % mLevelCount; - if( index < 0 ) + if (index < 0) index += mLevelCount; - } - else + } else { - if( index < 0 ) + if (index < 0) index = 0; - else if( index >= mLevelCount ) - index = mLevelCount - 1; + else if (index >= mLevelCount) + index = mLevelCount-1; } - return mColorBuffer.at( index ); + return mColorBuffer.at(index); } /*! @@ -16312,107 +16118,107 @@ QRgb QCPColorGradient::color( double position, const QCPRange& range, bool logar The available presets are: \image html QCPColorGradient.png */ -void QCPColorGradient::loadPreset( GradientPreset preset ) +void QCPColorGradient::loadPreset(GradientPreset preset) { clearColorStops(); - switch( preset ) + switch (preset) { - case gpGrayscale: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, Qt::black ); - setColorStopAt( 1, Qt::white ); - break; - case gpHot: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 50, 0, 0 ) ); - setColorStopAt( 0.2, QColor( 180, 10, 0 ) ); - setColorStopAt( 0.4, QColor( 245, 50, 0 ) ); - setColorStopAt( 0.6, QColor( 255, 150, 10 ) ); - setColorStopAt( 0.8, QColor( 255, 255, 50 ) ); - setColorStopAt( 1, QColor( 255, 255, 255 ) ); - break; - case gpCold: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 0, 0, 50 ) ); - setColorStopAt( 0.2, QColor( 0, 10, 180 ) ); - setColorStopAt( 0.4, QColor( 0, 50, 245 ) ); - setColorStopAt( 0.6, QColor( 10, 150, 255 ) ); - setColorStopAt( 0.8, QColor( 50, 255, 255 ) ); - setColorStopAt( 1, QColor( 255, 255, 255 ) ); - break; - case gpNight: - setColorInterpolation( ciHSV ); - setColorStopAt( 0, QColor( 10, 20, 30 ) ); - setColorStopAt( 1, QColor( 250, 255, 250 ) ); - break; - case gpCandy: - setColorInterpolation( ciHSV ); - setColorStopAt( 0, QColor( 0, 0, 255 ) ); - setColorStopAt( 1, QColor( 255, 250, 250 ) ); - break; - case gpGeography: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 70, 170, 210 ) ); - setColorStopAt( 0.20, QColor( 90, 160, 180 ) ); - setColorStopAt( 0.25, QColor( 45, 130, 175 ) ); - setColorStopAt( 0.30, QColor( 100, 140, 125 ) ); - setColorStopAt( 0.5, QColor( 100, 140, 100 ) ); - setColorStopAt( 0.6, QColor( 130, 145, 120 ) ); - setColorStopAt( 0.7, QColor( 140, 130, 120 ) ); - setColorStopAt( 0.9, QColor( 180, 190, 190 ) ); - setColorStopAt( 1, QColor( 210, 210, 230 ) ); - break; - case gpIon: - setColorInterpolation( ciHSV ); - setColorStopAt( 0, QColor( 50, 10, 10 ) ); - setColorStopAt( 0.45, QColor( 0, 0, 255 ) ); - setColorStopAt( 0.8, QColor( 0, 255, 255 ) ); - setColorStopAt( 1, QColor( 0, 255, 0 ) ); - break; - case gpThermal: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 0, 0, 50 ) ); - setColorStopAt( 0.15, QColor( 20, 0, 120 ) ); - setColorStopAt( 0.33, QColor( 200, 30, 140 ) ); - setColorStopAt( 0.6, QColor( 255, 100, 0 ) ); - setColorStopAt( 0.85, QColor( 255, 255, 40 ) ); - setColorStopAt( 1, QColor( 255, 255, 255 ) ); - break; - case gpPolar: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 50, 255, 255 ) ); - setColorStopAt( 0.18, QColor( 10, 70, 255 ) ); - setColorStopAt( 0.28, QColor( 10, 10, 190 ) ); - setColorStopAt( 0.5, QColor( 0, 0, 0 ) ); - setColorStopAt( 0.72, QColor( 190, 10, 10 ) ); - setColorStopAt( 0.82, QColor( 255, 70, 10 ) ); - setColorStopAt( 1, QColor( 255, 255, 50 ) ); - break; - case gpSpectrum: - setColorInterpolation( ciHSV ); - setColorStopAt( 0, QColor( 50, 0, 50 ) ); - setColorStopAt( 0.15, QColor( 0, 0, 255 ) ); - setColorStopAt( 0.35, QColor( 0, 255, 255 ) ); - setColorStopAt( 0.6, QColor( 255, 255, 0 ) ); - setColorStopAt( 0.75, QColor( 255, 30, 0 ) ); - setColorStopAt( 1, QColor( 50, 0, 0 ) ); - break; - case gpJet: - setColorInterpolation( ciRGB ); - setColorStopAt( 0, QColor( 0, 0, 100 ) ); - setColorStopAt( 0.15, QColor( 0, 50, 255 ) ); - setColorStopAt( 0.35, QColor( 0, 255, 255 ) ); - setColorStopAt( 0.65, QColor( 255, 255, 0 ) ); - setColorStopAt( 0.85, QColor( 255, 30, 0 ) ); - setColorStopAt( 1, QColor( 100, 0, 0 ) ); - break; - case gpHues: - setColorInterpolation( ciHSV ); - setColorStopAt( 0, QColor( 255, 0, 0 ) ); - setColorStopAt( 1.0 / 3.0, QColor( 0, 0, 255 ) ); - setColorStopAt( 2.0 / 3.0, QColor( 0, 255, 0 ) ); - setColorStopAt( 1, QColor( 255, 0, 0 ) ); - break; + case gpGrayscale: + setColorInterpolation(ciRGB); + setColorStopAt(0, Qt::black); + setColorStopAt(1, Qt::white); + break; + case gpHot: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 0, 0)); + setColorStopAt(0.2, QColor(180, 10, 0)); + setColorStopAt(0.4, QColor(245, 50, 0)); + setColorStopAt(0.6, QColor(255, 150, 10)); + setColorStopAt(0.8, QColor(255, 255, 50)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpCold: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.2, QColor(0, 10, 180)); + setColorStopAt(0.4, QColor(0, 50, 245)); + setColorStopAt(0.6, QColor(10, 150, 255)); + setColorStopAt(0.8, QColor(50, 255, 255)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpNight: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(10, 20, 30)); + setColorStopAt(1, QColor(250, 255, 250)); + break; + case gpCandy: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(0, 0, 255)); + setColorStopAt(1, QColor(255, 250, 250)); + break; + case gpGeography: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(70, 170, 210)); + setColorStopAt(0.20, QColor(90, 160, 180)); + setColorStopAt(0.25, QColor(45, 130, 175)); + setColorStopAt(0.30, QColor(100, 140, 125)); + setColorStopAt(0.5, QColor(100, 140, 100)); + setColorStopAt(0.6, QColor(130, 145, 120)); + setColorStopAt(0.7, QColor(140, 130, 120)); + setColorStopAt(0.9, QColor(180, 190, 190)); + setColorStopAt(1, QColor(210, 210, 230)); + break; + case gpIon: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 10, 10)); + setColorStopAt(0.45, QColor(0, 0, 255)); + setColorStopAt(0.8, QColor(0, 255, 255)); + setColorStopAt(1, QColor(0, 255, 0)); + break; + case gpThermal: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.15, QColor(20, 0, 120)); + setColorStopAt(0.33, QColor(200, 30, 140)); + setColorStopAt(0.6, QColor(255, 100, 0)); + setColorStopAt(0.85, QColor(255, 255, 40)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpPolar: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 255, 255)); + setColorStopAt(0.18, QColor(10, 70, 255)); + setColorStopAt(0.28, QColor(10, 10, 190)); + setColorStopAt(0.5, QColor(0, 0, 0)); + setColorStopAt(0.72, QColor(190, 10, 10)); + setColorStopAt(0.82, QColor(255, 70, 10)); + setColorStopAt(1, QColor(255, 255, 50)); + break; + case gpSpectrum: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 0, 50)); + setColorStopAt(0.15, QColor(0, 0, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.6, QColor(255, 255, 0)); + setColorStopAt(0.75, QColor(255, 30, 0)); + setColorStopAt(1, QColor(50, 0, 0)); + break; + case gpJet: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 100)); + setColorStopAt(0.15, QColor(0, 50, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.65, QColor(255, 255, 0)); + setColorStopAt(0.85, QColor(255, 30, 0)); + setColorStopAt(1, QColor(100, 0, 0)); + break; + case gpHues: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(255, 0, 0)); + setColorStopAt(1.0/3.0, QColor(0, 0, 255)); + setColorStopAt(2.0/3.0, QColor(0, 255, 0)); + setColorStopAt(1, QColor(255, 0, 0)); + break; } } @@ -16435,10 +16241,10 @@ void QCPColorGradient::clearColorStops() */ QCPColorGradient QCPColorGradient::inverted() const { - QCPColorGradient result( *this ); + QCPColorGradient result(*this); result.clearColorStops(); - for( QMap::const_iterator it = mColorStops.constBegin(); it != mColorStops.constEnd(); ++it ) - result.setColorStopAt( 1.0 - it.key(), it.value() ); + for (QMap::const_iterator it=mColorStops.constBegin(); it!=mColorStops.constEnd(); ++it) + result.setColorStopAt(1.0-it.key(), it.value()); return result; } @@ -16449,9 +16255,9 @@ QCPColorGradient QCPColorGradient::inverted() const */ bool QCPColorGradient::stopsUseAlpha() const { - for( QMap::const_iterator it = mColorStops.constBegin(); it != mColorStops.constEnd(); ++it ) + for (QMap::const_iterator it=mColorStops.constBegin(); it!=mColorStops.constEnd(); ++it) { - if( it.value().alpha() < 255 ) + if (it.value().alpha() < 255) return true; } return false; @@ -16464,102 +16270,94 @@ bool QCPColorGradient::stopsUseAlpha() const */ void QCPColorGradient::updateColorBuffer() { - if( mColorBuffer.size() != mLevelCount ) - mColorBuffer.resize( mLevelCount ); - if( mColorStops.size() > 1 ) + if (mColorBuffer.size() != mLevelCount) + mColorBuffer.resize(mLevelCount); + if (mColorStops.size() > 1) { - double indexToPosFactor = 1.0 / (double)( mLevelCount - 1 ); + double indexToPosFactor = 1.0/(double)(mLevelCount-1); const bool useAlpha = stopsUseAlpha(); - for( int i = 0; i < mLevelCount; ++i ) + for (int i=0; i::const_iterator it = mColorStops.lowerBound( position ); - if( it == mColorStops.constEnd() ) // position is on or after last stop, use color of last stop + double position = i*indexToPosFactor; + QMap::const_iterator it = mColorStops.lowerBound(position); + if (it == mColorStops.constEnd()) // position is on or after last stop, use color of last stop { - mColorBuffer[i] = ( it - 1 ).value().rgba(); - } - else if( it == mColorStops.constBegin() ) // position is on or before first stop, use color of first stop + mColorBuffer[i] = (it-1).value().rgba(); + } else if (it == mColorStops.constBegin()) // position is on or before first stop, use color of first stop { mColorBuffer[i] = it.value().rgba(); - } - else // position is in between stops (or on an intermediate stop), interpolate color + } else // position is in between stops (or on an intermediate stop), interpolate color { QMap::const_iterator high = it; - QMap::const_iterator low = it - 1; - double t = ( position - low.key() ) / ( high.key() - low.key() ); // interpolation factor 0..1 - switch( mColorInterpolation ) + QMap::const_iterator low = it-1; + double t = (position-low.key())/(high.key()-low.key()); // interpolation factor 0..1 + switch (mColorInterpolation) { - case ciRGB: - { - if( useAlpha ) + case ciRGB: { - const int alpha = ( 1 - t ) * low.value().alpha() + t * high.value().alpha(); - const float alphaPremultiplier = alpha / 255.0f; // since we use QImage::Format_ARGB32_Premultiplied - mColorBuffer[i] = qRgba( ( ( 1 - t ) * low.value().red() + t * high.value().red() ) * alphaPremultiplier, - ( ( 1 - t ) * low.value().green() + t * high.value().green() ) * alphaPremultiplier, - ( ( 1 - t ) * low.value().blue() + t * high.value().blue() ) * alphaPremultiplier, - alpha ); + if (useAlpha) + { + const int alpha = (1-t)*low.value().alpha() + t*high.value().alpha(); + const float alphaPremultiplier = alpha/255.0f; // since we use QImage::Format_ARGB32_Premultiplied + mColorBuffer[i] = qRgba(((1-t)*low.value().red() + t*high.value().red())*alphaPremultiplier, + ((1-t)*low.value().green() + t*high.value().green())*alphaPremultiplier, + ((1-t)*low.value().blue() + t*high.value().blue())*alphaPremultiplier, + alpha); + } else + { + mColorBuffer[i] = qRgb(((1-t)*low.value().red() + t*high.value().red()), + ((1-t)*low.value().green() + t*high.value().green()), + ((1-t)*low.value().blue() + t*high.value().blue())); + } + break; } - else + case ciHSV: { - mColorBuffer[i] = qRgb( ( ( 1 - t ) * low.value().red() + t * high.value().red() ), - ( ( 1 - t ) * low.value().green() + t * high.value().green() ), - ( ( 1 - t ) * low.value().blue() + t * high.value().blue() ) ); + QColor lowHsv = low.value().toHsv(); + QColor highHsv = high.value().toHsv(); + double hue = 0; + double hueDiff = highHsv.hueF()-lowHsv.hueF(); + if (hueDiff > 0.5) + hue = lowHsv.hueF() - t*(1.0-hueDiff); + else if (hueDiff < -0.5) + hue = lowHsv.hueF() + t*(1.0+hueDiff); + else + hue = lowHsv.hueF() + t*hueDiff; + if (hue < 0) hue += 1.0; + else if (hue >= 1.0) hue -= 1.0; + if (useAlpha) + { + const QRgb rgb = QColor::fromHsvF(hue, + (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(), + (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb(); + const float alpha = (1-t)*lowHsv.alphaF() + t*highHsv.alphaF(); + mColorBuffer[i] = qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha); + } + else + { + mColorBuffer[i] = QColor::fromHsvF(hue, + (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(), + (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb(); + } + break; } - break; - } - case ciHSV: - { - QColor lowHsv = low.value().toHsv(); - QColor highHsv = high.value().toHsv(); - double hue = 0; - double hueDiff = highHsv.hueF() - lowHsv.hueF(); - if( hueDiff > 0.5 ) - hue = lowHsv.hueF() - t * ( 1.0 - hueDiff ); - else if( hueDiff < -0.5 ) - hue = lowHsv.hueF() + t * ( 1.0 + hueDiff ); - else - hue = lowHsv.hueF() + t * hueDiff; - if( hue < 0 ) - hue += 1.0; - else if( hue >= 1.0 ) - hue -= 1.0; - if( useAlpha ) - { - const QRgb rgb = QColor::fromHsvF( hue, - ( 1 - t ) * lowHsv.saturationF() + t * highHsv.saturationF(), - ( 1 - t ) * lowHsv.valueF() + t * highHsv.valueF() ) - .rgb(); - const float alpha = ( 1 - t ) * lowHsv.alphaF() + t * highHsv.alphaF(); - mColorBuffer[i] = qRgba( qRed( rgb ) * alpha, qGreen( rgb ) * alpha, qBlue( rgb ) * alpha, 255 * alpha ); - } - else - { - mColorBuffer[i] = QColor::fromHsvF( hue, - ( 1 - t ) * lowHsv.saturationF() + t * highHsv.saturationF(), - ( 1 - t ) * lowHsv.valueF() + t * highHsv.valueF() ) - .rgb(); - } - break; - } } } } - } - else if( mColorStops.size() == 1 ) + } else if (mColorStops.size() == 1) { const QRgb rgb = mColorStops.constBegin().value().rgb(); const float alpha = mColorStops.constBegin().value().alphaF(); - mColorBuffer.fill( qRgba( qRed( rgb ) * alpha, qGreen( rgb ) * alpha, qBlue( rgb ) * alpha, 255 * alpha ) ); - } - else // mColorStops is empty, fill color buffer with black + mColorBuffer.fill(qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha)); + } else // mColorStops is empty, fill color buffer with black { - mColorBuffer.fill( qRgb( 0, 0, 0 ) ); + mColorBuffer.fill(qRgb(0, 0, 0)); } mColorBufferInvalidated = false; } /* end of 'src/colorgradient.cpp' */ + /* including file 'src/selectiondecorator-bracket.cpp', size 12313 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -16586,9 +16384,16 @@ void QCPColorGradient::updateColorBuffer() /*! Creates a new QCPSelectionDecoratorBracket instance with default values. */ -QCPSelectionDecoratorBracket::QCPSelectionDecoratorBracket() - : mBracketPen( QPen( Qt::black ) ), mBracketBrush( Qt::NoBrush ), mBracketWidth( 5 ), mBracketHeight( 50 ), mBracketStyle( bsSquareBracket ), mTangentToData( false ), mTangentAverage( 2 ) +QCPSelectionDecoratorBracket::QCPSelectionDecoratorBracket() : + mBracketPen(QPen(Qt::black)), + mBracketBrush(Qt::NoBrush), + mBracketWidth(5), + mBracketHeight(50), + mBracketStyle(bsSquareBracket), + mTangentToData(false), + mTangentAverage(2) { + } QCPSelectionDecoratorBracket::~QCPSelectionDecoratorBracket() @@ -16599,7 +16404,7 @@ QCPSelectionDecoratorBracket::~QCPSelectionDecoratorBracket() Sets the pen that will be used to draw the brackets at the beginning and end of each selected data segment. */ -void QCPSelectionDecoratorBracket::setBracketPen( const QPen& pen ) +void QCPSelectionDecoratorBracket::setBracketPen(const QPen &pen) { mBracketPen = pen; } @@ -16608,7 +16413,7 @@ void QCPSelectionDecoratorBracket::setBracketPen( const QPen& pen ) Sets the brush that will be used to draw the brackets at the beginning and end of each selected data segment. */ -void QCPSelectionDecoratorBracket::setBracketBrush( const QBrush& brush ) +void QCPSelectionDecoratorBracket::setBracketBrush(const QBrush &brush) { mBracketBrush = brush; } @@ -16618,7 +16423,7 @@ void QCPSelectionDecoratorBracket::setBracketBrush( const QBrush& brush ) the data, or the tangent direction of the current data slope, if \ref setTangentToData is enabled. */ -void QCPSelectionDecoratorBracket::setBracketWidth( int width ) +void QCPSelectionDecoratorBracket::setBracketWidth(int width) { mBracketWidth = width; } @@ -16628,7 +16433,7 @@ void QCPSelectionDecoratorBracket::setBracketWidth( int width ) of the data, or the tangent direction of the current data slope, if \ref setTangentToData is enabled. */ -void QCPSelectionDecoratorBracket::setBracketHeight( int height ) +void QCPSelectionDecoratorBracket::setBracketHeight(int height) { mBracketHeight = height; } @@ -16638,7 +16443,7 @@ void QCPSelectionDecoratorBracket::setBracketHeight( int height ) \see setBracketWidth, setBracketHeight */ -void QCPSelectionDecoratorBracket::setBracketStyle( QCPSelectionDecoratorBracket::BracketStyle style ) +void QCPSelectionDecoratorBracket::setBracketStyle(QCPSelectionDecoratorBracket::BracketStyle style) { mBracketStyle = style; } @@ -16650,7 +16455,7 @@ void QCPSelectionDecoratorBracket::setBracketStyle( QCPSelectionDecoratorBracket For noisy data, it might be more visually appealing to average the slope over multiple data points. This can be configured via \ref setTangentAverage. */ -void QCPSelectionDecoratorBracket::setTangentToData( bool enabled ) +void QCPSelectionDecoratorBracket::setTangentToData(bool enabled) { mTangentToData = enabled; } @@ -16663,10 +16468,10 @@ void QCPSelectionDecoratorBracket::setTangentToData( bool enabled ) taken into account. The smallest value of \a pointCount is 1, which is effectively equivalent to disabling \ref setTangentToData. */ -void QCPSelectionDecoratorBracket::setTangentAverage( int pointCount ) +void QCPSelectionDecoratorBracket::setTangentAverage(int pointCount) { mTangentAverage = pointCount; - if( mTangentAverage < 1 ) + if (mTangentAverage < 1) mTangentAverage = 1; } @@ -16683,38 +16488,38 @@ void QCPSelectionDecoratorBracket::setTangentAverage( int pointCount ) shapes (see \ref QCPSelectionDecoratorBracket::bsUserStyle), this is the method you should reimplement. */ -void QCPSelectionDecoratorBracket::drawBracket( QCPPainter* painter, int direction ) const +void QCPSelectionDecoratorBracket::drawBracket(QCPPainter *painter, int direction) const { - switch( mBracketStyle ) + switch (mBracketStyle) { - case bsSquareBracket: - { - painter->drawLine( QLineF( mBracketWidth * direction, -mBracketHeight * 0.5, 0, -mBracketHeight * 0.5 ) ); - painter->drawLine( QLineF( mBracketWidth * direction, mBracketHeight * 0.5, 0, mBracketHeight * 0.5 ) ); - painter->drawLine( QLineF( 0, -mBracketHeight * 0.5, 0, mBracketHeight * 0.5 ) ); - break; - } - case bsHalfEllipse: - { - painter->drawArc( -mBracketWidth * 0.5, -mBracketHeight * 0.5, mBracketWidth, mBracketHeight, -90 * 16, -180 * 16 * direction ); - break; - } - case bsEllipse: - { - painter->drawEllipse( -mBracketWidth * 0.5, -mBracketHeight * 0.5, mBracketWidth, mBracketHeight ); - break; - } - case bsPlus: - { - painter->drawLine( QLineF( 0, -mBracketHeight * 0.5, 0, mBracketHeight * 0.5 ) ); - painter->drawLine( QLineF( -mBracketWidth * 0.5, 0, mBracketWidth * 0.5, 0 ) ); - break; - } - default: - { - qDebug() << Q_FUNC_INFO << "unknown/custom bracket style can't be handeld by default implementation:" << static_cast( mBracketStyle ); - break; - } + case bsSquareBracket: + { + painter->drawLine(QLineF(mBracketWidth*direction, -mBracketHeight*0.5, 0, -mBracketHeight*0.5)); + painter->drawLine(QLineF(mBracketWidth*direction, mBracketHeight*0.5, 0, mBracketHeight*0.5)); + painter->drawLine(QLineF(0, -mBracketHeight*0.5, 0, mBracketHeight*0.5)); + break; + } + case bsHalfEllipse: + { + painter->drawArc(-mBracketWidth*0.5, -mBracketHeight*0.5, mBracketWidth, mBracketHeight, -90*16, -180*16*direction); + break; + } + case bsEllipse: + { + painter->drawEllipse(-mBracketWidth*0.5, -mBracketHeight*0.5, mBracketWidth, mBracketHeight); + break; + } + case bsPlus: + { + painter->drawLine(QLineF(0, -mBracketHeight*0.5, 0, mBracketHeight*0.5)); + painter->drawLine(QLineF(-mBracketWidth*0.5, 0, mBracketWidth*0.5, 0)); + break; + } + default: + { + qDebug() << Q_FUNC_INFO << "unknown/custom bracket style can't be handeld by default implementation:" << static_cast(mBracketStyle); + break; + } } } @@ -16726,42 +16531,41 @@ void QCPSelectionDecoratorBracket::drawBracket( QCPPainter* painter, int directi \seebaseclassmethod */ -void QCPSelectionDecoratorBracket::drawDecoration( QCPPainter* painter, QCPDataSelection selection ) +void QCPSelectionDecoratorBracket::drawDecoration(QCPPainter *painter, QCPDataSelection selection) { - if( !mPlottable || selection.isEmpty() ) - return; - - if( QCPPlottableInterface1D* interface1d = mPlottable->interface1D() ) + if (!mPlottable || selection.isEmpty()) return; + + if (QCPPlottableInterface1D *interface1d = mPlottable->interface1D()) { - foreach( const QCPDataRange& dataRange, selection.dataRanges() ) + foreach (const QCPDataRange &dataRange, selection.dataRanges()) { // determine position and (if tangent mode is enabled) angle of brackets: - int openBracketDir = ( mPlottable->keyAxis() && !mPlottable->keyAxis()->rangeReversed() ) ? 1 : -1; + int openBracketDir = (mPlottable->keyAxis() && !mPlottable->keyAxis()->rangeReversed()) ? 1 : -1; int closeBracketDir = -openBracketDir; - QPointF openBracketPos = getPixelCoordinates( interface1d, dataRange.begin() ); - QPointF closeBracketPos = getPixelCoordinates( interface1d, dataRange.end() - 1 ); + QPointF openBracketPos = getPixelCoordinates(interface1d, dataRange.begin()); + QPointF closeBracketPos = getPixelCoordinates(interface1d, dataRange.end()-1); double openBracketAngle = 0; double closeBracketAngle = 0; - if( mTangentToData ) + if (mTangentToData) { - openBracketAngle = getTangentAngle( interface1d, dataRange.begin(), openBracketDir ); - closeBracketAngle = getTangentAngle( interface1d, dataRange.end() - 1, closeBracketDir ); + openBracketAngle = getTangentAngle(interface1d, dataRange.begin(), openBracketDir); + closeBracketAngle = getTangentAngle(interface1d, dataRange.end()-1, closeBracketDir); } // draw opening bracket: QTransform oldTransform = painter->transform(); - painter->setPen( mBracketPen ); - painter->setBrush( mBracketBrush ); - painter->translate( openBracketPos ); - painter->rotate( openBracketAngle / M_PI * 180.0 ); - drawBracket( painter, openBracketDir ); - painter->setTransform( oldTransform ); + painter->setPen(mBracketPen); + painter->setBrush(mBracketBrush); + painter->translate(openBracketPos); + painter->rotate(openBracketAngle/M_PI*180.0); + drawBracket(painter, openBracketDir); + painter->setTransform(oldTransform); // draw closing bracket: - painter->setPen( mBracketPen ); - painter->setBrush( mBracketBrush ); - painter->translate( closeBracketPos ); - painter->rotate( closeBracketAngle / M_PI * 180.0 ); - drawBracket( painter, closeBracketDir ); - painter->setTransform( oldTransform ); + painter->setPen(mBracketPen); + painter->setBrush(mBracketBrush); + painter->translate(closeBracketPos); + painter->rotate(closeBracketAngle/M_PI*180.0); + drawBracket(painter, closeBracketDir); + painter->setTransform(oldTransform); } } } @@ -16779,46 +16583,45 @@ void QCPSelectionDecoratorBracket::drawDecoration( QCPPainter* painter, QCPDataS \a interface1d is the interface to the plottable's data which is used to query data coordinates. */ -double QCPSelectionDecoratorBracket::getTangentAngle( const QCPPlottableInterface1D* interface1d, int dataIndex, int direction ) const +double QCPSelectionDecoratorBracket::getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const { - if( !interface1d || dataIndex < 0 || dataIndex >= interface1d->dataCount() ) + if (!interface1d || dataIndex < 0 || dataIndex >= interface1d->dataCount()) return 0; - direction = direction < 0 ? -1 : 1; // enforce direction is either -1 or 1 - + direction = direction < 0 ? -1 : 1; // enforce direction is either -1 or 1 + // how many steps we can actually go from index in the given direction without exceeding data bounds: int averageCount; - if( direction < 0 ) - averageCount = qMin( mTangentAverage, dataIndex ); + if (direction < 0) + averageCount = qMin(mTangentAverage, dataIndex); else - averageCount = qMin( mTangentAverage, interface1d->dataCount() - 1 - dataIndex ); + averageCount = qMin(mTangentAverage, interface1d->dataCount()-1-dataIndex); qDebug() << averageCount; // calculate point average of averageCount points: - QVector points( averageCount ); + QVector points(averageCount); QPointF pointsAverage; int currentIndex = dataIndex; - for( int i = 0; i < averageCount; ++i ) + for (int i=0; ikeyAxis(); - QCPAxis* valueAxis = mPlottable->valueAxis(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QPointF( 0, 0 ); - } - - if( keyAxis->orientation() == Qt::Horizontal ) - return QPointF( keyAxis->coordToPixel( interface1d->dataMainKey( dataIndex ) ), valueAxis->coordToPixel( interface1d->dataMainValue( dataIndex ) ) ); + QCPAxis *keyAxis = mPlottable->keyAxis(); + QCPAxis *valueAxis = mPlottable->valueAxis(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(0, 0); } + + if (keyAxis->orientation() == Qt::Horizontal) + return QPointF(keyAxis->coordToPixel(interface1d->dataMainKey(dataIndex)), valueAxis->coordToPixel(interface1d->dataMainValue(dataIndex))); else - return QPointF( valueAxis->coordToPixel( interface1d->dataMainValue( dataIndex ) ), keyAxis->coordToPixel( interface1d->dataMainKey( dataIndex ) ) ); + return QPointF(valueAxis->coordToPixel(interface1d->dataMainValue(dataIndex)), keyAxis->coordToPixel(interface1d->dataMainKey(dataIndex))); } /* end of 'src/selectiondecorator-bracket.cpp' */ + /* including file 'src/layoutelements/layoutelement-axisrect.cpp', size 47584 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisRect //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -16976,38 +16777,47 @@ QPointF QCPSelectionDecoratorBracket::getPixelCoordinates( const QCPPlottableInt Creates a QCPAxisRect instance and sets default values. An axis is added for each of the four sides, the top and right axes are set invisible initially. */ -QCPAxisRect::QCPAxisRect( QCustomPlot* parentPlot, bool setupDefaultAxes ) - : QCPLayoutElement( parentPlot ), mBackgroundBrush( Qt::NoBrush ), mBackgroundScaled( true ), mBackgroundScaledMode( Qt::KeepAspectRatioByExpanding ), mInsetLayout( new QCPLayoutInset ), mRangeDrag( Qt::Horizontal | Qt::Vertical ), mRangeZoom( Qt::Horizontal | Qt::Vertical ), mRangeZoomFactorHorz( 0.85 ), mRangeZoomFactorVert( 0.85 ), mDragging( false ) +QCPAxisRect::QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes) : + QCPLayoutElement(parentPlot), + mBackgroundBrush(Qt::NoBrush), + mBackgroundScaled(true), + mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), + mInsetLayout(new QCPLayoutInset), + mRangeDrag(Qt::Horizontal|Qt::Vertical), + mRangeZoom(Qt::Horizontal|Qt::Vertical), + mRangeZoomFactorHorz(0.85), + mRangeZoomFactorVert(0.85), + mDragging(false) { - mInsetLayout->initializeParentPlot( mParentPlot ); - mInsetLayout->setParentLayerable( this ); - mInsetLayout->setParent( this ); - - setMinimumSize( 50, 50 ); - setMinimumMargins( QMargins( 15, 15, 15, 15 ) ); - mAxes.insert( QCPAxis::atLeft, QList() ); - mAxes.insert( QCPAxis::atRight, QList() ); - mAxes.insert( QCPAxis::atTop, QList() ); - mAxes.insert( QCPAxis::atBottom, QList() ); - - if( setupDefaultAxes ) + mInsetLayout->initializeParentPlot(mParentPlot); + mInsetLayout->setParentLayerable(this); + mInsetLayout->setParent(this); + + setMinimumSize(50, 50); + setMinimumMargins(QMargins(15, 15, 15, 15)); + mAxes.insert(QCPAxis::atLeft, QList()); + mAxes.insert(QCPAxis::atRight, QList()); + mAxes.insert(QCPAxis::atTop, QList()); + mAxes.insert(QCPAxis::atBottom, QList()); + + if (setupDefaultAxes) { - QCPAxis* xAxis = addAxis( QCPAxis::atBottom ); - QCPAxis* yAxis = addAxis( QCPAxis::atLeft ); - QCPAxis* xAxis2 = addAxis( QCPAxis::atTop ); - QCPAxis* yAxis2 = addAxis( QCPAxis::atRight ); - setRangeDragAxes( xAxis, yAxis ); - setRangeZoomAxes( xAxis, yAxis ); - xAxis2->setVisible( false ); - yAxis2->setVisible( false ); - xAxis->grid()->setVisible( true ); - yAxis->grid()->setVisible( true ); - xAxis2->grid()->setVisible( false ); - yAxis2->grid()->setVisible( false ); - xAxis2->grid()->setZeroLinePen( Qt::NoPen ); - yAxis2->grid()->setZeroLinePen( Qt::NoPen ); - xAxis2->grid()->setVisible( false ); - yAxis2->grid()->setVisible( false ); + QCPAxis *xAxis = addAxis(QCPAxis::atBottom); + QCPAxis *yAxis = addAxis(QCPAxis::atLeft); + QCPAxis *xAxis2 = addAxis(QCPAxis::atTop); + QCPAxis *yAxis2 = addAxis(QCPAxis::atRight); + setRangeDragAxes(xAxis, yAxis); + setRangeZoomAxes(xAxis, yAxis); + xAxis2->setVisible(false); + yAxis2->setVisible(false); + xAxis->grid()->setVisible(true); + yAxis->grid()->setVisible(true); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); + xAxis2->grid()->setZeroLinePen(Qt::NoPen); + yAxis2->grid()->setZeroLinePen(Qt::NoPen); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); } } @@ -17015,10 +16825,10 @@ QCPAxisRect::~QCPAxisRect() { delete mInsetLayout; mInsetLayout = 0; - + QList axesList = axes(); - for( int i = 0; i < axesList.size(); ++i ) - removeAxis( axesList.at( i ) ); + for (int i=0; i ax( mAxes.value( type ) ); - if( index >= 0 && index < ax.size() ) + QList ax(mAxes.value(type)); + if (index >= 0 && index < ax.size()) { - return ax.at( index ); - } - else + return ax.at(index); + } else { qDebug() << Q_FUNC_INFO << "Axis index out of bounds:" << index; return 0; @@ -17058,17 +16867,17 @@ QCPAxis* QCPAxisRect::axis( QCPAxis::AxisType type, int index ) const \see axis */ -QList QCPAxisRect::axes( QCPAxis::AxisTypes types ) const +QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const { QList result; - if( types.testFlag( QCPAxis::atLeft ) ) - result << mAxes.value( QCPAxis::atLeft ); - if( types.testFlag( QCPAxis::atRight ) ) - result << mAxes.value( QCPAxis::atRight ); - if( types.testFlag( QCPAxis::atTop ) ) - result << mAxes.value( QCPAxis::atTop ); - if( types.testFlag( QCPAxis::atBottom ) ) - result << mAxes.value( QCPAxis::atBottom ); + if (types.testFlag(QCPAxis::atLeft)) + result << mAxes.value(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << mAxes.value(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << mAxes.value(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << mAxes.value(QCPAxis::atBottom); return result; } @@ -17079,8 +16888,8 @@ QList QCPAxisRect::axes( QCPAxis::AxisTypes types ) const QList QCPAxisRect::axes() const { QList result; - QHashIterator > it( mAxes ); - while( it.hasNext() ) + QHashIterator > it(mAxes); + while (it.hasNext()) { it.next(); result << it.value(); @@ -17108,71 +16917,50 @@ QList QCPAxisRect::axes() const \see addAxes, setupFullAxesBox */ -QCPAxis* QCPAxisRect::addAxis( QCPAxis::AxisType type, QCPAxis* axis ) +QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type, QCPAxis *axis) { - QCPAxis* newAxis = axis; - if( !newAxis ) + QCPAxis *newAxis = axis; + if (!newAxis) { - newAxis = new QCPAxis( this, type ); - } - else // user provided existing axis instance, do some sanity checks + newAxis = new QCPAxis(this, type); + } else // user provided existing axis instance, do some sanity checks { - if( newAxis->axisType() != type ) + if (newAxis->axisType() != type) { qDebug() << Q_FUNC_INFO << "passed axis has different axis type than specified in type parameter"; return 0; } - if( newAxis->axisRect() != this ) + if (newAxis->axisRect() != this) { qDebug() << Q_FUNC_INFO << "passed axis doesn't have this axis rect as parent axis rect"; return 0; } - if( axes().contains( newAxis ) ) + if (axes().contains(newAxis)) { qDebug() << Q_FUNC_INFO << "passed axis is already owned by this axis rect"; return 0; } } - if( mAxes[type].size() > 0 ) // multiple axes on one side, add half-bar axis ending to additional axes with offset + if (mAxes[type].size() > 0) // multiple axes on one side, add half-bar axis ending to additional axes with offset { - bool invert = ( type == QCPAxis::atRight ) || ( type == QCPAxis::atBottom ); - newAxis->setLowerEnding( QCPLineEnding( QCPLineEnding::esHalfBar, 6, 10, !invert ) ); - newAxis->setUpperEnding( QCPLineEnding( QCPLineEnding::esHalfBar, 6, 10, invert ) ); + bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom); + newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert)); + newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert)); } - mAxes[type].append( newAxis ); - + mAxes[type].append(newAxis); + // reset convenience axis pointers on parent QCustomPlot if they are unset: - if( mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect( 0 ) == this ) + if (mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect(0) == this) { - switch( type ) + switch (type) { - case QCPAxis::atBottom: - { - if( !mParentPlot->xAxis ) - mParentPlot->xAxis = newAxis; - break; - } - case QCPAxis::atLeft: - { - if( !mParentPlot->yAxis ) - mParentPlot->yAxis = newAxis; - break; - } - case QCPAxis::atTop: - { - if( !mParentPlot->xAxis2 ) - mParentPlot->xAxis2 = newAxis; - break; - } - case QCPAxis::atRight: - { - if( !mParentPlot->yAxis2 ) - mParentPlot->yAxis2 = newAxis; - break; - } + case QCPAxis::atBottom: { if (!mParentPlot->xAxis) mParentPlot->xAxis = newAxis; break; } + case QCPAxis::atLeft: { if (!mParentPlot->yAxis) mParentPlot->yAxis = newAxis; break; } + case QCPAxis::atTop: { if (!mParentPlot->xAxis2) mParentPlot->xAxis2 = newAxis; break; } + case QCPAxis::atRight: { if (!mParentPlot->yAxis2) mParentPlot->yAxis2 = newAxis; break; } } } - + return newAxis; } @@ -17184,17 +16972,17 @@ QCPAxis* QCPAxisRect::addAxis( QCPAxis::AxisType type, QCPAxis* axis ) \see addAxis, setupFullAxesBox */ -QList QCPAxisRect::addAxes( QCPAxis::AxisTypes types ) +QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) { QList result; - if( types.testFlag( QCPAxis::atLeft ) ) - result << addAxis( QCPAxis::atLeft ); - if( types.testFlag( QCPAxis::atRight ) ) - result << addAxis( QCPAxis::atRight ); - if( types.testFlag( QCPAxis::atTop ) ) - result << addAxis( QCPAxis::atTop ); - if( types.testFlag( QCPAxis::atBottom ) ) - result << addAxis( QCPAxis::atBottom ); + if (types.testFlag(QCPAxis::atLeft)) + result << addAxis(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << addAxis(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << addAxis(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << addAxis(QCPAxis::atBottom); return result; } @@ -17205,25 +16993,25 @@ QList QCPAxisRect::addAxes( QCPAxis::AxisTypes types ) \see addAxis */ -bool QCPAxisRect::removeAxis( QCPAxis* axis ) +bool QCPAxisRect::removeAxis(QCPAxis *axis) { // don't access axis->axisType() to provide safety when axis is an invalid pointer, rather go through all axis containers: - QHashIterator > it( mAxes ); - while( it.hasNext() ) + QHashIterator > it(mAxes); + while (it.hasNext()) { it.next(); - if( it.value().contains( axis ) ) + if (it.value().contains(axis)) { - if( it.value().first() == axis && it.value().size() > 1 ) // if removing first axis, transfer axis offset to the new first axis (which at this point is the second axis, if it exists) - it.value()[1]->setOffset( axis->offset() ); - mAxes[it.key()].removeOne( axis ); - if( qobject_cast( parentPlot() ) ) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) - parentPlot()->axisRemoved( axis ); + if (it.value().first() == axis && it.value().size() > 1) // if removing first axis, transfer axis offset to the new first axis (which at this point is the second axis, if it exists) + it.value()[1]->setOffset(axis->offset()); + mAxes[it.key()].removeOne(axis); + if (qobject_cast(parentPlot())) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) + parentPlot()->axisRemoved(axis); delete axis; return true; } } - qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast( axis ); + qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast(axis); return false; } @@ -17235,9 +17023,9 @@ bool QCPAxisRect::removeAxis( QCPAxis* axis ) \see QCustomPlot::setSelectionRectMode */ -void QCPAxisRect::zoom( const QRectF& pixelRect ) +void QCPAxisRect::zoom(const QRectF &pixelRect) { - zoom( pixelRect, axes() ); + zoom(pixelRect, axes()); } /*! \overload @@ -17248,21 +17036,21 @@ void QCPAxisRect::zoom( const QRectF& pixelRect ) \see QCustomPlot::setSelectionRectMode */ -void QCPAxisRect::zoom( const QRectF& pixelRect, const QList& affectedAxes ) +void QCPAxisRect::zoom(const QRectF &pixelRect, const QList &affectedAxes) { - foreach( QCPAxis* axis, affectedAxes ) + foreach (QCPAxis *axis, affectedAxes) { - if( !axis ) + if (!axis) { qDebug() << Q_FUNC_INFO << "a passed axis was zero"; continue; } QCPRange pixelRange; - if( axis->orientation() == Qt::Horizontal ) - pixelRange = QCPRange( pixelRect.left(), pixelRect.right() ); + if (axis->orientation() == Qt::Horizontal) + pixelRange = QCPRange(pixelRect.left(), pixelRect.right()); else - pixelRange = QCPRange( pixelRect.top(), pixelRect.bottom() ); - axis->setRange( axis->pixelToCoord( pixelRange.lower ), axis->pixelToCoord( pixelRange.upper ) ); + pixelRange = QCPRange(pixelRect.top(), pixelRect.bottom()); + axis->setRange(axis->pixelToCoord(pixelRange.lower), axis->pixelToCoord(pixelRange.upper)); } } @@ -17285,58 +17073,58 @@ void QCPAxisRect::zoom( const QRectF& pixelRect, const QList& affected If \a connectRanges is true, the \ref QCPAxis::rangeChanged "rangeChanged" signals of the bottom and left axes are connected to the \ref QCPAxis::setRange slots of the top and right axes. */ -void QCPAxisRect::setupFullAxesBox( bool connectRanges ) +void QCPAxisRect::setupFullAxesBox(bool connectRanges) { QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; - if( axisCount( QCPAxis::atBottom ) == 0 ) - xAxis = addAxis( QCPAxis::atBottom ); + if (axisCount(QCPAxis::atBottom) == 0) + xAxis = addAxis(QCPAxis::atBottom); else - xAxis = axis( QCPAxis::atBottom ); - - if( axisCount( QCPAxis::atLeft ) == 0 ) - yAxis = addAxis( QCPAxis::atLeft ); + xAxis = axis(QCPAxis::atBottom); + + if (axisCount(QCPAxis::atLeft) == 0) + yAxis = addAxis(QCPAxis::atLeft); else - yAxis = axis( QCPAxis::atLeft ); - - if( axisCount( QCPAxis::atTop ) == 0 ) - xAxis2 = addAxis( QCPAxis::atTop ); + yAxis = axis(QCPAxis::atLeft); + + if (axisCount(QCPAxis::atTop) == 0) + xAxis2 = addAxis(QCPAxis::atTop); else - xAxis2 = axis( QCPAxis::atTop ); - - if( axisCount( QCPAxis::atRight ) == 0 ) - yAxis2 = addAxis( QCPAxis::atRight ); + xAxis2 = axis(QCPAxis::atTop); + + if (axisCount(QCPAxis::atRight) == 0) + yAxis2 = addAxis(QCPAxis::atRight); else - yAxis2 = axis( QCPAxis::atRight ); - - xAxis->setVisible( true ); - yAxis->setVisible( true ); - xAxis2->setVisible( true ); - yAxis2->setVisible( true ); - xAxis2->setTickLabels( false ); - yAxis2->setTickLabels( false ); - - xAxis2->setRange( xAxis->range() ); - xAxis2->setRangeReversed( xAxis->rangeReversed() ); - xAxis2->setScaleType( xAxis->scaleType() ); - xAxis2->setTicks( xAxis->ticks() ); - xAxis2->setNumberFormat( xAxis->numberFormat() ); - xAxis2->setNumberPrecision( xAxis->numberPrecision() ); - xAxis2->ticker()->setTickCount( xAxis->ticker()->tickCount() ); - xAxis2->ticker()->setTickOrigin( xAxis->ticker()->tickOrigin() ); - - yAxis2->setRange( yAxis->range() ); - yAxis2->setRangeReversed( yAxis->rangeReversed() ); - yAxis2->setScaleType( yAxis->scaleType() ); - yAxis2->setTicks( yAxis->ticks() ); - yAxis2->setNumberFormat( yAxis->numberFormat() ); - yAxis2->setNumberPrecision( yAxis->numberPrecision() ); - yAxis2->ticker()->setTickCount( yAxis->ticker()->tickCount() ); - yAxis2->ticker()->setTickOrigin( yAxis->ticker()->tickOrigin() ); - - if( connectRanges ) + yAxis2 = axis(QCPAxis::atRight); + + xAxis->setVisible(true); + yAxis->setVisible(true); + xAxis2->setVisible(true); + yAxis2->setVisible(true); + xAxis2->setTickLabels(false); + yAxis2->setTickLabels(false); + + xAxis2->setRange(xAxis->range()); + xAxis2->setRangeReversed(xAxis->rangeReversed()); + xAxis2->setScaleType(xAxis->scaleType()); + xAxis2->setTicks(xAxis->ticks()); + xAxis2->setNumberFormat(xAxis->numberFormat()); + xAxis2->setNumberPrecision(xAxis->numberPrecision()); + xAxis2->ticker()->setTickCount(xAxis->ticker()->tickCount()); + xAxis2->ticker()->setTickOrigin(xAxis->ticker()->tickOrigin()); + + yAxis2->setRange(yAxis->range()); + yAxis2->setRangeReversed(yAxis->rangeReversed()); + yAxis2->setScaleType(yAxis->scaleType()); + yAxis2->setTicks(yAxis->ticks()); + yAxis2->setNumberFormat(yAxis->numberFormat()); + yAxis2->setNumberPrecision(yAxis->numberPrecision()); + yAxis2->ticker()->setTickCount(yAxis->ticker()->tickCount()); + yAxis2->ticker()->setTickOrigin(yAxis->ticker()->tickOrigin()); + + if (connectRanges) { - connect( xAxis, SIGNAL( rangeChanged( QCPRange ) ), xAxis2, SLOT( setRange( QCPRange ) ) ); - connect( yAxis, SIGNAL( rangeChanged( QCPRange ) ), yAxis2, SLOT( setRange( QCPRange ) ) ); + connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); + connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange))); } } @@ -17352,10 +17140,10 @@ QList QCPAxisRect::plottables() const { // Note: don't append all QCPAxis::plottables() into a list, because we might get duplicate entries QList result; - for( int i = 0; i < mParentPlot->mPlottables.size(); ++i ) + for (int i=0; imPlottables.size(); ++i) { - if( mParentPlot->mPlottables.at( i )->keyAxis()->axisRect() == this || mParentPlot->mPlottables.at( i )->valueAxis()->axisRect() == this ) - result.append( mParentPlot->mPlottables.at( i ) ); + if (mParentPlot->mPlottables.at(i)->keyAxis()->axisRect() == this || mParentPlot->mPlottables.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mPlottables.at(i)); } return result; } @@ -17372,10 +17160,10 @@ QList QCPAxisRect::graphs() const { // Note: don't append all QCPAxis::graphs() into a list, because we might get duplicate entries QList result; - for( int i = 0; i < mParentPlot->mGraphs.size(); ++i ) + for (int i=0; imGraphs.size(); ++i) { - if( mParentPlot->mGraphs.at( i )->keyAxis()->axisRect() == this || mParentPlot->mGraphs.at( i )->valueAxis()->axisRect() == this ) - result.append( mParentPlot->mGraphs.at( i ) ); + if (mParentPlot->mGraphs.at(i)->keyAxis()->axisRect() == this || mParentPlot->mGraphs.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mGraphs.at(i)); } return result; } @@ -17390,26 +17178,26 @@ QList QCPAxisRect::graphs() const \see plottables, graphs */ -QList QCPAxisRect::items() const +QList QCPAxisRect::items() const { // Note: don't just append all QCPAxis::items() into a list, because we might get duplicate entries // and miss those items that have this axis rect as clipAxisRect. QList result; - for( int itemId = 0; itemId < mParentPlot->mItems.size(); ++itemId ) + for (int itemId=0; itemIdmItems.size(); ++itemId) { - if( mParentPlot->mItems.at( itemId )->clipAxisRect() == this ) + if (mParentPlot->mItems.at(itemId)->clipAxisRect() == this) { - result.append( mParentPlot->mItems.at( itemId ) ); + result.append(mParentPlot->mItems.at(itemId)); continue; } - QList positions = mParentPlot->mItems.at( itemId )->positions(); - for( int posId = 0; posId < positions.size(); ++posId ) + QList positions = mParentPlot->mItems.at(itemId)->positions(); + for (int posId=0; posIdaxisRect() == this || - positions.at( posId )->keyAxis()->axisRect() == this || - positions.at( posId )->valueAxis()->axisRect() == this ) + if (positions.at(posId)->axisRect() == this || + positions.at(posId)->keyAxis()->axisRect() == this || + positions.at(posId)->valueAxis()->axisRect() == this) { - result.append( mParentPlot->mItems.at( itemId ) ); + result.append(mParentPlot->mItems.at(itemId)); break; } } @@ -17427,55 +17215,54 @@ QList QCPAxisRect::items() const \seebaseclassmethod */ -void QCPAxisRect::update( UpdatePhase phase ) +void QCPAxisRect::update(UpdatePhase phase) { - QCPLayoutElement::update( phase ); - - switch( phase ) + QCPLayoutElement::update(phase); + + switch (phase) { - case upPreparation: - { - QList allAxes = axes(); - for( int i = 0; i < allAxes.size(); ++i ) - allAxes.at( i )->setupTickVectors(); - break; + case upPreparation: + { + QList allAxes = axes(); + for (int i=0; isetupTickVectors(); + break; + } + case upLayout: + { + mInsetLayout->setOuterRect(rect()); + break; + } + default: break; } - case upLayout: - { - mInsetLayout->setOuterRect( rect() ); - break; - } - default: - break; - } - + // pass update call on to inset layout (doesn't happen automatically, because QCPAxisRect doesn't derive from QCPLayout): - mInsetLayout->update( phase ); + mInsetLayout->update(phase); } /* inherits documentation from base class */ -QList QCPAxisRect::elements( bool recursive ) const +QList QCPAxisRect::elements(bool recursive) const { QList result; - if( mInsetLayout ) + if (mInsetLayout) { result << mInsetLayout; - if( recursive ) - result << mInsetLayout->elements( recursive ); + if (recursive) + result << mInsetLayout->elements(recursive); } return result; } /* inherits documentation from base class */ -void QCPAxisRect::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPAxisRect::applyDefaultAntialiasingHint(QCPPainter *painter) const { - painter->setAntialiasing( false ); + painter->setAntialiasing(false); } /* inherits documentation from base class */ -void QCPAxisRect::draw( QCPPainter* painter ) +void QCPAxisRect::draw(QCPPainter *painter) { - drawBackground( painter ); + drawBackground(painter); } /*! @@ -17493,7 +17280,7 @@ void QCPAxisRect::draw( QCPPainter* painter ) \see setBackgroundScaled, setBackgroundScaledMode, setBackground(const QBrush &brush) */ -void QCPAxisRect::setBackground( const QPixmap& pm ) +void QCPAxisRect::setBackground(const QPixmap &pm) { mBackgroundPixmap = pm; mScaledBackgroundPixmap = QPixmap(); @@ -17512,7 +17299,7 @@ void QCPAxisRect::setBackground( const QPixmap& pm ) \see setBackground(const QPixmap &pm) */ -void QCPAxisRect::setBackground( const QBrush& brush ) +void QCPAxisRect::setBackground(const QBrush &brush) { mBackgroundBrush = brush; } @@ -17524,7 +17311,7 @@ void QCPAxisRect::setBackground( const QBrush& brush ) \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode */ -void QCPAxisRect::setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatioMode mode ) +void QCPAxisRect::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) { mBackgroundPixmap = pm; mScaledBackgroundPixmap = QPixmap(); @@ -17542,7 +17329,7 @@ void QCPAxisRect::setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatio \see setBackground, setBackgroundScaledMode */ -void QCPAxisRect::setBackgroundScaled( bool scaled ) +void QCPAxisRect::setBackgroundScaled(bool scaled) { mBackgroundScaled = scaled; } @@ -17552,7 +17339,7 @@ void QCPAxisRect::setBackgroundScaled( bool scaled ) define whether and how the aspect ratio of the original pixmap passed to \ref setBackground is preserved. \see setBackground, setBackgroundScaled */ -void QCPAxisRect::setBackgroundScaledMode( Qt::AspectRatioMode mode ) +void QCPAxisRect::setBackgroundScaledMode(Qt::AspectRatioMode mode) { mBackgroundScaledMode = mode; } @@ -17563,9 +17350,9 @@ void QCPAxisRect::setBackgroundScaledMode( Qt::AspectRatioMode mode ) \see setRangeDragAxes */ -QCPAxis* QCPAxisRect::rangeDragAxis( Qt::Orientation orientation ) +QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) { - if( orientation == Qt::Horizontal ) + if (orientation == Qt::Horizontal) return mRangeDragHorzAxis.isEmpty() ? 0 : mRangeDragHorzAxis.first().data(); else return mRangeDragVertAxis.isEmpty() ? 0 : mRangeDragVertAxis.first().data(); @@ -17577,9 +17364,9 @@ QCPAxis* QCPAxisRect::rangeDragAxis( Qt::Orientation orientation ) \see setRangeZoomAxes */ -QCPAxis* QCPAxisRect::rangeZoomAxis( Qt::Orientation orientation ) +QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) { - if( orientation == Qt::Horizontal ) + if (orientation == Qt::Horizontal) return mRangeZoomHorzAxis.isEmpty() ? 0 : mRangeZoomHorzAxis.first().data(); else return mRangeZoomVertAxis.isEmpty() ? 0 : mRangeZoomVertAxis.first().data(); @@ -17590,23 +17377,22 @@ QCPAxis* QCPAxisRect::rangeZoomAxis( Qt::Orientation orientation ) \see rangeZoomAxis, setRangeZoomAxes */ -QList QCPAxisRect::rangeDragAxes( Qt::Orientation orientation ) +QList QCPAxisRect::rangeDragAxes(Qt::Orientation orientation) { QList result; - if( orientation == Qt::Horizontal ) + if (orientation == Qt::Horizontal) { - for( int i = 0; i < mRangeDragHorzAxis.size(); ++i ) + for (int i=0; i QCPAxisRect::rangeDragAxes( Qt::Orientation orientation ) \see rangeDragAxis, setRangeDragAxes */ -QList QCPAxisRect::rangeZoomAxes( Qt::Orientation orientation ) +QList QCPAxisRect::rangeZoomAxes(Qt::Orientation orientation) { QList result; - if( orientation == Qt::Horizontal ) + if (orientation == Qt::Horizontal) { - for( int i = 0; i < mRangeZoomHorzAxis.size(); ++i ) + for (int i=0; i QCPAxisRect::rangeZoomAxes( Qt::Orientation orientation ) \see setRangeZoomFactor */ -double QCPAxisRect::rangeZoomFactor( Qt::Orientation orientation ) +double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) { - return ( orientation == Qt::Horizontal ? mRangeZoomFactorHorz : mRangeZoomFactorVert ); + return (orientation == Qt::Horizontal ? mRangeZoomFactorHorz : mRangeZoomFactorVert); } /*! @@ -17665,7 +17450,7 @@ double QCPAxisRect::rangeZoomFactor( Qt::Orientation orientation ) \see setRangeZoom, setRangeDragAxes, QCustomPlot::setNoAntialiasingOnDrag */ -void QCPAxisRect::setRangeDrag( Qt::Orientations orientations ) +void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) { mRangeDrag = orientations; } @@ -17685,7 +17470,7 @@ void QCPAxisRect::setRangeDrag( Qt::Orientations orientations ) \see setRangeZoomFactor, setRangeZoomAxes, setRangeDrag */ -void QCPAxisRect::setRangeZoom( Qt::Orientations orientations ) +void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) { mRangeZoom = orientations; } @@ -17700,14 +17485,14 @@ void QCPAxisRect::setRangeZoom( Qt::Orientations orientations ) \see setRangeZoomAxes */ -void QCPAxisRect::setRangeDragAxes( QCPAxis* horizontal, QCPAxis* vertical ) +void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical) { QList horz, vert; - if( horizontal ) - horz.append( horizontal ); - if( vertical ) - vert.append( vertical ); - setRangeDragAxes( horz, vert ); + if (horizontal) + horz.append(horizontal); + if (vertical) + vert.append(vertical); + setRangeDragAxes(horz, vert); } /*! \overload @@ -17719,17 +17504,17 @@ void QCPAxisRect::setRangeDragAxes( QCPAxis* horizontal, QCPAxis* vertical ) In the unusual case that you wish to e.g. drag a vertically oriented axis with a horizontal drag motion, use the overload taking two separate lists for horizontal and vertical dragging. */ -void QCPAxisRect::setRangeDragAxes( QList axes ) +void QCPAxisRect::setRangeDragAxes(QList axes) { QList horz, vert; - foreach( QCPAxis* ax, axes ) + foreach (QCPAxis *ax, axes) { - if( ax->orientation() == Qt::Horizontal ) - horz.append( ax ); + if (ax->orientation() == Qt::Horizontal) + horz.append(ax); else - vert.append( ax ); + vert.append(ax); } - setRangeDragAxes( horz, vert ); + setRangeDragAxes(horz, vert); } /*! \overload @@ -17738,25 +17523,25 @@ void QCPAxisRect::setRangeDragAxes( QList axes ) define specifically which axis reacts to which drag orientation (irrespective of the axis orientation). */ -void QCPAxisRect::setRangeDragAxes( QList horizontal, QList vertical ) +void QCPAxisRect::setRangeDragAxes(QList horizontal, QList vertical) { mRangeDragHorzAxis.clear(); - foreach( QCPAxis* ax, horizontal ) + foreach (QCPAxis *ax, horizontal) { - QPointer axPointer( ax ); - if( !axPointer.isNull() ) - mRangeDragHorzAxis.append( axPointer ); + QPointer axPointer(ax); + if (!axPointer.isNull()) + mRangeDragHorzAxis.append(axPointer); else - qDebug() << Q_FUNC_INFO << "invalid axis passed in horizontal list:" << reinterpret_cast( ax ); + qDebug() << Q_FUNC_INFO << "invalid axis passed in horizontal list:" << reinterpret_cast(ax); } mRangeDragVertAxis.clear(); - foreach( QCPAxis* ax, vertical ) + foreach (QCPAxis *ax, vertical) { - QPointer axPointer( ax ); - if( !axPointer.isNull() ) - mRangeDragVertAxis.append( axPointer ); + QPointer axPointer(ax); + if (!axPointer.isNull()) + mRangeDragVertAxis.append(axPointer); else - qDebug() << Q_FUNC_INFO << "invalid axis passed in vertical list:" << reinterpret_cast( ax ); + qDebug() << Q_FUNC_INFO << "invalid axis passed in vertical list:" << reinterpret_cast(ax); } } @@ -17772,14 +17557,14 @@ void QCPAxisRect::setRangeDragAxes( QList horizontal, QList \see setRangeDragAxes */ -void QCPAxisRect::setRangeZoomAxes( QCPAxis* horizontal, QCPAxis* vertical ) +void QCPAxisRect::setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical) { QList horz, vert; - if( horizontal ) - horz.append( horizontal ); - if( vertical ) - vert.append( vertical ); - setRangeZoomAxes( horz, vert ); + if (horizontal) + horz.append(horizontal); + if (vertical) + vert.append(vertical); + setRangeZoomAxes(horz, vert); } /*! \overload @@ -17791,17 +17576,17 @@ void QCPAxisRect::setRangeZoomAxes( QCPAxis* horizontal, QCPAxis* vertical ) In the unusual case that you wish to e.g. zoom a vertically oriented axis with a horizontal zoom interaction, use the overload taking two separate lists for horizontal and vertical zooming. */ -void QCPAxisRect::setRangeZoomAxes( QList axes ) +void QCPAxisRect::setRangeZoomAxes(QList axes) { QList horz, vert; - foreach( QCPAxis* ax, axes ) + foreach (QCPAxis *ax, axes) { - if( ax->orientation() == Qt::Horizontal ) - horz.append( ax ); + if (ax->orientation() == Qt::Horizontal) + horz.append(ax); else - vert.append( ax ); + vert.append(ax); } - setRangeZoomAxes( horz, vert ); + setRangeZoomAxes(horz, vert); } /*! \overload @@ -17810,25 +17595,25 @@ void QCPAxisRect::setRangeZoomAxes( QList axes ) define specifically which axis reacts to which zoom orientation (irrespective of the axis orientation). */ -void QCPAxisRect::setRangeZoomAxes( QList horizontal, QList vertical ) +void QCPAxisRect::setRangeZoomAxes(QList horizontal, QList vertical) { mRangeZoomHorzAxis.clear(); - foreach( QCPAxis* ax, horizontal ) + foreach (QCPAxis *ax, horizontal) { - QPointer axPointer( ax ); - if( !axPointer.isNull() ) - mRangeZoomHorzAxis.append( axPointer ); + QPointer axPointer(ax); + if (!axPointer.isNull()) + mRangeZoomHorzAxis.append(axPointer); else - qDebug() << Q_FUNC_INFO << "invalid axis passed in horizontal list:" << reinterpret_cast( ax ); + qDebug() << Q_FUNC_INFO << "invalid axis passed in horizontal list:" << reinterpret_cast(ax); } mRangeZoomVertAxis.clear(); - foreach( QCPAxis* ax, vertical ) + foreach (QCPAxis *ax, vertical) { - QPointer axPointer( ax ); - if( !axPointer.isNull() ) - mRangeZoomVertAxis.append( axPointer ); + QPointer axPointer(ax); + if (!axPointer.isNull()) + mRangeZoomVertAxis.append(axPointer); else - qDebug() << Q_FUNC_INFO << "invalid axis passed in vertical list:" << reinterpret_cast( ax ); + qDebug() << Q_FUNC_INFO << "invalid axis passed in vertical list:" << reinterpret_cast(ax); } } @@ -17842,7 +17627,7 @@ void QCPAxisRect::setRangeZoomAxes( QList horizontal, QList will zoom in (make the currently visible range smaller). For zoom factors smaller than one, the same scrolling direction will zoom out. */ -void QCPAxisRect::setRangeZoomFactor( double horizontalFactor, double verticalFactor ) +void QCPAxisRect::setRangeZoomFactor(double horizontalFactor, double verticalFactor) { mRangeZoomFactorHorz = horizontalFactor; mRangeZoomFactorVert = verticalFactor; @@ -17852,7 +17637,7 @@ void QCPAxisRect::setRangeZoomFactor( double horizontalFactor, double verticalFa Sets both the horizontal and vertical zoom \a factor. */ -void QCPAxisRect::setRangeZoomFactor( double factor ) +void QCPAxisRect::setRangeZoomFactor(double factor) { mRangeZoomFactorHorz = factor; mRangeZoomFactorVert = factor; @@ -17876,27 +17661,26 @@ void QCPAxisRect::setRangeZoomFactor( double factor ) \see setBackground, setBackgroundScaled, setBackgroundScaledMode */ -void QCPAxisRect::drawBackground( QCPPainter* painter ) +void QCPAxisRect::drawBackground(QCPPainter *painter) { // draw background fill: - if( mBackgroundBrush != Qt::NoBrush ) - painter->fillRect( mRect, mBackgroundBrush ); - + if (mBackgroundBrush != Qt::NoBrush) + painter->fillRect(mRect, mBackgroundBrush); + // draw background pixmap (on top of fill, if brush specified): - if( !mBackgroundPixmap.isNull() ) + if (!mBackgroundPixmap.isNull()) { - if( mBackgroundScaled ) + if (mBackgroundScaled) { // check whether mScaledBackground needs to be updated: - QSize scaledSize( mBackgroundPixmap.size() ); - scaledSize.scale( mRect.size(), mBackgroundScaledMode ); - if( mScaledBackgroundPixmap.size() != scaledSize ) - mScaledBackgroundPixmap = mBackgroundPixmap.scaled( mRect.size(), mBackgroundScaledMode, Qt::SmoothTransformation ); - painter->drawPixmap( mRect.topLeft() + QPoint( 0, -1 ), mScaledBackgroundPixmap, QRect( 0, 0, mRect.width(), mRect.height() ) & mScaledBackgroundPixmap.rect() ); - } - else + QSize scaledSize(mBackgroundPixmap.size()); + scaledSize.scale(mRect.size(), mBackgroundScaledMode); + if (mScaledBackgroundPixmap.size() != scaledSize) + mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mRect.size(), mBackgroundScaledMode, Qt::SmoothTransformation); + painter->drawPixmap(mRect.topLeft()+QPoint(0, -1), mScaledBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height()) & mScaledBackgroundPixmap.rect()); + } else { - painter->drawPixmap( mRect.topLeft() + QPoint( 0, -1 ), mBackgroundPixmap, QRect( 0, 0, mRect.width(), mRect.height() ) ); + painter->drawPixmap(mRect.topLeft()+QPoint(0, -1), mBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height())); } } } @@ -17911,37 +17695,37 @@ void QCPAxisRect::drawBackground( QCPPainter* painter ) This function is called by \ref calculateAutoMargin. */ -void QCPAxisRect::updateAxesOffset( QCPAxis::AxisType type ) +void QCPAxisRect::updateAxesOffset(QCPAxis::AxisType type) { - const QList axesList = mAxes.value( type ); - if( axesList.isEmpty() ) + const QList axesList = mAxes.value(type); + if (axesList.isEmpty()) return; - - bool isFirstVisible = !axesList.first()->visible(); // if the first axis is visible, the second axis (which is where the loop starts) isn't the first visible axis, so initialize with false - for( int i = 1; i < axesList.size(); ++i ) + + bool isFirstVisible = !axesList.first()->visible(); // if the first axis is visible, the second axis (which is where the loop starts) isn't the first visible axis, so initialize with false + for (int i=1; ioffset() + axesList.at( i - 1 )->calculateMargin(); - if( axesList.at( i )->visible() ) // only add inner tick length to offset if this axis is visible and it's not the first visible one (might happen if true first axis is invisible) + int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin(); + if (axesList.at(i)->visible()) // only add inner tick length to offset if this axis is visible and it's not the first visible one (might happen if true first axis is invisible) { - if( !isFirstVisible ) - offset += axesList.at( i )->tickLengthIn(); + if (!isFirstVisible) + offset += axesList.at(i)->tickLengthIn(); isFirstVisible = false; } - axesList.at( i )->setOffset( offset ); + axesList.at(i)->setOffset(offset); } } /* inherits documentation from base class */ -int QCPAxisRect::calculateAutoMargin( QCP::MarginSide side ) +int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side) { - if( !mAutoMargins.testFlag( side ) ) + if (!mAutoMargins.testFlag(side)) qDebug() << Q_FUNC_INFO << "Called with side that isn't specified as auto margin"; - - updateAxesOffset( QCPAxis::marginSideToAxisType( side ) ); - + + updateAxesOffset(QCPAxis::marginSideToAxisType(side)); + // note: only need to look at the last (outer most) axis to determine the total margin, due to updateAxisOffset call - const QList axesList = mAxes.value( QCPAxis::marginSideToAxisType( side ) ); - if( axesList.size() > 0 ) + const QList axesList = mAxes.value(QCPAxis::marginSideToAxisType(side)); + if (axesList.size() > 0) return axesList.last()->offset() + axesList.last()->calculateMargin(); else return 0; @@ -17959,16 +17743,16 @@ int QCPAxisRect::calculateAutoMargin( QCP::MarginSide side ) */ void QCPAxisRect::layoutChanged() { - if( mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect( 0 ) == this ) + if (mParentPlot && mParentPlot->axisRectCount() > 0 && mParentPlot->axisRect(0) == this) { - if( axisCount( QCPAxis::atBottom ) > 0 && !mParentPlot->xAxis ) - mParentPlot->xAxis = axis( QCPAxis::atBottom ); - if( axisCount( QCPAxis::atLeft ) > 0 && !mParentPlot->yAxis ) - mParentPlot->yAxis = axis( QCPAxis::atLeft ); - if( axisCount( QCPAxis::atTop ) > 0 && !mParentPlot->xAxis2 ) - mParentPlot->xAxis2 = axis( QCPAxis::atTop ); - if( axisCount( QCPAxis::atRight ) > 0 && !mParentPlot->yAxis2 ) - mParentPlot->yAxis2 = axis( QCPAxis::atRight ); + if (axisCount(QCPAxis::atBottom) > 0 && !mParentPlot->xAxis) + mParentPlot->xAxis = axis(QCPAxis::atBottom); + if (axisCount(QCPAxis::atLeft) > 0 && !mParentPlot->yAxis) + mParentPlot->yAxis = axis(QCPAxis::atLeft); + if (axisCount(QCPAxis::atTop) > 0 && !mParentPlot->xAxis2) + mParentPlot->xAxis2 = axis(QCPAxis::atTop); + if (axisCount(QCPAxis::atRight) > 0 && !mParentPlot->yAxis2) + mParentPlot->yAxis2 = axis(QCPAxis::atRight); } } @@ -17983,27 +17767,27 @@ void QCPAxisRect::layoutChanged() \see mouseMoveEvent, mouseReleaseEvent */ -void QCPAxisRect::mousePressEvent( QMouseEvent* event, const QVariant& details ) +void QCPAxisRect::mousePressEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) - if( event->buttons() & Qt::LeftButton ) + Q_UNUSED(details) + if (event->buttons() & Qt::LeftButton) { mDragging = true; // initialize antialiasing backup in case we start dragging: - if( mParentPlot->noAntialiasingOnDrag() ) + if (mParentPlot->noAntialiasingOnDrag()) { mAADragBackup = mParentPlot->antialiasedElements(); mNotAADragBackup = mParentPlot->notAntialiasedElements(); } // Mouse range dragging interaction: - if( mParentPlot->interactions().testFlag( QCP::iRangeDrag ) ) + if (mParentPlot->interactions().testFlag(QCP::iRangeDrag)) { mDragStartHorzRange.clear(); - for( int i = 0; i < mRangeDragHorzAxis.size(); ++i ) - mDragStartHorzRange.append( mRangeDragHorzAxis.at( i ).isNull() ? QCPRange() : mRangeDragHorzAxis.at( i )->range() ); + for (int i=0; irange()); mDragStartVertRange.clear(); - for( int i = 0; i < mRangeDragVertAxis.size(); ++i ) - mDragStartVertRange.append( mRangeDragVertAxis.at( i ).isNull() ? QCPRange() : mRangeDragVertAxis.at( i )->range() ); + for (int i=0; irange()); } } } @@ -18015,75 +17799,75 @@ void QCPAxisRect::mousePressEvent( QMouseEvent* event, const QVariant& details ) \see mousePressEvent, mouseReleaseEvent */ -void QCPAxisRect::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPAxisRect::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) { - Q_UNUSED( startPos ) + Q_UNUSED(startPos) // Mouse range dragging interaction: - if( mDragging && mParentPlot->interactions().testFlag( QCP::iRangeDrag ) ) + if (mDragging && mParentPlot->interactions().testFlag(QCP::iRangeDrag)) { - if( mRangeDrag.testFlag( Qt::Horizontal ) ) + + if (mRangeDrag.testFlag(Qt::Horizontal)) { - for( int i = 0; i < mRangeDragHorzAxis.size(); ++i ) + for (int i=0; i= mDragStartHorzRange.size() ) + if (i >= mDragStartHorzRange.size()) break; - if( ax->mScaleType == QCPAxis::stLinear ) + if (ax->mScaleType == QCPAxis::stLinear) { - double diff = ax->pixelToCoord( startPos.x() ) - ax->pixelToCoord( event->pos().x() ); - ax->setRange( mDragStartHorzRange.at( i ).lower + diff, mDragStartHorzRange.at( i ).upper + diff ); - } - else if( ax->mScaleType == QCPAxis::stLogarithmic ) + double diff = ax->pixelToCoord(startPos.x()) - ax->pixelToCoord(event->pos().x()); + ax->setRange(mDragStartHorzRange.at(i).lower+diff, mDragStartHorzRange.at(i).upper+diff); + } else if (ax->mScaleType == QCPAxis::stLogarithmic) { - double diff = ax->pixelToCoord( startPos.x() ) / ax->pixelToCoord( event->pos().x() ); - ax->setRange( mDragStartHorzRange.at( i ).lower * diff, mDragStartHorzRange.at( i ).upper * diff ); + double diff = ax->pixelToCoord(startPos.x()) / ax->pixelToCoord(event->pos().x()); + ax->setRange(mDragStartHorzRange.at(i).lower*diff, mDragStartHorzRange.at(i).upper*diff); } } } - - if( mRangeDrag.testFlag( Qt::Vertical ) ) + + if (mRangeDrag.testFlag(Qt::Vertical)) { - for( int i = 0; i < mRangeDragVertAxis.size(); ++i ) + for (int i=0; i= mDragStartVertRange.size() ) + if (i >= mDragStartVertRange.size()) break; - if( ax->mScaleType == QCPAxis::stLinear ) + if (ax->mScaleType == QCPAxis::stLinear) { - double diff = ax->pixelToCoord( startPos.y() ) - ax->pixelToCoord( event->pos().y() ); - ax->setRange( mDragStartVertRange.at( i ).lower + diff, mDragStartVertRange.at( i ).upper + diff ); - } - else if( ax->mScaleType == QCPAxis::stLogarithmic ) + double diff = ax->pixelToCoord(startPos.y()) - ax->pixelToCoord(event->pos().y()); + ax->setRange(mDragStartVertRange.at(i).lower+diff, mDragStartVertRange.at(i).upper+diff); + } else if (ax->mScaleType == QCPAxis::stLogarithmic) { - double diff = ax->pixelToCoord( startPos.y() ) / ax->pixelToCoord( event->pos().y() ); - ax->setRange( mDragStartVertRange.at( i ).lower * diff, mDragStartVertRange.at( i ).upper * diff ); + double diff = ax->pixelToCoord(startPos.y()) / ax->pixelToCoord(event->pos().y()); + ax->setRange(mDragStartVertRange.at(i).lower*diff, mDragStartVertRange.at(i).upper*diff); } } } - - if( mRangeDrag != 0 ) // if either vertical or horizontal drag was enabled, do a replot + + if (mRangeDrag != 0) // if either vertical or horizontal drag was enabled, do a replot { - if( mParentPlot->noAntialiasingOnDrag() ) - mParentPlot->setNotAntialiasedElements( QCP::aeAll ); - mParentPlot->replot( QCustomPlot::rpQueuedReplot ); + if (mParentPlot->noAntialiasingOnDrag()) + mParentPlot->setNotAntialiasedElements(QCP::aeAll); + mParentPlot->replot(QCustomPlot::rpQueuedReplot); } + } } /* inherits documentation from base class */ -void QCPAxisRect::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPAxisRect::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) { - Q_UNUSED( event ) - Q_UNUSED( startPos ) + Q_UNUSED(event) + Q_UNUSED(startPos) mDragging = false; - if( mParentPlot->noAntialiasingOnDrag() ) + if (mParentPlot->noAntialiasingOnDrag()) { - mParentPlot->setAntialiasedElements( mAADragBackup ); - mParentPlot->setNotAntialiasedElements( mNotAADragBackup ); + mParentPlot->setAntialiasedElements(mAADragBackup); + mParentPlot->setNotAntialiasedElements(mNotAADragBackup); } } @@ -18101,31 +17885,31 @@ void QCPAxisRect::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos exponent of the range zoom factor. This takes care of the wheel direction automatically, by inverting the factor, when the wheel step is negative (f^-1 = 1/f). */ -void QCPAxisRect::wheelEvent( QWheelEvent* event ) +void QCPAxisRect::wheelEvent(QWheelEvent *event) { // Mouse range zooming interaction: - if( mParentPlot->interactions().testFlag( QCP::iRangeZoom ) ) + if (mParentPlot->interactions().testFlag(QCP::iRangeZoom)) { - if( mRangeZoom != 0 ) + if (mRangeZoom != 0) { double factor; - double wheelSteps = event->delta() / 120.0; // a single step delta is +/-120 usually - if( mRangeZoom.testFlag( Qt::Horizontal ) ) + double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually + if (mRangeZoom.testFlag(Qt::Horizontal)) { - factor = qPow( mRangeZoomFactorHorz, wheelSteps ); - for( int i = 0; i < mRangeZoomHorzAxis.size(); ++i ) + factor = qPow(mRangeZoomFactorHorz, wheelSteps); + for (int i=0; iscaleRange( factor, mRangeZoomHorzAxis.at( i )->pixelToCoord( event->pos().x() ) ); + if (!mRangeZoomHorzAxis.at(i).isNull()) + mRangeZoomHorzAxis.at(i)->scaleRange(factor, mRangeZoomHorzAxis.at(i)->pixelToCoord(event->pos().x())); } } - if( mRangeZoom.testFlag( Qt::Vertical ) ) + if (mRangeZoom.testFlag(Qt::Vertical)) { - factor = qPow( mRangeZoomFactorVert, wheelSteps ); - for( int i = 0; i < mRangeZoomVertAxis.size(); ++i ) + factor = qPow(mRangeZoomFactorVert, wheelSteps); + for (int i=0; iscaleRange( factor, mRangeZoomVertAxis.at( i )->pixelToCoord( event->pos().y() ) ); + if (!mRangeZoomVertAxis.at(i).isNull()) + mRangeZoomVertAxis.at(i)->scaleRange(factor, mRangeZoomVertAxis.at(i)->pixelToCoord(event->pos().y())); } } mParentPlot->replot(); @@ -18134,6 +17918,7 @@ void QCPAxisRect::wheelEvent( QWheelEvent* event ) } /* end of 'src/layoutelements/layoutelement-axisrect.cpp' */ + /* including file 'src/layoutelements/layoutelement-legend.cpp', size 31097 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -18179,11 +17964,18 @@ void QCPAxisRect::wheelEvent( QWheelEvent* event ) Constructs a QCPAbstractLegendItem and associates it with the QCPLegend \a parent. This does not cause the item to be added to \a parent, so \ref QCPLegend::addItem must be called separately. */ -QCPAbstractLegendItem::QCPAbstractLegendItem( QCPLegend* parent ) - : QCPLayoutElement( parent->parentPlot() ), mParentLegend( parent ), mFont( parent->font() ), mTextColor( parent->textColor() ), mSelectedFont( parent->selectedFont() ), mSelectedTextColor( parent->selectedTextColor() ), mSelectable( true ), mSelected( false ) +QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : + QCPLayoutElement(parent->parentPlot()), + mParentLegend(parent), + mFont(parent->font()), + mTextColor(parent->textColor()), + mSelectedFont(parent->selectedFont()), + mSelectedTextColor(parent->selectedTextColor()), + mSelectable(true), + mSelected(false) { - setLayer( QLatin1String( "legend" ) ); - setMargins( QMargins( 0, 0, 0, 0 ) ); + setLayer(QLatin1String("legend")); + setMargins(QMargins(0, 0, 0, 0)); } /*! @@ -18191,7 +17983,7 @@ QCPAbstractLegendItem::QCPAbstractLegendItem( QCPLegend* parent ) \see setTextColor, QCPLegend::setFont */ -void QCPAbstractLegendItem::setFont( const QFont& font ) +void QCPAbstractLegendItem::setFont(const QFont &font) { mFont = font; } @@ -18201,7 +17993,7 @@ void QCPAbstractLegendItem::setFont( const QFont& font ) \see setFont, QCPLegend::setTextColor */ -void QCPAbstractLegendItem::setTextColor( const QColor& color ) +void QCPAbstractLegendItem::setTextColor(const QColor &color) { mTextColor = color; } @@ -18212,7 +18004,7 @@ void QCPAbstractLegendItem::setTextColor( const QColor& color ) \see setFont, QCPLegend::setSelectedFont */ -void QCPAbstractLegendItem::setSelectedFont( const QFont& font ) +void QCPAbstractLegendItem::setSelectedFont(const QFont &font) { mSelectedFont = font; } @@ -18223,7 +18015,7 @@ void QCPAbstractLegendItem::setSelectedFont( const QFont& font ) \see setTextColor, QCPLegend::setSelectedTextColor */ -void QCPAbstractLegendItem::setSelectedTextColor( const QColor& color ) +void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) { mSelectedTextColor = color; } @@ -18233,12 +18025,12 @@ void QCPAbstractLegendItem::setSelectedTextColor( const QColor& color ) \see setSelectedParts, QCustomPlot::setInteractions */ -void QCPAbstractLegendItem::setSelectable( bool selectable ) +void QCPAbstractLegendItem::setSelectable(bool selectable) { - if( mSelectable != selectable ) + if (mSelectable != selectable) { mSelectable = selectable; - emit selectableChanged( mSelectable ); + emit selectableChanged(mSelectable); } } @@ -18250,34 +18042,33 @@ void QCPAbstractLegendItem::setSelectable( bool selectable ) \see setSelectableParts, QCustomPlot::setInteractions */ -void QCPAbstractLegendItem::setSelected( bool selected ) +void QCPAbstractLegendItem::setSelected(bool selected) { - if( mSelected != selected ) + if (mSelected != selected) { mSelected = selected; - emit selectionChanged( mSelected ); + emit selectionChanged(mSelected); } } /* inherits documentation from base class */ -double QCPAbstractLegendItem::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPAbstractLegendItem::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( !mParentPlot ) + Q_UNUSED(details) + if (!mParentPlot) return -1; + if (onlySelectable && (!mSelectable || !mParentLegend->selectableParts().testFlag(QCPLegend::spItems))) return -1; - if( onlySelectable && ( !mSelectable || !mParentLegend->selectableParts().testFlag( QCPLegend::spItems ) ) ) - return -1; - - if( mRect.contains( pos.toPoint() ) ) - return mParentPlot->selectionTolerance() * 0.99; + + if (mRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; else return -1; } /* inherits documentation from base class */ -void QCPAbstractLegendItem::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPAbstractLegendItem::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeLegendItems ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegendItems); } /* inherits documentation from base class */ @@ -18287,27 +18078,27 @@ QRect QCPAbstractLegendItem::clipRect() const } /* inherits documentation from base class */ -void QCPAbstractLegendItem::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPAbstractLegendItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - Q_UNUSED( details ) - if( mSelectable && mParentLegend->selectableParts().testFlag( QCPLegend::spItems ) ) + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) { bool selBefore = mSelected; - setSelected( additive ? !mSelected : true ); - if( selectionStateChanged ) + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } /* inherits documentation from base class */ -void QCPAbstractLegendItem::deselectEvent( bool* selectionStateChanged ) +void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) { - if( mSelectable && mParentLegend->selectableParts().testFlag( QCPLegend::spItems ) ) + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) { bool selBefore = mSelected; - setSelected( false ); - if( selectionStateChanged ) + setSelected(false); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } @@ -18347,10 +18138,11 @@ void QCPAbstractLegendItem::deselectEvent( bool* selectionStateChanged ) A more convenient way of adding/removing a plottable to/from the legend is via the functions \ref QCPAbstractPlottable::addToLegend and \ref QCPAbstractPlottable::removeFromLegend. */ -QCPPlottableLegendItem::QCPPlottableLegendItem( QCPLegend* parent, QCPAbstractPlottable* plottable ) - : QCPAbstractLegendItem( parent ), mPlottable( plottable ) +QCPPlottableLegendItem::QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable) : + QCPAbstractLegendItem(parent), + mPlottable(plottable) { - setAntialiased( false ); + setAntialiased(false); } /*! \internal @@ -18389,30 +18181,29 @@ QFont QCPPlottableLegendItem::getFont() const parent layout (typically a \ref QCPLegend) and the \ref minimumOuterSizeHint and \ref maximumOuterSizeHint of this legend item. */ -void QCPPlottableLegendItem::draw( QCPPainter* painter ) +void QCPPlottableLegendItem::draw(QCPPainter *painter) { - if( !mPlottable ) - return; - painter->setFont( getFont() ); - painter->setPen( QPen( getTextColor() ) ); + if (!mPlottable) return; + painter->setFont(getFont()); + painter->setPen(QPen(getTextColor())); QSizeF iconSize = mParentLegend->iconSize(); - QRectF textRect = painter->fontMetrics().boundingRect( 0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name() ); - QRectF iconRect( mRect.topLeft(), iconSize ); - int textHeight = qMax( textRect.height(), iconSize.height() ); // if text has smaller height than icon, center text vertically in icon height, else align tops - painter->drawText( mRect.x() + iconSize.width() + mParentLegend->iconTextPadding(), mRect.y(), textRect.width(), textHeight, Qt::TextDontClip, mPlottable->name() ); + QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + QRectF iconRect(mRect.topLeft(), iconSize); + int textHeight = qMax(textRect.height(), iconSize.height()); // if text has smaller height than icon, center text vertically in icon height, else align tops + painter->drawText(mRect.x()+iconSize.width()+mParentLegend->iconTextPadding(), mRect.y(), textRect.width(), textHeight, Qt::TextDontClip, mPlottable->name()); // draw icon: painter->save(); - painter->setClipRect( iconRect, Qt::IntersectClip ); - mPlottable->drawLegendIcon( painter, iconRect ); + painter->setClipRect(iconRect, Qt::IntersectClip); + mPlottable->drawLegendIcon(painter, iconRect); painter->restore(); // draw icon border: - if( getIconBorderPen().style() != Qt::NoPen ) + if (getIconBorderPen().style() != Qt::NoPen) { - painter->setPen( getIconBorderPen() ); - painter->setBrush( Qt::NoBrush ); - int halfPen = qCeil( painter->pen().widthF() * 0.5 ) + 1; - painter->setClipRect( mOuterRect.adjusted( -halfPen, -halfPen, halfPen, halfPen ) ); // extend default clip rect so thicker pens (especially during selection) are not clipped - painter->drawRect( iconRect ); + painter->setPen(getIconBorderPen()); + painter->setBrush(Qt::NoBrush); + int halfPen = qCeil(painter->pen().widthF()*0.5)+1; + painter->setClipRect(mOuterRect.adjusted(-halfPen, -halfPen, halfPen, halfPen)); // extend default clip rect so thicker pens (especially during selection) are not clipped + painter->drawRect(iconRect); } } @@ -18425,20 +18216,20 @@ void QCPPlottableLegendItem::draw( QCPPainter* painter ) */ QSize QCPPlottableLegendItem::minimumOuterSizeHint() const { - if( !mPlottable ) - return QSize(); - QSize result( 0, 0 ); + if (!mPlottable) return QSize(); + QSize result(0, 0); QRect textRect; - QFontMetrics fontMetrics( getFont() ); + QFontMetrics fontMetrics(getFont()); QSize iconSize = mParentLegend->iconSize(); - textRect = fontMetrics.boundingRect( 0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name() ); - result.setWidth( iconSize.width() + mParentLegend->iconTextPadding() + textRect.width() ); - result.setHeight( qMax( textRect.height(), iconSize.height() ) ); - result.rwidth() += mMargins.left() + mMargins.right(); - result.rheight() += mMargins.top() + mMargins.bottom(); + textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + result.setWidth(iconSize.width() + mParentLegend->iconTextPadding() + textRect.width()); + result.setHeight(qMax(textRect.height(), iconSize.height())); + result.rwidth() += mMargins.left()+mMargins.right(); + result.rheight() += mMargins.top()+mMargins.bottom(); return result; } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLegend //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -18496,35 +18287,35 @@ QSize QCPPlottableLegendItem::minimumOuterSizeHint() const */ QCPLegend::QCPLegend() { - setFillOrder( QCPLayoutGrid::foRowsFirst ); - setWrap( 0 ); - - setRowSpacing( 3 ); - setColumnSpacing( 8 ); - setMargins( QMargins( 7, 5, 7, 4 ) ); - setAntialiased( false ); - setIconSize( 32, 18 ); - - setIconTextPadding( 7 ); - - setSelectableParts( spLegendBox | spItems ); - setSelectedParts( spNone ); - - setBorderPen( QPen( Qt::black, 0 ) ); - setSelectedBorderPen( QPen( Qt::blue, 2 ) ); - setIconBorderPen( Qt::NoPen ); - setSelectedIconBorderPen( QPen( Qt::blue, 2 ) ); - setBrush( Qt::white ); - setSelectedBrush( Qt::white ); - setTextColor( Qt::black ); - setSelectedTextColor( Qt::blue ); + setFillOrder(QCPLayoutGrid::foRowsFirst); + setWrap(0); + + setRowSpacing(3); + setColumnSpacing(8); + setMargins(QMargins(7, 5, 7, 4)); + setAntialiased(false); + setIconSize(32, 18); + + setIconTextPadding(7); + + setSelectableParts(spLegendBox | spItems); + setSelectedParts(spNone); + + setBorderPen(QPen(Qt::black, 0)); + setSelectedBorderPen(QPen(Qt::blue, 2)); + setIconBorderPen(Qt::NoPen); + setSelectedIconBorderPen(QPen(Qt::blue, 2)); + setBrush(Qt::white); + setSelectedBrush(Qt::white); + setTextColor(Qt::black); + setSelectedTextColor(Qt::blue); } QCPLegend::~QCPLegend() { clearItems(); - if( qobject_cast( mParentPlot ) ) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the legend is not in any layout and thus QObject-child of QCustomPlot) - mParentPlot->legendRemoved( this ); + if (qobject_cast(mParentPlot)) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the legend is not in any layout and thus QObject-child of QCustomPlot) + mParentPlot->legendRemoved(this); } /* no doc for getter, see setSelectedParts */ @@ -18532,15 +18323,15 @@ QCPLegend::SelectableParts QCPLegend::selectedParts() const { // check whether any legend elements selected, if yes, add spItems to return value bool hasSelectedItems = false; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; iselected() ) + if (item(i) && item(i)->selected()) { hasSelectedItems = true; break; } } - if( hasSelectedItems ) + if (hasSelectedItems) return mSelectedParts | spItems; else return mSelectedParts & ~spItems; @@ -18549,7 +18340,7 @@ QCPLegend::SelectableParts QCPLegend::selectedParts() const /*! Sets the pen, the border of the entire legend is drawn with. */ -void QCPLegend::setBorderPen( const QPen& pen ) +void QCPLegend::setBorderPen(const QPen &pen) { mBorderPen = pen; } @@ -18557,7 +18348,7 @@ void QCPLegend::setBorderPen( const QPen& pen ) /*! Sets the brush of the legend background. */ -void QCPLegend::setBrush( const QBrush& brush ) +void QCPLegend::setBrush(const QBrush &brush) { mBrush = brush; } @@ -18571,13 +18362,13 @@ void QCPLegend::setBrush( const QBrush& brush ) \see QCPAbstractLegendItem::setFont */ -void QCPLegend::setFont( const QFont& font ) +void QCPLegend::setFont(const QFont &font) { mFont = font; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; isetFont( mFont ); + if (item(i)) + item(i)->setFont(mFont); } } @@ -18590,13 +18381,13 @@ void QCPLegend::setFont( const QFont& font ) \see QCPAbstractLegendItem::setTextColor */ -void QCPLegend::setTextColor( const QColor& color ) +void QCPLegend::setTextColor(const QColor &color) { mTextColor = color; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; isetTextColor( color ); + if (item(i)) + item(i)->setTextColor(color); } } @@ -18604,17 +18395,17 @@ void QCPLegend::setTextColor( const QColor& color ) Sets the size of legend icons. Legend items that draw an icon (e.g. a visual representation of the graph) will use this size by default. */ -void QCPLegend::setIconSize( const QSize& size ) +void QCPLegend::setIconSize(const QSize &size) { mIconSize = size; } /*! \overload */ -void QCPLegend::setIconSize( int width, int height ) +void QCPLegend::setIconSize(int width, int height) { - mIconSize.setWidth( width ); - mIconSize.setHeight( height ); + mIconSize.setWidth(width); + mIconSize.setHeight(height); } /*! @@ -18622,7 +18413,7 @@ void QCPLegend::setIconSize( int width, int height ) Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the name of the graph) will use this space by default. */ -void QCPLegend::setIconTextPadding( int padding ) +void QCPLegend::setIconTextPadding(int padding) { mIconTextPadding = padding; } @@ -18633,7 +18424,7 @@ void QCPLegend::setIconTextPadding( int padding ) If no border is wanted, set this to \a Qt::NoPen. */ -void QCPLegend::setIconBorderPen( const QPen& pen ) +void QCPLegend::setIconBorderPen(const QPen &pen) { mIconBorderPen = pen; } @@ -18648,12 +18439,12 @@ void QCPLegend::setIconBorderPen( const QPen& pen ) \see SelectablePart, setSelectedParts */ -void QCPLegend::setSelectableParts( const SelectableParts& selectable ) +void QCPLegend::setSelectableParts(const SelectableParts &selectable) { - if( mSelectableParts != selectable ) + if (mSelectableParts != selectable) { mSelectableParts = selectable; - emit selectableChanged( mSelectableParts ); + emit selectableChanged(mSelectableParts); } } @@ -18678,28 +18469,28 @@ void QCPLegend::setSelectableParts( const SelectableParts& selectable ) \see SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, setSelectedFont */ -void QCPLegend::setSelectedParts( const SelectableParts& selected ) +void QCPLegend::setSelectedParts(const SelectableParts &selected) { SelectableParts newSelected = selected; - mSelectedParts = this->selectedParts(); // update mSelectedParts in case item selection changed + mSelectedParts = this->selectedParts(); // update mSelectedParts in case item selection changed - if( mSelectedParts != newSelected ) + if (mSelectedParts != newSelected) { - if( !mSelectedParts.testFlag( spItems ) && newSelected.testFlag( spItems ) ) // attempt to set spItems flag (can't do that) + if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems)) // attempt to set spItems flag (can't do that) { qDebug() << Q_FUNC_INFO << "spItems flag can not be set, it can only be unset with this function"; newSelected &= ~spItems; } - if( mSelectedParts.testFlag( spItems ) && !newSelected.testFlag( spItems ) ) // spItems flag was unset, so clear item selection + if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems)) // spItems flag was unset, so clear item selection { - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; isetSelected( false ); + if (item(i)) + item(i)->setSelected(false); } } mSelectedParts = newSelected; - emit selectionChanged( mSelectedParts ); + emit selectionChanged(mSelectedParts); } } @@ -18709,7 +18500,7 @@ void QCPLegend::setSelectedParts( const SelectableParts& selected ) \see setSelectedParts, setSelectableParts, setSelectedBrush */ -void QCPLegend::setSelectedBorderPen( const QPen& pen ) +void QCPLegend::setSelectedBorderPen(const QPen &pen) { mSelectedBorderPen = pen; } @@ -18719,7 +18510,7 @@ void QCPLegend::setSelectedBorderPen( const QPen& pen ) \see setSelectedParts, setSelectableParts, setSelectedFont */ -void QCPLegend::setSelectedIconBorderPen( const QPen& pen ) +void QCPLegend::setSelectedIconBorderPen(const QPen &pen) { mSelectedIconBorderPen = pen; } @@ -18730,7 +18521,7 @@ void QCPLegend::setSelectedIconBorderPen( const QPen& pen ) \see setSelectedParts, setSelectableParts, setSelectedBorderPen */ -void QCPLegend::setSelectedBrush( const QBrush& brush ) +void QCPLegend::setSelectedBrush(const QBrush &brush) { mSelectedBrush = brush; } @@ -18742,13 +18533,13 @@ void QCPLegend::setSelectedBrush( const QBrush& brush ) \see setFont, QCPAbstractLegendItem::setSelectedFont */ -void QCPLegend::setSelectedFont( const QFont& font ) +void QCPLegend::setSelectedFont(const QFont &font) { mSelectedFont = font; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; isetSelectedFont( font ); + if (item(i)) + item(i)->setSelectedFont(font); } } @@ -18759,13 +18550,13 @@ void QCPLegend::setSelectedFont( const QFont& font ) \see setTextColor, QCPAbstractLegendItem::setSelectedTextColor */ -void QCPLegend::setSelectedTextColor( const QColor& color ) +void QCPLegend::setSelectedTextColor(const QColor &color) { mSelectedTextColor = color; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; isetSelectedTextColor( color ); + if (item(i)) + item(i)->setSelectedTextColor(color); } } @@ -18776,9 +18567,9 @@ void QCPLegend::setSelectedTextColor( const QColor& color ) \see itemCount, addItem, itemWithPlottable */ -QCPAbstractLegendItem* QCPLegend::item( int index ) const +QCPAbstractLegendItem *QCPLegend::item(int index) const { - return qobject_cast( elementAt( index ) ); + return qobject_cast(elementAt(index)); } /*! @@ -18787,13 +18578,13 @@ QCPAbstractLegendItem* QCPLegend::item( int index ) const \see hasItemWithPlottable */ -QCPPlottableLegendItem* QCPLegend::itemWithPlottable( const QCPAbstractPlottable* plottable ) const +QCPPlottableLegendItem *QCPLegend::itemWithPlottable(const QCPAbstractPlottable *plottable) const { - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; i( item( i ) ) ) + if (QCPPlottableLegendItem *pli = qobject_cast(item(i))) { - if( pli->plottable() == plottable ) + if (pli->plottable() == plottable) return pli; } } @@ -18818,12 +18609,12 @@ int QCPLegend::itemCount() const \see hasItemWithPlottable */ -bool QCPLegend::hasItem( QCPAbstractLegendItem* item ) const +bool QCPLegend::hasItem(QCPAbstractLegendItem *item) const { - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; iitem( i ) ) - return true; + if (item == this->item(i)) + return true; } return false; } @@ -18834,9 +18625,9 @@ bool QCPLegend::hasItem( QCPAbstractLegendItem* item ) const \see itemWithPlottable */ -bool QCPLegend::hasItemWithPlottable( const QCPAbstractPlottable* plottable ) const +bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) const { - return itemWithPlottable( plottable ); + return itemWithPlottable(plottable); } /*! @@ -18849,9 +18640,9 @@ bool QCPLegend::hasItemWithPlottable( const QCPAbstractPlottable* plottable ) co \see removeItem, item, hasItem */ -bool QCPLegend::addItem( QCPAbstractLegendItem* item ) +bool QCPLegend::addItem(QCPAbstractLegendItem *item) { - return addElement( item ); + return addElement(item); } /*! \overload @@ -18867,16 +18658,15 @@ bool QCPLegend::addItem( QCPAbstractLegendItem* item ) \see itemCount, clearItems */ -bool QCPLegend::removeItem( int index ) +bool QCPLegend::removeItem(int index) { - if( QCPAbstractLegendItem* ali = item( index ) ) + if (QCPAbstractLegendItem *ali = item(index)) { - bool success = remove( ali ); - if( success ) - setFillOrder( fillOrder(), true ); // gets rid of empty cell by reordering + bool success = remove(ali); + if (success) + setFillOrder(fillOrder(), true); // gets rid of empty cell by reordering return success; - } - else + } else return false; } @@ -18892,11 +18682,11 @@ bool QCPLegend::removeItem( int index ) \see clearItems */ -bool QCPLegend::removeItem( QCPAbstractLegendItem* item ) +bool QCPLegend::removeItem(QCPAbstractLegendItem *item) { - bool success = remove( item ); - if( success ) - setFillOrder( fillOrder(), true ); // gets rid of empty cell by reordering + bool success = remove(item); + if (success) + setFillOrder(fillOrder(), true); // gets rid of empty cell by reordering return success; } @@ -18905,8 +18695,8 @@ bool QCPLegend::removeItem( QCPAbstractLegendItem* item ) */ void QCPLegend::clearItems() { - for( int i = itemCount() - 1; i >= 0; --i ) - removeItem( i ); + for (int i=itemCount()-1; i>=0; --i) + removeItem(i); } /*! @@ -18915,15 +18705,15 @@ void QCPLegend::clearItems() \see QCPAbstractLegendItem::setSelected, setSelectable */ -QList QCPLegend::selectedItems() const +QList QCPLegend::selectedItems() const { QList result; - for( int i = 0; i < itemCount(); ++i ) + for (int i=0; iselected() ) - result.append( ali ); + if (ali->selected()) + result.append(ali); } } return result; @@ -18944,9 +18734,9 @@ QList QCPLegend::selectedItems() const \see setAntialiased */ -void QCPLegend::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeLegend ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegend); } /*! \internal @@ -18956,7 +18746,7 @@ void QCPLegend::applyDefaultAntialiasingHint( QCPPainter* painter ) const */ QPen QCPLegend::getBorderPen() const { - return mSelectedParts.testFlag( spLegendBox ) ? mSelectedBorderPen : mBorderPen; + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen; } /*! \internal @@ -18966,7 +18756,7 @@ QPen QCPLegend::getBorderPen() const */ QBrush QCPLegend::getBrush() const { - return mSelectedParts.testFlag( spLegendBox ) ? mSelectedBrush : mBrush; + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush; } /*! \internal @@ -18974,54 +18764,52 @@ QBrush QCPLegend::getBrush() const Draws the legend box with the provided \a painter. The individual legend items are layerables themselves, thus are drawn independently. */ -void QCPLegend::draw( QCPPainter* painter ) +void QCPLegend::draw(QCPPainter *painter) { // draw background rect: - painter->setBrush( getBrush() ); - painter->setPen( getBorderPen() ); - painter->drawRect( mOuterRect ); + painter->setBrush(getBrush()); + painter->setPen(getBorderPen()); + painter->drawRect(mOuterRect); } /* inherits documentation from base class */ -double QCPLegend::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPLegend::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( !mParentPlot ) + if (!mParentPlot) return -1; + if (onlySelectable && !mSelectableParts.testFlag(spLegendBox)) return -1; - if( onlySelectable && !mSelectableParts.testFlag( spLegendBox ) ) - return -1; - - if( mOuterRect.contains( pos.toPoint() ) ) + + if (mOuterRect.contains(pos.toPoint())) { - if( details ) - details->setValue( spLegendBox ); - return mParentPlot->selectionTolerance() * 0.99; + if (details) details->setValue(spLegendBox); + return mParentPlot->selectionTolerance()*0.99; } return -1; } /* inherits documentation from base class */ -void QCPLegend::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPLegend::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - mSelectedParts = selectedParts(); // in case item selection has changed - if( details.value() == spLegendBox && mSelectableParts.testFlag( spLegendBox ) ) + Q_UNUSED(event) + mSelectedParts = selectedParts(); // in case item selection has changed + if (details.value() == spLegendBox && mSelectableParts.testFlag(spLegendBox)) { SelectableParts selBefore = mSelectedParts; - setSelectedParts( additive ? mSelectedParts ^ spLegendBox : mSelectedParts | spLegendBox ); // no need to unset spItems in !additive case, because they will be deselected by QCustomPlot (they're normal QCPLayerables with own deselectEvent) - if( selectionStateChanged ) + setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox); // no need to unset spItems in !additive case, because they will be deselected by QCustomPlot (they're normal QCPLayerables with own deselectEvent) + if (selectionStateChanged) *selectionStateChanged = mSelectedParts != selBefore; } } /* inherits documentation from base class */ -void QCPLegend::deselectEvent( bool* selectionStateChanged ) +void QCPLegend::deselectEvent(bool *selectionStateChanged) { - mSelectedParts = selectedParts(); // in case item selection has changed - if( mSelectableParts.testFlag( spLegendBox ) ) + mSelectedParts = selectedParts(); // in case item selection has changed + if (mSelectableParts.testFlag(spLegendBox)) { SelectableParts selBefore = mSelectedParts; - setSelectedParts( selectedParts() & ~spLegendBox ); - if( selectionStateChanged ) + setSelectedParts(selectedParts() & ~spLegendBox); + if (selectionStateChanged) *selectionStateChanged = mSelectedParts != selBefore; } } @@ -19039,13 +18827,14 @@ QCP::Interaction QCPAbstractLegendItem::selectionCategory() const } /* inherits documentation from base class */ -void QCPLegend::parentPlotInitialized( QCustomPlot* parentPlot ) +void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) { - if( parentPlot && !parentPlot->legend ) + if (parentPlot && !parentPlot->legend) parentPlot->legend = this; } /* end of 'src/layoutelements/layoutelement-legend.cpp' */ + /* including file 'src/layoutelements/layoutelement-textelement.cpp', size 12761 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -19094,21 +18883,23 @@ void QCPLegend::parentPlotInitialized( QCustomPlot* parentPlot ) Creates a new QCPTextElement instance and sets default values. The initial text is empty (\ref setText). */ -QCPTextElement::QCPTextElement( QCustomPlot* parentPlot ) - : QCPLayoutElement( parentPlot ), mText(), mTextFlags( Qt::AlignCenter | Qt::TextWordWrap ), mFont( QFont( QLatin1String( "sans serif" ), 12 ) ), // will be taken from parentPlot if available, see below - mTextColor( Qt::black ) - , mSelectedFont( QFont( QLatin1String( "sans serif" ), 12 ) ) - , // will be taken from parentPlot if available, see below - mSelectedTextColor( Qt::blue ) - , mSelectable( false ) - , mSelected( false ) +QCPTextElement::QCPTextElement(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mText(), + mTextFlags(Qt::AlignCenter|Qt::TextWordWrap), + mFont(QFont(QLatin1String("sans serif"), 12)), // will be taken from parentPlot if available, see below + mTextColor(Qt::black), + mSelectedFont(QFont(QLatin1String("sans serif"), 12)), // will be taken from parentPlot if available, see below + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - if( parentPlot ) + if (parentPlot) { mFont = parentPlot->font(); mSelectedFont = parentPlot->font(); } - setMargins( QMargins( 2, 2, 2, 2 ) ); + setMargins(QMargins(2, 2, 2, 2)); } /*! \overload @@ -19117,21 +18908,23 @@ QCPTextElement::QCPTextElement( QCustomPlot* parentPlot ) The initial text is set to \a text. */ -QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text ) - : QCPLayoutElement( parentPlot ), mText( text ), mTextFlags( Qt::AlignCenter | Qt::TextWordWrap ), mFont( QFont( QLatin1String( "sans serif" ), 12 ) ), // will be taken from parentPlot if available, see below - mTextColor( Qt::black ) - , mSelectedFont( QFont( QLatin1String( "sans serif" ), 12 ) ) - , // will be taken from parentPlot if available, see below - mSelectedTextColor( Qt::blue ) - , mSelectable( false ) - , mSelected( false ) +QCPTextElement::QCPTextElement(QCustomPlot *parentPlot, const QString &text) : + QCPLayoutElement(parentPlot), + mText(text), + mTextFlags(Qt::AlignCenter|Qt::TextWordWrap), + mFont(QFont(QLatin1String("sans serif"), 12)), // will be taken from parentPlot if available, see below + mTextColor(Qt::black), + mSelectedFont(QFont(QLatin1String("sans serif"), 12)), // will be taken from parentPlot if available, see below + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - if( parentPlot ) + if (parentPlot) { mFont = parentPlot->font(); mSelectedFont = parentPlot->font(); } - setMargins( QMargins( 2, 2, 2, 2 ) ); + setMargins(QMargins(2, 2, 2, 2)); } /*! \overload @@ -19140,23 +18933,25 @@ QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text ) The initial text is set to \a text with \a pointSize. */ -QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, double pointSize ) - : QCPLayoutElement( parentPlot ), mText( text ), mTextFlags( Qt::AlignCenter | Qt::TextWordWrap ), mFont( QFont( QLatin1String( "sans serif" ), pointSize ) ), // will be taken from parentPlot if available, see below - mTextColor( Qt::black ) - , mSelectedFont( QFont( QLatin1String( "sans serif" ), pointSize ) ) - , // will be taken from parentPlot if available, see below - mSelectedTextColor( Qt::blue ) - , mSelectable( false ) - , mSelected( false ) +QCPTextElement::QCPTextElement(QCustomPlot *parentPlot, const QString &text, double pointSize) : + QCPLayoutElement(parentPlot), + mText(text), + mTextFlags(Qt::AlignCenter|Qt::TextWordWrap), + mFont(QFont(QLatin1String("sans serif"), pointSize)), // will be taken from parentPlot if available, see below + mTextColor(Qt::black), + mSelectedFont(QFont(QLatin1String("sans serif"), pointSize)), // will be taken from parentPlot if available, see below + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - if( parentPlot ) + if (parentPlot) { mFont = parentPlot->font(); - mFont.setPointSizeF( pointSize ); + mFont.setPointSizeF(pointSize); mSelectedFont = parentPlot->font(); - mSelectedFont.setPointSizeF( pointSize ); + mSelectedFont.setPointSizeF(pointSize); } - setMargins( QMargins( 2, 2, 2, 2 ) ); + setMargins(QMargins(2, 2, 2, 2)); } /*! \overload @@ -19165,10 +18960,18 @@ QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, do The initial text is set to \a text with \a pointSize and the specified \a fontFamily. */ -QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, const QString& fontFamily, double pointSize ) - : QCPLayoutElement( parentPlot ), mText( text ), mTextFlags( Qt::AlignCenter | Qt::TextWordWrap ), mFont( QFont( fontFamily, pointSize ) ), mTextColor( Qt::black ), mSelectedFont( QFont( fontFamily, pointSize ) ), mSelectedTextColor( Qt::blue ), mSelectable( false ), mSelected( false ) +QCPTextElement::QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize) : + QCPLayoutElement(parentPlot), + mText(text), + mTextFlags(Qt::AlignCenter|Qt::TextWordWrap), + mFont(QFont(fontFamily, pointSize)), + mTextColor(Qt::black), + mSelectedFont(QFont(fontFamily, pointSize)), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - setMargins( QMargins( 2, 2, 2, 2 ) ); + setMargins(QMargins(2, 2, 2, 2)); } /*! \overload @@ -19177,10 +18980,18 @@ QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, co The initial text is set to \a text with the specified \a font. */ -QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, const QFont& font ) - : QCPLayoutElement( parentPlot ), mText( text ), mTextFlags( Qt::AlignCenter | Qt::TextWordWrap ), mFont( font ), mTextColor( Qt::black ), mSelectedFont( font ), mSelectedTextColor( Qt::blue ), mSelectable( false ), mSelected( false ) +QCPTextElement::QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QFont &font) : + QCPLayoutElement(parentPlot), + mText(text), + mTextFlags(Qt::AlignCenter|Qt::TextWordWrap), + mFont(font), + mTextColor(Qt::black), + mSelectedFont(font), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) { - setMargins( QMargins( 2, 2, 2, 2 ) ); + setMargins(QMargins(2, 2, 2, 2)); } /*! @@ -19188,7 +18999,7 @@ QCPTextElement::QCPTextElement( QCustomPlot* parentPlot, const QString& text, co \see setFont, setTextColor, setTextFlags */ -void QCPTextElement::setText( const QString& text ) +void QCPTextElement::setText(const QString &text) { mText = text; } @@ -19213,7 +19024,7 @@ void QCPTextElement::setText( const QString& text ) - Qt::TextWordWrap - Qt::TextIncludeTrailingSpaces */ -void QCPTextElement::setTextFlags( int flags ) +void QCPTextElement::setTextFlags(int flags) { mTextFlags = flags; } @@ -19223,7 +19034,7 @@ void QCPTextElement::setTextFlags( int flags ) \see setTextColor, setSelectedFont */ -void QCPTextElement::setFont( const QFont& font ) +void QCPTextElement::setFont(const QFont &font) { mFont = font; } @@ -19233,7 +19044,7 @@ void QCPTextElement::setFont( const QFont& font ) \see setFont, setSelectedTextColor */ -void QCPTextElement::setTextColor( const QColor& color ) +void QCPTextElement::setTextColor(const QColor &color) { mTextColor = color; } @@ -19243,7 +19054,7 @@ void QCPTextElement::setTextColor( const QColor& color ) \see setFont */ -void QCPTextElement::setSelectedFont( const QFont& font ) +void QCPTextElement::setSelectedFont(const QFont &font) { mSelectedFont = font; } @@ -19253,7 +19064,7 @@ void QCPTextElement::setSelectedFont( const QFont& font ) \see setTextColor */ -void QCPTextElement::setSelectedTextColor( const QColor& color ) +void QCPTextElement::setSelectedTextColor(const QColor &color) { mSelectedTextColor = color; } @@ -19264,12 +19075,12 @@ void QCPTextElement::setSelectedTextColor( const QColor& color ) Note that even when \a selectable is set to false, the selection state may be changed programmatically via \ref setSelected. */ -void QCPTextElement::setSelectable( bool selectable ) +void QCPTextElement::setSelectable(bool selectable) { - if( mSelectable != selectable ) + if (mSelectable != selectable) { mSelectable = selectable; - emit selectableChanged( mSelectable ); + emit selectableChanged(mSelectable); } } @@ -19280,71 +19091,71 @@ void QCPTextElement::setSelectable( bool selectable ) Note that this function can change the selection state independently of the current \ref setSelectable state. */ -void QCPTextElement::setSelected( bool selected ) +void QCPTextElement::setSelected(bool selected) { - if( mSelected != selected ) + if (mSelected != selected) { mSelected = selected; - emit selectionChanged( mSelected ); + emit selectionChanged(mSelected); } } /* inherits documentation from base class */ -void QCPTextElement::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPTextElement::applyDefaultAntialiasingHint(QCPPainter *painter) const { - applyAntialiasingHint( painter, mAntialiased, QCP::aeOther ); + applyAntialiasingHint(painter, mAntialiased, QCP::aeOther); } /* inherits documentation from base class */ -void QCPTextElement::draw( QCPPainter* painter ) +void QCPTextElement::draw(QCPPainter *painter) { - painter->setFont( mainFont() ); - painter->setPen( QPen( mainTextColor() ) ); - painter->drawText( mRect, Qt::AlignCenter, mText, &mTextBoundingRect ); + painter->setFont(mainFont()); + painter->setPen(QPen(mainTextColor())); + painter->drawText(mRect, Qt::AlignCenter, mText, &mTextBoundingRect); } /* inherits documentation from base class */ QSize QCPTextElement::minimumOuterSizeHint() const { - QFontMetrics metrics( mFont ); - QSize result( metrics.boundingRect( 0, 0, 0, 0, Qt::AlignCenter, mText ).size() ); - result.rwidth() += mMargins.left() + mMargins.right(); - result.rheight() += mMargins.top() + mMargins.bottom(); + QFontMetrics metrics(mFont); + QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size()); + result.rwidth() += mMargins.left()+mMargins.right(); + result.rheight() += mMargins.top()+mMargins.bottom(); return result; } /* inherits documentation from base class */ QSize QCPTextElement::maximumOuterSizeHint() const { - QFontMetrics metrics( mFont ); - QSize result( metrics.boundingRect( 0, 0, 0, 0, Qt::AlignCenter, mText ).size() ); - result.setWidth( QWIDGETSIZE_MAX ); - result.rheight() += mMargins.top() + mMargins.bottom(); + QFontMetrics metrics(mFont); + QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size()); + result.setWidth(QWIDGETSIZE_MAX); + result.rheight() += mMargins.top()+mMargins.bottom(); return result; } /* inherits documentation from base class */ -void QCPTextElement::selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) +void QCPTextElement::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) { - Q_UNUSED( event ) - Q_UNUSED( details ) - if( mSelectable ) + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) { bool selBefore = mSelected; - setSelected( additive ? !mSelected : true ); - if( selectionStateChanged ) + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } /* inherits documentation from base class */ -void QCPTextElement::deselectEvent( bool* selectionStateChanged ) +void QCPTextElement::deselectEvent(bool *selectionStateChanged) { - if( mSelectable ) + if (mSelectable) { bool selBefore = mSelected; - setSelected( false ); - if( selectionStateChanged ) + setSelected(false); + if (selectionStateChanged) *selectionStateChanged = mSelected != selBefore; } } @@ -19359,14 +19170,14 @@ void QCPTextElement::deselectEvent( bool* selectionStateChanged ) \seebaseclassmethod */ -double QCPTextElement::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPTextElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - if( mTextBoundingRect.contains( pos.toPoint() ) ) - return mParentPlot->selectionTolerance() * 0.99; + + if (mTextBoundingRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; else return -1; } @@ -19377,9 +19188,9 @@ double QCPTextElement::selectTest( const QPointF& pos, bool onlySelectable, QVar \seebaseclassmethod */ -void QCPTextElement::mousePressEvent( QMouseEvent* event, const QVariant& details ) +void QCPTextElement::mousePressEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) + Q_UNUSED(details) event->accept(); } @@ -19389,10 +19200,10 @@ void QCPTextElement::mousePressEvent( QMouseEvent* event, const QVariant& detail \seebaseclassmethod */ -void QCPTextElement::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPTextElement::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) { - if( ( QPointF( event->pos() ) - startPos ).manhattanLength() <= 3 ) - emit clicked( event ); + if ((QPointF(event->pos())-startPos).manhattanLength() <= 3) + emit clicked(event); } /*! @@ -19400,10 +19211,10 @@ void QCPTextElement::mouseReleaseEvent( QMouseEvent* event, const QPointF& start \seebaseclassmethod */ -void QCPTextElement::mouseDoubleClickEvent( QMouseEvent* event, const QVariant& details ) +void QCPTextElement::mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) { - Q_UNUSED( details ) - emit doubleClicked( event ); + Q_UNUSED(details) + emit doubleClicked(event); } /*! \internal @@ -19427,9 +19238,11 @@ QColor QCPTextElement::mainTextColor() const } /* end of 'src/layoutelements/layoutelement-textelement.cpp' */ + /* including file 'src/layoutelements/layoutelement-colorscale.cpp', size 25770 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPColorScale //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -19516,15 +19329,16 @@ QColor QCPTextElement::mainTextColor() const /*! Constructs a new QCPColorScale. */ -QCPColorScale::QCPColorScale( QCustomPlot* parentPlot ) - : QCPLayoutElement( parentPlot ), mType( QCPAxis::atTop ), // set to atTop such that setType(QCPAxis::atRight) below doesn't skip work because it thinks it's already atRight - mDataScaleType( QCPAxis::stLinear ) - , mBarWidth( 20 ) - , mAxisRect( new QCPColorScaleAxisRectPrivate( this ) ) +QCPColorScale::QCPColorScale(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mType(QCPAxis::atTop), // set to atTop such that setType(QCPAxis::atRight) below doesn't skip work because it thinks it's already atRight + mDataScaleType(QCPAxis::stLinear), + mBarWidth(20), + mAxisRect(new QCPColorScaleAxisRectPrivate(this)) { - setMinimumMargins( QMargins( 0, 6, 0, 6 ) ); // for default right color scale types, keep some room at bottom and top (important if no margin group is used) - setType( QCPAxis::atRight ); - setDataRange( QCPRange( 0, 6 ) ); + setMinimumMargins(QMargins(0, 6, 0, 6)); // for default right color scale types, keep some room at bottom and top (important if no margin group is used) + setType(QCPAxis::atRight); + setDataRange(QCPRange(0, 6)); } QCPColorScale::~QCPColorScale() @@ -19535,41 +19349,41 @@ QCPColorScale::~QCPColorScale() /* undocumented getter */ QString QCPColorScale::label() const { - if( !mColorAxis ) + if (!mColorAxis) { qDebug() << Q_FUNC_INFO << "internal color axis undefined"; return QString(); } - + return mColorAxis.data()->label(); } /* undocumented getter */ bool QCPColorScale::rangeDrag() const { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return false; } - - return mAxisRect.data()->rangeDrag().testFlag( QCPAxis::orientation( mType ) ) && - mAxisRect.data()->rangeDragAxis( QCPAxis::orientation( mType ) ) && - mAxisRect.data()->rangeDragAxis( QCPAxis::orientation( mType ) )->orientation() == QCPAxis::orientation( mType ); + + return mAxisRect.data()->rangeDrag().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); } /* undocumented getter */ bool QCPColorScale::rangeZoom() const { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return false; } - - return mAxisRect.data()->rangeZoom().testFlag( QCPAxis::orientation( mType ) ) && - mAxisRect.data()->rangeZoomAxis( QCPAxis::orientation( mType ) ) && - mAxisRect.data()->rangeZoomAxis( QCPAxis::orientation( mType ) )->orientation() == QCPAxis::orientation( mType ); + + return mAxisRect.data()->rangeZoom().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); } /*! @@ -19579,48 +19393,48 @@ bool QCPColorScale::rangeZoom() const be a different one. The new axis will adopt the following properties from the previous axis: The range, scale type, label and ticker (the latter will be shared and not copied). */ -void QCPColorScale::setType( QCPAxis::AxisType type ) +void QCPColorScale::setType(QCPAxis::AxisType type) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - if( mType != type ) + if (mType != type) { mType = type; - QCPRange rangeTransfer( 0, 6 ); + QCPRange rangeTransfer(0, 6); QString labelTransfer; QSharedPointer tickerTransfer; // transfer/revert some settings on old axis if it exists: bool doTransfer = (bool)mColorAxis; - if( doTransfer ) + if (doTransfer) { rangeTransfer = mColorAxis.data()->range(); labelTransfer = mColorAxis.data()->label(); tickerTransfer = mColorAxis.data()->ticker(); - mColorAxis.data()->setLabel( QString() ); - disconnect( mColorAxis.data(), SIGNAL( rangeChanged( QCPRange ) ), this, SLOT( setDataRange( QCPRange ) ) ); - disconnect( mColorAxis.data(), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), this, SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); + mColorAxis.data()->setLabel(QString()); + disconnect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); } QList allAxisTypes = QList() << QCPAxis::atLeft << QCPAxis::atRight << QCPAxis::atBottom << QCPAxis::atTop; - foreach( QCPAxis::AxisType atype, allAxisTypes ) + foreach (QCPAxis::AxisType atype, allAxisTypes) { - mAxisRect.data()->axis( atype )->setTicks( atype == mType ); - mAxisRect.data()->axis( atype )->setTickLabels( atype == mType ); + mAxisRect.data()->axis(atype)->setTicks(atype == mType); + mAxisRect.data()->axis(atype)->setTickLabels(atype== mType); } // set new mColorAxis pointer: - mColorAxis = mAxisRect.data()->axis( mType ); + mColorAxis = mAxisRect.data()->axis(mType); // transfer settings to new axis: - if( doTransfer ) + if (doTransfer) { - mColorAxis.data()->setRange( rangeTransfer ); // range transfer necessary if axis changes from vertical to horizontal or vice versa (axes with same orientation are synchronized via signals) - mColorAxis.data()->setLabel( labelTransfer ); - mColorAxis.data()->setTicker( tickerTransfer ); + mColorAxis.data()->setRange(rangeTransfer); // range transfer necessary if axis changes from vertical to horizontal or vice versa (axes with same orientation are synchronized via signals) + mColorAxis.data()->setLabel(labelTransfer); + mColorAxis.data()->setTicker(tickerTransfer); } - connect( mColorAxis.data(), SIGNAL( rangeChanged( QCPRange ) ), this, SLOT( setDataRange( QCPRange ) ) ); - connect( mColorAxis.data(), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), this, SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); - mAxisRect.data()->setRangeDragAxes( QList() << mColorAxis.data() ); + connect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + mAxisRect.data()->setRangeDragAxes(QList() << mColorAxis.data()); } } @@ -19633,14 +19447,14 @@ void QCPColorScale::setType( QCPAxis::AxisType type ) \see setDataScaleType, setGradient, rescaleDataRange */ -void QCPColorScale::setDataRange( const QCPRange& dataRange ) +void QCPColorScale::setDataRange(const QCPRange &dataRange) { - if( mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper ) + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) { mDataRange = dataRange; - if( mColorAxis ) - mColorAxis.data()->setRange( mDataRange ); - emit dataRangeChanged( mDataRange ); + if (mColorAxis) + mColorAxis.data()->setRange(mDataRange); + emit dataRangeChanged(mDataRange); } } @@ -19654,16 +19468,16 @@ void QCPColorScale::setDataRange( const QCPRange& dataRange ) \see setDataRange, setGradient */ -void QCPColorScale::setDataScaleType( QCPAxis::ScaleType scaleType ) +void QCPColorScale::setDataScaleType(QCPAxis::ScaleType scaleType) { - if( mDataScaleType != scaleType ) + if (mDataScaleType != scaleType) { mDataScaleType = scaleType; - if( mColorAxis ) - mColorAxis.data()->setScaleType( mDataScaleType ); - if( mDataScaleType == QCPAxis::stLogarithmic ) - setDataRange( mDataRange.sanitizedForLogScale() ); - emit dataScaleTypeChanged( mDataScaleType ); + if (mColorAxis) + mColorAxis.data()->setScaleType(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); + emit dataScaleTypeChanged(mDataScaleType); } } @@ -19674,14 +19488,14 @@ void QCPColorScale::setDataScaleType( QCPAxis::ScaleType scaleType ) \see setDataRange, setDataScaleType */ -void QCPColorScale::setGradient( const QCPColorGradient& gradient ) +void QCPColorScale::setGradient(const QCPColorGradient &gradient) { - if( mGradient != gradient ) + if (mGradient != gradient) { mGradient = gradient; - if( mAxisRect ) + if (mAxisRect) mAxisRect.data()->mGradientImageInvalidated = true; - emit gradientChanged( mGradient ); + emit gradientChanged(mGradient); } } @@ -19689,22 +19503,22 @@ void QCPColorScale::setGradient( const QCPColorGradient& gradient ) Sets the axis label of the color scale. This is equivalent to calling \ref QCPAxis::setLabel on the internal \ref axis. */ -void QCPColorScale::setLabel( const QString& str ) +void QCPColorScale::setLabel(const QString &str) { - if( !mColorAxis ) + if (!mColorAxis) { qDebug() << Q_FUNC_INFO << "internal color axis undefined"; return; } - - mColorAxis.data()->setLabel( str ); + + mColorAxis.data()->setLabel(str); } /*! Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed will have. */ -void QCPColorScale::setBarWidth( int width ) +void QCPColorScale::setBarWidth(int width) { mBarWidth = width; } @@ -19715,18 +19529,18 @@ void QCPColorScale::setBarWidth( int width ) Note that \ref QCP::iRangeDrag must be in the QCustomPlot's interactions (\ref QCustomPlot::setInteractions) to allow range dragging. */ -void QCPColorScale::setRangeDrag( bool enabled ) +void QCPColorScale::setRangeDrag(bool enabled) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - - if( enabled ) - mAxisRect.data()->setRangeDrag( QCPAxis::orientation( mType ) ); + + if (enabled) + mAxisRect.data()->setRangeDrag(QCPAxis::orientation(mType)); else - mAxisRect.data()->setRangeDrag( 0 ); + mAxisRect.data()->setRangeDrag(0); } /*! @@ -19735,18 +19549,18 @@ void QCPColorScale::setRangeDrag( bool enabled ) Note that \ref QCP::iRangeZoom must be in the QCustomPlot's interactions (\ref QCustomPlot::setInteractions) to allow range dragging. */ -void QCPColorScale::setRangeZoom( bool enabled ) +void QCPColorScale::setRangeZoom(bool enabled) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - - if( enabled ) - mAxisRect.data()->setRangeZoom( QCPAxis::orientation( mType ) ); + + if (enabled) + mAxisRect.data()->setRangeZoom(QCPAxis::orientation(mType)); else - mAxisRect.data()->setRangeZoom( 0 ); + mAxisRect.data()->setRangeZoom(0); } /*! @@ -19755,11 +19569,11 @@ void QCPColorScale::setRangeZoom( bool enabled ) QList QCPColorScale::colorMaps() const { QList result; - for( int i = 0; i < mParentPlot->plottableCount(); ++i ) + for (int i=0; iplottableCount(); ++i) { - if( QCPColorMap* cm = qobject_cast( mParentPlot->plottable( i ) ) ) - if( cm->colorScale() == this ) - result.append( cm ); + if (QCPColorMap *cm = qobject_cast(mParentPlot->plottable(i))) + if (cm->colorScale() == this) + result.append(cm); } return result; } @@ -19770,153 +19584,149 @@ QList QCPColorScale::colorMaps() const \see setDataRange */ -void QCPColorScale::rescaleDataRange( bool onlyVisibleMaps ) +void QCPColorScale::rescaleDataRange(bool onlyVisibleMaps) { QList maps = colorMaps(); QCPRange newRange; bool haveRange = false; QCP::SignDomain sign = QCP::sdBoth; - if( mDataScaleType == QCPAxis::stLogarithmic ) - sign = ( mDataRange.upper < 0 ? QCP::sdNegative : QCP::sdPositive ); - for( int i = 0; i < maps.size(); ++i ) + if (mDataScaleType == QCPAxis::stLogarithmic) + sign = (mDataRange.upper < 0 ? QCP::sdNegative : QCP::sdPositive); + for (int i=0; irealVisibility() && onlyVisibleMaps ) + if (!maps.at(i)->realVisibility() && onlyVisibleMaps) continue; QCPRange mapRange; - if( maps.at( i )->colorScale() == this ) + if (maps.at(i)->colorScale() == this) { bool currentFoundRange = true; - mapRange = maps.at( i )->data()->dataBounds(); - if( sign == QCP::sdPositive ) + mapRange = maps.at(i)->data()->dataBounds(); + if (sign == QCP::sdPositive) { - if( mapRange.lower <= 0 && mapRange.upper > 0 ) - mapRange.lower = mapRange.upper * 1e-3; - else if( mapRange.lower <= 0 && mapRange.upper <= 0 ) + if (mapRange.lower <= 0 && mapRange.upper > 0) + mapRange.lower = mapRange.upper*1e-3; + else if (mapRange.lower <= 0 && mapRange.upper <= 0) + currentFoundRange = false; + } else if (sign == QCP::sdNegative) + { + if (mapRange.upper >= 0 && mapRange.lower < 0) + mapRange.upper = mapRange.lower*1e-3; + else if (mapRange.upper >= 0 && mapRange.lower >= 0) currentFoundRange = false; } - else if( sign == QCP::sdNegative ) + if (currentFoundRange) { - if( mapRange.upper >= 0 && mapRange.lower < 0 ) - mapRange.upper = mapRange.lower * 1e-3; - else if( mapRange.upper >= 0 && mapRange.lower >= 0 ) - currentFoundRange = false; - } - if( currentFoundRange ) - { - if( !haveRange ) + if (!haveRange) newRange = mapRange; else - newRange.expand( mapRange ); + newRange.expand(mapRange); haveRange = true; } } } - if( haveRange ) + if (haveRange) { - if( !QCPRange::validRange( newRange ) ) // likely due to range being zero (plottable has only constant data in this dimension), shift current range to at least center the data + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this dimension), shift current range to at least center the data { - double center = ( newRange.lower + newRange.upper ) * 0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason - if( mDataScaleType == QCPAxis::stLinear ) + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mDataScaleType == QCPAxis::stLinear) { - newRange.lower = center - mDataRange.size() / 2.0; - newRange.upper = center + mDataRange.size() / 2.0; - } - else // mScaleType == stLogarithmic + newRange.lower = center-mDataRange.size()/2.0; + newRange.upper = center+mDataRange.size()/2.0; + } else // mScaleType == stLogarithmic { - newRange.lower = center / qSqrt( mDataRange.upper / mDataRange.lower ); - newRange.upper = center * qSqrt( mDataRange.upper / mDataRange.lower ); + newRange.lower = center/qSqrt(mDataRange.upper/mDataRange.lower); + newRange.upper = center*qSqrt(mDataRange.upper/mDataRange.lower); } } - setDataRange( newRange ); + setDataRange(newRange); } } /* inherits documentation from base class */ -void QCPColorScale::update( UpdatePhase phase ) +void QCPColorScale::update(UpdatePhase phase) { - QCPLayoutElement::update( phase ); - if( !mAxisRect ) + QCPLayoutElement::update(phase); + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - - mAxisRect.data()->update( phase ); - - switch( phase ) + + mAxisRect.data()->update(phase); + + switch (phase) { - case upMargins: - { - if( mType == QCPAxis::atBottom || mType == QCPAxis::atTop ) + case upMargins: { - setMaximumSize( QWIDGETSIZE_MAX, mBarWidth + mAxisRect.data()->margins().top() + mAxisRect.data()->margins().bottom() ); - setMinimumSize( 0, mBarWidth + mAxisRect.data()->margins().top() + mAxisRect.data()->margins().bottom() ); + if (mType == QCPAxis::atBottom || mType == QCPAxis::atTop) + { + setMaximumSize(QWIDGETSIZE_MAX, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()); + setMinimumSize(0, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()); + } else + { + setMaximumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right(), QWIDGETSIZE_MAX); + setMinimumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right(), 0); + } + break; } - else + case upLayout: { - setMaximumSize( mBarWidth + mAxisRect.data()->margins().left() + mAxisRect.data()->margins().right(), QWIDGETSIZE_MAX ); - setMinimumSize( mBarWidth + mAxisRect.data()->margins().left() + mAxisRect.data()->margins().right(), 0 ); + mAxisRect.data()->setOuterRect(rect()); + break; } - break; - } - case upLayout: - { - mAxisRect.data()->setOuterRect( rect() ); - break; - } - default: - break; + default: break; } } /* inherits documentation from base class */ -void QCPColorScale::applyDefaultAntialiasingHint( QCPPainter* painter ) const +void QCPColorScale::applyDefaultAntialiasingHint(QCPPainter *painter) const { - painter->setAntialiasing( false ); + painter->setAntialiasing(false); } /* inherits documentation from base class */ -void QCPColorScale::mousePressEvent( QMouseEvent* event, const QVariant& details ) +void QCPColorScale::mousePressEvent(QMouseEvent *event, const QVariant &details) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - mAxisRect.data()->mousePressEvent( event, details ); + mAxisRect.data()->mousePressEvent(event, details); } /* inherits documentation from base class */ -void QCPColorScale::mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPColorScale::mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - mAxisRect.data()->mouseMoveEvent( event, startPos ); + mAxisRect.data()->mouseMoveEvent(event, startPos); } /* inherits documentation from base class */ -void QCPColorScale::mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) +void QCPColorScale::mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - mAxisRect.data()->mouseReleaseEvent( event, startPos ); + mAxisRect.data()->mouseReleaseEvent(event, startPos); } /* inherits documentation from base class */ -void QCPColorScale::wheelEvent( QWheelEvent* event ) +void QCPColorScale::wheelEvent(QWheelEvent *event) { - if( !mAxisRect ) + if (!mAxisRect) { qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; return; } - mAxisRect.data()->wheelEvent( event ); + mAxisRect.data()->wheelEvent(event); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -19933,38 +19743,41 @@ void QCPColorScale::wheelEvent( QWheelEvent* event ) It provides the axis rect functionality for the QCPColorScale class. */ + /*! Creates a new instance, as a child of \a parentColorScale. */ -QCPColorScaleAxisRectPrivate::QCPColorScaleAxisRectPrivate( QCPColorScale* parentColorScale ) - : QCPAxisRect( parentColorScale->parentPlot(), true ), mParentColorScale( parentColorScale ), mGradientImageInvalidated( true ) +QCPColorScaleAxisRectPrivate::QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale) : + QCPAxisRect(parentColorScale->parentPlot(), true), + mParentColorScale(parentColorScale), + mGradientImageInvalidated(true) { - setParentLayerable( parentColorScale ); - setMinimumMargins( QMargins( 0, 0, 0, 0 ) ); + setParentLayerable(parentColorScale); + setMinimumMargins(QMargins(0, 0, 0, 0)); QList allAxisTypes = QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight; - foreach( QCPAxis::AxisType type, allAxisTypes ) + foreach (QCPAxis::AxisType type, allAxisTypes) { - axis( type )->setVisible( true ); - axis( type )->grid()->setVisible( false ); - axis( type )->setPadding( 0 ); - connect( axis( type ), SIGNAL( selectionChanged( QCPAxis::SelectableParts ) ), this, SLOT( axisSelectionChanged( QCPAxis::SelectableParts ) ) ); - connect( axis( type ), SIGNAL( selectableChanged( QCPAxis::SelectableParts ) ), this, SLOT( axisSelectableChanged( QCPAxis::SelectableParts ) ) ); + axis(type)->setVisible(true); + axis(type)->grid()->setVisible(false); + axis(type)->setPadding(0); + connect(axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectionChanged(QCPAxis::SelectableParts))); + connect(axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectableChanged(QCPAxis::SelectableParts))); } - connect( axis( QCPAxis::atLeft ), SIGNAL( rangeChanged( QCPRange ) ), axis( QCPAxis::atRight ), SLOT( setRange( QCPRange ) ) ); - connect( axis( QCPAxis::atRight ), SIGNAL( rangeChanged( QCPRange ) ), axis( QCPAxis::atLeft ), SLOT( setRange( QCPRange ) ) ); - connect( axis( QCPAxis::atBottom ), SIGNAL( rangeChanged( QCPRange ) ), axis( QCPAxis::atTop ), SLOT( setRange( QCPRange ) ) ); - connect( axis( QCPAxis::atTop ), SIGNAL( rangeChanged( QCPRange ) ), axis( QCPAxis::atBottom ), SLOT( setRange( QCPRange ) ) ); - connect( axis( QCPAxis::atLeft ), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), axis( QCPAxis::atRight ), SLOT( setScaleType( QCPAxis::ScaleType ) ) ); - connect( axis( QCPAxis::atRight ), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), axis( QCPAxis::atLeft ), SLOT( setScaleType( QCPAxis::ScaleType ) ) ); - connect( axis( QCPAxis::atBottom ), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), axis( QCPAxis::atTop ), SLOT( setScaleType( QCPAxis::ScaleType ) ) ); - connect( axis( QCPAxis::atTop ), SIGNAL( scaleTypeChanged( QCPAxis::ScaleType ) ), axis( QCPAxis::atBottom ), SLOT( setScaleType( QCPAxis::ScaleType ) ) ); - + connect(axis(QCPAxis::atLeft), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atRight), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atRight), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atLeft), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atTop), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atTop), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atBottom), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atLeft), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atRight), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atRight), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atLeft), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atBottom), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atTop), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atTop), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atBottom), SLOT(setScaleType(QCPAxis::ScaleType))); + // make layer transfers of color scale transfer to axis rect and axes // the axes must be set after axis rect, such that they appear above color gradient drawn by axis rect: - connect( parentColorScale, SIGNAL( layerChanged( QCPLayer* ) ), this, SLOT( setLayer( QCPLayer* ) ) ); - foreach( QCPAxis::AxisType type, allAxisTypes ) - connect( parentColorScale, SIGNAL( layerChanged( QCPLayer* ) ), axis( type ), SLOT( setLayer( QCPLayer* ) ) ); + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), this, SLOT(setLayer(QCPLayer*))); + foreach (QCPAxis::AxisType type, allAxisTypes) + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), axis(type), SLOT(setLayer(QCPLayer*))); } /*! \internal @@ -19974,21 +19787,21 @@ QCPColorScaleAxisRectPrivate::QCPColorScaleAxisRectPrivate( QCPColorScale* paren \seebaseclassmethod */ -void QCPColorScaleAxisRectPrivate::draw( QCPPainter* painter ) +void QCPColorScaleAxisRectPrivate::draw(QCPPainter *painter) { - if( mGradientImageInvalidated ) + if (mGradientImageInvalidated) updateGradientImage(); - + bool mirrorHorz = false; bool mirrorVert = false; - if( mParentColorScale->mColorAxis ) + if (mParentColorScale->mColorAxis) { - mirrorHorz = mParentColorScale->mColorAxis.data()->rangeReversed() && ( mParentColorScale->type() == QCPAxis::atBottom || mParentColorScale->type() == QCPAxis::atTop ); - mirrorVert = mParentColorScale->mColorAxis.data()->rangeReversed() && ( mParentColorScale->type() == QCPAxis::atLeft || mParentColorScale->type() == QCPAxis::atRight ); + mirrorHorz = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atBottom || mParentColorScale->type() == QCPAxis::atTop); + mirrorVert = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atLeft || mParentColorScale->type() == QCPAxis::atRight); } - - painter->drawImage( rect().adjusted( 0, -1, 0, -1 ), mGradientImage.mirrored( mirrorHorz, mirrorVert ) ); - QCPAxisRect::draw( painter ); + + painter->drawImage(rect().adjusted(0, -1, 0, -1), mGradientImage.mirrored(mirrorHorz, mirrorVert)); + QCPAxisRect::draw(painter); } /*! \internal @@ -19998,37 +19811,36 @@ void QCPColorScaleAxisRectPrivate::draw( QCPPainter* painter ) */ void QCPColorScaleAxisRectPrivate::updateGradientImage() { - if( rect().isEmpty() ) + if (rect().isEmpty()) return; - + const QImage::Format format = QImage::Format_ARGB32_Premultiplied; int n = mParentColorScale->mGradient.levelCount(); int w, h; - QVector data( n ); - for( int i = 0; i < n; ++i ) + QVector data(n); + for (int i=0; imType == QCPAxis::atBottom || mParentColorScale->mType == QCPAxis::atTop ) + if (mParentColorScale->mType == QCPAxis::atBottom || mParentColorScale->mType == QCPAxis::atTop) { w = n; h = rect().height(); - mGradientImage = QImage( w, h, format ); + mGradientImage = QImage(w, h, format); QVector pixels; - for( int y = 0; y < h; ++y ) - pixels.append( reinterpret_cast( mGradientImage.scanLine( y ) ) ); - mParentColorScale->mGradient.colorize( data.constData(), QCPRange( 0, n - 1 ), pixels.first(), n ); - for( int y = 1; y < h; ++y ) - memcpy( pixels.at( y ), pixels.first(), n * sizeof( QRgb ) ); - } - else + for (int y=0; y(mGradientImage.scanLine(y))); + mParentColorScale->mGradient.colorize(data.constData(), QCPRange(0, n-1), pixels.first(), n); + for (int y=1; y( mGradientImage.scanLine( y ) ); - const QRgb lineColor = mParentColorScale->mGradient.color( data[h - 1 - y], QCPRange( 0, n - 1 ) ); - for( int x = 0; x < w; ++x ) + QRgb *pixels = reinterpret_cast(mGradientImage.scanLine(y)); + const QRgb lineColor = mParentColorScale->mGradient.color(data[h-1-y], QCPRange(0, n-1)); + for (int x=0; x allAxisTypes = QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight; - foreach( QCPAxis::AxisType type, allAxisTypes ) + foreach (QCPAxis::AxisType type, allAxisTypes) { - if( QCPAxis* senderAxis = qobject_cast( sender() ) ) - if( senderAxis->axisType() == type ) + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) continue; - - if( axis( type )->selectableParts().testFlag( QCPAxis::spAxis ) ) + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) { - if( selectedParts.testFlag( QCPAxis::spAxis ) ) - axis( type )->setSelectedParts( axis( type )->selectedParts() | QCPAxis::spAxis ); + if (selectedParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectedParts(axis(type)->selectedParts() | QCPAxis::spAxis); else - axis( type )->setSelectedParts( axis( type )->selectedParts() & ~QCPAxis::spAxis ); + axis(type)->setSelectedParts(axis(type)->selectedParts() & ~QCPAxis::spAxis); } } } @@ -20065,27 +19877,28 @@ void QCPColorScaleAxisRectPrivate::axisSelectionChanged( QCPAxis::SelectablePart This slot is connected to the selectableChanged signals of the four axes in the constructor. It synchronizes the selectability of the axes. */ -void QCPColorScaleAxisRectPrivate::axisSelectableChanged( QCPAxis::SelectableParts selectableParts ) +void QCPColorScaleAxisRectPrivate::axisSelectableChanged(QCPAxis::SelectableParts selectableParts) { // synchronize axis base selectability: QList allAxisTypes = QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight; - foreach( QCPAxis::AxisType type, allAxisTypes ) + foreach (QCPAxis::AxisType type, allAxisTypes) { - if( QCPAxis* senderAxis = qobject_cast( sender() ) ) - if( senderAxis->axisType() == type ) + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) continue; - - if( axis( type )->selectableParts().testFlag( QCPAxis::spAxis ) ) + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) { - if( selectableParts.testFlag( QCPAxis::spAxis ) ) - axis( type )->setSelectableParts( axis( type )->selectableParts() | QCPAxis::spAxis ); + if (selectableParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectableParts(axis(type)->selectableParts() | QCPAxis::spAxis); else - axis( type )->setSelectableParts( axis( type )->selectableParts() & ~QCPAxis::spAxis ); + axis(type)->setSelectableParts(axis(type)->selectableParts() & ~QCPAxis::spAxis); } } } /* end of 'src/layoutelements/layoutelement-colorscale.cpp' */ + /* including file 'src/plottables/plottable-graph.cpp', size 73960 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -20163,19 +19976,22 @@ void QCPColorScaleAxisRectPrivate::axisSelectableChanged( QCPAxis::SelectablePar /*! Constructs a data point with key and value set to zero. */ -QCPGraphData::QCPGraphData() - : key( 0 ), value( 0 ) +QCPGraphData::QCPGraphData() : + key(0), + value(0) { } /*! Constructs a data point with the specified \a key and \a value. */ -QCPGraphData::QCPGraphData( double key, double value ) - : key( key ), value( value ) +QCPGraphData::QCPGraphData(double key, double value) : + key(key), + value(value) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPGraph //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -20241,19 +20057,19 @@ QCPGraphData::QCPGraphData( double key, double value ) To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function. */ -QCPGraph::QCPGraph( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable1D( keyAxis, valueAxis ) +QCPGraph::QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable1D(keyAxis, valueAxis) { // special handling for QCPGraphs to maintain the simple graph interface: - mParentPlot->registerGraph( this ); + mParentPlot->registerGraph(this); - setPen( QPen( Qt::blue, 0 ) ); - setBrush( Qt::NoBrush ); - - setLineStyle( lsLine ); - setScatterSkip( 0 ); - setChannelFillGraph( 0 ); - setAdaptiveSampling( true ); + setPen(QPen(Qt::blue, 0)); + setBrush(Qt::NoBrush); + + setLineStyle(lsLine); + setScatterSkip(0); + setChannelFillGraph(0); + setAdaptiveSampling(true); } QCPGraph::~QCPGraph() @@ -20275,7 +20091,7 @@ QCPGraph::~QCPGraph() \see addData */ -void QCPGraph::setData( QSharedPointer data ) +void QCPGraph::setData(QSharedPointer data) { mDataContainer = data; } @@ -20291,10 +20107,10 @@ void QCPGraph::setData( QSharedPointer data ) \see addData */ -void QCPGraph::setData( const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPGraph::setData(const QVector &keys, const QVector &values, bool alreadySorted) { mDataContainer->clear(); - addData( keys, values, alreadySorted ); + addData(keys, values, alreadySorted); } /*! @@ -20303,7 +20119,7 @@ void QCPGraph::setData( const QVector& keys, const QVector& valu \see setScatterStyle */ -void QCPGraph::setLineStyle( LineStyle ls ) +void QCPGraph::setLineStyle(LineStyle ls) { mLineStyle = ls; } @@ -20314,7 +20130,7 @@ void QCPGraph::setLineStyle( LineStyle ls ) \see QCPScatterStyle, setLineStyle */ -void QCPGraph::setScatterStyle( const QCPScatterStyle& style ) +void QCPGraph::setScatterStyle(const QCPScatterStyle &style) { mScatterStyle = style; } @@ -20330,9 +20146,9 @@ void QCPGraph::setScatterStyle( const QCPScatterStyle& style ) \see setScatterStyle */ -void QCPGraph::setScatterSkip( int skip ) +void QCPGraph::setScatterSkip(int skip) { - mScatterSkip = qMax( 0, skip ); + mScatterSkip = qMax(0, skip); } /*! @@ -20344,23 +20160,23 @@ void QCPGraph::setScatterSkip( int skip ) \see setBrush */ -void QCPGraph::setChannelFillGraph( QCPGraph* targetGraph ) +void QCPGraph::setChannelFillGraph(QCPGraph *targetGraph) { // prevent setting channel target to this graph itself: - if( targetGraph == this ) + if (targetGraph == this) { qDebug() << Q_FUNC_INFO << "targetGraph is this graph itself"; mChannelFillGraph = 0; return; } // prevent setting channel target to a graph not in the plot: - if( targetGraph && targetGraph->mParentPlot != mParentPlot ) + if (targetGraph && targetGraph->mParentPlot != mParentPlot) { qDebug() << Q_FUNC_INFO << "targetGraph not in same plot"; mChannelFillGraph = 0; return; } - + mChannelFillGraph = targetGraph; } @@ -20395,7 +20211,7 @@ void QCPGraph::setChannelFillGraph( QCPGraph* targetGraph ) enabled to false before issuing a command like \ref QCustomPlot::savePng, and setting \a enabled back to true afterwards. */ -void QCPGraph::setAdaptiveSampling( bool enabled ) +void QCPGraph::setAdaptiveSampling(bool enabled) { mAdaptiveSampling = enabled; } @@ -20412,23 +20228,23 @@ void QCPGraph::setAdaptiveSampling( bool enabled ) Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPGraph::addData( const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPGraph::addData(const QVector &keys, const QVector &values, bool alreadySorted) { - if( keys.size() != values.size() ) + if (keys.size() != values.size()) qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); - const int n = qMin( keys.size(), values.size() ); - QVector tempData( n ); + const int n = qMin(keys.size(), values.size()); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->key = keys[i]; it->value = values[i]; ++it; ++i; } - mDataContainer->add( tempData, alreadySorted ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -20438,153 +20254,144 @@ void QCPGraph::addData( const QVector& keys, const QVector& valu Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPGraph::addData( double key, double value ) +void QCPGraph::addData(double key, double value) { - mDataContainer->add( QCPGraphData( key, value ) ); + mDataContainer->add(QCPGraphData(key, value)); } /* inherits documentation from base class */ -double QCPGraph::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPGraph::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { QCPGraphDataContainer::const_iterator closestDataPoint = mDataContainer->constEnd(); - double result = pointDistance( pos, closestDataPoint ); - if( details ) + double result = pointDistance(pos, closestDataPoint); + if (details) { - int pointIndex = closestDataPoint - mDataContainer->constBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = closestDataPoint-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } return result; - } - else + } else return -1; } /* inherits documentation from base class */ -QCPRange QCPGraph::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPGraph::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { - return mDataContainer->keyRange( foundRange, inSignDomain ); + return mDataContainer->keyRange(foundRange, inSignDomain); } /* inherits documentation from base class */ -QCPRange QCPGraph::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPGraph::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - return mDataContainer->valueRange( foundRange, inSignDomain, inKeyRange ); + return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange); } /* inherits documentation from base class */ -void QCPGraph::draw( QCPPainter* painter ) +void QCPGraph::draw(QCPPainter *painter) { - if( !mKeyAxis || !mValueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - if( mKeyAxis.data()->range().size() <= 0 || mDataContainer->isEmpty() ) - return; - if( mLineStyle == lsNone && mScatterStyle.isNone() ) - return; - - QVector lines, scatters; // line and (if necessary) scatter pixel coordinates will be stored here while iterating over segments - + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mKeyAxis.data()->range().size() <= 0 || mDataContainer->isEmpty()) return; + if (mLineStyle == lsNone && mScatterStyle.isNone()) return; + + QVector lines, scatters; // line and (if necessary) scatter pixel coordinates will be stored here while iterating over segments + // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); // get line pixel points appropriate to line style: - QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at( i ) : allSegments.at( i ).adjusted( -1, 1 ); // unselected segments extend lines to bordering selected data point (safe to exceed total data bounds in first/last segment, getLines takes care) - getLines( &lines, lineDataRange ); - + QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).adjusted(-1, 1); // unselected segments extend lines to bordering selected data point (safe to exceed total data bounds in first/last segment, getLines takes care) + getLines(&lines, lineDataRange); + // check data validity if flag set: #ifdef QCUSTOMPLOT_CHECK_DATA QCPGraphDataContainer::const_iterator it; - for( it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it ) + for (it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it) { - if( QCP::isInvalidData( it->key, it->value ) ) - qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "invalid." - << "Plottable name:" << name(); + if (QCP::isInvalidData(it->key, it->value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "invalid." << "Plottable name:" << name(); } #endif - + // draw fill of graph: - if( isSelectedSegment && mSelectionDecorator ) - mSelectionDecorator->applyBrush( painter ); + if (isSelectedSegment && mSelectionDecorator) + mSelectionDecorator->applyBrush(painter); else - painter->setBrush( mBrush ); - painter->setPen( Qt::NoPen ); - drawFill( painter, &lines ); - + painter->setBrush(mBrush); + painter->setPen(Qt::NoPen); + drawFill(painter, &lines); + // draw line: - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { - if( isSelectedSegment && mSelectionDecorator ) - mSelectionDecorator->applyPen( painter ); + if (isSelectedSegment && mSelectionDecorator) + mSelectionDecorator->applyPen(painter); else - painter->setPen( mPen ); - painter->setBrush( Qt::NoBrush ); - if( mLineStyle == lsImpulse ) - drawImpulsePlot( painter, lines ); + painter->setPen(mPen); + painter->setBrush(Qt::NoBrush); + if (mLineStyle == lsImpulse) + drawImpulsePlot(painter, lines); else - drawLinePlot( painter, lines ); // also step plots can be drawn as a line plot + drawLinePlot(painter, lines); // also step plots can be drawn as a line plot } - + // draw scatters: QCPScatterStyle finalScatterStyle = mScatterStyle; - if( isSelectedSegment && mSelectionDecorator ) - finalScatterStyle = mSelectionDecorator->getFinalScatterStyle( mScatterStyle ); - if( !finalScatterStyle.isNone() ) + if (isSelectedSegment && mSelectionDecorator) + finalScatterStyle = mSelectionDecorator->getFinalScatterStyle(mScatterStyle); + if (!finalScatterStyle.isNone()) { - getScatters( &scatters, allSegments.at( i ) ); - drawScatterPlot( painter, scatters, finalScatterStyle ); + getScatters(&scatters, allSegments.at(i)); + drawScatterPlot(painter, scatters, finalScatterStyle); } } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPGraph::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { // draw fill: - if( mBrush.style() != Qt::NoBrush ) + if (mBrush.style() != Qt::NoBrush) { - applyFillAntialiasingHint( painter ); - painter->fillRect( QRectF( rect.left(), rect.top() + rect.height() / 2.0, rect.width(), rect.height() / 3.0 ), mBrush ); + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); } // draw line vertically centered: - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - painter->drawLine( QLineF( rect.left(), rect.top() + rect.height() / 2.0, rect.right() + 5, rect.top() + rect.height() / 2.0 ) ); // +5 on x2 else last segment is missing from dashed/dotted pens + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens } // draw scatter symbol: - if( !mScatterStyle.isNone() ) + if (!mScatterStyle.isNone()) { - applyScattersAntialiasingHint( painter ); + applyScattersAntialiasingHint(painter); // scale scatter pixmap if it's too large to fit in legend icon rect: - if( mScatterStyle.shape() == QCPScatterStyle::ssPixmap && ( mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height() ) ) + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) { - QCPScatterStyle scaledStyle( mScatterStyle ); - scaledStyle.setPixmap( scaledStyle.pixmap().scaled( rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); - scaledStyle.applyTo( painter, mPen ); - scaledStyle.drawShape( painter, QRectF( rect ).center() ); - } - else + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else { - mScatterStyle.applyTo( painter, mPen ); - mScatterStyle.drawShape( painter, QRectF( rect ).center() ); + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); } } } @@ -20609,45 +20416,32 @@ void QCPGraph::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const \see getScatters */ -void QCPGraph::getLines( QVector* lines, const QCPDataRange& dataRange ) const +void QCPGraph::getLines(QVector *lines, const QCPDataRange &dataRange) const { - if( !lines ) - return; + if (!lines) return; QCPGraphDataContainer::const_iterator begin, end; - getVisibleDataBounds( begin, end, dataRange ); - if( begin == end ) + getVisibleDataBounds(begin, end, dataRange); + if (begin == end) { lines->clear(); return; } - + QVector lineData; - if( mLineStyle != lsNone ) - getOptimizedLineData( &lineData, begin, end ); + if (mLineStyle != lsNone) + getOptimizedLineData(&lineData, begin, end); + + if (mKeyAxis->rangeReversed() != (mKeyAxis->orientation() == Qt::Vertical)) // make sure key pixels are sorted ascending in lineData (significantly simplifies following processing) + std::reverse(lineData.begin(), lineData.end()); - if( mKeyAxis->rangeReversed() != ( mKeyAxis->orientation() == Qt::Vertical ) ) // make sure key pixels are sorted ascending in lineData (significantly simplifies following processing) - std::reverse( lineData.begin(), lineData.end() ); - - switch( mLineStyle ) + switch (mLineStyle) { - case lsNone: - lines->clear(); - break; - case lsLine: - *lines = dataToLines( lineData ); - break; - case lsStepLeft: - *lines = dataToStepLeftLines( lineData ); - break; - case lsStepRight: - *lines = dataToStepRightLines( lineData ); - break; - case lsStepCenter: - *lines = dataToStepCenterLines( lineData ); - break; - case lsImpulse: - *lines = dataToImpulseLines( lineData ); - break; + case lsNone: lines->clear(); break; + case lsLine: *lines = dataToLines(lineData); break; + case lsStepLeft: *lines = dataToStepLeftLines(lineData); break; + case lsStepRight: *lines = dataToStepRightLines(lineData); break; + case lsStepCenter: *lines = dataToStepCenterLines(lineData); break; + case lsImpulse: *lines = dataToImpulseLines(lineData); break; } } @@ -20663,53 +20457,46 @@ void QCPGraph::getLines( QVector* lines, const QCPDataRange& dataRange function to check for valid indices in \a dataRange, e.g. when extending ranges coming from \ref getDataSegments. */ -void QCPGraph::getScatters( QVector* scatters, const QCPDataRange& dataRange ) const +void QCPGraph::getScatters(QVector *scatters, const QCPDataRange &dataRange) const { - if( !scatters ) - return; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - scatters->clear(); - return; - } - + if (!scatters) return; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; scatters->clear(); return; } + QCPGraphDataContainer::const_iterator begin, end; - getVisibleDataBounds( begin, end, dataRange ); - if( begin == end ) + getVisibleDataBounds(begin, end, dataRange); + if (begin == end) { scatters->clear(); return; } - + QVector data; - getOptimizedScatterData( &data, begin, end ); - - if( mKeyAxis->rangeReversed() != ( mKeyAxis->orientation() == Qt::Vertical ) ) // make sure key pixels are sorted ascending in data (significantly simplifies following processing) - std::reverse( data.begin(), data.end() ); - - scatters->resize( data.size() ); - if( keyAxis->orientation() == Qt::Vertical ) + getOptimizedScatterData(&data, begin, end); + + if (mKeyAxis->rangeReversed() != (mKeyAxis->orientation() == Qt::Vertical)) // make sure key pixels are sorted ascending in data (significantly simplifies following processing) + std::reverse(data.begin(), data.end()); + + scatters->resize(data.size()); + if (keyAxis->orientation() == Qt::Vertical) { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).value ) ); - ( *scatters )[i].setY( keyAxis->coordToPixel( data.at( i ).key ) ); + (*scatters)[i].setX(valueAxis->coordToPixel(data.at(i).value)); + (*scatters)[i].setY(keyAxis->coordToPixel(data.at(i).key)); } } - } - else + } else { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).key ) ); - ( *scatters )[i].setY( valueAxis->coordToPixel( data.at( i ).value ) ); + (*scatters)[i].setX(keyAxis->coordToPixel(data.at(i).key)); + (*scatters)[i].setY(valueAxis->coordToPixel(data.at(i).value)); } } } @@ -20725,34 +20512,29 @@ void QCPGraph::getScatters( QVector* scatters, const QCPDataRange& data \see dataToStepLeftLines, dataToStepRightLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot */ -QVector QCPGraph::dataToLines( const QVector& data ) const +QVector QCPGraph::dataToLines(const QVector &data) const { QVector result; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return result; - } - - result.resize( data.size() ); + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } + result.resize(data.size()); + // transform data points to pixels: - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).value ) ); - result[i].setY( keyAxis->coordToPixel( data.at( i ).key ) ); + result[i].setX(valueAxis->coordToPixel(data.at(i).value)); + result[i].setY(keyAxis->coordToPixel(data.at(i).key)); } - } - else // key axis is horizontal + } else // key axis is horizontal { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).key ) ); - result[i].setY( valueAxis->coordToPixel( data.at( i ).value ) ); + result[i].setX(keyAxis->coordToPixel(data.at(i).key)); + result[i].setY(valueAxis->coordToPixel(data.at(i).value)); } } return result; @@ -20768,44 +20550,39 @@ QVector QCPGraph::dataToLines( const QVector& data ) cons \see dataToLines, dataToStepRightLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot */ -QVector QCPGraph::dataToStepLeftLines( const QVector& data ) const +QVector QCPGraph::dataToStepLeftLines(const QVector &data) const { QVector result; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return result; - } - - result.resize( data.size() * 2 ); - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } + + result.resize(data.size()*2); + // calculate steps from data and transform to pixel coordinates: - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - double lastValue = valueAxis->coordToPixel( data.first().value ); - for( int i = 0; i < data.size(); ++i ) + double lastValue = valueAxis->coordToPixel(data.first().value); + for (int i=0; icoordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( lastValue ); - result[i * 2 + 0].setY( key ); - lastValue = valueAxis->coordToPixel( data.at( i ).value ); - result[i * 2 + 1].setX( lastValue ); - result[i * 2 + 1].setY( key ); + const double key = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(lastValue); + result[i*2+0].setY(key); + lastValue = valueAxis->coordToPixel(data.at(i).value); + result[i*2+1].setX(lastValue); + result[i*2+1].setY(key); } - } - else // key axis is horizontal + } else // key axis is horizontal { - double lastValue = valueAxis->coordToPixel( data.first().value ); - for( int i = 0; i < data.size(); ++i ) + double lastValue = valueAxis->coordToPixel(data.first().value); + for (int i=0; icoordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( key ); - result[i * 2 + 0].setY( lastValue ); - lastValue = valueAxis->coordToPixel( data.at( i ).value ); - result[i * 2 + 1].setX( key ); - result[i * 2 + 1].setY( lastValue ); + const double key = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(key); + result[i*2+0].setY(lastValue); + lastValue = valueAxis->coordToPixel(data.at(i).value); + result[i*2+1].setX(key); + result[i*2+1].setY(lastValue); } } return result; @@ -20821,44 +20598,39 @@ QVector QCPGraph::dataToStepLeftLines( const QVector& dat \see dataToLines, dataToStepLeftLines, dataToStepCenterLines, dataToImpulseLines, getLines, drawLinePlot */ -QVector QCPGraph::dataToStepRightLines( const QVector& data ) const +QVector QCPGraph::dataToStepRightLines(const QVector &data) const { QVector result; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return result; - } - - result.resize( data.size() * 2 ); - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } + + result.resize(data.size()*2); + // calculate steps from data and transform to pixel coordinates: - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - double lastKey = keyAxis->coordToPixel( data.first().key ); - for( int i = 0; i < data.size(); ++i ) + double lastKey = keyAxis->coordToPixel(data.first().key); + for (int i=0; icoordToPixel( data.at( i ).value ); - result[i * 2 + 0].setX( value ); - result[i * 2 + 0].setY( lastKey ); - lastKey = keyAxis->coordToPixel( data.at( i ).key ); - result[i * 2 + 1].setX( value ); - result[i * 2 + 1].setY( lastKey ); + const double value = valueAxis->coordToPixel(data.at(i).value); + result[i*2+0].setX(value); + result[i*2+0].setY(lastKey); + lastKey = keyAxis->coordToPixel(data.at(i).key); + result[i*2+1].setX(value); + result[i*2+1].setY(lastKey); } - } - else // key axis is horizontal + } else // key axis is horizontal { - double lastKey = keyAxis->coordToPixel( data.first().key ); - for( int i = 0; i < data.size(); ++i ) + double lastKey = keyAxis->coordToPixel(data.first().key); + for (int i=0; icoordToPixel( data.at( i ).value ); - result[i * 2 + 0].setX( lastKey ); - result[i * 2 + 0].setY( value ); - lastKey = keyAxis->coordToPixel( data.at( i ).key ); - result[i * 2 + 1].setX( lastKey ); - result[i * 2 + 1].setY( value ); + const double value = valueAxis->coordToPixel(data.at(i).value); + result[i*2+0].setX(lastKey); + result[i*2+0].setY(value); + lastKey = keyAxis->coordToPixel(data.at(i).key); + result[i*2+1].setX(lastKey); + result[i*2+1].setY(value); } } return result; @@ -20874,57 +20646,52 @@ QVector QCPGraph::dataToStepRightLines( const QVector& da \see dataToLines, dataToStepLeftLines, dataToStepRightLines, dataToImpulseLines, getLines, drawLinePlot */ -QVector QCPGraph::dataToStepCenterLines( const QVector& data ) const +QVector QCPGraph::dataToStepCenterLines(const QVector &data) const { QVector result; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return result; - } - - result.resize( data.size() * 2 ); - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } + + result.resize(data.size()*2); + // calculate steps from data and transform to pixel coordinates: - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - double lastKey = keyAxis->coordToPixel( data.first().key ); - double lastValue = valueAxis->coordToPixel( data.first().value ); - result[0].setX( lastValue ); - result[0].setY( lastKey ); - for( int i = 1; i < data.size(); ++i ) + double lastKey = keyAxis->coordToPixel(data.first().key); + double lastValue = valueAxis->coordToPixel(data.first().value); + result[0].setX(lastValue); + result[0].setY(lastKey); + for (int i=1; icoordToPixel( data.at( i ).key ) + lastKey ) * 0.5; - result[i * 2 - 1].setX( lastValue ); - result[i * 2 - 1].setY( key ); - lastValue = valueAxis->coordToPixel( data.at( i ).value ); - lastKey = keyAxis->coordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( lastValue ); - result[i * 2 + 0].setY( key ); + const double key = (keyAxis->coordToPixel(data.at(i).key)+lastKey)*0.5; + result[i*2-1].setX(lastValue); + result[i*2-1].setY(key); + lastValue = valueAxis->coordToPixel(data.at(i).value); + lastKey = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(lastValue); + result[i*2+0].setY(key); } - result[data.size() * 2 - 1].setX( lastValue ); - result[data.size() * 2 - 1].setY( lastKey ); - } - else // key axis is horizontal + result[data.size()*2-1].setX(lastValue); + result[data.size()*2-1].setY(lastKey); + } else // key axis is horizontal { - double lastKey = keyAxis->coordToPixel( data.first().key ); - double lastValue = valueAxis->coordToPixel( data.first().value ); - result[0].setX( lastKey ); - result[0].setY( lastValue ); - for( int i = 1; i < data.size(); ++i ) + double lastKey = keyAxis->coordToPixel(data.first().key); + double lastValue = valueAxis->coordToPixel(data.first().value); + result[0].setX(lastKey); + result[0].setY(lastValue); + for (int i=1; icoordToPixel( data.at( i ).key ) + lastKey ) * 0.5; - result[i * 2 - 1].setX( key ); - result[i * 2 - 1].setY( lastValue ); - lastValue = valueAxis->coordToPixel( data.at( i ).value ); - lastKey = keyAxis->coordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( key ); - result[i * 2 + 0].setY( lastValue ); + const double key = (keyAxis->coordToPixel(data.at(i).key)+lastKey)*0.5; + result[i*2-1].setX(key); + result[i*2-1].setY(lastValue); + lastValue = valueAxis->coordToPixel(data.at(i).value); + lastKey = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(key); + result[i*2+0].setY(lastValue); } - result[data.size() * 2 - 1].setX( lastKey ); - result[data.size() * 2 - 1].setY( lastValue ); + result[data.size()*2-1].setX(lastKey); + result[data.size()*2-1].setY(lastValue); } return result; } @@ -20939,40 +20706,35 @@ QVector QCPGraph::dataToStepCenterLines( const QVector& d \see dataToLines, dataToStepLeftLines, dataToStepRightLines, dataToStepCenterLines, getLines, drawImpulsePlot */ -QVector QCPGraph::dataToImpulseLines( const QVector& data ) const +QVector QCPGraph::dataToImpulseLines(const QVector &data) const { QVector result; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return result; - } - - result.resize( data.size() * 2 ); - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return result; } + + result.resize(data.size()*2); + // transform data points to pixels: - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( valueAxis->coordToPixel( 0 ) ); - result[i * 2 + 0].setY( key ); - result[i * 2 + 1].setX( valueAxis->coordToPixel( data.at( i ).value ) ); - result[i * 2 + 1].setY( key ); + const double key = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(valueAxis->coordToPixel(0)); + result[i*2+0].setY(key); + result[i*2+1].setX(valueAxis->coordToPixel(data.at(i).value)); + result[i*2+1].setY(key); } - } - else // key axis is horizontal + } else // key axis is horizontal { - for( int i = 0; i < data.size(); ++i ) + for (int i=0; icoordToPixel( data.at( i ).key ); - result[i * 2 + 0].setX( key ); - result[i * 2 + 0].setY( valueAxis->coordToPixel( 0 ) ); - result[i * 2 + 1].setX( key ); - result[i * 2 + 1].setY( valueAxis->coordToPixel( data.at( i ).value ) ); + const double key = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(key); + result[i*2+0].setY(valueAxis->coordToPixel(0)); + result[i*2+1].setX(key); + result[i*2+1].setY(valueAxis->coordToPixel(data.at(i).value)); } } return result; @@ -20995,32 +20757,29 @@ QVector QCPGraph::dataToImpulseLines( const QVector& data \see drawLinePlot, drawImpulsePlot, drawScatterPlot */ -void QCPGraph::drawFill( QCPPainter* painter, QVector* lines ) const +void QCPGraph::drawFill(QCPPainter *painter, QVector *lines) const { - if( mLineStyle == lsImpulse ) - return; // fill doesn't make sense for impulse plot - if( painter->brush().style() == Qt::NoBrush || painter->brush().color().alpha() == 0 ) - return; - - applyFillAntialiasingHint( painter ); - QVector segments = getNonNanSegments( lines, keyAxis()->orientation() ); - if( !mChannelFillGraph ) + if (mLineStyle == lsImpulse) return; // fill doesn't make sense for impulse plot + if (painter->brush().style() == Qt::NoBrush || painter->brush().color().alpha() == 0) return; + + applyFillAntialiasingHint(painter); + QVector segments = getNonNanSegments(lines, keyAxis()->orientation()); + if (!mChannelFillGraph) { // draw base fill under graph, fill goes all the way to the zero-value-line: - for( int i = 0; i < segments.size(); ++i ) - painter->drawPolygon( getFillPolygon( lines, segments.at( i ) ) ); - } - else + for (int i=0; idrawPolygon(getFillPolygon(lines, segments.at(i))); + } else { // draw fill between this graph and mChannelFillGraph: QVector otherLines; - mChannelFillGraph->getLines( &otherLines, QCPDataRange( 0, mChannelFillGraph->dataCount() ) ); - if( !otherLines.isEmpty() ) + mChannelFillGraph->getLines(&otherLines, QCPDataRange(0, mChannelFillGraph->dataCount())); + if (!otherLines.isEmpty()) { - QVector otherSegments = getNonNanSegments( &otherLines, mChannelFillGraph->keyAxis()->orientation() ); - QVector > segmentPairs = getOverlappingSegments( segments, lines, otherSegments, &otherLines ); - for( int i = 0; i < segmentPairs.size(); ++i ) - painter->drawPolygon( getChannelFillPolygon( lines, segmentPairs.at( i ).first, &otherLines, segmentPairs.at( i ).second ) ); + QVector otherSegments = getNonNanSegments(&otherLines, mChannelFillGraph->keyAxis()->orientation()); + QVector > segmentPairs = getOverlappingSegments(segments, lines, otherSegments, &otherLines); + for (int i=0; idrawPolygon(getChannelFillPolygon(lines, segmentPairs.at(i).first, &otherLines, segmentPairs.at(i).second)); } } } @@ -21032,12 +20791,12 @@ void QCPGraph::drawFill( QCPPainter* painter, QVector* lines ) const \see drawLinePlot, drawImpulsePlot */ -void QCPGraph::drawScatterPlot( QCPPainter* painter, const QVector& scatters, const QCPScatterStyle& style ) const +void QCPGraph::drawScatterPlot(QCPPainter *painter, const QVector &scatters, const QCPScatterStyle &style) const { - applyScattersAntialiasingHint( painter ); - style.applyTo( painter, mPen ); - for( int i = 0; i < scatters.size(); ++i ) - style.drawShape( painter, scatters.at( i ).x(), scatters.at( i ).y() ); + applyScattersAntialiasingHint(painter); + style.applyTo(painter, mPen); + for (int i=0; i& sca \see drawScatterPlot, drawImpulsePlot, QCPAbstractPlottable1D::drawPolyline */ -void QCPGraph::drawLinePlot( QCPPainter* painter, const QVector& lines ) const +void QCPGraph::drawLinePlot(QCPPainter *painter, const QVector &lines) const { - if( painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0 ) + if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0) { - applyDefaultAntialiasingHint( painter ); - drawPolyline( painter, lines ); + applyDefaultAntialiasingHint(painter); + drawPolyline(painter, lines); } } @@ -21063,17 +20822,17 @@ void QCPGraph::drawLinePlot( QCPPainter* painter, const QVector& lines \see drawLinePlot, drawScatterPlot */ -void QCPGraph::drawImpulsePlot( QCPPainter* painter, const QVector& lines ) const +void QCPGraph::drawImpulsePlot(QCPPainter *painter, const QVector &lines) const { - if( painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0 ) + if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0) { - applyDefaultAntialiasingHint( painter ); + applyDefaultAntialiasingHint(painter); QPen oldPen = painter->pen(); QPen newPen = painter->pen(); - newPen.setCapStyle( Qt::FlatCap ); // so impulse line doesn't reach beyond zero-line - painter->setPen( newPen ); - painter->drawLines( lines ); - painter->setPen( oldPen ); + newPen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line + painter->setPen(newPen); + painter->drawLines(lines); + painter->setPen(oldPen); } } @@ -21089,92 +20848,83 @@ void QCPGraph::drawImpulsePlot( QCPPainter* painter, const QVector& lin \see getOptimizedScatterData */ -void QCPGraph::getOptimizedLineData( QVector* lineData, const QCPGraphDataContainer::const_iterator& begin, const QCPGraphDataContainer::const_iterator& end ) const +void QCPGraph::getOptimizedLineData(QVector *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const { - if( !lineData ) - return; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - if( begin == end ) - return; - - int dataCount = end - begin; + if (!lineData) return; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (begin == end) return; + + int dataCount = end-begin; int maxCount = std::numeric_limits::max(); - if( mAdaptiveSampling ) + if (mAdaptiveSampling) { - double keyPixelSpan = qAbs( keyAxis->coordToPixel( begin->key ) - keyAxis->coordToPixel( ( end - 1 )->key ) ); - if( 2 * keyPixelSpan + 2 < (double)std::numeric_limits::max() ) - maxCount = 2 * keyPixelSpan + 2; + double keyPixelSpan = qAbs(keyAxis->coordToPixel(begin->key)-keyAxis->coordToPixel((end-1)->key)); + if (2*keyPixelSpan+2 < (double)std::numeric_limits::max()) + maxCount = 2*keyPixelSpan+2; } - - if( mAdaptiveSampling && dataCount >= maxCount ) // use adaptive sampling only if there are at least two points per pixel on average + + if (mAdaptiveSampling && dataCount >= maxCount) // use adaptive sampling only if there are at least two points per pixel on average { QCPGraphDataContainer::const_iterator it = begin; double minValue = it->value; double maxValue = it->value; QCPGraphDataContainer::const_iterator currentIntervalFirstPoint = it; - int reversedFactor = keyAxis->pixelOrientation(); // is used to calculate keyEpsilon pixel into the correct direction - int reversedRound = reversedFactor == -1 ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey - double currentIntervalStartKey = keyAxis->pixelToCoord( (int)( keyAxis->coordToPixel( begin->key ) + reversedRound ) ); + int reversedFactor = keyAxis->pixelOrientation(); // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = reversedFactor==-1 ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(begin->key)+reversedRound)); double lastIntervalEndKey = currentIntervalStartKey; - double keyEpsilon = qAbs( currentIntervalStartKey - keyAxis->pixelToCoord( keyAxis->coordToPixel( currentIntervalStartKey ) + 1.0 * reversedFactor ) ); // interval of one pixel on screen when mapped to plot key coordinates - bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) int intervalDataCount = 1; - ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect - while( it != end ) + ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect + while (it != end) { - if( it->key < currentIntervalStartKey + keyEpsilon ) // data point is still within same pixel, so skip it and expand value span of this cluster if necessary + if (it->key < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this cluster if necessary { - if( it->value < minValue ) + if (it->value < minValue) minValue = it->value; - else if( it->value > maxValue ) + else if (it->value > maxValue) maxValue = it->value; ++intervalDataCount; - } - else // new pixel interval started + } else // new pixel interval started { - if( intervalDataCount >= 2 ) // last pixel had multiple data points, consolidate them to a cluster + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster { - if( lastIntervalEndKey < currentIntervalStartKey - keyEpsilon ) // last point is further away, so first point of this cluster must be at a real data point - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.2, currentIntervalFirstPoint->value ) ); - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.25, minValue ) ); - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.75, maxValue ) ); - if( it->key > currentIntervalStartKey + keyEpsilon * 2 ) // new pixel started further away from previous cluster, so make sure the last point of the cluster is at a real data point - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.8, ( it - 1 )->value ) ); - } - else - lineData->append( QCPGraphData( currentIntervalFirstPoint->key, currentIntervalFirstPoint->value ) ); - lastIntervalEndKey = ( it - 1 )->key; + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point is further away, so first point of this cluster must be at a real data point + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value)); + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + if (it->key > currentIntervalStartKey+keyEpsilon*2) // new pixel started further away from previous cluster, so make sure the last point of the cluster is at a real data point + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.8, (it-1)->value)); + } else + lineData->append(QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value)); + lastIntervalEndKey = (it-1)->key; minValue = it->value; maxValue = it->value; currentIntervalFirstPoint = it; - currentIntervalStartKey = keyAxis->pixelToCoord( (int)( keyAxis->coordToPixel( it->key ) + reversedRound ) ); - if( keyEpsilonVariable ) - keyEpsilon = qAbs( currentIntervalStartKey - keyAxis->pixelToCoord( keyAxis->coordToPixel( currentIntervalStartKey ) + 1.0 * reversedFactor ) ); + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it->key)+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); intervalDataCount = 1; } ++it; } // handle last interval: - if( intervalDataCount >= 2 ) // last pixel had multiple data points, consolidate them to a cluster + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster { - if( lastIntervalEndKey < currentIntervalStartKey - keyEpsilon ) // last point wasn't a cluster, so first point of this cluster must be at a real data point - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.2, currentIntervalFirstPoint->value ) ); - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.25, minValue ) ); - lineData->append( QCPGraphData( currentIntervalStartKey + keyEpsilon * 0.75, maxValue ) ); - } - else - lineData->append( QCPGraphData( currentIntervalFirstPoint->key, currentIntervalFirstPoint->value ) ); - } - else // don't use adaptive sampling algorithm, transfer points one-to-one from the data container into the output + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point wasn't a cluster, so first point of this cluster must be at a real data point + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value)); + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + } else + lineData->append(QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value)); + + } else // don't use adaptive sampling algorithm, transfer points one-to-one from the data container into the output { - lineData->resize( dataCount ); - std::copy( begin, end, lineData->begin() ); + lineData->resize(dataCount); + std::copy(begin, end, lineData->begin()); } } @@ -21190,38 +20940,32 @@ void QCPGraph::getOptimizedLineData( QVector* lineData, const QCPG \see getOptimizedLineData */ -void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end ) const +void QCPGraph::getOptimizedScatterData(QVector *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const { - if( !scatterData ) - return; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - - const int scatterModulo = mScatterSkip + 1; + if (!scatterData) return; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + const int scatterModulo = mScatterSkip+1; const bool doScatterSkip = mScatterSkip > 0; - int beginIndex = begin - mDataContainer->constBegin(); - int endIndex = end - mDataContainer->constBegin(); - while( doScatterSkip && begin != end && beginIndex % scatterModulo != 0 ) // advance begin iterator to first non-skipped scatter + int beginIndex = begin-mDataContainer->constBegin(); + int endIndex = end-mDataContainer->constBegin(); + while (doScatterSkip && begin != end && beginIndex % scatterModulo != 0) // advance begin iterator to first non-skipped scatter { ++beginIndex; ++begin; } - if( begin == end ) - return; - int dataCount = end - begin; + if (begin == end) return; + int dataCount = end-begin; int maxCount = std::numeric_limits::max(); - if( mAdaptiveSampling ) + if (mAdaptiveSampling) { - int keyPixelSpan = qAbs( keyAxis->coordToPixel( begin->key ) - keyAxis->coordToPixel( ( end - 1 )->key ) ); - maxCount = 2 * keyPixelSpan + 2; + int keyPixelSpan = qAbs(keyAxis->coordToPixel(begin->key)-keyAxis->coordToPixel((end-1)->key)); + maxCount = 2*keyPixelSpan+2; } - - if( mAdaptiveSampling && dataCount >= maxCount ) // use adaptive sampling only if there are at least two points per pixel on average + + if (mAdaptiveSampling && dataCount >= maxCount) // use adaptive sampling only if there are at least two points per pixel on average { double valueMaxRange = valueAxis->range().upper; double valueMinRange = valueAxis->range().lower; @@ -21232,19 +20976,19 @@ void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPG QCPGraphDataContainer::const_iterator minValueIt = it; QCPGraphDataContainer::const_iterator maxValueIt = it; QCPGraphDataContainer::const_iterator currentIntervalStart = it; - int reversedFactor = keyAxis->pixelOrientation(); // is used to calculate keyEpsilon pixel into the correct direction - int reversedRound = reversedFactor == -1 ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey - double currentIntervalStartKey = keyAxis->pixelToCoord( (int)( keyAxis->coordToPixel( begin->key ) + reversedRound ) ); - double keyEpsilon = qAbs( currentIntervalStartKey - keyAxis->pixelToCoord( keyAxis->coordToPixel( currentIntervalStartKey ) + 1.0 * reversedFactor ) ); // interval of one pixel on screen when mapped to plot key coordinates - bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + int reversedFactor = keyAxis->pixelOrientation(); // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = reversedFactor==-1 ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(begin->key)+reversedRound)); + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) int intervalDataCount = 1; // advance iterator to second (non-skipped) data point because adaptive sampling works in 1 point retrospect: - if( !doScatterSkip ) + if (!doScatterSkip) ++it; else { itIndex += scatterModulo; - if( itIndex < endIndex ) // make sure we didn't jump over end + if (itIndex < endIndex) // make sure we didn't jump over end it += scatterModulo; else { @@ -21253,59 +20997,56 @@ void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPG } } // main loop over data points: - while( it != end ) + while (it != end) { - if( it->key < currentIntervalStartKey + keyEpsilon ) // data point is still within same pixel, so skip it and expand value span of this pixel if necessary + if (it->key < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this pixel if necessary { - if( it->value < minValue && it->value > valueMinRange && it->value < valueMaxRange ) + if (it->value < minValue && it->value > valueMinRange && it->value < valueMaxRange) { minValue = it->value; minValueIt = it; - } - else if( it->value > maxValue && it->value > valueMinRange && it->value < valueMaxRange ) + } else if (it->value > maxValue && it->value > valueMinRange && it->value < valueMaxRange) { maxValue = it->value; maxValueIt = it; } ++intervalDataCount; - } - else // new pixel started + } else // new pixel started { - if( intervalDataCount >= 2 ) // last pixel had multiple data points, consolidate them + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them { // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): - double valuePixelSpan = qAbs( valueAxis->coordToPixel( minValue ) - valueAxis->coordToPixel( maxValue ) ); - int dataModulo = qMax( 1, qRound( intervalDataCount / ( valuePixelSpan / 4.0 ) ) ); // approximately every 4 value pixels one data point on average + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average QCPGraphDataContainer::const_iterator intervalIt = currentIntervalStart; int c = 0; - while( intervalIt != it ) + while (intervalIt != it) { - if( ( c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt ) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange ) - scatterData->append( *intervalIt ); + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange) + scatterData->append(*intervalIt); ++c; - if( !doScatterSkip ) + if (!doScatterSkip) ++intervalIt; else - intervalIt += scatterModulo; // since we know indices of "currentIntervalStart", "intervalIt" and "it" are multiples of scatterModulo, we can't accidentally jump over "it" here + intervalIt += scatterModulo; // since we know indices of "currentIntervalStart", "intervalIt" and "it" are multiples of scatterModulo, we can't accidentally jump over "it" here } - } - else if( currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange ) - scatterData->append( *currentIntervalStart ); + } else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange) + scatterData->append(*currentIntervalStart); minValue = it->value; maxValue = it->value; currentIntervalStart = it; - currentIntervalStartKey = keyAxis->pixelToCoord( (int)( keyAxis->coordToPixel( it->key ) + reversedRound ) ); - if( keyEpsilonVariable ) - keyEpsilon = qAbs( currentIntervalStartKey - keyAxis->pixelToCoord( keyAxis->coordToPixel( currentIntervalStartKey ) + 1.0 * reversedFactor ) ); + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it->key)+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); intervalDataCount = 1; } // advance to next data point: - if( !doScatterSkip ) + if (!doScatterSkip) ++it; else { itIndex += scatterModulo; - if( itIndex < endIndex ) // make sure we didn't jump over end + if (itIndex < endIndex) // make sure we didn't jump over end it += scatterModulo; else { @@ -21315,25 +21056,25 @@ void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPG } } // handle last interval: - if( intervalDataCount >= 2 ) // last pixel had multiple data points, consolidate them + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them { // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): - double valuePixelSpan = qAbs( valueAxis->coordToPixel( minValue ) - valueAxis->coordToPixel( maxValue ) ); - int dataModulo = qMax( 1, qRound( intervalDataCount / ( valuePixelSpan / 4.0 ) ) ); // approximately every 4 value pixels one data point on average + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average QCPGraphDataContainer::const_iterator intervalIt = currentIntervalStart; - int intervalItIndex = intervalIt - mDataContainer->constBegin(); + int intervalItIndex = intervalIt-mDataContainer->constBegin(); int c = 0; - while( intervalIt != it ) + while (intervalIt != it) { - if( ( c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt ) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange ) - scatterData->append( *intervalIt ); + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange) + scatterData->append(*intervalIt); ++c; - if( !doScatterSkip ) + if (!doScatterSkip) ++intervalIt; - else // here we can't guarantee that adding scatterModulo doesn't exceed "it" (because "it" is equal to "end" here, and "end" isn't scatterModulo-aligned), so check via index comparison: + else // here we can't guarantee that adding scatterModulo doesn't exceed "it" (because "it" is equal to "end" here, and "end" isn't scatterModulo-aligned), so check via index comparison: { intervalItIndex += scatterModulo; - if( intervalItIndex < itIndex ) + if (intervalItIndex < itIndex) intervalIt += scatterModulo; else { @@ -21342,25 +21083,24 @@ void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPG } } } - } - else if( currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange ) - scatterData->append( *currentIntervalStart ); - } - else // don't use adaptive sampling algorithm, transfer points one-to-one from the data container into the output + } else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange) + scatterData->append(*currentIntervalStart); + + } else // don't use adaptive sampling algorithm, transfer points one-to-one from the data container into the output { QCPGraphDataContainer::const_iterator it = begin; int itIndex = beginIndex; - scatterData->reserve( dataCount ); - while( it != end ) + scatterData->reserve(dataCount); + while (it != end) { - scatterData->append( *it ); + scatterData->append(*it); // advance to next data point: - if( !doScatterSkip ) + if (!doScatterSkip) ++it; else { itIndex += scatterModulo; - if( itIndex < endIndex ) + if (itIndex < endIndex) it += scatterModulo; else { @@ -21381,27 +21121,22 @@ void QCPGraph::getOptimizedScatterData( QVector* scatterData, QCPG indicate a range that contains one additional data point to the left and right of the visible axis range. */ -void QCPGraph::getVisibleDataBounds( QCPGraphDataContainer::const_iterator& begin, QCPGraphDataContainer::const_iterator& end, const QCPDataRange& rangeRestriction ) const +void QCPGraph::getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const { - if( rangeRestriction.isEmpty() ) + if (rangeRestriction.isEmpty()) { end = mDataContainer->constEnd(); begin = end; - } - else + } else { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } // get visible data range: - begin = mDataContainer->findBegin( keyAxis->range().lower ); - end = mDataContainer->findEnd( keyAxis->range().upper ); + begin = mDataContainer->findBegin(keyAxis->range().lower); + end = mDataContainer->findEnd(keyAxis->range().upper); // limit lower/upperEnd to rangeRestriction: - mDataContainer->limitIteratorsToDataRange( begin, end, rangeRestriction ); // this also ensures rangeRestriction outside data bounds doesn't break anything + mDataContainer->limitIteratorsToDataRange(begin, end, rangeRestriction); // this also ensures rangeRestriction outside data bounds doesn't break anything } } @@ -21416,42 +21151,41 @@ void QCPGraph::getVisibleDataBounds( QCPGraphDataContainer::const_iterator& begi \see getOverlappingSegments, drawFill */ -QVector QCPGraph::getNonNanSegments( const QVector* lineData, Qt::Orientation keyOrientation ) const +QVector QCPGraph::getNonNanSegments(const QVector *lineData, Qt::Orientation keyOrientation) const { QVector result; const int n = lineData->size(); - - QCPDataRange currentSegment( -1, -1 ); + + QCPDataRange currentSegment(-1, -1); int i = 0; - - if( keyOrientation == Qt::Horizontal ) + + if (keyOrientation == Qt::Horizontal) { - while( i < n ) + while (i < n) { - while( i < n && qIsNaN( lineData->at( i ).y() ) ) // seek next non-NaN data point + while (i < n && qIsNaN(lineData->at(i).y())) // seek next non-NaN data point ++i; - if( i == n ) + if (i == n) break; - currentSegment.setBegin( i++ ); - while( i < n && !qIsNaN( lineData->at( i ).y() ) ) // seek next NaN data point or end of data + currentSegment.setBegin(i++); + while (i < n && !qIsNaN(lineData->at(i).y())) // seek next NaN data point or end of data ++i; - currentSegment.setEnd( i++ ); - result.append( currentSegment ); + currentSegment.setEnd(i++); + result.append(currentSegment); } - } - else // keyOrientation == Qt::Vertical + } else // keyOrientation == Qt::Vertical { - while( i < n ) + while (i < n) { - while( i < n && qIsNaN( lineData->at( i ).x() ) ) // seek next non-NaN data point + while (i < n && qIsNaN(lineData->at(i).x())) // seek next non-NaN data point ++i; - if( i == n ) + if (i == n) break; - currentSegment.setBegin( i++ ); - while( i < n && !qIsNaN( lineData->at( i ).x() ) ) // seek next NaN data point or end of data + currentSegment.setBegin(i++); + while (i < n && !qIsNaN(lineData->at(i).x())) // seek next NaN data point or end of data ++i; - currentSegment.setEnd( i++ ); - result.append( currentSegment ); + currentSegment.setEnd(i++); + result.append(currentSegment); } } return result; @@ -21475,53 +21209,52 @@ QVector QCPGraph::getNonNanSegments( const QVector* lineD \see getNonNanSegments, segmentsIntersect, drawFill, getChannelFillPolygon */ -QVector > QCPGraph::getOverlappingSegments( QVector thisSegments, const QVector* thisData, QVector otherSegments, const QVector* otherData ) const +QVector > QCPGraph::getOverlappingSegments(QVector thisSegments, const QVector *thisData, QVector otherSegments, const QVector *otherData) const { QVector > result; - if( thisData->isEmpty() || otherData->isEmpty() || thisSegments.isEmpty() || otherSegments.isEmpty() ) + if (thisData->isEmpty() || otherData->isEmpty() || thisSegments.isEmpty() || otherSegments.isEmpty()) return result; - + int thisIndex = 0; int otherIndex = 0; const bool verticalKey = mKeyAxis->orientation() == Qt::Vertical; - while( thisIndex < thisSegments.size() && otherIndex < otherSegments.size() ) + while (thisIndex < thisSegments.size() && otherIndex < otherSegments.size()) { - if( thisSegments.at( thisIndex ).size() < 2 ) // segments with fewer than two points won't have a fill anyhow + if (thisSegments.at(thisIndex).size() < 2) // segments with fewer than two points won't have a fill anyhow { ++thisIndex; continue; } - if( otherSegments.at( otherIndex ).size() < 2 ) // segments with fewer than two points won't have a fill anyhow + if (otherSegments.at(otherIndex).size() < 2) // segments with fewer than two points won't have a fill anyhow { ++otherIndex; continue; } double thisLower, thisUpper, otherLower, otherUpper; - if( !verticalKey ) + if (!verticalKey) { - thisLower = thisData->at( thisSegments.at( thisIndex ).begin() ).x(); - thisUpper = thisData->at( thisSegments.at( thisIndex ).end() - 1 ).x(); - otherLower = otherData->at( otherSegments.at( otherIndex ).begin() ).x(); - otherUpper = otherData->at( otherSegments.at( otherIndex ).end() - 1 ).x(); - } - else + thisLower = thisData->at(thisSegments.at(thisIndex).begin()).x(); + thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).x(); + otherLower = otherData->at(otherSegments.at(otherIndex).begin()).x(); + otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).x(); + } else { - thisLower = thisData->at( thisSegments.at( thisIndex ).begin() ).y(); - thisUpper = thisData->at( thisSegments.at( thisIndex ).end() - 1 ).y(); - otherLower = otherData->at( otherSegments.at( otherIndex ).begin() ).y(); - otherUpper = otherData->at( otherSegments.at( otherIndex ).end() - 1 ).y(); + thisLower = thisData->at(thisSegments.at(thisIndex).begin()).y(); + thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).y(); + otherLower = otherData->at(otherSegments.at(otherIndex).begin()).y(); + otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).y(); } - + int bPrecedence; - if( segmentsIntersect( thisLower, thisUpper, otherLower, otherUpper, bPrecedence ) ) - result.append( QPair( thisSegments.at( thisIndex ), otherSegments.at( otherIndex ) ) ); - - if( bPrecedence <= 0 ) // otherSegment doesn't reach as far as thisSegment, so continue with next otherSegment, keeping current thisSegment + if (segmentsIntersect(thisLower, thisUpper, otherLower, otherUpper, bPrecedence)) + result.append(QPair(thisSegments.at(thisIndex), otherSegments.at(otherIndex))); + + if (bPrecedence <= 0) // otherSegment doesn't reach as far as thisSegment, so continue with next otherSegment, keeping current thisSegment ++otherIndex; - else // otherSegment reaches further than thisSegment, so continue with next thisSegment, keeping current otherSegment + else // otherSegment reaches further than thisSegment, so continue with next thisSegment, keeping current otherSegment ++thisIndex; } - + return result; } @@ -21539,26 +21272,24 @@ QVector > QCPGraph::getOverlappingSegments( QV \see getOverlappingSegments */ -bool QCPGraph::segmentsIntersect( double aLower, double aUpper, double bLower, double bUpper, int& bPrecedence ) const +bool QCPGraph::segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const { bPrecedence = 0; - if( aLower > bUpper ) + if (aLower > bUpper) { bPrecedence = -1; return false; - } - else if( bLower > aUpper ) + } else if (bLower > aUpper) { bPrecedence = 1; return false; - } - else + } else { - if( aUpper > bUpper ) + if (aUpper > bUpper) bPrecedence = -1; - else if( aUpper < bUpper ) + else if (aUpper < bUpper) bPrecedence = 1; - + return true; } } @@ -21574,51 +21305,44 @@ bool QCPGraph::segmentsIntersect( double aLower, double aUpper, double bLower, d the key axis of this graph is horizontal or vertical, \a matchingDataPoint will provide the x or y value of the returned point, respectively. */ -QPointF QCPGraph::getFillBasePoint( QPointF matchingDataPoint ) const +QPointF QCPGraph::getFillBasePoint(QPointF matchingDataPoint) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QPointF(); - } - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + QPointF result; - if( valueAxis->scaleType() == QCPAxis::stLinear ) + if (valueAxis->scaleType() == QCPAxis::stLinear) { - if( keyAxis->orientation() == Qt::Horizontal ) + if (keyAxis->orientation() == Qt::Horizontal) { - result.setX( matchingDataPoint.x() ); - result.setY( valueAxis->coordToPixel( 0 ) ); - } - else // keyAxis->orientation() == Qt::Vertical + result.setX(matchingDataPoint.x()); + result.setY(valueAxis->coordToPixel(0)); + } else // keyAxis->orientation() == Qt::Vertical { - result.setX( valueAxis->coordToPixel( 0 ) ); - result.setY( matchingDataPoint.y() ); + result.setX(valueAxis->coordToPixel(0)); + result.setY(matchingDataPoint.y()); } - } - else // valueAxis->mScaleType == QCPAxis::stLogarithmic + } else // valueAxis->mScaleType == QCPAxis::stLogarithmic { // In logarithmic scaling we can't just draw to value 0 so we just fill all the way // to the axis which is in the direction towards 0 - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - if( ( valueAxis->range().upper < 0 && !valueAxis->rangeReversed() ) || - ( valueAxis->range().upper > 0 && valueAxis->rangeReversed() ) ) // if range is negative, zero is on opposite side of key axis - result.setX( keyAxis->axisRect()->right() ); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + result.setX(keyAxis->axisRect()->right()); else - result.setX( keyAxis->axisRect()->left() ); - result.setY( matchingDataPoint.y() ); - } - else if( keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom ) + result.setX(keyAxis->axisRect()->left()); + result.setY(matchingDataPoint.y()); + } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) { - result.setX( matchingDataPoint.x() ); - if( ( valueAxis->range().upper < 0 && !valueAxis->rangeReversed() ) || - ( valueAxis->range().upper > 0 && valueAxis->rangeReversed() ) ) // if range is negative, zero is on opposite side of key axis - result.setY( keyAxis->axisRect()->top() ); + result.setX(matchingDataPoint.x()); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + result.setY(keyAxis->axisRect()->top()); else - result.setY( keyAxis->axisRect()->bottom() ); + result.setY(keyAxis->axisRect()->bottom()); } } return result; @@ -21640,16 +21364,16 @@ QPointF QCPGraph::getFillBasePoint( QPointF matchingDataPoint ) const \see drawFill, getNonNanSegments */ -const QPolygonF QCPGraph::getFillPolygon( const QVector* lineData, QCPDataRange segment ) const +const QPolygonF QCPGraph::getFillPolygon(const QVector *lineData, QCPDataRange segment) const { - if( segment.size() < 2 ) + if (segment.size() < 2) return QPolygonF(); - QPolygonF result( segment.size() + 2 ); - - result[0] = getFillBasePoint( lineData->at( segment.begin() ) ); - std::copy( lineData->constBegin() + segment.begin(), lineData->constBegin() + segment.end(), result.begin() + 1 ); - result[result.size() - 1] = getFillBasePoint( lineData->at( segment.end() - 1 ) ); - + QPolygonF result(segment.size()+2); + + result[0] = getFillBasePoint(lineData->at(segment.begin())); + std::copy(lineData->constBegin()+segment.begin(), lineData->constBegin()+segment.end(), result.begin()+1); + result[result.size()-1] = getFillBasePoint(lineData->at(segment.end()-1)); + return result; } @@ -21671,121 +21395,103 @@ const QPolygonF QCPGraph::getFillPolygon( const QVector* lineData, QCPD \see drawFill, getOverlappingSegments, getNonNanSegments */ -const QPolygonF QCPGraph::getChannelFillPolygon( const QVector* thisData, QCPDataRange thisSegment, const QVector* otherData, QCPDataRange otherSegment ) const +const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *thisData, QCPDataRange thisSegment, const QVector *otherData, QCPDataRange otherSegment) const { - if( !mChannelFillGraph ) + if (!mChannelFillGraph) return QPolygonF(); - - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QPolygonF(); - } - if( !mChannelFillGraph.data()->mKeyAxis ) - { - qDebug() << Q_FUNC_INFO << "channel fill target key axis invalid"; - return QPolygonF(); - } - - if( mChannelFillGraph.data()->mKeyAxis.data()->orientation() != keyAxis->orientation() ) - return QPolygonF(); // don't have same axis orientation, can't fill that (Note: if keyAxis fits, valueAxis will fit too, because it's always orthogonal to keyAxis) - - if( thisData->isEmpty() ) - return QPolygonF(); - QVector thisSegmentData( thisSegment.size() ); - QVector otherSegmentData( otherSegment.size() ); - std::copy( thisData->constBegin() + thisSegment.begin(), thisData->constBegin() + thisSegment.end(), thisSegmentData.begin() ); - std::copy( otherData->constBegin() + otherSegment.begin(), otherData->constBegin() + otherSegment.end(), otherSegmentData.begin() ); + + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPolygonF(); } + if (!mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO << "channel fill target key axis invalid"; return QPolygonF(); } + + if (mChannelFillGraph.data()->mKeyAxis.data()->orientation() != keyAxis->orientation()) + return QPolygonF(); // don't have same axis orientation, can't fill that (Note: if keyAxis fits, valueAxis will fit too, because it's always orthogonal to keyAxis) + + if (thisData->isEmpty()) return QPolygonF(); + QVector thisSegmentData(thisSegment.size()); + QVector otherSegmentData(otherSegment.size()); + std::copy(thisData->constBegin()+thisSegment.begin(), thisData->constBegin()+thisSegment.end(), thisSegmentData.begin()); + std::copy(otherData->constBegin()+otherSegment.begin(), otherData->constBegin()+otherSegment.end(), otherSegmentData.begin()); // pointers to be able to swap them, depending which data range needs cropping: - QVector* staticData = &thisSegmentData; - QVector* croppedData = &otherSegmentData; - + QVector *staticData = &thisSegmentData; + QVector *croppedData = &otherSegmentData; + // crop both vectors to ranges in which the keys overlap (which coord is key, depends on axisType): - if( keyAxis->orientation() == Qt::Horizontal ) + if (keyAxis->orientation() == Qt::Horizontal) { // x is key // crop lower bound: - if( staticData->first().x() < croppedData->first().x() ) // other one must be cropped - qSwap( staticData, croppedData ); - const int lowBound = findIndexBelowX( croppedData, staticData->first().x() ); - if( lowBound == -1 ) - return QPolygonF(); // key ranges have no overlap - croppedData->remove( 0, lowBound ); + if (staticData->first().x() < croppedData->first().x()) // other one must be cropped + qSwap(staticData, croppedData); + const int lowBound = findIndexBelowX(croppedData, staticData->first().x()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); // set lowest point of cropped data to fit exactly key position of first static data point via linear interpolation: - if( croppedData->size() < 2 ) - return QPolygonF(); // need at least two points for interpolation + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation double slope; - if( !qFuzzyCompare( croppedData->at( 1 ).x(), croppedData->at( 0 ).x() ) ) - slope = ( croppedData->at( 1 ).y() - croppedData->at( 0 ).y() ) / ( croppedData->at( 1 ).x() - croppedData->at( 0 ).x() ); + if (!qFuzzyCompare(croppedData->at(1).x(), croppedData->at(0).x())) + slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x()); else slope = 0; - ( *croppedData )[0].setY( croppedData->at( 0 ).y() + slope * ( staticData->first().x() - croppedData->at( 0 ).x() ) ); - ( *croppedData )[0].setX( staticData->first().x() ); - + (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x())); + (*croppedData)[0].setX(staticData->first().x()); + // crop upper bound: - if( staticData->last().x() > croppedData->last().x() ) // other one must be cropped - qSwap( staticData, croppedData ); - int highBound = findIndexAboveX( croppedData, staticData->last().x() ); - if( highBound == -1 ) - return QPolygonF(); // key ranges have no overlap - croppedData->remove( highBound + 1, croppedData->size() - ( highBound + 1 ) ); + if (staticData->last().x() > croppedData->last().x()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexAboveX(croppedData, staticData->last().x()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); // set highest point of cropped data to fit exactly key position of last static data point via linear interpolation: - if( croppedData->size() < 2 ) - return QPolygonF(); // need at least two points for interpolation - const int li = croppedData->size() - 1; // last index - if( !qFuzzyCompare( croppedData->at( li ).x(), croppedData->at( li - 1 ).x() ) ) - slope = ( croppedData->at( li ).y() - croppedData->at( li - 1 ).y() ) / ( croppedData->at( li ).x() - croppedData->at( li - 1 ).x() ); + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + const int li = croppedData->size()-1; // last index + if (!qFuzzyCompare(croppedData->at(li).x(), croppedData->at(li-1).x())) + slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x()); else slope = 0; - ( *croppedData )[li].setY( croppedData->at( li - 1 ).y() + slope * ( staticData->last().x() - croppedData->at( li - 1 ).x() ) ); - ( *croppedData )[li].setX( staticData->last().x() ); - } - else // mKeyAxis->orientation() == Qt::Vertical + (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x())); + (*croppedData)[li].setX(staticData->last().x()); + } else // mKeyAxis->orientation() == Qt::Vertical { // y is key // crop lower bound: - if( staticData->first().y() < croppedData->first().y() ) // other one must be cropped - qSwap( staticData, croppedData ); - int lowBound = findIndexBelowY( croppedData, staticData->first().y() ); - if( lowBound == -1 ) - return QPolygonF(); // key ranges have no overlap - croppedData->remove( 0, lowBound ); + if (staticData->first().y() < croppedData->first().y()) // other one must be cropped + qSwap(staticData, croppedData); + int lowBound = findIndexBelowY(croppedData, staticData->first().y()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); // set lowest point of cropped data to fit exactly key position of first static data point via linear interpolation: - if( croppedData->size() < 2 ) - return QPolygonF(); // need at least two points for interpolation + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation double slope; - if( !qFuzzyCompare( croppedData->at( 1 ).y(), croppedData->at( 0 ).y() ) ) // avoid division by zero in step plots - slope = ( croppedData->at( 1 ).x() - croppedData->at( 0 ).x() ) / ( croppedData->at( 1 ).y() - croppedData->at( 0 ).y() ); + if (!qFuzzyCompare(croppedData->at(1).y(), croppedData->at(0).y())) // avoid division by zero in step plots + slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y()); else slope = 0; - ( *croppedData )[0].setX( croppedData->at( 0 ).x() + slope * ( staticData->first().y() - croppedData->at( 0 ).y() ) ); - ( *croppedData )[0].setY( staticData->first().y() ); - + (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y())); + (*croppedData)[0].setY(staticData->first().y()); + // crop upper bound: - if( staticData->last().y() > croppedData->last().y() ) // other one must be cropped - qSwap( staticData, croppedData ); - int highBound = findIndexAboveY( croppedData, staticData->last().y() ); - if( highBound == -1 ) - return QPolygonF(); // key ranges have no overlap - croppedData->remove( highBound + 1, croppedData->size() - ( highBound + 1 ) ); + if (staticData->last().y() > croppedData->last().y()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexAboveY(croppedData, staticData->last().y()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); // set highest point of cropped data to fit exactly key position of last static data point via linear interpolation: - if( croppedData->size() < 2 ) - return QPolygonF(); // need at least two points for interpolation - int li = croppedData->size() - 1; // last index - if( !qFuzzyCompare( croppedData->at( li ).y(), croppedData->at( li - 1 ).y() ) ) // avoid division by zero in step plots - slope = ( croppedData->at( li ).x() - croppedData->at( li - 1 ).x() ) / ( croppedData->at( li ).y() - croppedData->at( li - 1 ).y() ); + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + int li = croppedData->size()-1; // last index + if (!qFuzzyCompare(croppedData->at(li).y(), croppedData->at(li-1).y())) // avoid division by zero in step plots + slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y()); else slope = 0; - ( *croppedData )[li].setX( croppedData->at( li - 1 ).x() + slope * ( staticData->last().y() - croppedData->at( li - 1 ).y() ) ); - ( *croppedData )[li].setY( staticData->last().y() ); + (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y())); + (*croppedData)[li].setY(staticData->last().y()); } - + // return joined: - for( int i = otherSegmentData.size() - 1; i >= 0; --i ) // insert reversed, otherwise the polygon will be twisted - thisSegmentData << otherSegmentData.at( i ); - return QPolygonF( thisSegmentData ); + for (int i=otherSegmentData.size()-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted + thisSegmentData << otherSegmentData.at(i); + return QPolygonF(thisSegmentData); } /*! \internal @@ -21796,16 +21502,16 @@ const QPolygonF QCPGraph::getChannelFillPolygon( const QVector* thisDat Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. */ -int QCPGraph::findIndexAboveX( const QVector* data, double x ) const +int QCPGraph::findIndexAboveX(const QVector *data, double x) const { - for( int i = data->size() - 1; i >= 0; --i ) + for (int i=data->size()-1; i>=0; --i) { - if( data->at( i ).x() < x ) + if (data->at(i).x() < x) { - if( i < data->size() - 1 ) - return i + 1; + if (isize()-1) + return i+1; else - return data->size() - 1; + return data->size()-1; } } return -1; @@ -21819,14 +21525,14 @@ int QCPGraph::findIndexAboveX( const QVector* data, double x ) const Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. */ -int QCPGraph::findIndexBelowX( const QVector* data, double x ) const +int QCPGraph::findIndexBelowX(const QVector *data, double x) const { - for( int i = 0; i < data->size(); ++i ) + for (int i=0; isize(); ++i) { - if( data->at( i ).x() > x ) + if (data->at(i).x() > x) { - if( i > 0 ) - return i - 1; + if (i>0) + return i-1; else return 0; } @@ -21842,16 +21548,16 @@ int QCPGraph::findIndexBelowX( const QVector* data, double x ) const Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. */ -int QCPGraph::findIndexAboveY( const QVector* data, double y ) const +int QCPGraph::findIndexAboveY(const QVector *data, double y) const { - for( int i = data->size() - 1; i >= 0; --i ) + for (int i=data->size()-1; i>=0; --i) { - if( data->at( i ).y() < y ) + if (data->at(i).y() < y) { - if( i < data->size() - 1 ) - return i + 1; + if (isize()-1) + return i+1; else - return data->size() - 1; + return data->size()-1; } } return -1; @@ -21868,52 +21574,52 @@ int QCPGraph::findIndexAboveY( const QVector* data, double y ) const If either the graph has no data or if the line style is \ref lsNone and the scatter style's shape is \ref QCPScatterStyle::ssNone (i.e. there is no visual representation of the graph), returns -1.0. */ -double QCPGraph::pointDistance( const QPointF& pixelPoint, QCPGraphDataContainer::const_iterator& closestData ) const +double QCPGraph::pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const { closestData = mDataContainer->constEnd(); - if( mDataContainer->isEmpty() ) + if (mDataContainer->isEmpty()) return -1.0; - if( mLineStyle == lsNone && mScatterStyle.isNone() ) + if (mLineStyle == lsNone && mScatterStyle.isNone()) return -1.0; - + // calculate minimum distances to graph data points and find closestData iterator: double minDistSqr = std::numeric_limits::max(); // determine which key range comes into question, taking selection tolerance around pos into account: double posKeyMin, posKeyMax, dummy; - pixelsToCoords( pixelPoint - QPointF( mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance() ), posKeyMin, dummy ); - pixelsToCoords( pixelPoint + QPointF( mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance() ), posKeyMax, dummy ); - if( posKeyMin > posKeyMax ) - qSwap( posKeyMin, posKeyMax ); + pixelsToCoords(pixelPoint-QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMin, dummy); + pixelsToCoords(pixelPoint+QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMax, dummy); + if (posKeyMin > posKeyMax) + qSwap(posKeyMin, posKeyMax); // iterate over found data points and then choose the one with the shortest distance to pos: - QCPGraphDataContainer::const_iterator begin = mDataContainer->findBegin( posKeyMin, true ); - QCPGraphDataContainer::const_iterator end = mDataContainer->findEnd( posKeyMax, true ); - for( QCPGraphDataContainer::const_iterator it = begin; it != end; ++it ) + QCPGraphDataContainer::const_iterator begin = mDataContainer->findBegin(posKeyMin, true); + QCPGraphDataContainer::const_iterator end = mDataContainer->findEnd(posKeyMax, true); + for (QCPGraphDataContainer::const_iterator it=begin; it!=end; ++it) { - const double currentDistSqr = QCPVector2D( coordsToPixels( it->key, it->value ) - pixelPoint ).lengthSquared(); - if( currentDistSqr < minDistSqr ) + const double currentDistSqr = QCPVector2D(coordsToPixels(it->key, it->value)-pixelPoint).lengthSquared(); + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; closestData = it; } } - + // calculate distance to graph line if there is one (if so, will probably be smaller than distance to closest data point): - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { // line displayed, calculate distance to line segments: QVector lineData; - getLines( &lineData, QCPDataRange( 0, dataCount() ) ); - QCPVector2D p( pixelPoint ); - const int step = mLineStyle == lsImpulse ? 2 : 1; // impulse plot differs from other line styles in that the lineData points are only pairwise connected - for( int i = 0; i < lineData.size() - 1; i += step ) + getLines(&lineData, QCPDataRange(0, dataCount())); + QCPVector2D p(pixelPoint); + const int step = mLineStyle==lsImpulse ? 2 : 1; // impulse plot differs from other line styles in that the lineData points are only pairwise connected + for (int i=0; i* data, double y ) const +int QCPGraph::findIndexBelowY(const QVector *data, double y) const { - for( int i = 0; i < data->size(); ++i ) + for (int i=0; isize(); ++i) { - if( data->at( i ).y() > y ) + if (data->at(i).y() > y) { - if( i > 0 ) - return i - 1; + if (i>0) + return i-1; else return 0; } @@ -21940,6 +21646,7 @@ int QCPGraph::findIndexBelowY( const QVector* data, double y ) const } /* end of 'src/plottables/plottable-graph.cpp' */ + /* including file 'src/plottables/plottable-curve.cpp', size 63527 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -22019,19 +21726,24 @@ int QCPGraph::findIndexBelowY( const QVector* data, double y ) const /*! Constructs a curve data point with t, key and value set to zero. */ -QCPCurveData::QCPCurveData() - : t( 0 ), key( 0 ), value( 0 ) +QCPCurveData::QCPCurveData() : + t(0), + key(0), + value(0) { } /*! Constructs a curve data point with the specified \a t, \a key and \a value. */ -QCPCurveData::QCPCurveData( double t, double key, double value ) - : t( t ), key( key ), value( value ) +QCPCurveData::QCPCurveData(double t, double key, double value) : + t(t), + key(key), + value(value) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPCurve //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -22093,16 +21805,16 @@ QCPCurveData::QCPCurveData( double t, double key, double value ) keyAxis. This QCustomPlot instance takes ownership of the QCPCurve, so do not delete it manually but use QCustomPlot::removePlottable() instead. */ -QCPCurve::QCPCurve( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable1D( keyAxis, valueAxis ) +QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable1D(keyAxis, valueAxis) { // modify inherited properties from abstract plottable: - setPen( QPen( Qt::blue, 0 ) ); - setBrush( Qt::NoBrush ); - - setScatterStyle( QCPScatterStyle() ); - setLineStyle( lsLine ); - setScatterSkip( 0 ); + setPen(QPen(Qt::blue, 0)); + setBrush(Qt::NoBrush); + + setScatterStyle(QCPScatterStyle()); + setLineStyle(lsLine); + setScatterSkip(0); } QCPCurve::~QCPCurve() @@ -22124,7 +21836,7 @@ QCPCurve::~QCPCurve() \see addData */ -void QCPCurve::setData( QSharedPointer data ) +void QCPCurve::setData(QSharedPointer data) { mDataContainer = data; } @@ -22140,12 +21852,13 @@ void QCPCurve::setData( QSharedPointer data ) \see addData */ -void QCPCurve::setData( const QVector& t, const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPCurve::setData(const QVector &t, const QVector &keys, const QVector &values, bool alreadySorted) { mDataContainer->clear(); - addData( t, keys, values, alreadySorted ); + addData(t, keys, values, alreadySorted); } + /*! \overload Replaces the current data with the provided points in \a keys and \a values. The provided vectors @@ -22157,10 +21870,10 @@ void QCPCurve::setData( const QVector& t, const QVector& keys, c \see addData */ -void QCPCurve::setData( const QVector& keys, const QVector& values ) +void QCPCurve::setData(const QVector &keys, const QVector &values) { mDataContainer->clear(); - addData( keys, values ); + addData(keys, values); } /*! @@ -22170,7 +21883,7 @@ void QCPCurve::setData( const QVector& keys, const QVector& valu \see QCPScatterStyle, setLineStyle */ -void QCPCurve::setScatterStyle( const QCPScatterStyle& style ) +void QCPCurve::setScatterStyle(const QCPScatterStyle &style) { mScatterStyle = style; } @@ -22186,9 +21899,9 @@ void QCPCurve::setScatterStyle( const QCPScatterStyle& style ) \see setScatterStyle */ -void QCPCurve::setScatterSkip( int skip ) +void QCPCurve::setScatterSkip(int skip) { - mScatterSkip = qMax( 0, skip ); + mScatterSkip = qMax(0, skip); } /*! @@ -22198,7 +21911,7 @@ void QCPCurve::setScatterSkip( int skip ) \see setScatterStyle */ -void QCPCurve::setLineStyle( QCPCurve::LineStyle style ) +void QCPCurve::setLineStyle(QCPCurve::LineStyle style) { mLineStyle = style; } @@ -22215,16 +21928,16 @@ void QCPCurve::setLineStyle( QCPCurve::LineStyle style ) Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPCurve::addData( const QVector& t, const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPCurve::addData(const QVector &t, const QVector &keys, const QVector &values, bool alreadySorted) { - if( t.size() != keys.size() || t.size() != values.size() ) + if (t.size() != keys.size() || t.size() != values.size()) qDebug() << Q_FUNC_INFO << "ts, keys and values have different sizes:" << t.size() << keys.size() << values.size(); - const int n = qMin( qMin( t.size(), keys.size() ), values.size() ); - QVector tempData( n ); + const int n = qMin(qMin(t.size(), keys.size()), values.size()); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->t = t[i]; it->key = keys[i]; @@ -22232,7 +21945,7 @@ void QCPCurve::addData( const QVector& t, const QVector& keys, c ++it; ++i; } - mDataContainer->add( tempData, alreadySorted ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -22247,21 +21960,21 @@ void QCPCurve::addData( const QVector& t, const QVector& keys, c Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPCurve::addData( const QVector& keys, const QVector& values ) +void QCPCurve::addData(const QVector &keys, const QVector &values) { - if( keys.size() != values.size() ) + if (keys.size() != values.size()) qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); - const int n = qMin( keys.size(), values.size() ); + const int n = qMin(keys.size(), values.size()); double tStart; - if( !mDataContainer->isEmpty() ) - tStart = ( mDataContainer->constEnd() - 1 )->t + 1.0; + if (!mDataContainer->isEmpty()) + tStart = (mDataContainer->constEnd()-1)->t + 1.0; else tStart = 0; - QVector tempData( n ); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->t = tStart + i; it->key = keys[i]; @@ -22269,7 +21982,7 @@ void QCPCurve::addData( const QVector& keys, const QVector& valu ++it; ++i; } - mDataContainer->add( tempData, true ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, true); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -22278,9 +21991,9 @@ void QCPCurve::addData( const QVector& keys, const QVector& valu Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPCurve::addData( double t, double key, double value ) +void QCPCurve::addData(double t, double key, double value) { - mDataContainer->add( QCPCurveData( t, key, value ) ); + mDataContainer->add(QCPCurveData(t, key, value)); } /*! \overload @@ -22293,151 +22006,147 @@ void QCPCurve::addData( double t, double key, double value ) Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPCurve::addData( double key, double value ) +void QCPCurve::addData(double key, double value) { - if( !mDataContainer->isEmpty() ) - mDataContainer->add( QCPCurveData( ( mDataContainer->constEnd() - 1 )->t + 1.0, key, value ) ); + if (!mDataContainer->isEmpty()) + mDataContainer->add(QCPCurveData((mDataContainer->constEnd()-1)->t + 1.0, key, value)); else - mDataContainer->add( QCPCurveData( 0.0, key, value ) ); + mDataContainer->add(QCPCurveData(0.0, key, value)); } /* inherits documentation from base class */ -double QCPCurve::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { QCPCurveDataContainer::const_iterator closestDataPoint = mDataContainer->constEnd(); - double result = pointDistance( pos, closestDataPoint ); - if( details ) + double result = pointDistance(pos, closestDataPoint); + if (details) { - int pointIndex = closestDataPoint - mDataContainer->constBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = closestDataPoint-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } return result; - } - else + } else return -1; } /* inherits documentation from base class */ -QCPRange QCPCurve::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPCurve::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { - return mDataContainer->keyRange( foundRange, inSignDomain ); + return mDataContainer->keyRange(foundRange, inSignDomain); } /* inherits documentation from base class */ -QCPRange QCPCurve::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPCurve::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - return mDataContainer->valueRange( foundRange, inSignDomain, inKeyRange ); + return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange); } /* inherits documentation from base class */ -void QCPCurve::draw( QCPPainter* painter ) +void QCPCurve::draw(QCPPainter *painter) { - if( mDataContainer->isEmpty() ) - return; - + if (mDataContainer->isEmpty()) return; + // allocate line vector: QVector lines, scatters; - + // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); - + // fill with curve data: - QPen finalCurvePen = mPen; // determine the final pen already here, because the line optimization depends on its stroke width - if( isSelectedSegment && mSelectionDecorator ) + QPen finalCurvePen = mPen; // determine the final pen already here, because the line optimization depends on its stroke width + if (isSelectedSegment && mSelectionDecorator) finalCurvePen = mSelectionDecorator->pen(); - - QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at( i ) : allSegments.at( i ).adjusted( -1, 1 ); // unselected segments extend lines to bordering selected data point (safe to exceed total data bounds in first/last segment, getCurveLines takes care) - getCurveLines( &lines, lineDataRange, finalCurvePen.widthF() ); - + + QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).adjusted(-1, 1); // unselected segments extend lines to bordering selected data point (safe to exceed total data bounds in first/last segment, getCurveLines takes care) + getCurveLines(&lines, lineDataRange, finalCurvePen.widthF()); + // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - for( QCPCurveDataContainer::const_iterator it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it ) + #ifdef QCUSTOMPLOT_CHECK_DATA + for (QCPCurveDataContainer::const_iterator it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it) { - if( QCP::isInvalidData( it->t ) || - QCP::isInvalidData( it->key, it->value ) ) - qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "invalid." - << "Plottable name:" << name(); + if (QCP::isInvalidData(it->t) || + QCP::isInvalidData(it->key, it->value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "invalid." << "Plottable name:" << name(); } -#endif - + #endif + // draw curve fill: - applyFillAntialiasingHint( painter ); - if( isSelectedSegment && mSelectionDecorator ) - mSelectionDecorator->applyBrush( painter ); + applyFillAntialiasingHint(painter); + if (isSelectedSegment && mSelectionDecorator) + mSelectionDecorator->applyBrush(painter); else - painter->setBrush( mBrush ); - painter->setPen( Qt::NoPen ); - if( painter->brush().style() != Qt::NoBrush && painter->brush().color().alpha() != 0 ) - painter->drawPolygon( QPolygonF( lines ) ); - + painter->setBrush(mBrush); + painter->setPen(Qt::NoPen); + if (painter->brush().style() != Qt::NoBrush && painter->brush().color().alpha() != 0) + painter->drawPolygon(QPolygonF(lines)); + // draw curve line: - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { - painter->setPen( finalCurvePen ); - painter->setBrush( Qt::NoBrush ); - drawCurveLine( painter, lines ); + painter->setPen(finalCurvePen); + painter->setBrush(Qt::NoBrush); + drawCurveLine(painter, lines); } - + // draw scatters: QCPScatterStyle finalScatterStyle = mScatterStyle; - if( isSelectedSegment && mSelectionDecorator ) - finalScatterStyle = mSelectionDecorator->getFinalScatterStyle( mScatterStyle ); - if( !finalScatterStyle.isNone() ) + if (isSelectedSegment && mSelectionDecorator) + finalScatterStyle = mSelectionDecorator->getFinalScatterStyle(mScatterStyle); + if (!finalScatterStyle.isNone()) { - getScatters( &scatters, allSegments.at( i ), finalScatterStyle.size() ); - drawScatterPlot( painter, scatters, finalScatterStyle ); + getScatters(&scatters, allSegments.at(i), finalScatterStyle.size()); + drawScatterPlot(painter, scatters, finalScatterStyle); } } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPCurve::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPCurve::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { // draw fill: - if( mBrush.style() != Qt::NoBrush ) + if (mBrush.style() != Qt::NoBrush) { - applyFillAntialiasingHint( painter ); - painter->fillRect( QRectF( rect.left(), rect.top() + rect.height() / 2.0, rect.width(), rect.height() / 3.0 ), mBrush ); + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); } // draw line vertically centered: - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - painter->drawLine( QLineF( rect.left(), rect.top() + rect.height() / 2.0, rect.right() + 5, rect.top() + rect.height() / 2.0 ) ); // +5 on x2 else last segment is missing from dashed/dotted pens + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens } // draw scatter symbol: - if( !mScatterStyle.isNone() ) + if (!mScatterStyle.isNone()) { - applyScattersAntialiasingHint( painter ); + applyScattersAntialiasingHint(painter); // scale scatter pixmap if it's too large to fit in legend icon rect: - if( mScatterStyle.shape() == QCPScatterStyle::ssPixmap && ( mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height() ) ) + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) { - QCPScatterStyle scaledStyle( mScatterStyle ); - scaledStyle.setPixmap( scaledStyle.pixmap().scaled( rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); - scaledStyle.applyTo( painter, mPen ); - scaledStyle.drawShape( painter, QRectF( rect ).center() ); - } - else + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else { - mScatterStyle.applyTo( painter, mPen ); - mScatterStyle.drawShape( painter, QRectF( rect ).center() ); + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); } } } @@ -22448,12 +22157,12 @@ void QCPCurve::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const \see drawScatterPlot, getCurveLines */ -void QCPCurve::drawCurveLine( QCPPainter* painter, const QVector& lines ) const +void QCPCurve::drawCurveLine(QCPPainter *painter, const QVector &lines) const { - if( painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0 ) + if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0) { - applyDefaultAntialiasingHint( painter ); - drawPolyline( painter, lines ); + applyDefaultAntialiasingHint(painter); + drawPolyline(painter, lines); } } @@ -22464,14 +22173,14 @@ void QCPCurve::drawCurveLine( QCPPainter* painter, const QVector& lines \see drawCurveLine, getCurveLines */ -void QCPCurve::drawScatterPlot( QCPPainter* painter, const QVector& points, const QCPScatterStyle& style ) const +void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector &points, const QCPScatterStyle &style) const { // draw scatter point symbols: - applyScattersAntialiasingHint( painter ); - style.applyTo( painter, mPen ); - for( int i = 0; i < points.size(); ++i ) - if( !qIsNaN( points.at( i ).x() ) && !qIsNaN( points.at( i ).y() ) ) - style.drawShape( painter, points.at( i ) ); + applyScattersAntialiasingHint(painter); + style.applyTo(painter, mPen); + for (int i=0; i& poi \see drawCurveLine, drawScatterPlot */ -void QCPCurve::getCurveLines( QVector* lines, const QCPDataRange& dataRange, double penWidth ) const +void QCPCurve::getCurveLines(QVector *lines, const QCPDataRange &dataRange, double penWidth) const { - if( !lines ) - return; + if (!lines) return; lines->clear(); - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + // add margins to rect to compensate for stroke width - const double strokeMargin = qMax( qreal( 1.0 ), qreal( penWidth * 0.75 ) ); // stroke radius + 50% safety - const double keyMin = keyAxis->pixelToCoord( keyAxis->coordToPixel( keyAxis->range().lower ) - strokeMargin * keyAxis->pixelOrientation() ); - const double keyMax = keyAxis->pixelToCoord( keyAxis->coordToPixel( keyAxis->range().upper ) + strokeMargin * keyAxis->pixelOrientation() ); - const double valueMin = valueAxis->pixelToCoord( valueAxis->coordToPixel( valueAxis->range().lower ) - strokeMargin * valueAxis->pixelOrientation() ); - const double valueMax = valueAxis->pixelToCoord( valueAxis->coordToPixel( valueAxis->range().upper ) + strokeMargin * valueAxis->pixelOrientation() ); + const double strokeMargin = qMax(qreal(1.0), qreal(penWidth*0.75)); // stroke radius + 50% safety + const double keyMin = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyAxis->range().lower)-strokeMargin*keyAxis->pixelOrientation()); + const double keyMax = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyAxis->range().upper)+strokeMargin*keyAxis->pixelOrientation()); + const double valueMin = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueAxis->range().lower)-strokeMargin*valueAxis->pixelOrientation()); + const double valueMax = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueAxis->range().upper)+strokeMargin*valueAxis->pixelOrientation()); QCPCurveDataContainer::const_iterator itBegin = mDataContainer->constBegin(); QCPCurveDataContainer::const_iterator itEnd = mDataContainer->constEnd(); - mDataContainer->limitIteratorsToDataRange( itBegin, itEnd, dataRange ); - if( itBegin == itEnd ) + mDataContainer->limitIteratorsToDataRange(itBegin, itEnd, dataRange); + if (itBegin == itEnd) return; QCPCurveDataContainer::const_iterator it = itBegin; - QCPCurveDataContainer::const_iterator prevIt = itEnd - 1; - int prevRegion = getRegion( prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin ); - QVector trailingPoints; // points that must be applied after all other points (are generated only when handling first point to get virtual segment between last and first point right) - while( it != itEnd ) + QCPCurveDataContainer::const_iterator prevIt = itEnd-1; + int prevRegion = getRegion(prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin); + QVector trailingPoints; // points that must be applied after all other points (are generated only when handling first point to get virtual segment between last and first point right) + while (it != itEnd) { - const int currentRegion = getRegion( it->key, it->value, keyMin, valueMax, keyMax, valueMin ); - if( currentRegion != prevRegion ) // changed region, possibly need to add some optimized edge points or original points if entering R + const int currentRegion = getRegion(it->key, it->value, keyMin, valueMax, keyMax, valueMin); + if (currentRegion != prevRegion) // changed region, possibly need to add some optimized edge points or original points if entering R { - if( currentRegion != 5 ) // segment doesn't end in R, so it's a candidate for removal + if (currentRegion != 5) // segment doesn't end in R, so it's a candidate for removal { QPointF crossA, crossB; - if( prevRegion == 5 ) // we're coming from R, so add this point optimized + if (prevRegion == 5) // we're coming from R, so add this point optimized { - lines->append( getOptimizedPoint( currentRegion, it->key, it->value, prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin ) ); + lines->append(getOptimizedPoint(currentRegion, it->key, it->value, prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin)); // in the situations 5->1/7/9/3 the segment may leave R and directly cross through two outer regions. In these cases we need to add an additional corner point - *lines << getOptimizedCornerPoints( prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin ); - } - else if( mayTraverse( prevRegion, currentRegion ) && - getTraverse( prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin, crossA, crossB ) ) + *lines << getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin); + } else if (mayTraverse(prevRegion, currentRegion) && + getTraverse(prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin, crossA, crossB)) { // add the two cross points optimized if segment crosses R and if segment isn't virtual zeroth segment between last and first curve point: QVector beforeTraverseCornerPoints, afterTraverseCornerPoints; - getTraverseCornerPoints( prevRegion, currentRegion, keyMin, valueMax, keyMax, valueMin, beforeTraverseCornerPoints, afterTraverseCornerPoints ); - if( it != itBegin ) + getTraverseCornerPoints(prevRegion, currentRegion, keyMin, valueMax, keyMax, valueMin, beforeTraverseCornerPoints, afterTraverseCornerPoints); + if (it != itBegin) { *lines << beforeTraverseCornerPoints; - lines->append( crossA ); - lines->append( crossB ); + lines->append(crossA); + lines->append(crossB); *lines << afterTraverseCornerPoints; - } - else + } else { - lines->append( crossB ); + lines->append(crossB); *lines << afterTraverseCornerPoints; - trailingPoints << beforeTraverseCornerPoints << crossA; + trailingPoints << beforeTraverseCornerPoints << crossA ; } - } - else // doesn't cross R, line is just moving around in outside regions, so only need to add optimized point(s) at the boundary corner(s) + } else // doesn't cross R, line is just moving around in outside regions, so only need to add optimized point(s) at the boundary corner(s) { - *lines << getOptimizedCornerPoints( prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin ); + *lines << getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin); } - } - else // segment does end in R, so we add previous point optimized and this point at original position + } else // segment does end in R, so we add previous point optimized and this point at original position { - if( it == itBegin ) // it is first point in curve and prevIt is last one. So save optimized point for adding it to the lineData in the end - trailingPoints << getOptimizedPoint( prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin ); + if (it == itBegin) // it is first point in curve and prevIt is last one. So save optimized point for adding it to the lineData in the end + trailingPoints << getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin); else - lines->append( getOptimizedPoint( prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin ) ); - lines->append( coordsToPixels( it->key, it->value ) ); + lines->append(getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin)); + lines->append(coordsToPixels(it->key, it->value)); } - } - else // region didn't change + } else // region didn't change { - if( currentRegion == 5 ) // still in R, keep adding original points + if (currentRegion == 5) // still in R, keep adding original points { - lines->append( coordsToPixels( it->key, it->value ) ); - } - else // still outside R, no need to add anything + lines->append(coordsToPixels(it->key, it->value)); + } else // still outside R, no need to add anything { // see how this is not doing anything? That's the main optimization... } @@ -22616,57 +22314,52 @@ void QCPCurve::getCurveLines( QVector* lines, const QCPDataRange& dataR \see draw, drawScatterPlot */ -void QCPCurve::getScatters( QVector* scatters, const QCPDataRange& dataRange, double scatterWidth ) const +void QCPCurve::getScatters(QVector *scatters, const QCPDataRange &dataRange, double scatterWidth) const { - if( !scatters ) - return; + if (!scatters) return; scatters->clear(); - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + QCPCurveDataContainer::const_iterator begin = mDataContainer->constBegin(); QCPCurveDataContainer::const_iterator end = mDataContainer->constEnd(); - mDataContainer->limitIteratorsToDataRange( begin, end, dataRange ); - if( begin == end ) + mDataContainer->limitIteratorsToDataRange(begin, end, dataRange); + if (begin == end) return; - const int scatterModulo = mScatterSkip + 1; + const int scatterModulo = mScatterSkip+1; const bool doScatterSkip = mScatterSkip > 0; - int endIndex = end - mDataContainer->constBegin(); - + int endIndex = end-mDataContainer->constBegin(); + QCPRange keyRange = keyAxis->range(); QCPRange valueRange = valueAxis->range(); // extend range to include width of scatter symbols: - keyRange.lower = keyAxis->pixelToCoord( keyAxis->coordToPixel( keyRange.lower ) - scatterWidth * keyAxis->pixelOrientation() ); - keyRange.upper = keyAxis->pixelToCoord( keyAxis->coordToPixel( keyRange.upper ) + scatterWidth * keyAxis->pixelOrientation() ); - valueRange.lower = valueAxis->pixelToCoord( valueAxis->coordToPixel( valueRange.lower ) - scatterWidth * valueAxis->pixelOrientation() ); - valueRange.upper = valueAxis->pixelToCoord( valueAxis->coordToPixel( valueRange.upper ) + scatterWidth * valueAxis->pixelOrientation() ); - + keyRange.lower = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyRange.lower)-scatterWidth*keyAxis->pixelOrientation()); + keyRange.upper = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyRange.upper)+scatterWidth*keyAxis->pixelOrientation()); + valueRange.lower = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueRange.lower)-scatterWidth*valueAxis->pixelOrientation()); + valueRange.upper = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueRange.upper)+scatterWidth*valueAxis->pixelOrientation()); + QCPCurveDataContainer::const_iterator it = begin; - int itIndex = begin - mDataContainer->constBegin(); - while( doScatterSkip && it != end && itIndex % scatterModulo != 0 ) // advance begin iterator to first non-skipped scatter + int itIndex = begin-mDataContainer->constBegin(); + while (doScatterSkip && it != end && itIndex % scatterModulo != 0) // advance begin iterator to first non-skipped scatter { ++itIndex; ++it; } - if( keyAxis->orientation() == Qt::Vertical ) + if (keyAxis->orientation() == Qt::Vertical) { - while( it != end ) + while (it != end) { - if( !qIsNaN( it->value ) && keyRange.contains( it->key ) && valueRange.contains( it->value ) ) - scatters->append( QPointF( valueAxis->coordToPixel( it->value ), keyAxis->coordToPixel( it->key ) ) ); - + if (!qIsNaN(it->value) && keyRange.contains(it->key) && valueRange.contains(it->value)) + scatters->append(QPointF(valueAxis->coordToPixel(it->value), keyAxis->coordToPixel(it->key))); + // advance iterator to next (non-skipped) data point: - if( !doScatterSkip ) + if (!doScatterSkip) ++it; else { itIndex += scatterModulo; - if( itIndex < endIndex ) // make sure we didn't jump over end + if (itIndex < endIndex) // make sure we didn't jump over end it += scatterModulo; else { @@ -22675,21 +22368,20 @@ void QCPCurve::getScatters( QVector* scatters, const QCPDataRange& data } } } - } - else + } else { - while( it != end ) + while (it != end) { - if( !qIsNaN( it->value ) && keyRange.contains( it->key ) && valueRange.contains( it->value ) ) - scatters->append( QPointF( keyAxis->coordToPixel( it->key ), valueAxis->coordToPixel( it->value ) ) ); - + if (!qIsNaN(it->value) && keyRange.contains(it->key) && valueRange.contains(it->value)) + scatters->append(QPointF(keyAxis->coordToPixel(it->key), valueAxis->coordToPixel(it->value))); + // advance iterator to next (non-skipped) data point: - if( !doScatterSkip ) + if (!doScatterSkip) ++it; else { itIndex += scatterModulo; - if( itIndex < endIndex ) // make sure we didn't jump over end + if (itIndex < endIndex) // make sure we didn't jump over end it += scatterModulo; else { @@ -22720,31 +22412,29 @@ void QCPCurve::getScatters( QVector* scatters, const QCPDataRange& data With the rectangle being region 5, and the outer regions extending infinitely outwards. In the curve optimization algorithm, region 5 is considered to be the visible portion of the plot. */ -int QCPCurve::getRegion( double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const +int QCPCurve::getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const { - if( key < keyMin ) // region 123 + if (key < keyMin) // region 123 { - if( value > valueMax ) + if (value > valueMax) return 1; - else if( value < valueMin ) + else if (value < valueMin) return 3; else return 2; - } - else if( key > keyMax ) // region 789 + } else if (key > keyMax) // region 789 { - if( value > valueMax ) + if (value > valueMax) return 7; - else if( value < valueMin ) + else if (value < valueMin) return 9; else return 8; - } - else // region 456 + } else // region 456 { - if( value > valueMax ) + if (value > valueMax) return 4; - else if( value < valueMin ) + else if (value < valueMin) return 6; else return 5; @@ -22766,102 +22456,102 @@ int QCPCurve::getRegion( double key, double value, double keyMin, double valueMa leaving it. It is important though that \a otherRegion correctly identifies the other region not equal to 5. */ -QPointF QCPCurve::getOptimizedPoint( int otherRegion, double otherKey, double otherValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const +QPointF QCPCurve::getOptimizedPoint(int otherRegion, double otherKey, double otherValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const { // The intersection point interpolation here is done in pixel coordinates, so we don't need to // differentiate between different axis scale types. Note that the nomenclature // top/left/bottom/right/min/max is with respect to the rect in plot coordinates, wich may be // different in pixel coordinates (horz/vert key axes, reversed ranges) - - const double keyMinPx = mKeyAxis->coordToPixel( keyMin ); - const double keyMaxPx = mKeyAxis->coordToPixel( keyMax ); - const double valueMinPx = mValueAxis->coordToPixel( valueMin ); - const double valueMaxPx = mValueAxis->coordToPixel( valueMax ); - const double otherValuePx = mValueAxis->coordToPixel( otherValue ); - const double valuePx = mValueAxis->coordToPixel( value ); - const double otherKeyPx = mKeyAxis->coordToPixel( otherKey ); - const double keyPx = mKeyAxis->coordToPixel( key ); - double intersectKeyPx = keyMinPx; // initial key just a fail-safe - double intersectValuePx = valueMinPx; // initial value just a fail-safe - switch( otherRegion ) + + const double keyMinPx = mKeyAxis->coordToPixel(keyMin); + const double keyMaxPx = mKeyAxis->coordToPixel(keyMax); + const double valueMinPx = mValueAxis->coordToPixel(valueMin); + const double valueMaxPx = mValueAxis->coordToPixel(valueMax); + const double otherValuePx = mValueAxis->coordToPixel(otherValue); + const double valuePx = mValueAxis->coordToPixel(value); + const double otherKeyPx = mKeyAxis->coordToPixel(otherKey); + const double keyPx = mKeyAxis->coordToPixel(key); + double intersectKeyPx = keyMinPx; // initial key just a fail-safe + double intersectValuePx = valueMinPx; // initial value just a fail-safe + switch (otherRegion) { - case 1: // top and left edge - { - intersectValuePx = valueMaxPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - if( intersectKeyPx < qMin( keyMinPx, keyMaxPx ) || intersectKeyPx > qMax( keyMinPx, keyMaxPx ) ) // check whether top edge is not intersected, then it must be left edge (qMin/qMax necessary since axes may be reversed) + case 1: // top and left edge + { + intersectValuePx = valueMaxPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx)) // check whether top edge is not intersected, then it must be left edge (qMin/qMax necessary since axes may be reversed) + { + intersectKeyPx = keyMinPx; + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + } + break; + } + case 2: // left edge { intersectKeyPx = keyMinPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + break; } - break; - } - case 2: // left edge - { - intersectKeyPx = keyMinPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); - break; - } - case 3: // bottom and left edge - { - intersectValuePx = valueMinPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - if( intersectKeyPx < qMin( keyMinPx, keyMaxPx ) || intersectKeyPx > qMax( keyMinPx, keyMaxPx ) ) // check whether bottom edge is not intersected, then it must be left edge (qMin/qMax necessary since axes may be reversed) + case 3: // bottom and left edge { - intersectKeyPx = keyMinPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); + intersectValuePx = valueMinPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx)) // check whether bottom edge is not intersected, then it must be left edge (qMin/qMax necessary since axes may be reversed) + { + intersectKeyPx = keyMinPx; + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + } + break; } - break; - } - case 4: // top edge - { - intersectValuePx = valueMaxPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - break; - } - case 5: - { - break; // case 5 shouldn't happen for this function but we add it anyway to prevent potential discontinuity in branch table - } - case 6: // bottom edge - { - intersectValuePx = valueMinPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - break; - } - case 7: // top and right edge - { - intersectValuePx = valueMaxPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - if( intersectKeyPx < qMin( keyMinPx, keyMaxPx ) || intersectKeyPx > qMax( keyMinPx, keyMaxPx ) ) // check whether top edge is not intersected, then it must be right edge (qMin/qMax necessary since axes may be reversed) + case 4: // top edge + { + intersectValuePx = valueMaxPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + break; + } + case 5: + { + break; // case 5 shouldn't happen for this function but we add it anyway to prevent potential discontinuity in branch table + } + case 6: // bottom edge + { + intersectValuePx = valueMinPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + break; + } + case 7: // top and right edge + { + intersectValuePx = valueMaxPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx)) // check whether top edge is not intersected, then it must be right edge (qMin/qMax necessary since axes may be reversed) + { + intersectKeyPx = keyMaxPx; + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + } + break; + } + case 8: // right edge { intersectKeyPx = keyMaxPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + break; } - break; - } - case 8: // right edge - { - intersectKeyPx = keyMaxPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); - break; - } - case 9: // bottom and right edge - { - intersectValuePx = valueMinPx; - intersectKeyPx = otherKeyPx + ( keyPx - otherKeyPx ) / ( valuePx - otherValuePx ) * ( intersectValuePx - otherValuePx ); - if( intersectKeyPx < qMin( keyMinPx, keyMaxPx ) || intersectKeyPx > qMax( keyMinPx, keyMaxPx ) ) // check whether bottom edge is not intersected, then it must be right edge (qMin/qMax necessary since axes may be reversed) + case 9: // bottom and right edge { - intersectKeyPx = keyMaxPx; - intersectValuePx = otherValuePx + ( valuePx - otherValuePx ) / ( keyPx - otherKeyPx ) * ( intersectKeyPx - otherKeyPx ); + intersectValuePx = valueMinPx; + intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx); + if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx)) // check whether bottom edge is not intersected, then it must be right edge (qMin/qMax necessary since axes may be reversed) + { + intersectKeyPx = keyMaxPx; + intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx); + } + break; } - break; } - } - if( mKeyAxis->orientation() == Qt::Horizontal ) - return QPointF( intersectKeyPx, intersectValuePx ); + if (mKeyAxis->orientation() == Qt::Horizontal) + return QPointF(intersectKeyPx, intersectValuePx); else - return QPointF( intersectValuePx, intersectKeyPx ); + return QPointF(intersectValuePx, intersectKeyPx); } /*! \internal @@ -22882,430 +22572,154 @@ QPointF QCPCurve::getOptimizedPoint( int otherRegion, double otherKey, double ot the top left corner, making the optimized curve correctly pass from region 4 to 1 to 2 without traversing 5. */ -QVector QCPCurve::getOptimizedCornerPoints( int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const +QVector QCPCurve::getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const { QVector result; - switch( prevRegion ) + switch (prevRegion) { - case 1: - { - switch( currentRegion ) - { - case 2: - { - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 4: - { - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 3: - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMin, valueMin ); - break; - } - case 7: - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMax, valueMax ); - break; - } - case 6: - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - break; - } - case 8: - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - break; - } - case 9: - { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points - if( ( value - prevValue ) / ( key - prevKey ) * ( keyMin - key ) + value < valueMin ) // segment passes below R - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMin ); - } - else - { - result << coordsToPixels( keyMin, valueMax ) << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMin ); - } - break; - } - } - break; - } - case 2: - { - switch( currentRegion ) - { case 1: { - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 3: - { - result << coordsToPixels( keyMin, valueMin ); - break; - } - case 4: - { - result << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - break; - } - case 6: - { - result << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - break; - } - case 7: - { - result << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMax ); - break; - } - case 9: - { - result << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMin ); - break; - } - } - break; - } - case 3: - { - switch( currentRegion ) - { - case 2: - { - result << coordsToPixels( keyMin, valueMin ); - break; - } - case 6: - { - result << coordsToPixels( keyMin, valueMin ); - break; - } - case 1: - { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMin, valueMax ); - break; - } - case 9: - { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMax, valueMin ); - break; - } - case 4: - { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - break; - } - case 8: - { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - break; - } - case 7: - { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points - if( ( value - prevValue ) / ( key - prevKey ) * ( keyMax - key ) + value < valueMin ) // segment passes below R + switch (currentRegion) { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMax ); + case 2: { result << coordsToPixels(keyMin, valueMax); break; } + case 4: { result << coordsToPixels(keyMin, valueMax); break; } + case 3: { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMin, valueMin); break; } + case 7: { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMax, valueMax); break; } + case 6: { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMin, valueMin); result.append(result.last()); break; } + case 8: { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMax, valueMax); result.append(result.last()); break; } + case 9: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin) // segment passes below R + { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMin, valueMin); result.append(result.last()); result << coordsToPixels(keyMax, valueMin); } + else + { result << coordsToPixels(keyMin, valueMax) << coordsToPixels(keyMax, valueMax); result.append(result.last()); result << coordsToPixels(keyMax, valueMin); } + break; + } } - else - { - result << coordsToPixels( keyMin, valueMin ) << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMax ); - } - break; - } - } - break; - } - case 4: - { - switch( currentRegion ) - { - case 1: - { - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 7: - { - result << coordsToPixels( keyMax, valueMax ); break; } case 2: { - result << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - break; - } - case 8: - { - result << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - break; - } - case 3: - { - result << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMin ); - break; - } - case 9: - { - result << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMin ); - break; - } - } - break; - } - case 5: - { - switch( currentRegion ) - { - case 1: - { - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 7: - { - result << coordsToPixels( keyMax, valueMax ); - break; - } - case 9: - { - result << coordsToPixels( keyMax, valueMin ); - break; - } - case 3: - { - result << coordsToPixels( keyMin, valueMin ); - break; - } - } - break; - } - case 6: - { - switch( currentRegion ) - { - case 3: - { - result << coordsToPixels( keyMin, valueMin ); - break; - } - case 9: - { - result << coordsToPixels( keyMax, valueMin ); - break; - } - case 2: - { - result << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - break; - } - case 8: - { - result << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - break; - } - case 1: - { - result << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 7: - { - result << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMax, valueMax ); - break; - } - } - break; - } - case 7: - { - switch( currentRegion ) - { - case 4: - { - result << coordsToPixels( keyMax, valueMax ); - break; - } - case 8: - { - result << coordsToPixels( keyMax, valueMax ); - break; - } - case 1: - { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMin, valueMax ); - break; - } - case 9: - { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMax, valueMin ); - break; - } - case 2: - { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - break; - } - case 6: - { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - break; - } - case 3: - { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points - if( ( value - prevValue ) / ( key - prevKey ) * ( keyMax - key ) + value < valueMin ) // segment passes below R + switch (currentRegion) { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMin ); - } - else - { - result << coordsToPixels( keyMax, valueMax ) << coordsToPixels( keyMin, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMin ); + case 1: { result << coordsToPixels(keyMin, valueMax); break; } + case 3: { result << coordsToPixels(keyMin, valueMin); break; } + case 4: { result << coordsToPixels(keyMin, valueMax); result.append(result.last()); break; } + case 6: { result << coordsToPixels(keyMin, valueMin); result.append(result.last()); break; } + case 7: { result << coordsToPixels(keyMin, valueMax); result.append(result.last()); result << coordsToPixels(keyMax, valueMax); break; } + case 9: { result << coordsToPixels(keyMin, valueMin); result.append(result.last()); result << coordsToPixels(keyMax, valueMin); break; } } break; } - } - break; - } - case 8: - { - switch( currentRegion ) + case 3: { - case 7: - { - result << coordsToPixels( keyMax, valueMax ); - break; - } - case 9: - { - result << coordsToPixels( keyMax, valueMin ); + switch (currentRegion) + { + case 2: { result << coordsToPixels(keyMin, valueMin); break; } + case 6: { result << coordsToPixels(keyMin, valueMin); break; } + case 1: { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMin, valueMax); break; } + case 9: { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMax, valueMin); break; } + case 4: { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMin, valueMax); result.append(result.last()); break; } + case 8: { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMax, valueMin); result.append(result.last()); break; } + case 7: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin) // segment passes below R + { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMax, valueMin); result.append(result.last()); result << coordsToPixels(keyMax, valueMax); } + else + { result << coordsToPixels(keyMin, valueMin) << coordsToPixels(keyMin, valueMax); result.append(result.last()); result << coordsToPixels(keyMax, valueMax); } + break; + } + } break; } case 4: { - result << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); + switch (currentRegion) + { + case 1: { result << coordsToPixels(keyMin, valueMax); break; } + case 7: { result << coordsToPixels(keyMax, valueMax); break; } + case 2: { result << coordsToPixels(keyMin, valueMax); result.append(result.last()); break; } + case 8: { result << coordsToPixels(keyMax, valueMax); result.append(result.last()); break; } + case 3: { result << coordsToPixels(keyMin, valueMax); result.append(result.last()); result << coordsToPixels(keyMin, valueMin); break; } + case 9: { result << coordsToPixels(keyMax, valueMax); result.append(result.last()); result << coordsToPixels(keyMax, valueMin); break; } + } + break; + } + case 5: + { + switch (currentRegion) + { + case 1: { result << coordsToPixels(keyMin, valueMax); break; } + case 7: { result << coordsToPixels(keyMax, valueMax); break; } + case 9: { result << coordsToPixels(keyMax, valueMin); break; } + case 3: { result << coordsToPixels(keyMin, valueMin); break; } + } break; } case 6: { - result << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - break; - } - case 1: - { - result << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMax ); - break; - } - case 3: - { - result << coordsToPixels( keyMax, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMin ); - break; - } - } - break; - } - case 9: - { - switch( currentRegion ) - { - case 6: - { - result << coordsToPixels( keyMax, valueMin ); - break; - } - case 8: - { - result << coordsToPixels( keyMax, valueMin ); - break; - } - case 3: - { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMin, valueMin ); + switch (currentRegion) + { + case 3: { result << coordsToPixels(keyMin, valueMin); break; } + case 9: { result << coordsToPixels(keyMax, valueMin); break; } + case 2: { result << coordsToPixels(keyMin, valueMin); result.append(result.last()); break; } + case 8: { result << coordsToPixels(keyMax, valueMin); result.append(result.last()); break; } + case 1: { result << coordsToPixels(keyMin, valueMin); result.append(result.last()); result << coordsToPixels(keyMin, valueMax); break; } + case 7: { result << coordsToPixels(keyMax, valueMin); result.append(result.last()); result << coordsToPixels(keyMax, valueMax); break; } + } break; } case 7: { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMax, valueMax ); - break; - } - case 2: - { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - break; - } - case 4: - { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - break; - } - case 1: - { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points - if( ( value - prevValue ) / ( key - prevKey ) * ( keyMin - key ) + value < valueMin ) // segment passes below R + switch (currentRegion) { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMin, valueMin ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMax ); - } - else - { - result << coordsToPixels( keyMax, valueMin ) << coordsToPixels( keyMax, valueMax ); - result.append( result.last() ); - result << coordsToPixels( keyMin, valueMax ); + case 4: { result << coordsToPixels(keyMax, valueMax); break; } + case 8: { result << coordsToPixels(keyMax, valueMax); break; } + case 1: { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMin, valueMax); break; } + case 9: { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMax, valueMin); break; } + case 2: { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMin, valueMax); result.append(result.last()); break; } + case 6: { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMax, valueMin); result.append(result.last()); break; } + case 3: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin) // segment passes below R + { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMax, valueMin); result.append(result.last()); result << coordsToPixels(keyMin, valueMin); } + else + { result << coordsToPixels(keyMax, valueMax) << coordsToPixels(keyMin, valueMax); result.append(result.last()); result << coordsToPixels(keyMin, valueMin); } + break; + } } break; } + case 8: + { + switch (currentRegion) + { + case 7: { result << coordsToPixels(keyMax, valueMax); break; } + case 9: { result << coordsToPixels(keyMax, valueMin); break; } + case 4: { result << coordsToPixels(keyMax, valueMax); result.append(result.last()); break; } + case 6: { result << coordsToPixels(keyMax, valueMin); result.append(result.last()); break; } + case 1: { result << coordsToPixels(keyMax, valueMax); result.append(result.last()); result << coordsToPixels(keyMin, valueMax); break; } + case 3: { result << coordsToPixels(keyMax, valueMin); result.append(result.last()); result << coordsToPixels(keyMin, valueMin); break; } + } + break; + } + case 9: + { + switch (currentRegion) + { + case 6: { result << coordsToPixels(keyMax, valueMin); break; } + case 8: { result << coordsToPixels(keyMax, valueMin); break; } + case 3: { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMin, valueMin); break; } + case 7: { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMax, valueMax); break; } + case 2: { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMin, valueMin); result.append(result.last()); break; } + case 4: { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMax, valueMax); result.append(result.last()); break; } + case 1: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin) // segment passes below R + { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMin, valueMin); result.append(result.last()); result << coordsToPixels(keyMin, valueMax); } + else + { result << coordsToPixels(keyMax, valueMin) << coordsToPixels(keyMax, valueMax); result.append(result.last()); result << coordsToPixels(keyMin, valueMax); } + break; + } + } + break; } - break; - } } return result; } @@ -23322,113 +22736,96 @@ QVector QCPCurve::getOptimizedCornerPoints( int prevRegion, int current segment may or may not pass region 5 and a more fine-grained calculation must be used (\ref getTraverse). */ -bool QCPCurve::mayTraverse( int prevRegion, int currentRegion ) const +bool QCPCurve::mayTraverse(int prevRegion, int currentRegion) const { - switch( prevRegion ) + switch (prevRegion) { - case 1: - { - switch( currentRegion ) + case 1: { - case 4: - case 7: + switch (currentRegion) + { + case 4: + case 7: + case 2: + case 3: return false; + default: return true; + } + } case 2: + { + switch (currentRegion) + { + case 1: + case 3: return false; + default: return true; + } + } case 3: - return false; - default: - return true; - } - } - case 2: - { - switch( currentRegion ) { - case 1: - case 3: - return false; - default: - return true; + switch (currentRegion) + { + case 1: + case 2: + case 6: + case 9: return false; + default: return true; + } } - } - case 3: - { - switch( currentRegion ) - { - case 1: - case 2: - case 6: - case 9: - return false; - default: - return true; - } - } - case 4: - { - switch( currentRegion ) - { - case 1: - case 7: - return false; - default: - return true; - } - } - case 5: - return false; // should never occur - case 6: - { - switch( currentRegion ) - { - case 3: - case 9: - return false; - default: - return true; - } - } - case 7: - { - switch( currentRegion ) - { - case 1: case 4: - case 8: - case 9: - return false; - default: - return true; - } - } - case 8: - { - switch( currentRegion ) { - case 7: - case 9: - return false; - default: - return true; + switch (currentRegion) + { + case 1: + case 7: return false; + default: return true; + } } - } - case 9: - { - switch( currentRegion ) - { - case 3: + case 5: return false; // should never occur case 6: - case 8: - case 7: - return false; - default: - return true; + { + switch (currentRegion) + { + case 3: + case 9: return false; + default: return true; + } } - } - default: - return true; + case 7: + { + switch (currentRegion) + { + case 1: + case 4: + case 8: + case 9: return false; + default: return true; + } + } + case 8: + { + switch (currentRegion) + { + case 7: + case 9: return false; + default: return true; + } + } + case 9: + { + switch (currentRegion) + { + case 3: + case 6: + case 8: + case 7: return false; + default: return true; + } + } + default: return true; } } + /*! \internal This function is part of the curve optimization algorithm of \ref getCurveLines. @@ -23442,94 +22839,91 @@ bool QCPCurve::mayTraverse( int prevRegion, int currentRegion ) const If the segment traverses 5, the output parameters \a crossA and \a crossB indicate the entry and exit points of region 5. They will become the optimized points for that segment. */ -bool QCPCurve::getTraverse( double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF& crossA, QPointF& crossB ) const +bool QCPCurve::getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const { // The intersection point interpolation here is done in pixel coordinates, so we don't need to // differentiate between different axis scale types. Note that the nomenclature // top/left/bottom/right/min/max is with respect to the rect in plot coordinates, wich may be // different in pixel coordinates (horz/vert key axes, reversed ranges) - + QList intersections; - const double valueMinPx = mValueAxis->coordToPixel( valueMin ); - const double valueMaxPx = mValueAxis->coordToPixel( valueMax ); - const double keyMinPx = mKeyAxis->coordToPixel( keyMin ); - const double keyMaxPx = mKeyAxis->coordToPixel( keyMax ); - const double keyPx = mKeyAxis->coordToPixel( key ); - const double valuePx = mValueAxis->coordToPixel( value ); - const double prevKeyPx = mKeyAxis->coordToPixel( prevKey ); - const double prevValuePx = mValueAxis->coordToPixel( prevValue ); - if( qFuzzyIsNull( key - prevKey ) ) // line is parallel to value axis + const double valueMinPx = mValueAxis->coordToPixel(valueMin); + const double valueMaxPx = mValueAxis->coordToPixel(valueMax); + const double keyMinPx = mKeyAxis->coordToPixel(keyMin); + const double keyMaxPx = mKeyAxis->coordToPixel(keyMax); + const double keyPx = mKeyAxis->coordToPixel(key); + const double valuePx = mValueAxis->coordToPixel(value); + const double prevKeyPx = mKeyAxis->coordToPixel(prevKey); + const double prevValuePx = mValueAxis->coordToPixel(prevValue); + if (qFuzzyIsNull(key-prevKey)) // line is parallel to value axis { // due to region filter in mayTraverse(), if line is parallel to value or key axis, region 5 is traversed here - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyPx, valueMinPx ) : QPointF( valueMinPx, keyPx ) ); // direction will be taken care of at end of method - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyPx, valueMaxPx ) : QPointF( valueMaxPx, keyPx ) ); - } - else if( qFuzzyIsNull( value - prevValue ) ) // line is parallel to key axis + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMinPx) : QPointF(valueMinPx, keyPx)); // direction will be taken care of at end of method + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMaxPx) : QPointF(valueMaxPx, keyPx)); + } else if (qFuzzyIsNull(value-prevValue)) // line is parallel to key axis { // due to region filter in mayTraverse(), if line is parallel to value or key axis, region 5 is traversed here - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyMinPx, valuePx ) : QPointF( valuePx, keyMinPx ) ); // direction will be taken care of at end of method - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyMaxPx, valuePx ) : QPointF( valuePx, keyMaxPx ) ); - } - else // line is skewed + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, valuePx) : QPointF(valuePx, keyMinPx)); // direction will be taken care of at end of method + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, valuePx) : QPointF(valuePx, keyMaxPx)); + } else // line is skewed { double gamma; - double keyPerValuePx = ( keyPx - prevKeyPx ) / ( valuePx - prevValuePx ); + double keyPerValuePx = (keyPx-prevKeyPx)/(valuePx-prevValuePx); // check top of rect: - gamma = prevKeyPx + ( valueMaxPx - prevValuePx ) * keyPerValuePx; - if( gamma >= qMin( keyMinPx, keyMaxPx ) && gamma <= qMax( keyMinPx, keyMaxPx ) ) // qMin/qMax necessary since axes may be reversed - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( gamma, valueMaxPx ) : QPointF( valueMaxPx, gamma ) ); + gamma = prevKeyPx + (valueMaxPx-prevValuePx)*keyPerValuePx; + if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx)) // qMin/qMax necessary since axes may be reversed + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMaxPx) : QPointF(valueMaxPx, gamma)); // check bottom of rect: - gamma = prevKeyPx + ( valueMinPx - prevValuePx ) * keyPerValuePx; - if( gamma >= qMin( keyMinPx, keyMaxPx ) && gamma <= qMax( keyMinPx, keyMaxPx ) ) // qMin/qMax necessary since axes may be reversed - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( gamma, valueMinPx ) : QPointF( valueMinPx, gamma ) ); - const double valuePerKeyPx = 1.0 / keyPerValuePx; + gamma = prevKeyPx + (valueMinPx-prevValuePx)*keyPerValuePx; + if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx)) // qMin/qMax necessary since axes may be reversed + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMinPx) : QPointF(valueMinPx, gamma)); + const double valuePerKeyPx = 1.0/keyPerValuePx; // check left of rect: - gamma = prevValuePx + ( keyMinPx - prevKeyPx ) * valuePerKeyPx; - if( gamma >= qMin( valueMinPx, valueMaxPx ) && gamma <= qMax( valueMinPx, valueMaxPx ) ) // qMin/qMax necessary since axes may be reversed - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyMinPx, gamma ) : QPointF( gamma, keyMinPx ) ); + gamma = prevValuePx + (keyMinPx-prevKeyPx)*valuePerKeyPx; + if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx)) // qMin/qMax necessary since axes may be reversed + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, gamma) : QPointF(gamma, keyMinPx)); // check right of rect: - gamma = prevValuePx + ( keyMaxPx - prevKeyPx ) * valuePerKeyPx; - if( gamma >= qMin( valueMinPx, valueMaxPx ) && gamma <= qMax( valueMinPx, valueMaxPx ) ) // qMin/qMax necessary since axes may be reversed - intersections.append( mKeyAxis->orientation() == Qt::Horizontal ? QPointF( keyMaxPx, gamma ) : QPointF( gamma, keyMaxPx ) ); + gamma = prevValuePx + (keyMaxPx-prevKeyPx)*valuePerKeyPx; + if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx)) // qMin/qMax necessary since axes may be reversed + intersections.append(mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, gamma) : QPointF(gamma, keyMaxPx)); } - + // handle cases where found points isn't exactly 2: - if( intersections.size() > 2 ) + if (intersections.size() > 2) { // line probably goes through corner of rect, and we got duplicate points there. single out the point pair with greatest distance in between: double distSqrMax = 0; QPointF pv1, pv2; - for( int i = 0; i < intersections.size() - 1; ++i ) + for (int i=0; i distSqrMax ) + QPointF distPoint = intersections.at(i)-intersections.at(k); + double distSqr = distPoint.x()*distPoint.x()+distPoint.y()+distPoint.y(); + if (distSqr > distSqrMax) { - pv1 = intersections.at( i ); - pv2 = intersections.at( k ); + pv1 = intersections.at(i); + pv2 = intersections.at(k); distSqrMax = distSqr; } } } intersections = QList() << pv1 << pv2; - } - else if( intersections.size() != 2 ) + } else if (intersections.size() != 2) { // one or even zero points found (shouldn't happen unless line perfectly tangent to corner), no need to draw segment return false; } - + // possibly re-sort points so optimized point segment has same direction as original segment: - double xDelta = keyPx - prevKeyPx; - double yDelta = valuePx - prevValuePx; - if( mKeyAxis->orientation() != Qt::Horizontal ) - qSwap( xDelta, yDelta ); - if( xDelta * ( intersections.at( 1 ).x() - intersections.at( 0 ).x() ) + yDelta * ( intersections.at( 1 ).y() - intersections.at( 0 ).y() ) < 0 ) // scalar product of both segments < 0 -> opposite direction - intersections.move( 0, 1 ); - crossA = intersections.at( 0 ); - crossB = intersections.at( 1 ); + double xDelta = keyPx-prevKeyPx; + double yDelta = valuePx-prevValuePx; + if (mKeyAxis->orientation() != Qt::Horizontal) + qSwap(xDelta, yDelta); + if (xDelta*(intersections.at(1).x()-intersections.at(0).x()) + yDelta*(intersections.at(1).y()-intersections.at(0).y()) < 0) // scalar product of both segments < 0 -> opposite direction + intersections.move(0, 1); + crossA = intersections.at(0); + crossB = intersections.at(1); return true; } @@ -23558,174 +22952,87 @@ bool QCPCurve::getTraverse( double prevKey, double prevValue, double key, double corner points before and after the traverse. Then both \a beforeTraverse and \a afterTraverse return the respective corner points. */ -void QCPCurve::getTraverseCornerPoints( int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector& beforeTraverse, QVector& afterTraverse ) const +void QCPCurve::getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector &beforeTraverse, QVector &afterTraverse) const { - switch( prevRegion ) + switch (prevRegion) { - case 1: - { - switch( currentRegion ) - { - case 6: - { - beforeTraverse << coordsToPixels( keyMin, valueMax ); - break; - } - case 9: - { - beforeTraverse << coordsToPixels( keyMin, valueMax ); - afterTraverse << coordsToPixels( keyMax, valueMin ); - break; - } - case 8: - { - beforeTraverse << coordsToPixels( keyMin, valueMax ); - break; - } - } - break; - } - case 2: - { - switch( currentRegion ) - { - case 7: - { - afterTraverse << coordsToPixels( keyMax, valueMax ); - break; - } - case 9: - { - afterTraverse << coordsToPixels( keyMax, valueMin ); - break; - } - } - break; - } - case 3: - { - switch( currentRegion ) - { - case 4: - { - beforeTraverse << coordsToPixels( keyMin, valueMin ); - break; - } - case 7: - { - beforeTraverse << coordsToPixels( keyMin, valueMin ); - afterTraverse << coordsToPixels( keyMax, valueMax ); - break; - } - case 8: - { - beforeTraverse << coordsToPixels( keyMin, valueMin ); - break; - } - } - break; - } - case 4: - { - switch( currentRegion ) - { - case 3: - { - afterTraverse << coordsToPixels( keyMin, valueMin ); - break; - } - case 9: - { - afterTraverse << coordsToPixels( keyMax, valueMin ); - break; - } - } - break; - } - case 5: - { - break; - } // shouldn't happen because this method only handles full traverses - case 6: - { - switch( currentRegion ) - { case 1: { - afterTraverse << coordsToPixels( keyMin, valueMax ); + switch (currentRegion) + { + case 6: { beforeTraverse << coordsToPixels(keyMin, valueMax); break; } + case 9: { beforeTraverse << coordsToPixels(keyMin, valueMax); afterTraverse << coordsToPixels(keyMax, valueMin); break; } + case 8: { beforeTraverse << coordsToPixels(keyMin, valueMax); break; } + } break; } - case 7: - { - afterTraverse << coordsToPixels( keyMax, valueMax ); - break; - } - } - break; - } - case 7: - { - switch( currentRegion ) - { case 2: { - beforeTraverse << coordsToPixels( keyMax, valueMax ); + switch (currentRegion) + { + case 7: { afterTraverse << coordsToPixels(keyMax, valueMax); break; } + case 9: { afterTraverse << coordsToPixels(keyMax, valueMin); break; } + } break; } case 3: { - beforeTraverse << coordsToPixels( keyMax, valueMax ); - afterTraverse << coordsToPixels( keyMin, valueMin ); - break; - } - case 6: - { - beforeTraverse << coordsToPixels( keyMax, valueMax ); - break; - } - } - break; - } - case 8: - { - switch( currentRegion ) - { - case 1: - { - afterTraverse << coordsToPixels( keyMin, valueMax ); - break; - } - case 3: - { - afterTraverse << coordsToPixels( keyMin, valueMin ); - break; - } - } - break; - } - case 9: - { - switch( currentRegion ) - { - case 2: - { - beforeTraverse << coordsToPixels( keyMax, valueMin ); - break; - } - case 1: - { - beforeTraverse << coordsToPixels( keyMax, valueMin ); - afterTraverse << coordsToPixels( keyMin, valueMax ); + switch (currentRegion) + { + case 4: { beforeTraverse << coordsToPixels(keyMin, valueMin); break; } + case 7: { beforeTraverse << coordsToPixels(keyMin, valueMin); afterTraverse << coordsToPixels(keyMax, valueMax); break; } + case 8: { beforeTraverse << coordsToPixels(keyMin, valueMin); break; } + } break; } case 4: { - beforeTraverse << coordsToPixels( keyMax, valueMin ); + switch (currentRegion) + { + case 3: { afterTraverse << coordsToPixels(keyMin, valueMin); break; } + case 9: { afterTraverse << coordsToPixels(keyMax, valueMin); break; } + } break; } + case 5: { break; } // shouldn't happen because this method only handles full traverses + case 6: + { + switch (currentRegion) + { + case 1: { afterTraverse << coordsToPixels(keyMin, valueMax); break; } + case 7: { afterTraverse << coordsToPixels(keyMax, valueMax); break; } + } + break; + } + case 7: + { + switch (currentRegion) + { + case 2: { beforeTraverse << coordsToPixels(keyMax, valueMax); break; } + case 3: { beforeTraverse << coordsToPixels(keyMax, valueMax); afterTraverse << coordsToPixels(keyMin, valueMin); break; } + case 6: { beforeTraverse << coordsToPixels(keyMax, valueMax); break; } + } + break; + } + case 8: + { + switch (currentRegion) + { + case 1: { afterTraverse << coordsToPixels(keyMin, valueMax); break; } + case 3: { afterTraverse << coordsToPixels(keyMin, valueMin); break; } + } + break; + } + case 9: + { + switch (currentRegion) + { + case 2: { beforeTraverse << coordsToPixels(keyMax, valueMin); break; } + case 1: { beforeTraverse << coordsToPixels(keyMax, valueMin); afterTraverse << coordsToPixels(keyMin, valueMax); break; } + case 4: { beforeTraverse << coordsToPixels(keyMax, valueMin); break; } + } + break; } - break; - } } } @@ -23741,56 +23048,58 @@ void QCPCurve::getTraverseCornerPoints( int prevRegion, int currentRegion, doubl is \ref QCPScatterStyle::ssNone (i.e. there is no visual representation of the curve), returns -1.0. */ -double QCPCurve::pointDistance( const QPointF& pixelPoint, QCPCurveDataContainer::const_iterator& closestData ) const +double QCPCurve::pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const { closestData = mDataContainer->constEnd(); - if( mDataContainer->isEmpty() ) + if (mDataContainer->isEmpty()) return -1.0; - if( mLineStyle == lsNone && mScatterStyle.isNone() ) + if (mLineStyle == lsNone && mScatterStyle.isNone()) return -1.0; - - if( mDataContainer->size() == 1 ) + + if (mDataContainer->size() == 1) { - QPointF dataPoint = coordsToPixels( mDataContainer->constBegin()->key, mDataContainer->constBegin()->value ); + QPointF dataPoint = coordsToPixels(mDataContainer->constBegin()->key, mDataContainer->constBegin()->value); closestData = mDataContainer->constBegin(); - return QCPVector2D( dataPoint - pixelPoint ).length(); + return QCPVector2D(dataPoint-pixelPoint).length(); } - + // calculate minimum distances to curve data points and find closestData iterator: double minDistSqr = std::numeric_limits::max(); // iterate over found data points and then choose the one with the shortest distance to pos: QCPCurveDataContainer::const_iterator begin = mDataContainer->constBegin(); QCPCurveDataContainer::const_iterator end = mDataContainer->constEnd(); - for( QCPCurveDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPCurveDataContainer::const_iterator it=begin; it!=end; ++it) { - const double currentDistSqr = QCPVector2D( coordsToPixels( it->key, it->value ) - pixelPoint ).lengthSquared(); - if( currentDistSqr < minDistSqr ) + const double currentDistSqr = QCPVector2D(coordsToPixels(it->key, it->value)-pixelPoint).lengthSquared(); + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; closestData = it; } } - + // calculate distance to line if there is one (if so, will probably be smaller than distance to closest data point): - if( mLineStyle != lsNone ) + if (mLineStyle != lsNone) { QVector lines; - getCurveLines( &lines, QCPDataRange( 0, dataCount() ), mParentPlot->selectionTolerance() * 1.2 ); // optimized lines outside axis rect shouldn't respond to clicks at the edge, so use 1.2*tolerance as pen width - for( int i = 0; i < lines.size() - 1; ++i ) + getCurveLines(&lines, QCPDataRange(0, dataCount()), mParentPlot->selectionTolerance()*1.2); // optimized lines outside axis rect shouldn't respond to clicks at the edge, so use 1.2*tolerance as pen width + for (int i=0; i= 0 && index < mBars.size() ) + if (index >= 0 && index < mBars.size()) { - return mBars.at( index ); - } - else + return mBars.at(index); + } else { qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; return 0; @@ -23921,8 +23232,8 @@ QCPBars* QCPBarsGroup::bars( int index ) const */ void QCPBarsGroup::clear() { - foreach( QCPBars* bars, mBars ) // since foreach takes a copy, removing bars in the loop is okay - bars->setBarsGroup( 0 ); // removes itself via removeBars + foreach (QCPBars *bars, mBars) // since foreach takes a copy, removing bars in the loop is okay + bars->setBarsGroup(0); // removes itself via removeBars } /*! @@ -23931,18 +23242,18 @@ void QCPBarsGroup::clear() \see insert, remove */ -void QCPBarsGroup::append( QCPBars* bars ) +void QCPBarsGroup::append(QCPBars *bars) { - if( !bars ) + if (!bars) { qDebug() << Q_FUNC_INFO << "bars is 0"; return; } - - if( !mBars.contains( bars ) ) - bars->setBarsGroup( this ); + + if (!mBars.contains(bars)) + bars->setBarsGroup(this); else - qDebug() << Q_FUNC_INFO << "bars plottable is already in this bars group:" << reinterpret_cast( bars ); + qDebug() << Q_FUNC_INFO << "bars plottable is already in this bars group:" << reinterpret_cast(bars); } /*! @@ -23954,19 +23265,19 @@ void QCPBarsGroup::append( QCPBars* bars ) \see append, remove */ -void QCPBarsGroup::insert( int i, QCPBars* bars ) +void QCPBarsGroup::insert(int i, QCPBars *bars) { - if( !bars ) + if (!bars) { qDebug() << Q_FUNC_INFO << "bars is 0"; return; } - + // first append to bars list normally: - if( !mBars.contains( bars ) ) - bars->setBarsGroup( this ); + if (!mBars.contains(bars)) + bars->setBarsGroup(this); // then move to according position: - mBars.move( mBars.indexOf( bars ), qBound( 0, i, mBars.size() - 1 ) ); + mBars.move(mBars.indexOf(bars), qBound(0, i, mBars.size()-1)); } /*! @@ -23974,18 +23285,18 @@ void QCPBarsGroup::insert( int i, QCPBars* bars ) \see contains, clear */ -void QCPBarsGroup::remove( QCPBars* bars ) +void QCPBarsGroup::remove(QCPBars *bars) { - if( !bars ) + if (!bars) { qDebug() << Q_FUNC_INFO << "bars is 0"; return; } - - if( mBars.contains( bars ) ) - bars->setBarsGroup( 0 ); + + if (mBars.contains(bars)) + bars->setBarsGroup(0); else - qDebug() << Q_FUNC_INFO << "bars plottable is not in this bars group:" << reinterpret_cast( bars ); + qDebug() << Q_FUNC_INFO << "bars plottable is not in this bars group:" << reinterpret_cast(bars); } /*! \internal @@ -23995,10 +23306,10 @@ void QCPBarsGroup::remove( QCPBars* bars ) \see unregisterBars */ -void QCPBarsGroup::registerBars( QCPBars* bars ) +void QCPBarsGroup::registerBars(QCPBars *bars) { - if( !mBars.contains( bars ) ) - mBars.append( bars ); + if (!mBars.contains(bars)) + mBars.append(bars); } /*! \internal @@ -24008,9 +23319,9 @@ void QCPBarsGroup::registerBars( QCPBars* bars ) \see registerBars */ -void QCPBarsGroup::unregisterBars( QCPBars* bars ) +void QCPBarsGroup::unregisterBars(QCPBars *bars) { - mBars.removeOne( bars ); + mBars.removeOne(bars); } /*! \internal @@ -24019,59 +23330,57 @@ void QCPBarsGroup::unregisterBars( QCPBars* bars ) given key coordinate \a keyCoord. The offset is relative to the pixel position of the key coordinate \a keyCoord. */ -double QCPBarsGroup::keyPixelOffset( const QCPBars* bars, double keyCoord ) +double QCPBarsGroup::keyPixelOffset(const QCPBars *bars, double keyCoord) { // find list of all base bars in case some mBars are stacked: QList baseBars; - foreach( const QCPBars* b, mBars ) + foreach (const QCPBars *b, mBars) { - while( b->barBelow() ) + while (b->barBelow()) b = b->barBelow(); - if( !baseBars.contains( b ) ) - baseBars.append( b ); + if (!baseBars.contains(b)) + baseBars.append(b); } // find base bar this "bars" is stacked on: - const QCPBars* thisBase = bars; - while( thisBase->barBelow() ) + const QCPBars *thisBase = bars; + while (thisBase->barBelow()) thisBase = thisBase->barBelow(); - + // determine key pixel offset of this base bars considering all other base bars in this barsgroup: double result = 0; - int index = baseBars.indexOf( thisBase ); - if( index >= 0 ) + int index = baseBars.indexOf(thisBase); + if (index >= 0) { - if( baseBars.size() % 2 == 1 && index == ( baseBars.size() - 1 ) / 2 ) // is center bar (int division on purpose) + if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2) // is center bar (int division on purpose) { return result; - } - else + } else { double lowerPixelWidth, upperPixelWidth; int startIndex; - int dir = ( index <= ( baseBars.size() - 1 ) / 2 ) ? -1 : 1; // if bar is to lower keys of center, dir is negative - if( baseBars.size() % 2 == 0 ) // even number of bars + int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1; // if bar is to lower keys of center, dir is negative + if (baseBars.size() % 2 == 0) // even number of bars { - startIndex = baseBars.size() / 2 + ( dir < 0 ? -1 : 0 ); - result += getPixelSpacing( baseBars.at( startIndex ), keyCoord ) * 0.5; // half of middle spacing + startIndex = baseBars.size()/2 + (dir < 0 ? -1 : 0); + result += getPixelSpacing(baseBars.at(startIndex), keyCoord)*0.5; // half of middle spacing + } else // uneven number of bars + { + startIndex = (baseBars.size()-1)/2+dir; + baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // half of center bar + result += getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord); // center bar spacing } - else // uneven number of bars + for (int i = startIndex; i != index; i += dir) // add widths and spacings of bars in between center and our bars { - startIndex = ( baseBars.size() - 1 ) / 2 + dir; - baseBars.at( ( baseBars.size() - 1 ) / 2 )->getPixelWidth( keyCoord, lowerPixelWidth, upperPixelWidth ); - result += qAbs( upperPixelWidth - lowerPixelWidth ) * 0.5; // half of center bar - result += getPixelSpacing( baseBars.at( ( baseBars.size() - 1 ) / 2 ), keyCoord ); // center bar spacing - } - for( int i = startIndex; i != index; i += dir ) // add widths and spacings of bars in between center and our bars - { - baseBars.at( i )->getPixelWidth( keyCoord, lowerPixelWidth, upperPixelWidth ); - result += qAbs( upperPixelWidth - lowerPixelWidth ); - result += getPixelSpacing( baseBars.at( i ), keyCoord ); + baseBars.at(i)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth); + result += getPixelSpacing(baseBars.at(i), keyCoord); } // finally half of our bars width: - baseBars.at( index )->getPixelWidth( keyCoord, lowerPixelWidth, upperPixelWidth ); - result += qAbs( upperPixelWidth - lowerPixelWidth ) * 0.5; + baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // correct sign of result depending on orientation and direction of key axis: - result *= dir * thisBase->keyAxis()->pixelOrientation(); + result *= dir*thisBase->keyAxis()->pixelOrientation(); } } return result; @@ -24087,30 +23396,31 @@ double QCPBarsGroup::keyPixelOffset( const QCPBars* bars, double keyCoord ) stAxisRectRatio and \ref stPlotCoords. The \a keyCoord is only relevant for spacings given in \ref stPlotCoords on a logarithmic axis. */ -double QCPBarsGroup::getPixelSpacing( const QCPBars* bars, double keyCoord ) +double QCPBarsGroup::getPixelSpacing(const QCPBars *bars, double keyCoord) { - switch( mSpacingType ) + switch (mSpacingType) { - case stAbsolute: - { - return mSpacing; - } - case stAxisRectRatio: - { - if( bars->keyAxis()->orientation() == Qt::Horizontal ) - return bars->keyAxis()->axisRect()->width() * mSpacing; - else - return bars->keyAxis()->axisRect()->height() * mSpacing; - } - case stPlotCoords: - { - double keyPixel = bars->keyAxis()->coordToPixel( keyCoord ); - return qAbs( bars->keyAxis()->coordToPixel( keyCoord + mSpacing ) - keyPixel ); - } + case stAbsolute: + { + return mSpacing; + } + case stAxisRectRatio: + { + if (bars->keyAxis()->orientation() == Qt::Horizontal) + return bars->keyAxis()->axisRect()->width()*mSpacing; + else + return bars->keyAxis()->axisRect()->height()*mSpacing; + } + case stPlotCoords: + { + double keyPixel = bars->keyAxis()->coordToPixel(keyCoord); + return qAbs(bars->keyAxis()->coordToPixel(keyCoord+mSpacing)-keyPixel); + } } return 0; } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPBarsData //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -24185,19 +23495,22 @@ double QCPBarsGroup::getPixelSpacing( const QCPBars* bars, double keyCoord ) /*! Constructs a bar data point with key and value set to zero. */ -QCPBarsData::QCPBarsData() - : key( 0 ), value( 0 ) +QCPBarsData::QCPBarsData() : + key(0), + value(0) { } /*! Constructs a bar data point with the specified \a key and \a value. */ -QCPBarsData::QCPBarsData( double key, double value ) - : key( key ), value( value ) +QCPBarsData::QCPBarsData(double key, double value) : + key(key), + value(value) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPBars //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -24272,22 +23585,27 @@ QCPBarsData::QCPBarsData( double key, double value ) keyAxis. This QCustomPlot instance takes ownership of the QCPBars, so do not delete it manually but use QCustomPlot::removePlottable() instead. */ -QCPBars::QCPBars( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable1D( keyAxis, valueAxis ), mWidth( 0.75 ), mWidthType( wtPlotCoords ), mBarsGroup( 0 ), mBaseValue( 0 ), mStackingGap( 0 ) +QCPBars::QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable1D(keyAxis, valueAxis), + mWidth(0.75), + mWidthType(wtPlotCoords), + mBarsGroup(0), + mBaseValue(0), + mStackingGap(0) { // modify inherited properties from abstract plottable: - mPen.setColor( Qt::blue ); - mPen.setStyle( Qt::SolidLine ); - mBrush.setColor( QColor( 40, 50, 255, 30 ) ); - mBrush.setStyle( Qt::SolidPattern ); - mSelectionDecorator->setBrush( QBrush( QColor( 160, 160, 255 ) ) ); + mPen.setColor(Qt::blue); + mPen.setStyle(Qt::SolidLine); + mBrush.setColor(QColor(40, 50, 255, 30)); + mBrush.setStyle(Qt::SolidPattern); + mSelectionDecorator->setBrush(QBrush(QColor(160, 160, 255))); } QCPBars::~QCPBars() { - setBarsGroup( 0 ); - if( mBarBelow || mBarAbove ) - connectBars( mBarBelow.data(), mBarAbove.data() ); // take this bar out of any stacking + setBarsGroup(0); + if (mBarBelow || mBarAbove) + connectBars(mBarBelow.data(), mBarAbove.data()); // take this bar out of any stacking } /*! \overload @@ -24305,7 +23623,7 @@ QCPBars::~QCPBars() \see addData */ -void QCPBars::setData( QSharedPointer data ) +void QCPBars::setData(QSharedPointer data) { mDataContainer = data; } @@ -24321,10 +23639,10 @@ void QCPBars::setData( QSharedPointer data ) \see addData */ -void QCPBars::setData( const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPBars::setData(const QVector &keys, const QVector &values, bool alreadySorted) { mDataContainer->clear(); - addData( keys, values, alreadySorted ); + addData(keys, values, alreadySorted); } /*! @@ -24333,7 +23651,7 @@ void QCPBars::setData( const QVector& keys, const QVector& value How the number passed as \a width is interpreted (e.g. screen pixels, plot coordinates,...), depends on the currently set width type, see \ref setWidthType and \ref WidthType. */ -void QCPBars::setWidth( double width ) +void QCPBars::setWidth(double width) { mWidth = width; } @@ -24346,7 +23664,7 @@ void QCPBars::setWidth( double width ) \see setWidth */ -void QCPBars::setWidthType( QCPBars::WidthType widthType ) +void QCPBars::setWidthType(QCPBars::WidthType widthType) { mWidthType = widthType; } @@ -24357,15 +23675,15 @@ void QCPBars::setWidthType( QCPBars::WidthType widthType ) To remove this QCPBars from any group, set \a barsGroup to 0. */ -void QCPBars::setBarsGroup( QCPBarsGroup* barsGroup ) +void QCPBars::setBarsGroup(QCPBarsGroup *barsGroup) { // deregister at old group: - if( mBarsGroup ) - mBarsGroup->unregisterBars( this ); + if (mBarsGroup) + mBarsGroup->unregisterBars(this); mBarsGroup = barsGroup; // register at new group: - if( mBarsGroup ) - mBarsGroup->registerBars( this ); + if (mBarsGroup) + mBarsGroup->registerBars(this); } /*! @@ -24380,7 +23698,7 @@ void QCPBars::setBarsGroup( QCPBarsGroup* barsGroup ) The default base value is 0. */ -void QCPBars::setBaseValue( double baseValue ) +void QCPBars::setBaseValue(double baseValue) { mBaseValue = baseValue; } @@ -24390,7 +23708,7 @@ void QCPBars::setBaseValue( double baseValue ) allows specifying a distance in \a pixels, by which the drawn bar rectangles will be separated by the bars below it. */ -void QCPBars::setStackingGap( double pixels ) +void QCPBars::setStackingGap(double pixels) { mStackingGap = pixels; } @@ -24407,23 +23725,23 @@ void QCPBars::setStackingGap( double pixels ) Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPBars::addData( const QVector& keys, const QVector& values, bool alreadySorted ) +void QCPBars::addData(const QVector &keys, const QVector &values, bool alreadySorted) { - if( keys.size() != values.size() ) + if (keys.size() != values.size()) qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); - const int n = qMin( keys.size(), values.size() ); - QVector tempData( n ); + const int n = qMin(keys.size(), values.size()); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->key = keys[i]; it->value = values[i]; ++it; ++i; } - mDataContainer->add( tempData, alreadySorted ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -24432,9 +23750,9 @@ void QCPBars::addData( const QVector& keys, const QVector& value Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPBars::addData( double key, double value ) +void QCPBars::addData(double key, double value) { - mDataContainer->add( QCPBarsData( key, value ) ); + mDataContainer->add(QCPBarsData(key, value)); } /*! @@ -24451,23 +23769,22 @@ void QCPBars::addData( double key, double value ) \see moveBelow, barAbove, barBelow */ -void QCPBars::moveBelow( QCPBars* bars ) +void QCPBars::moveBelow(QCPBars *bars) { - if( bars == this ) - return; - if( bars && ( bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data() ) ) + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) { qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; return; } // remove from stacking: - connectBars( mBarBelow.data(), mBarAbove.data() ); // Note: also works if one (or both) of them is 0 + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 // if new bar given, insert this bar below it: - if( bars ) + if (bars) { - if( bars->mBarBelow ) - connectBars( bars->mBarBelow.data(), this ); - connectBars( this, bars ); + if (bars->mBarBelow) + connectBars(bars->mBarBelow.data(), this); + connectBars(this, bars); } } @@ -24485,73 +23802,72 @@ void QCPBars::moveBelow( QCPBars* bars ) \see moveBelow, barBelow, barAbove */ -void QCPBars::moveAbove( QCPBars* bars ) +void QCPBars::moveAbove(QCPBars *bars) { - if( bars == this ) - return; - if( bars && ( bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data() ) ) + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) { qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; return; } // remove from stacking: - connectBars( mBarBelow.data(), mBarAbove.data() ); // Note: also works if one (or both) of them is 0 + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 // if new bar given, insert this bar above it: - if( bars ) + if (bars) { - if( bars->mBarAbove ) - connectBars( this, bars->mBarAbove.data() ); - connectBars( bars, this ); + if (bars->mBarAbove) + connectBars(this, bars->mBarAbove.data()); + connectBars(bars, this); } } /*! \copydoc QCPPlottableInterface1D::selectTestRect */ -QCPDataSelection QCPBars::selectTestRect( const QRectF& rect, bool onlySelectable ) const +QCPDataSelection QCPBars::selectTestRect(const QRectF &rect, bool onlySelectable) const { QCPDataSelection result; - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return result; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return result; - + QCPBarsDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - - for( QCPBarsDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + getVisibleDataBounds(visibleBegin, visibleEnd); + + for (QCPBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { - if( rect.intersects( getBarRect( it->key, it->value ) ) ) - result.addDataRange( QCPDataRange( it - mDataContainer->constBegin(), it - mDataContainer->constBegin() + 1 ), false ); + if (rect.intersects(getBarRect(it->key, it->value))) + result.addDataRange(QCPDataRange(it-mDataContainer->constBegin(), it-mDataContainer->constBegin()+1), false); } result.simplify(); return result; } /* inherits documentation from base class */ -double QCPBars::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + Q_UNUSED(details) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { // get visible data range: QCPBarsDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - for( QCPBarsDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + getVisibleDataBounds(visibleBegin, visibleEnd); + for (QCPBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { - if( getBarRect( it->key, it->value ).contains( pos ) ) + if (getBarRect(it->key, it->value).contains(pos)) { - if( details ) + if (details) { - int pointIndex = it - mDataContainer->constBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = it-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } - return mParentPlot->selectionTolerance() * 0.99; + return mParentPlot->selectionTolerance()*0.99; } } } @@ -24559,7 +23875,7 @@ double QCPBars::selectTest( const QPointF& pos, bool onlySelectable, QVariant* d } /* inherits documentation from base class */ -QCPRange QCPBars::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPBars::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { /* Note: If this QCPBars uses absolute pixels as width (or is in a QCPBarsGroup with spacing in absolute pixels), using this method to adapt the key axis range to fit the bars into the @@ -24571,95 +23887,89 @@ QCPRange QCPBars::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) better fit, he should call the corresponding axis rescale multiple times in a row. */ QCPRange range; - range = mDataContainer->keyRange( foundRange, inSignDomain ); - + range = mDataContainer->keyRange(foundRange, inSignDomain); + // determine exact range of bars by including bar width and barsgroup offset: - if( foundRange && mKeyAxis ) + if (foundRange && mKeyAxis) { double lowerPixelWidth, upperPixelWidth, keyPixel; // lower range bound: - getPixelWidth( range.lower, lowerPixelWidth, upperPixelWidth ); - keyPixel = mKeyAxis.data()->coordToPixel( range.lower ) + lowerPixelWidth; - if( mBarsGroup ) - keyPixel += mBarsGroup->keyPixelOffset( this, range.lower ); - const double lowerCorrected = mKeyAxis.data()->pixelToCoord( keyPixel ); - if( !qIsNaN( lowerCorrected ) && qIsFinite( lowerCorrected ) && range.lower > lowerCorrected ) + getPixelWidth(range.lower, lowerPixelWidth, upperPixelWidth); + keyPixel = mKeyAxis.data()->coordToPixel(range.lower) + lowerPixelWidth; + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, range.lower); + const double lowerCorrected = mKeyAxis.data()->pixelToCoord(keyPixel); + if (!qIsNaN(lowerCorrected) && qIsFinite(lowerCorrected) && range.lower > lowerCorrected) range.lower = lowerCorrected; // upper range bound: - getPixelWidth( range.upper, lowerPixelWidth, upperPixelWidth ); - keyPixel = mKeyAxis.data()->coordToPixel( range.upper ) + upperPixelWidth; - if( mBarsGroup ) - keyPixel += mBarsGroup->keyPixelOffset( this, range.upper ); - const double upperCorrected = mKeyAxis.data()->pixelToCoord( keyPixel ); - if( !qIsNaN( upperCorrected ) && qIsFinite( upperCorrected ) && range.upper < upperCorrected ) + getPixelWidth(range.upper, lowerPixelWidth, upperPixelWidth); + keyPixel = mKeyAxis.data()->coordToPixel(range.upper) + upperPixelWidth; + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, range.upper); + const double upperCorrected = mKeyAxis.data()->pixelToCoord(keyPixel); + if (!qIsNaN(upperCorrected) && qIsFinite(upperCorrected) && range.upper < upperCorrected) range.upper = upperCorrected; } return range; } /* inherits documentation from base class */ -QCPRange QCPBars::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPBars::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { // Note: can't simply use mDataContainer->valueRange here because we need to // take into account bar base value and possible stacking of multiple bars QCPRange range; range.lower = mBaseValue; range.upper = mBaseValue; - bool haveLower = true; // set to true, because baseValue should always be visible in bar charts - bool haveUpper = true; // set to true, because baseValue should always be visible in bar charts + bool haveLower = true; // set to true, because baseValue should always be visible in bar charts + bool haveUpper = true; // set to true, because baseValue should always be visible in bar charts QCPBarsDataContainer::const_iterator itBegin = mDataContainer->constBegin(); QCPBarsDataContainer::const_iterator itEnd = mDataContainer->constEnd(); - if( inKeyRange != QCPRange() ) + if (inKeyRange != QCPRange()) { - itBegin = mDataContainer->findBegin( inKeyRange.lower ); - itEnd = mDataContainer->findEnd( inKeyRange.upper ); + itBegin = mDataContainer->findBegin(inKeyRange.lower); + itEnd = mDataContainer->findEnd(inKeyRange.upper); } - for( QCPBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it ) + for (QCPBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it) { - const double current = it->value + getStackedBaseValue( it->key, it->value >= 0 ); - if( qIsNaN( current ) ) - continue; - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + const double current = it->value + getStackedBaseValue(it->key, it->value >= 0); + if (qIsNaN(current)) continue; + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; } - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; } } } - - foundRange = true; // return true because bar charts always have the 0-line visible + + foundRange = true; // return true because bar charts always have the 0-line visible return range; } /* inherits documentation from base class */ -QPointF QCPBars::dataPixelPosition( int index ) const +QPointF QCPBars::dataPixelPosition(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QPointF(); - } - - const QCPDataContainer::const_iterator it = mDataContainer->constBegin() + index; - const double valuePixel = valueAxis->coordToPixel( getStackedBaseValue( it->key, it->value >= 0 ) + it->value ); - const double keyPixel = keyAxis->coordToPixel( it->key ) + ( mBarsGroup ? mBarsGroup->keyPixelOffset( this, it->key ) : 0 ); - if( keyAxis->orientation() == Qt::Horizontal ) - return QPointF( keyPixel, valuePixel ); + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + const QCPDataContainer::const_iterator it = mDataContainer->constBegin()+index; + const double valuePixel = valueAxis->coordToPixel(getStackedBaseValue(it->key, it->value >= 0) + it->value); + const double keyPixel = keyAxis->coordToPixel(it->key) + (mBarsGroup ? mBarsGroup->keyPixelOffset(this, it->key) : 0); + if (keyAxis->orientation() == Qt::Horizontal) + return QPointF(keyPixel, valuePixel); else - return QPointF( valuePixel, keyPixel ); - } - else + return QPointF(valuePixel, keyPixel); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; return QPointF(); @@ -24667,71 +23977,64 @@ QPointF QCPBars::dataPixelPosition( int index ) const } /* inherits documentation from base class */ -void QCPBars::draw( QCPPainter* painter ) +void QCPBars::draw(QCPPainter *painter) { - if( !mKeyAxis || !mValueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - if( mDataContainer->isEmpty() ) - return; - + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mDataContainer->isEmpty()) return; + QCPBarsDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - + getVisibleDataBounds(visibleBegin, visibleEnd); + // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); QCPBarsDataContainer::const_iterator begin = visibleBegin; QCPBarsDataContainer::const_iterator end = visibleEnd; - mDataContainer->limitIteratorsToDataRange( begin, end, allSegments.at( i ) ); - if( begin == end ) + mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i)); + if (begin == end) continue; - - for( QCPBarsDataContainer::const_iterator it = begin; it != end; ++it ) + + for (QCPBarsDataContainer::const_iterator it=begin; it!=end; ++it) { - // check data validity if flag set: + // check data validity if flag set: #ifdef QCUSTOMPLOT_CHECK_DATA - if( QCP::isInvalidData( it->key, it->value ) ) - qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "of drawn range invalid." - << "Plottable name:" << name(); + if (QCP::isInvalidData(it->key, it->value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "of drawn range invalid." << "Plottable name:" << name(); #endif // draw bar: - if( isSelectedSegment && mSelectionDecorator ) + if (isSelectedSegment && mSelectionDecorator) { - mSelectionDecorator->applyBrush( painter ); - mSelectionDecorator->applyPen( painter ); - } - else + mSelectionDecorator->applyBrush(painter); + mSelectionDecorator->applyPen(painter); + } else { - painter->setBrush( mBrush ); - painter->setPen( mPen ); + painter->setBrush(mBrush); + painter->setPen(mPen); } - applyDefaultAntialiasingHint( painter ); - painter->drawPolygon( getBarRect( it->key, it->value ) ); + applyDefaultAntialiasingHint(painter); + painter->drawPolygon(getBarRect(it->key, it->value)); } } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPBars::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { // draw filled rect: - applyDefaultAntialiasingHint( painter ); - painter->setBrush( mBrush ); - painter->setPen( mPen ); - QRectF r = QRectF( 0, 0, rect.width() * 0.67, rect.height() * 0.67 ); - r.moveCenter( rect.center() ); - painter->drawRect( r ); + applyDefaultAntialiasingHint(painter); + painter->setBrush(mBrush); + painter->setPen(mPen); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); } /*! \internal @@ -24748,54 +24051,54 @@ void QCPBars::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const if the plottable contains no data, both \a begin and \a end point to constEnd. */ -void QCPBars::getVisibleDataBounds( QCPBarsDataContainer::const_iterator& begin, QCPBarsDataContainer::const_iterator& end ) const +void QCPBars::getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const { - if( !mKeyAxis ) + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; begin = mDataContainer->constEnd(); end = mDataContainer->constEnd(); return; } - if( mDataContainer->isEmpty() ) + if (mDataContainer->isEmpty()) { begin = mDataContainer->constEnd(); end = mDataContainer->constEnd(); return; } - + // get visible data range as QMap iterators - begin = mDataContainer->findBegin( mKeyAxis.data()->range().lower ); - end = mDataContainer->findEnd( mKeyAxis.data()->range().upper ); - double lowerPixelBound = mKeyAxis.data()->coordToPixel( mKeyAxis.data()->range().lower ); - double upperPixelBound = mKeyAxis.data()->coordToPixel( mKeyAxis.data()->range().upper ); + begin = mDataContainer->findBegin(mKeyAxis.data()->range().lower); + end = mDataContainer->findEnd(mKeyAxis.data()->range().upper); + double lowerPixelBound = mKeyAxis.data()->coordToPixel(mKeyAxis.data()->range().lower); + double upperPixelBound = mKeyAxis.data()->coordToPixel(mKeyAxis.data()->range().upper); bool isVisible = false; // walk left from begin to find lower bar that actually is completely outside visible pixel range: QCPBarsDataContainer::const_iterator it = begin; - while( it != mDataContainer->constBegin() ) + while (it != mDataContainer->constBegin()) { --it; - const QRectF barRect = getBarRect( it->key, it->value ); - if( mKeyAxis.data()->orientation() == Qt::Horizontal ) - isVisible = ( ( !mKeyAxis.data()->rangeReversed() && barRect.right() >= lowerPixelBound ) || ( mKeyAxis.data()->rangeReversed() && barRect.left() <= lowerPixelBound ) ); - else // keyaxis is vertical - isVisible = ( ( !mKeyAxis.data()->rangeReversed() && barRect.top() <= lowerPixelBound ) || ( mKeyAxis.data()->rangeReversed() && barRect.bottom() >= lowerPixelBound ) ); - if( isVisible ) + const QRectF barRect = getBarRect(it->key, it->value); + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + isVisible = ((!mKeyAxis.data()->rangeReversed() && barRect.right() >= lowerPixelBound) || (mKeyAxis.data()->rangeReversed() && barRect.left() <= lowerPixelBound)); + else // keyaxis is vertical + isVisible = ((!mKeyAxis.data()->rangeReversed() && barRect.top() <= lowerPixelBound) || (mKeyAxis.data()->rangeReversed() && barRect.bottom() >= lowerPixelBound)); + if (isVisible) begin = it; else break; } // walk right from ubound to find upper bar that actually is completely outside visible pixel range: it = end; - while( it != mDataContainer->constEnd() ) + while (it != mDataContainer->constEnd()) { - const QRectF barRect = getBarRect( it->key, it->value ); - if( mKeyAxis.data()->orientation() == Qt::Horizontal ) - isVisible = ( ( !mKeyAxis.data()->rangeReversed() && barRect.left() <= upperPixelBound ) || ( mKeyAxis.data()->rangeReversed() && barRect.right() >= upperPixelBound ) ); - else // keyaxis is vertical - isVisible = ( ( !mKeyAxis.data()->rangeReversed() && barRect.bottom() >= upperPixelBound ) || ( mKeyAxis.data()->rangeReversed() && barRect.top() <= upperPixelBound ) ); - if( isVisible ) - end = it + 1; + const QRectF barRect = getBarRect(it->key, it->value); + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + isVisible = ((!mKeyAxis.data()->rangeReversed() && barRect.left() <= upperPixelBound) || (mKeyAxis.data()->rangeReversed() && barRect.right() >= upperPixelBound)); + else // keyaxis is vertical + isVisible = ((!mKeyAxis.data()->rangeReversed() && barRect.bottom() >= upperPixelBound) || (mKeyAxis.data()->rangeReversed() && barRect.top() <= upperPixelBound)); + if (isVisible) + end = it+1; else break; ++it; @@ -24808,36 +24111,31 @@ void QCPBars::getVisibleDataBounds( QCPBarsDataContainer::const_iterator& begin, rect is shifted according to the bar stacking (see \ref moveAbove) and base value (see \ref setBaseValue), and to have non-overlapping border lines with the bars stacked below. */ -QRectF QCPBars::getBarRect( double key, double value ) const +QRectF QCPBars::getBarRect(double key, double value) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QRectF(); - } - + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QRectF(); } + double lowerPixelWidth, upperPixelWidth; - getPixelWidth( key, lowerPixelWidth, upperPixelWidth ); - double base = getStackedBaseValue( key, value >= 0 ); - double basePixel = valueAxis->coordToPixel( base ); - double valuePixel = valueAxis->coordToPixel( base + value ); - double keyPixel = keyAxis->coordToPixel( key ); - if( mBarsGroup ) - keyPixel += mBarsGroup->keyPixelOffset( this, key ); - double bottomOffset = ( mBarBelow && mPen != Qt::NoPen ? 1 : 0 ) * ( mPen.isCosmetic() ? 1 : mPen.widthF() ); + getPixelWidth(key, lowerPixelWidth, upperPixelWidth); + double base = getStackedBaseValue(key, value >= 0); + double basePixel = valueAxis->coordToPixel(base); + double valuePixel = valueAxis->coordToPixel(base+value); + double keyPixel = keyAxis->coordToPixel(key); + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, key); + double bottomOffset = (mBarBelow && mPen != Qt::NoPen ? 1 : 0)*(mPen.isCosmetic() ? 1 : mPen.widthF()); bottomOffset += mBarBelow ? mStackingGap : 0; - bottomOffset *= ( value < 0 ? -1 : 1 ) * valueAxis->pixelOrientation(); - if( qAbs( valuePixel - basePixel ) <= qAbs( bottomOffset ) ) - bottomOffset = valuePixel - basePixel; - if( keyAxis->orientation() == Qt::Horizontal ) + bottomOffset *= (value<0 ? -1 : 1)*valueAxis->pixelOrientation(); + if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset)) + bottomOffset = valuePixel-basePixel; + if (keyAxis->orientation() == Qt::Horizontal) { - return QRectF( QPointF( keyPixel + lowerPixelWidth, valuePixel ), QPointF( keyPixel + upperPixelWidth, basePixel + bottomOffset ) ).normalized(); - } - else + return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized(); + } else { - return QRectF( QPointF( basePixel + bottomOffset, keyPixel + lowerPixelWidth ), QPointF( valuePixel, keyPixel + upperPixelWidth ) ).normalized(); + return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized(); } } @@ -24850,46 +24148,44 @@ QRectF QCPBars::getBarRect( double key, double value ) const and higher keys, relative to the \a key coordinate (so with a non-reversed horizontal axis, \a lower is negative and \a upper positive). */ -void QCPBars::getPixelWidth( double key, double& lower, double& upper ) const +void QCPBars::getPixelWidth(double key, double &lower, double &upper) const { lower = 0; upper = 0; - switch( mWidthType ) + switch (mWidthType) { - case wtAbsolute: - { - upper = mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); - lower = -upper; - break; - } - case wtAxisRectRatio: - { - if( mKeyAxis && mKeyAxis.data()->axisRect() ) + case wtAbsolute: { - if( mKeyAxis.data()->orientation() == Qt::Horizontal ) - upper = mKeyAxis.data()->axisRect()->width() * mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); - else - upper = mKeyAxis.data()->axisRect()->height() * mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); + upper = mWidth*0.5*mKeyAxis.data()->pixelOrientation(); lower = -upper; + break; } - else - qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined"; - break; - } - case wtPlotCoords: - { - if( mKeyAxis ) + case wtAxisRectRatio: { - double keyPixel = mKeyAxis.data()->coordToPixel( key ); - upper = mKeyAxis.data()->coordToPixel( key + mWidth * 0.5 ) - keyPixel; - lower = mKeyAxis.data()->coordToPixel( key - mWidth * 0.5 ) - keyPixel; - // no need to qSwap(lower, higher) when range reversed, because higher/lower are gained by - // coordinate transform which includes range direction + if (mKeyAxis && mKeyAxis.data()->axisRect()) + { + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + upper = mKeyAxis.data()->axisRect()->width()*mWidth*0.5*mKeyAxis.data()->pixelOrientation(); + else + upper = mKeyAxis.data()->axisRect()->height()*mWidth*0.5*mKeyAxis.data()->pixelOrientation(); + lower = -upper; + } else + qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined"; + break; + } + case wtPlotCoords: + { + if (mKeyAxis) + { + double keyPixel = mKeyAxis.data()->coordToPixel(key); + upper = mKeyAxis.data()->coordToPixel(key+mWidth*0.5)-keyPixel; + lower = mKeyAxis.data()->coordToPixel(key-mWidth*0.5)-keyPixel; + // no need to qSwap(lower, higher) when range reversed, because higher/lower are gained by + // coordinate transform which includes range direction + } else + qDebug() << Q_FUNC_INFO << "No key axis defined"; + break; } - else - qDebug() << Q_FUNC_INFO << "No key axis defined"; - break; - } } } @@ -24902,31 +24198,30 @@ void QCPBars::getPixelWidth( double key, double& lower, double& upper ) const negative are stacked below baseValue downwards). This can be indicated with \a positive. So if the bar for which we need the base value is negative, set \a positive to false. */ -double QCPBars::getStackedBaseValue( double key, bool positive ) const +double QCPBars::getStackedBaseValue(double key, bool positive) const { - if( mBarBelow ) + if (mBarBelow) { - double max = 0; // don't initialize with mBaseValue here because only base value of bottom-most bar has meaning in a bar stack + double max = 0; // don't initialize with mBaseValue here because only base value of bottom-most bar has meaning in a bar stack // find bars of mBarBelow that are approximately at key and find largest one: - double epsilon = qAbs( key ) * ( sizeof( key ) == 4 ? 1e-6 : 1e-14 ); // should be safe even when changed to use float at some point - if( key == 0 ) - epsilon = ( sizeof( key ) == 4 ? 1e-6 : 1e-14 ); - QCPBarsDataContainer::const_iterator it = mBarBelow.data()->mDataContainer->findBegin( key - epsilon ); - QCPBarsDataContainer::const_iterator itEnd = mBarBelow.data()->mDataContainer->findEnd( key + epsilon ); - while( it != itEnd ) + double epsilon = qAbs(key)*(sizeof(key)==4 ? 1e-6 : 1e-14); // should be safe even when changed to use float at some point + if (key == 0) + epsilon = (sizeof(key)==4 ? 1e-6 : 1e-14); + QCPBarsDataContainer::const_iterator it = mBarBelow.data()->mDataContainer->findBegin(key-epsilon); + QCPBarsDataContainer::const_iterator itEnd = mBarBelow.data()->mDataContainer->findEnd(key+epsilon); + while (it != itEnd) { - if( it->key > key - epsilon && it->key < key + epsilon ) + if (it->key > key-epsilon && it->key < key+epsilon) { - if( ( positive && it->value > max ) || - ( !positive && it->value < max ) ) + if ((positive && it->value > max) || + (!positive && it->value < max)) max = it->value; } ++it; } // recurse down the bar-stack to find the total height: - return max + mBarBelow.data()->getStackedBaseValue( key, positive ); - } - else + return max + mBarBelow.data()->getStackedBaseValue(key, positive); + } else return mBaseValue; } @@ -24938,32 +24233,29 @@ double QCPBars::getStackedBaseValue( double key, bool positive ) const If lower is zero, upper will be disconnected at the bottom. If upper is zero, lower will be disconnected at the top. */ -void QCPBars::connectBars( QCPBars* lower, QCPBars* upper ) +void QCPBars::connectBars(QCPBars *lower, QCPBars *upper) { - if( !lower && !upper ) - return; - - if( !lower ) // disconnect upper at bottom + if (!lower && !upper) return; + + if (!lower) // disconnect upper at bottom { // disconnect old bar below upper: - if( upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper ) + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) upper->mBarBelow.data()->mBarAbove = 0; upper->mBarBelow = 0; - } - else if( !upper ) // disconnect lower at top + } else if (!upper) // disconnect lower at top { // disconnect old bar above lower: - if( lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower ) + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) lower->mBarAbove.data()->mBarBelow = 0; lower->mBarAbove = 0; - } - else // connect lower and upper + } else // connect lower and upper { // disconnect old bar above lower: - if( lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower ) + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) lower->mBarAbove.data()->mBarBelow = 0; // disconnect old bar below upper: - if( upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper ) + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) upper->mBarBelow.data()->mBarAbove = 0; lower->mBarAbove = upper; upper->mBarBelow = lower; @@ -24971,6 +24263,7 @@ void QCPBars::connectBars( QCPBars* lower, QCPBars* upper ) } /* end of 'src/plottables/plottable-bars.cpp' */ + /* including file 'src/plottables/plottable-statisticalbox.cpp', size 28622 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -25070,8 +24363,13 @@ void QCPBars::connectBars( QCPBars* lower, QCPBars* upper ) /*! Constructs a data point with key and all values set to zero. */ -QCPStatisticalBoxData::QCPStatisticalBoxData() - : key( 0 ), minimum( 0 ), lowerQuartile( 0 ), median( 0 ), upperQuartile( 0 ), maximum( 0 ) +QCPStatisticalBoxData::QCPStatisticalBoxData() : + key(0), + minimum(0), + lowerQuartile(0), + median(0), + upperQuartile(0), + maximum(0) { } @@ -25079,11 +24377,18 @@ QCPStatisticalBoxData::QCPStatisticalBoxData() Constructs a data point with the specified \a key, \a minimum, \a lowerQuartile, \a median, \a upperQuartile, \a maximum and optionally a number of \a outliers. */ -QCPStatisticalBoxData::QCPStatisticalBoxData( double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector& outliers ) - : key( key ), minimum( minimum ), lowerQuartile( lowerQuartile ), median( median ), upperQuartile( upperQuartile ), maximum( maximum ), outliers( outliers ) +QCPStatisticalBoxData::QCPStatisticalBoxData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector &outliers) : + key(key), + minimum(minimum), + lowerQuartile(lowerQuartile), + median(median), + upperQuartile(upperQuartile), + maximum(maximum), + outliers(outliers) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPStatisticalBox //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -25157,11 +24462,18 @@ QCPStatisticalBoxData::QCPStatisticalBoxData( double key, double minimum, double from \a keyAxis. This QCustomPlot instance takes ownership of the QCPStatisticalBox, so do not delete it manually but use QCustomPlot::removePlottable() instead. */ -QCPStatisticalBox::QCPStatisticalBox( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable1D( keyAxis, valueAxis ), mWidth( 0.5 ), mWhiskerWidth( 0.2 ), mWhiskerPen( Qt::black, 0, Qt::DashLine, Qt::FlatCap ), mWhiskerBarPen( Qt::black ), mWhiskerAntialiased( false ), mMedianPen( Qt::black, 3, Qt::SolidLine, Qt::FlatCap ), mOutlierStyle( QCPScatterStyle::ssCircle, Qt::blue, 6 ) +QCPStatisticalBox::QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable1D(keyAxis, valueAxis), + mWidth(0.5), + mWhiskerWidth(0.2), + mWhiskerPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap), + mWhiskerBarPen(Qt::black), + mWhiskerAntialiased(false), + mMedianPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap), + mOutlierStyle(QCPScatterStyle::ssCircle, Qt::blue, 6) { - setPen( QPen( Qt::black ) ); - setBrush( Qt::NoBrush ); + setPen(QPen(Qt::black)); + setBrush(Qt::NoBrush); } /*! \overload @@ -25180,7 +24492,7 @@ QCPStatisticalBox::QCPStatisticalBox( QCPAxis* keyAxis, QCPAxis* valueAxis ) \see addData */ -void QCPStatisticalBox::setData( QSharedPointer data ) +void QCPStatisticalBox::setData(QSharedPointer data) { mDataContainer = data; } @@ -25195,10 +24507,10 @@ void QCPStatisticalBox::setData( QSharedPointer \see addData */ -void QCPStatisticalBox::setData( const QVector& keys, const QVector& minimum, const QVector& lowerQuartile, const QVector& median, const QVector& upperQuartile, const QVector& maximum, bool alreadySorted ) +void QCPStatisticalBox::setData(const QVector &keys, const QVector &minimum, const QVector &lowerQuartile, const QVector &median, const QVector &upperQuartile, const QVector &maximum, bool alreadySorted) { mDataContainer->clear(); - addData( keys, minimum, lowerQuartile, median, upperQuartile, maximum, alreadySorted ); + addData(keys, minimum, lowerQuartile, median, upperQuartile, maximum, alreadySorted); } /*! @@ -25206,7 +24518,7 @@ void QCPStatisticalBox::setData( const QVector& keys, const QVector &outliers) */ -void QCPStatisticalBox::setOutlierStyle( const QCPScatterStyle& style ) +void QCPStatisticalBox::setOutlierStyle(const QCPScatterStyle &style) { mOutlierStyle = style; } @@ -25296,18 +24608,18 @@ void QCPStatisticalBox::setOutlierStyle( const QCPScatterStyle& style ) Alternatively, you can also access and modify the data directly via the \ref data method, which returns a pointer to the internal data container. */ -void QCPStatisticalBox::addData( const QVector& keys, const QVector& minimum, const QVector& lowerQuartile, const QVector& median, const QVector& upperQuartile, const QVector& maximum, bool alreadySorted ) +void QCPStatisticalBox::addData(const QVector &keys, const QVector &minimum, const QVector &lowerQuartile, const QVector &median, const QVector &upperQuartile, const QVector &maximum, bool alreadySorted) { - if( keys.size() != minimum.size() || minimum.size() != lowerQuartile.size() || lowerQuartile.size() != median.size() || - median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size() ) + if (keys.size() != minimum.size() || minimum.size() != lowerQuartile.size() || lowerQuartile.size() != median.size() || + median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size()) qDebug() << Q_FUNC_INFO << "keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:" << keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size(); - const int n = qMin( keys.size(), qMin( minimum.size(), qMin( lowerQuartile.size(), qMin( median.size(), qMin( upperQuartile.size(), maximum.size() ) ) ) ) ); - QVector tempData( n ); + const int n = qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size()))))); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->key = keys[i]; it->minimum = minimum[i]; @@ -25318,7 +24630,7 @@ void QCPStatisticalBox::addData( const QVector& keys, const QVectoradd( tempData, alreadySorted ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -25329,68 +24641,67 @@ void QCPStatisticalBox::addData( const QVector& keys, const QVector& outliers ) +void QCPStatisticalBox::addData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector &outliers) { - mDataContainer->add( QCPStatisticalBoxData( key, minimum, lowerQuartile, median, upperQuartile, maximum, outliers ) ); + mDataContainer->add(QCPStatisticalBoxData(key, minimum, lowerQuartile, median, upperQuartile, maximum, outliers)); } /*! \copydoc QCPPlottableInterface1D::selectTestRect */ -QCPDataSelection QCPStatisticalBox::selectTestRect( const QRectF& rect, bool onlySelectable ) const +QCPDataSelection QCPStatisticalBox::selectTestRect(const QRectF &rect, bool onlySelectable) const { QCPDataSelection result; - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return result; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return result; - + QCPStatisticalBoxDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - - for( QCPStatisticalBoxDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + getVisibleDataBounds(visibleBegin, visibleEnd); + + for (QCPStatisticalBoxDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { - if( rect.intersects( getQuartileBox( it ) ) ) - result.addDataRange( QCPDataRange( it - mDataContainer->constBegin(), it - mDataContainer->constBegin() + 1 ), false ); + if (rect.intersects(getQuartileBox(it))) + result.addDataRange(QCPDataRange(it-mDataContainer->constBegin(), it-mDataContainer->constBegin()+1), false); } result.simplify(); return result; } /* inherits documentation from base class */ -double QCPStatisticalBox::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + Q_UNUSED(details) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis->axisRect()->rect().contains(pos.toPoint())) { // get visible data range: QCPStatisticalBoxDataContainer::const_iterator visibleBegin, visibleEnd; QCPStatisticalBoxDataContainer::const_iterator closestDataPoint = mDataContainer->constEnd(); - getVisibleDataBounds( visibleBegin, visibleEnd ); + getVisibleDataBounds(visibleBegin, visibleEnd); double minDistSqr = std::numeric_limits::max(); - for( QCPStatisticalBoxDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + for (QCPStatisticalBoxDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { - if( getQuartileBox( it ).contains( pos ) ) // quartile box + if (getQuartileBox(it).contains(pos)) // quartile box { - double currentDistSqr = mParentPlot->selectionTolerance() * 0.99 * mParentPlot->selectionTolerance() * 0.99; - if( currentDistSqr < minDistSqr ) + double currentDistSqr = mParentPlot->selectionTolerance()*0.99 * mParentPlot->selectionTolerance()*0.99; + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; closestDataPoint = it; } - } - else // whiskers + } else // whiskers { - const QVector whiskerBackbones( getWhiskerBackboneLines( it ) ); - for( int i = 0; i < whiskerBackbones.size(); ++i ) + const QVector whiskerBackbones(getWhiskerBackboneLines(it)); + for (int i=0; iconstBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = closestDataPoint-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } - return qSqrt( minDistSqr ); + return qSqrt(minDistSqr); } return -1; } /* inherits documentation from base class */ -QCPRange QCPStatisticalBox::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPStatisticalBox::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { - QCPRange range = mDataContainer->keyRange( foundRange, inSignDomain ); + QCPRange range = mDataContainer->keyRange(foundRange, inSignDomain); // determine exact range by including width of bars/flags: - if( foundRange ) + if (foundRange) { - if( inSignDomain != QCP::sdPositive || range.lower - mWidth * 0.5 > 0 ) - range.lower -= mWidth * 0.5; - if( inSignDomain != QCP::sdNegative || range.upper + mWidth * 0.5 < 0 ) - range.upper += mWidth * 0.5; + if (inSignDomain != QCP::sdPositive || range.lower-mWidth*0.5 > 0) + range.lower -= mWidth*0.5; + if (inSignDomain != QCP::sdNegative || range.upper+mWidth*0.5 < 0) + range.upper += mWidth*0.5; } return range; } /* inherits documentation from base class */ -QCPRange QCPStatisticalBox::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPStatisticalBox::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - return mDataContainer->valueRange( foundRange, inSignDomain, inKeyRange ); + return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange); } /* inherits documentation from base class */ -void QCPStatisticalBox::draw( QCPPainter* painter ) +void QCPStatisticalBox::draw(QCPPainter *painter) { - if( mDataContainer->isEmpty() ) - return; - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - + if (mDataContainer->isEmpty()) return; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + QCPStatisticalBoxDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - + getVisibleDataBounds(visibleBegin, visibleEnd); + // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); QCPStatisticalBoxDataContainer::const_iterator begin = visibleBegin; QCPStatisticalBoxDataContainer::const_iterator end = visibleEnd; - mDataContainer->limitIteratorsToDataRange( begin, end, allSegments.at( i ) ); - if( begin == end ) + mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i)); + if (begin == end) continue; - - for( QCPStatisticalBoxDataContainer::const_iterator it = begin; it != end; ++it ) + + for (QCPStatisticalBoxDataContainer::const_iterator it=begin; it!=end; ++it) { - // check data validity if flag set: -#ifdef QCUSTOMPLOT_CHECK_DATA - if( QCP::isInvalidData( it->key, it->minimum ) || - QCP::isInvalidData( it->lowerQuartile, it->median ) || - QCP::isInvalidData( it->upperQuartile, it->maximum ) ) - qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "of drawn range has invalid data." - << "Plottable name:" << name(); - for( int i = 0; i < it->outliers.size(); ++i ) - if( QCP::isInvalidData( it->outliers.at( i ) ) ) - qDebug() << Q_FUNC_INFO << "Data point outlier at" << it->key << "of drawn range invalid." - << "Plottable name:" << name(); -#endif - - if( isSelectedSegment && mSelectionDecorator ) + // check data validity if flag set: +# ifdef QCUSTOMPLOT_CHECK_DATA + if (QCP::isInvalidData(it->key, it->minimum) || + QCP::isInvalidData(it->lowerQuartile, it->median) || + QCP::isInvalidData(it->upperQuartile, it->maximum)) + qDebug() << Q_FUNC_INFO << "Data point at" << it->key << "of drawn range has invalid data." << "Plottable name:" << name(); + for (int i=0; ioutliers.size(); ++i) + if (QCP::isInvalidData(it->outliers.at(i))) + qDebug() << Q_FUNC_INFO << "Data point outlier at" << it->key << "of drawn range invalid." << "Plottable name:" << name(); +# endif + + if (isSelectedSegment && mSelectionDecorator) { - mSelectionDecorator->applyPen( painter ); - mSelectionDecorator->applyBrush( painter ); - } - else + mSelectionDecorator->applyPen(painter); + mSelectionDecorator->applyBrush(painter); + } else { - painter->setPen( mPen ); - painter->setBrush( mBrush ); + painter->setPen(mPen); + painter->setBrush(mBrush); } QCPScatterStyle finalOutlierStyle = mOutlierStyle; - if( isSelectedSegment && mSelectionDecorator ) - finalOutlierStyle = mSelectionDecorator->getFinalScatterStyle( mOutlierStyle ); - drawStatisticalBox( painter, it, finalOutlierStyle ); + if (isSelectedSegment && mSelectionDecorator) + finalOutlierStyle = mSelectionDecorator->getFinalScatterStyle(mOutlierStyle); + drawStatisticalBox(painter, it, finalOutlierStyle); } } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPStatisticalBox::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPStatisticalBox::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { // draw filled rect: - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - painter->setBrush( mBrush ); - QRectF r = QRectF( 0, 0, rect.width() * 0.67, rect.height() * 0.67 ); - r.moveCenter( rect.center() ); - painter->drawRect( r ); + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->setBrush(mBrush); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); } /*! @@ -25515,29 +24818,29 @@ void QCPStatisticalBox::drawLegendIcon( QCPPainter* painter, const QRectF& rect \see getQuartileBox, getWhiskerBackboneLines, getWhiskerBarLines */ -void QCPStatisticalBox::drawStatisticalBox( QCPPainter* painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle& outlierStyle ) const +void QCPStatisticalBox::drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const { // draw quartile box: - applyDefaultAntialiasingHint( painter ); - const QRectF quartileBox = getQuartileBox( it ); - painter->drawRect( quartileBox ); + applyDefaultAntialiasingHint(painter); + const QRectF quartileBox = getQuartileBox(it); + painter->drawRect(quartileBox); // draw median line with cliprect set to quartile box: painter->save(); - painter->setClipRect( quartileBox, Qt::IntersectClip ); - painter->setPen( mMedianPen ); - painter->drawLine( QLineF( coordsToPixels( it->key - mWidth * 0.5, it->median ), coordsToPixels( it->key + mWidth * 0.5, it->median ) ) ); + painter->setClipRect(quartileBox, Qt::IntersectClip); + painter->setPen(mMedianPen); + painter->drawLine(QLineF(coordsToPixels(it->key-mWidth*0.5, it->median), coordsToPixels(it->key+mWidth*0.5, it->median))); painter->restore(); // draw whisker lines: - applyAntialiasingHint( painter, mWhiskerAntialiased, QCP::aePlottables ); - painter->setPen( mWhiskerPen ); - painter->drawLines( getWhiskerBackboneLines( it ) ); - painter->setPen( mWhiskerBarPen ); - painter->drawLines( getWhiskerBarLines( it ) ); + applyAntialiasingHint(painter, mWhiskerAntialiased, QCP::aePlottables); + painter->setPen(mWhiskerPen); + painter->drawLines(getWhiskerBackboneLines(it)); + painter->setPen(mWhiskerBarPen); + painter->drawLines(getWhiskerBarLines(it)); // draw outliers: - applyScattersAntialiasingHint( painter ); - outlierStyle.applyTo( painter, mPen ); - for( int i = 0; i < it->outliers.size(); ++i ) - outlierStyle.drawShape( painter, coordsToPixels( it->key, it->outliers.at( i ) ) ); + applyScattersAntialiasingHint(painter); + outlierStyle.applyTo(painter, mPen); + for (int i=0; ioutliers.size(); ++i) + outlierStyle.drawShape(painter, coordsToPixels(it->key, it->outliers.at(i))); } /*! \internal @@ -25554,17 +24857,17 @@ void QCPStatisticalBox::drawStatisticalBox( QCPPainter* painter, QCPStatisticalB if the plottable contains no data, both \a begin and \a end point to constEnd. */ -void QCPStatisticalBox::getVisibleDataBounds( QCPStatisticalBoxDataContainer::const_iterator& begin, QCPStatisticalBoxDataContainer::const_iterator& end ) const +void QCPStatisticalBox::getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const { - if( !mKeyAxis ) + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; begin = mDataContainer->constEnd(); end = mDataContainer->constEnd(); return; } - begin = mDataContainer->findBegin( mKeyAxis.data()->range().lower - mWidth * 0.5 ); // subtract half width of box to include partially visible data points - end = mDataContainer->findEnd( mKeyAxis.data()->range().upper + mWidth * 0.5 ); // add half width of box to include partially visible data points + begin = mDataContainer->findBegin(mKeyAxis.data()->range().lower-mWidth*0.5); // subtract half width of box to include partially visible data points + end = mDataContainer->findEnd(mKeyAxis.data()->range().upper+mWidth*0.5); // add half width of box to include partially visible data points } /*! \internal @@ -25574,11 +24877,11 @@ void QCPStatisticalBox::getVisibleDataBounds( QCPStatisticalBoxDataContainer::co \see drawStatisticalBox, getWhiskerBackboneLines, getWhiskerBarLines */ -QRectF QCPStatisticalBox::getQuartileBox( QCPStatisticalBoxDataContainer::const_iterator it ) const +QRectF QCPStatisticalBox::getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const { QRectF result; - result.setTopLeft( coordsToPixels( it->key - mWidth * 0.5, it->upperQuartile ) ); - result.setBottomRight( coordsToPixels( it->key + mWidth * 0.5, it->lowerQuartile ) ); + result.setTopLeft(coordsToPixels(it->key-mWidth*0.5, it->upperQuartile)); + result.setBottomRight(coordsToPixels(it->key+mWidth*0.5, it->lowerQuartile)); return result; } @@ -25590,11 +24893,11 @@ QRectF QCPStatisticalBox::getQuartileBox( QCPStatisticalBoxDataContainer::const_ \see drawStatisticalBox, getQuartileBox, getWhiskerBarLines */ -QVector QCPStatisticalBox::getWhiskerBackboneLines( QCPStatisticalBoxDataContainer::const_iterator it ) const +QVector QCPStatisticalBox::getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const { - QVector result( 2 ); - result[0].setPoints( coordsToPixels( it->key, it->lowerQuartile ), coordsToPixels( it->key, it->minimum ) ); // min backbone - result[1].setPoints( coordsToPixels( it->key, it->upperQuartile ), coordsToPixels( it->key, it->maximum ) ); // max backbone + QVector result(2); + result[0].setPoints(coordsToPixels(it->key, it->lowerQuartile), coordsToPixels(it->key, it->minimum)); // min backbone + result[1].setPoints(coordsToPixels(it->key, it->upperQuartile), coordsToPixels(it->key, it->maximum)); // max backbone return result; } @@ -25605,15 +24908,16 @@ QVector QCPStatisticalBox::getWhiskerBackboneLines( QCPStatisticalBoxDat \see drawStatisticalBox, getQuartileBox, getWhiskerBackboneLines */ -QVector QCPStatisticalBox::getWhiskerBarLines( QCPStatisticalBoxDataContainer::const_iterator it ) const +QVector QCPStatisticalBox::getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const { - QVector result( 2 ); - result[0].setPoints( coordsToPixels( it->key - mWhiskerWidth * 0.5, it->minimum ), coordsToPixels( it->key + mWhiskerWidth * 0.5, it->minimum ) ); // min bar - result[1].setPoints( coordsToPixels( it->key - mWhiskerWidth * 0.5, it->maximum ), coordsToPixels( it->key + mWhiskerWidth * 0.5, it->maximum ) ); // max bar + QVector result(2); + result[0].setPoints(coordsToPixels(it->key-mWhiskerWidth*0.5, it->minimum), coordsToPixels(it->key+mWhiskerWidth*0.5, it->minimum)); // min bar + result[1].setPoints(coordsToPixels(it->key-mWhiskerWidth*0.5, it->maximum), coordsToPixels(it->key+mWhiskerWidth*0.5, it->maximum)); // max bar return result; } /* end of 'src/plottables/plottable-statisticalbox.cpp' */ + /* including file 'src/plottables/plottable-colormap.cpp', size 47881 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -25671,26 +24975,38 @@ QVector QCPStatisticalBox::getWhiskerBarLines( QCPStatisticalBoxDataCont \see setSize, setKeySize, setValueSize, setRange, setKeyRange, setValueRange */ -QCPColorMapData::QCPColorMapData( int keySize, int valueSize, const QCPRange& keyRange, const QCPRange& valueRange ) - : mKeySize( 0 ), mValueSize( 0 ), mKeyRange( keyRange ), mValueRange( valueRange ), mIsEmpty( true ), mData( 0 ), mAlpha( 0 ), mDataModified( true ) +QCPColorMapData::QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange) : + mKeySize(0), + mValueSize(0), + mKeyRange(keyRange), + mValueRange(valueRange), + mIsEmpty(true), + mData(0), + mAlpha(0), + mDataModified(true) { - setSize( keySize, valueSize ); - fill( 0 ); + setSize(keySize, valueSize); + fill(0); } QCPColorMapData::~QCPColorMapData() { - if( mData ) + if (mData) delete[] mData; - if( mAlpha ) + if (mAlpha) delete[] mAlpha; } /*! Constructs a new QCPColorMapData instance copying the data and range of \a other. */ -QCPColorMapData::QCPColorMapData( const QCPColorMapData& other ) - : mKeySize( 0 ), mValueSize( 0 ), mIsEmpty( true ), mData( 0 ), mAlpha( 0 ), mDataModified( true ) +QCPColorMapData::QCPColorMapData(const QCPColorMapData &other) : + mKeySize(0), + mValueSize(0), + mIsEmpty(true), + mData(0), + mAlpha(0), + mDataModified(true) { *this = other; } @@ -25699,23 +25015,23 @@ QCPColorMapData::QCPColorMapData( const QCPColorMapData& other ) Overwrites this color map data instance with the data stored in \a other. The alpha map state is transferred, too. */ -QCPColorMapData& QCPColorMapData::operator=( const QCPColorMapData& other ) +QCPColorMapData &QCPColorMapData::operator=(const QCPColorMapData &other) { - if( &other != this ) + if (&other != this) { const int keySize = other.keySize(); const int valueSize = other.valueSize(); - if( !other.mAlpha && mAlpha ) + if (!other.mAlpha && mAlpha) clearAlpha(); - setSize( keySize, valueSize ); - if( other.mAlpha && !mAlpha ) - createAlpha( false ); - setRange( other.keyRange(), other.valueRange() ); - if( !isEmpty() ) + setSize(keySize, valueSize); + if (other.mAlpha && !mAlpha) + createAlpha(false); + setRange(other.keyRange(), other.valueRange()); + if (!isEmpty()) { - memcpy( mData, other.mData, sizeof( mData[0] ) * keySize * valueSize ); - if( mAlpha ) - memcpy( mAlpha, other.mAlpha, sizeof( mAlpha[0] ) * keySize * valueSize ); + memcpy(mData, other.mData, sizeof(mData[0])*keySize*valueSize); + if (mAlpha) + memcpy(mAlpha, other.mAlpha, sizeof(mAlpha[0])*keySize*valueSize); } mDataBounds = other.mDataBounds; mDataModified = true; @@ -25724,21 +25040,21 @@ QCPColorMapData& QCPColorMapData::operator=( const QCPColorMapData& other ) } /* undocumented getter */ -double QCPColorMapData::data( double key, double value ) +double QCPColorMapData::data(double key, double value) { - int keyCell = ( key - mKeyRange.lower ) / ( mKeyRange.upper - mKeyRange.lower ) * ( mKeySize - 1 ) + 0.5; - int valueCell = ( value - mValueRange.lower ) / ( mValueRange.upper - mValueRange.lower ) * ( mValueSize - 1 ) + 0.5; - if( keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize ) - return mData[valueCell * mKeySize + keyCell]; + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower)*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) + return mData[valueCell*mKeySize + keyCell]; else return 0; } /* undocumented getter */ -double QCPColorMapData::cell( int keyIndex, int valueIndex ) +double QCPColorMapData::cell(int keyIndex, int valueIndex) { - if( keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize ) - return mData[valueIndex * mKeySize + keyIndex]; + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + return mData[valueIndex*mKeySize + keyIndex]; else return 0; } @@ -25751,10 +25067,10 @@ double QCPColorMapData::cell( int keyIndex, int valueIndex ) \see setAlpha */ -unsigned char QCPColorMapData::alpha( int keyIndex, int valueIndex ) +unsigned char QCPColorMapData::alpha(int keyIndex, int valueIndex) { - if( mAlpha && keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize ) - return mAlpha[valueIndex * mKeySize + keyIndex]; + if (mAlpha && keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + return mAlpha[valueIndex*mKeySize + keyIndex]; else return 255; } @@ -25771,40 +25087,34 @@ unsigned char QCPColorMapData::alpha( int keyIndex, int valueIndex ) \see setRange, setKeySize, setValueSize */ -void QCPColorMapData::setSize( int keySize, int valueSize ) +void QCPColorMapData::setSize(int keySize, int valueSize) { - if( keySize != mKeySize || valueSize != mValueSize ) + if (keySize != mKeySize || valueSize != mValueSize) { mKeySize = keySize; mValueSize = valueSize; - if( mData ) + if (mData) delete[] mData; mIsEmpty = mKeySize == 0 || mValueSize == 0; - if( !mIsEmpty ) + if (!mIsEmpty) { #ifdef __EXCEPTIONS - try - { // 2D arrays get memory intensive fast. So if the allocation fails, at least output debug message + try { // 2D arrays get memory intensive fast. So if the allocation fails, at least output debug message #endif - mData = new double[mKeySize * mValueSize]; + mData = new double[mKeySize*mValueSize]; #ifdef __EXCEPTIONS - } - catch( ... ) - { - mData = 0; - } + } catch (...) { mData = 0; } #endif - if( mData ) - fill( 0 ); + if (mData) + fill(0); else - qDebug() << Q_FUNC_INFO << "out of memory for data dimensions " << mKeySize << "*" << mValueSize; - } - else + qDebug() << Q_FUNC_INFO << "out of memory for data dimensions "<< mKeySize << "*" << mValueSize; + } else mData = 0; - - if( mAlpha ) // if we had an alpha map, recreate it with new size + + if (mAlpha) // if we had an alpha map, recreate it with new size createAlpha(); - + mDataModified = true; } } @@ -25819,9 +25129,9 @@ void QCPColorMapData::setSize( int keySize, int valueSize ) \see setKeyRange, setSize, setValueSize */ -void QCPColorMapData::setKeySize( int keySize ) +void QCPColorMapData::setKeySize(int keySize) { - setSize( keySize, mValueSize ); + setSize(keySize, mValueSize); } /*! @@ -25834,9 +25144,9 @@ void QCPColorMapData::setKeySize( int keySize ) \see setValueRange, setSize, setKeySize */ -void QCPColorMapData::setValueSize( int valueSize ) +void QCPColorMapData::setValueSize(int valueSize) { - setSize( mKeySize, valueSize ); + setSize(mKeySize, valueSize); } /*! @@ -25849,10 +25159,10 @@ void QCPColorMapData::setValueSize( int valueSize ) \see setSize */ -void QCPColorMapData::setRange( const QCPRange& keyRange, const QCPRange& valueRange ) +void QCPColorMapData::setRange(const QCPRange &keyRange, const QCPRange &valueRange) { - setKeyRange( keyRange ); - setValueRange( valueRange ); + setKeyRange(keyRange); + setValueRange(valueRange); } /*! @@ -25865,7 +25175,7 @@ void QCPColorMapData::setRange( const QCPRange& keyRange, const QCPRange& valueR \see setRange, setValueRange, setSize */ -void QCPColorMapData::setKeyRange( const QCPRange& keyRange ) +void QCPColorMapData::setKeyRange(const QCPRange &keyRange) { mKeyRange = keyRange; } @@ -25880,7 +25190,7 @@ void QCPColorMapData::setKeyRange( const QCPRange& keyRange ) \see setRange, setKeyRange, setSize */ -void QCPColorMapData::setValueRange( const QCPRange& valueRange ) +void QCPColorMapData::setValueRange(const QCPRange &valueRange) { mValueRange = valueRange; } @@ -25897,18 +25207,18 @@ void QCPColorMapData::setValueRange( const QCPRange& valueRange ) \see setCell, setRange */ -void QCPColorMapData::setData( double key, double value, double z ) +void QCPColorMapData::setData(double key, double value, double z) { - int keyCell = ( key - mKeyRange.lower ) / ( mKeyRange.upper - mKeyRange.lower ) * ( mKeySize - 1 ) + 0.5; - int valueCell = ( value - mValueRange.lower ) / ( mValueRange.upper - mValueRange.lower ) * ( mValueSize - 1 ) + 0.5; - if( keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize ) + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower)*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) { - mData[valueCell * mKeySize + keyCell] = z; - if( z < mDataBounds.lower ) + mData[valueCell*mKeySize + keyCell] = z; + if (z < mDataBounds.lower) mDataBounds.lower = z; - if( z > mDataBounds.upper ) + if (z > mDataBounds.upper) mDataBounds.upper = z; - mDataModified = true; + mDataModified = true; } } @@ -25923,18 +25233,17 @@ void QCPColorMapData::setData( double key, double value, double z ) \see setData, setSize */ -void QCPColorMapData::setCell( int keyIndex, int valueIndex, double z ) +void QCPColorMapData::setCell(int keyIndex, int valueIndex, double z) { - if( keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize ) + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) { - mData[valueIndex * mKeySize + keyIndex] = z; - if( z < mDataBounds.lower ) + mData[valueIndex*mKeySize + keyIndex] = z; + if (z < mDataBounds.lower) mDataBounds.lower = z; - if( z > mDataBounds.upper ) + if (z > mDataBounds.upper) mDataBounds.upper = z; - mDataModified = true; - } - else + mDataModified = true; + } else qDebug() << Q_FUNC_INFO << "index out of bounds:" << keyIndex << valueIndex; } @@ -25953,17 +25262,16 @@ void QCPColorMapData::setCell( int keyIndex, int valueIndex, double z ) \see fillAlpha, clearAlpha */ -void QCPColorMapData::setAlpha( int keyIndex, int valueIndex, unsigned char alpha ) +void QCPColorMapData::setAlpha(int keyIndex, int valueIndex, unsigned char alpha) { - if( keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize ) + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) { - if( mAlpha || createAlpha() ) + if (mAlpha || createAlpha()) { - mAlpha[valueIndex * mKeySize + keyIndex] = alpha; + mAlpha[valueIndex*mKeySize + keyIndex] = alpha; mDataModified = true; } - } - else + } else qDebug() << Q_FUNC_INFO << "index out of bounds:" << keyIndex << valueIndex; } @@ -25982,16 +25290,16 @@ void QCPColorMapData::setAlpha( int keyIndex, int valueIndex, unsigned char alph */ void QCPColorMapData::recalculateDataBounds() { - if( mKeySize > 0 && mValueSize > 0 ) + if (mKeySize > 0 && mValueSize > 0) { double minHeight = mData[0]; double maxHeight = mData[0]; - const int dataCount = mValueSize * mKeySize; - for( int i = 0; i < dataCount; ++i ) + const int dataCount = mValueSize*mKeySize; + for (int i=0; i maxHeight ) + if (mData[i] > maxHeight) maxHeight = mData[i]; - if( mData[i] < minHeight ) + if (mData[i] < minHeight) minHeight = mData[i]; } mDataBounds.lower = minHeight; @@ -26006,7 +25314,7 @@ void QCPColorMapData::recalculateDataBounds() */ void QCPColorMapData::clear() { - setSize( 0, 0 ); + setSize(0, 0); } /*! @@ -26014,7 +25322,7 @@ void QCPColorMapData::clear() */ void QCPColorMapData::clearAlpha() { - if( mAlpha ) + if (mAlpha) { delete[] mAlpha; mAlpha = 0; @@ -26025,12 +25333,12 @@ void QCPColorMapData::clearAlpha() /*! Sets all cells to the value \a z. */ -void QCPColorMapData::fill( double z ) +void QCPColorMapData::fill(double z) { - const int dataCount = mValueSize * mKeySize; - for( int i = 0; i < dataCount; ++i ) + const int dataCount = mValueSize*mKeySize; + for (int i=0; i( data ); + qDebug() << Q_FUNC_INFO << "The data pointer is already in (and owned by) this plottable" << reinterpret_cast(data); return; } - if( copy ) + if (copy) { *mMapData = *data; - } - else + } else { delete mMapData; mMapData = data; @@ -26313,18 +25621,17 @@ void QCPColorMap::setData( QCPColorMapData* data, bool copy ) \see QCPColorScale::setDataRange */ -void QCPColorMap::setDataRange( const QCPRange& dataRange ) +void QCPColorMap::setDataRange(const QCPRange &dataRange) { - if( !QCPRange::validRange( dataRange ) ) - return; - if( mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper ) + if (!QCPRange::validRange(dataRange)) return; + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) { - if( mDataScaleType == QCPAxis::stLogarithmic ) + if (mDataScaleType == QCPAxis::stLogarithmic) mDataRange = dataRange.sanitizedForLogScale(); else mDataRange = dataRange.sanitizedForLinScale(); mMapImageInvalidated = true; - emit dataRangeChanged( mDataRange ); + emit dataRangeChanged(mDataRange); } } @@ -26333,15 +25640,15 @@ void QCPColorMap::setDataRange( const QCPRange& dataRange ) \see QCPColorScale::setDataScaleType */ -void QCPColorMap::setDataScaleType( QCPAxis::ScaleType scaleType ) +void QCPColorMap::setDataScaleType(QCPAxis::ScaleType scaleType) { - if( mDataScaleType != scaleType ) + if (mDataScaleType != scaleType) { mDataScaleType = scaleType; mMapImageInvalidated = true; - emit dataScaleTypeChanged( mDataScaleType ); - if( mDataScaleType == QCPAxis::stLogarithmic ) - setDataRange( mDataRange.sanitizedForLogScale() ); + emit dataScaleTypeChanged(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); } } @@ -26356,13 +25663,13 @@ void QCPColorMap::setDataScaleType( QCPAxis::ScaleType scaleType ) \see QCPColorScale::setGradient */ -void QCPColorMap::setGradient( const QCPColorGradient& gradient ) +void QCPColorMap::setGradient(const QCPColorGradient &gradient) { - if( mGradient != gradient ) + if (mGradient != gradient) { mGradient = gradient; mMapImageInvalidated = true; - emit gradientChanged( mGradient ); + emit gradientChanged(mGradient); } } @@ -26372,10 +25679,10 @@ void QCPColorMap::setGradient( const QCPColorGradient& gradient ) \image html QCPColorMap-interpolate.png "A 10*10 color map, with interpolation and without interpolation enabled" */ -void QCPColorMap::setInterpolate( bool enabled ) +void QCPColorMap::setInterpolate(bool enabled) { mInterpolate = enabled; - mMapImageInvalidated = true; // because oversampling factors might need to change + mMapImageInvalidated = true; // because oversampling factors might need to change } /*! @@ -26389,7 +25696,7 @@ void QCPColorMap::setInterpolate( bool enabled ) \image html QCPColorMap-tightboundary.png "A color map, with tight boundary enabled and disabled" */ -void QCPColorMap::setTightBoundary( bool enabled ) +void QCPColorMap::setTightBoundary(bool enabled) { mTightBoundary = enabled; } @@ -26408,29 +25715,29 @@ void QCPColorMap::setTightBoundary( bool enabled ) Pass 0 as \a colorScale to disconnect the color scale from this color map again. */ -void QCPColorMap::setColorScale( QCPColorScale* colorScale ) +void QCPColorMap::setColorScale(QCPColorScale *colorScale) { - if( mColorScale ) // unconnect signals from old color scale + if (mColorScale) // unconnect signals from old color scale { - disconnect( this, SIGNAL( dataRangeChanged( QCPRange ) ), mColorScale.data(), SLOT( setDataRange( QCPRange ) ) ); - disconnect( this, SIGNAL( dataScaleTypeChanged( QCPAxis::ScaleType ) ), mColorScale.data(), SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); - disconnect( this, SIGNAL( gradientChanged( QCPColorGradient ) ), mColorScale.data(), SLOT( setGradient( QCPColorGradient ) ) ); - disconnect( mColorScale.data(), SIGNAL( dataRangeChanged( QCPRange ) ), this, SLOT( setDataRange( QCPRange ) ) ); - disconnect( mColorScale.data(), SIGNAL( gradientChanged( QCPColorGradient ) ), this, SLOT( setGradient( QCPColorGradient ) ) ); - disconnect( mColorScale.data(), SIGNAL( dataScaleTypeChanged( QCPAxis::ScaleType ) ), this, SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); + disconnect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + disconnect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + disconnect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); } mColorScale = colorScale; - if( mColorScale ) // connect signals to new color scale + if (mColorScale) // connect signals to new color scale { - setGradient( mColorScale.data()->gradient() ); - setDataRange( mColorScale.data()->dataRange() ); - setDataScaleType( mColorScale.data()->dataScaleType() ); - connect( this, SIGNAL( dataRangeChanged( QCPRange ) ), mColorScale.data(), SLOT( setDataRange( QCPRange ) ) ); - connect( this, SIGNAL( dataScaleTypeChanged( QCPAxis::ScaleType ) ), mColorScale.data(), SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); - connect( this, SIGNAL( gradientChanged( QCPColorGradient ) ), mColorScale.data(), SLOT( setGradient( QCPColorGradient ) ) ); - connect( mColorScale.data(), SIGNAL( dataRangeChanged( QCPRange ) ), this, SLOT( setDataRange( QCPRange ) ) ); - connect( mColorScale.data(), SIGNAL( gradientChanged( QCPColorGradient ) ), this, SLOT( setGradient( QCPColorGradient ) ) ); - connect( mColorScale.data(), SIGNAL( dataScaleTypeChanged( QCPAxis::ScaleType ) ), this, SLOT( setDataScaleType( QCPAxis::ScaleType ) ) ); + setGradient(mColorScale.data()->gradient()); + setDataRange(mColorScale.data()->dataRange()); + setDataScaleType(mColorScale.data()->dataScaleType()); + connect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + connect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + connect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); } } @@ -26454,11 +25761,11 @@ void QCPColorMap::setColorScale( QCPColorScale* colorScale ) \see setDataRange */ -void QCPColorMap::rescaleDataRange( bool recalculateDataBounds ) +void QCPColorMap::rescaleDataRange(bool recalculateDataBounds) { - if( recalculateDataBounds ) + if (recalculateDataBounds) mMapData->recalculateDataBounds(); - setDataRange( mMapData->dataBounds() ); + setDataRange(mMapData->dataBounds()); } /*! @@ -26475,92 +25782,90 @@ void QCPColorMap::rescaleDataRange( bool recalculateDataBounds ) \see setDataRange */ -void QCPColorMap::updateLegendIcon( Qt::TransformationMode transformMode, const QSize& thumbSize ) +void QCPColorMap::updateLegendIcon(Qt::TransformationMode transformMode, const QSize &thumbSize) { - if( mMapImage.isNull() && !data()->isEmpty() ) - updateMapImage(); // try to update map image if it's null (happens if no draw has happened yet) - - if( !mMapImage.isNull() ) // might still be null, e.g. if data is empty, so check here again + if (mMapImage.isNull() && !data()->isEmpty()) + updateMapImage(); // try to update map image if it's null (happens if no draw has happened yet) + + if (!mMapImage.isNull()) // might still be null, e.g. if data is empty, so check here again { - bool mirrorX = ( keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis() )->rangeReversed(); - bool mirrorY = ( valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis() )->rangeReversed(); - mLegendIcon = QPixmap::fromImage( mMapImage.mirrored( mirrorX, mirrorY ) ).scaled( thumbSize, Qt::KeepAspectRatio, transformMode ); + bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + mLegendIcon = QPixmap::fromImage(mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode); } } /* inherits documentation from base class */ -double QCPColorMap::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPColorMap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( ( onlySelectable && mSelectable == QCP::stNone ) || mMapData->isEmpty() ) + Q_UNUSED(details) + if ((onlySelectable && mSelectable == QCP::stNone) || mMapData->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { double posKey, posValue; - pixelsToCoords( pos, posKey, posValue ); - if( mMapData->keyRange().contains( posKey ) && mMapData->valueRange().contains( posValue ) ) + pixelsToCoords(pos, posKey, posValue); + if (mMapData->keyRange().contains(posKey) && mMapData->valueRange().contains(posValue)) { - if( details ) - details->setValue( QCPDataSelection( QCPDataRange( 0, 1 ) ) ); // temporary solution, to facilitate whole-plottable selection. Replace in future version with segmented 2D selection. - return mParentPlot->selectionTolerance() * 0.99; + if (details) + details->setValue(QCPDataSelection(QCPDataRange(0, 1))); // temporary solution, to facilitate whole-plottable selection. Replace in future version with segmented 2D selection. + return mParentPlot->selectionTolerance()*0.99; } } return -1; } /* inherits documentation from base class */ -QCPRange QCPColorMap::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPColorMap::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { foundRange = true; QCPRange result = mMapData->keyRange(); result.normalize(); - if( inSignDomain == QCP::sdPositive ) + if (inSignDomain == QCP::sdPositive) { - if( result.lower <= 0 && result.upper > 0 ) - result.lower = result.upper * 1e-3; - else if( result.lower <= 0 && result.upper <= 0 ) + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) foundRange = false; - } - else if( inSignDomain == QCP::sdNegative ) + } else if (inSignDomain == QCP::sdNegative) { - if( result.upper >= 0 && result.lower < 0 ) - result.upper = result.lower * 1e-3; - else if( result.upper >= 0 && result.lower >= 0 ) + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) foundRange = false; } return result; } /* inherits documentation from base class */ -QCPRange QCPColorMap::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPColorMap::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - if( inKeyRange != QCPRange() ) + if (inKeyRange != QCPRange()) { - if( mMapData->keyRange().upper < inKeyRange.lower || mMapData->keyRange().lower > inKeyRange.upper ) + if (mMapData->keyRange().upper < inKeyRange.lower || mMapData->keyRange().lower > inKeyRange.upper) { foundRange = false; return QCPRange(); } } - + foundRange = true; QCPRange result = mMapData->valueRange(); result.normalize(); - if( inSignDomain == QCP::sdPositive ) + if (inSignDomain == QCP::sdPositive) { - if( result.lower <= 0 && result.upper > 0 ) - result.lower = result.upper * 1e-3; - else if( result.lower <= 0 && result.upper <= 0 ) + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) foundRange = false; - } - else if( inSignDomain == QCP::sdNegative ) + } else if (inSignDomain == QCP::sdNegative) { - if( result.upper >= 0 && result.lower < 0 ) - result.upper = result.lower * 1e-3; - else if( result.upper >= 0 && result.lower >= 0 ) + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) foundRange = false; } return result; @@ -26582,80 +25887,75 @@ QCPRange QCPColorMap::getValueRange( bool& foundRange, QCP::SignDomain inSignDom */ void QCPColorMap::updateMapImage() { - QCPAxis* keyAxis = mKeyAxis.data(); - if( !keyAxis ) - return; - if( mMapData->isEmpty() ) - return; - + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) return; + if (mMapData->isEmpty()) return; + const QImage::Format format = QImage::Format_ARGB32_Premultiplied; const int keySize = mMapData->keySize(); const int valueSize = mMapData->valueSize(); - int keyOversamplingFactor = mInterpolate ? 1 : (int)( 1.0 + 100.0 / (double)keySize ); // make mMapImage have at least size 100, factor becomes 1 if size > 200 or interpolation is on - int valueOversamplingFactor = mInterpolate ? 1 : (int)( 1.0 + 100.0 / (double)valueSize ); // make mMapImage have at least size 100, factor becomes 1 if size > 200 or interpolation is on - + int keyOversamplingFactor = mInterpolate ? 1 : (int)(1.0+100.0/(double)keySize); // make mMapImage have at least size 100, factor becomes 1 if size > 200 or interpolation is on + int valueOversamplingFactor = mInterpolate ? 1 : (int)(1.0+100.0/(double)valueSize); // make mMapImage have at least size 100, factor becomes 1 if size > 200 or interpolation is on + // resize mMapImage to correct dimensions including possible oversampling factors, according to key/value axes orientation: - if( keyAxis->orientation() == Qt::Horizontal && ( mMapImage.width() != keySize * keyOversamplingFactor || mMapImage.height() != valueSize * valueOversamplingFactor ) ) - mMapImage = QImage( QSize( keySize * keyOversamplingFactor, valueSize * valueOversamplingFactor ), format ); - else if( keyAxis->orientation() == Qt::Vertical && ( mMapImage.width() != valueSize * valueOversamplingFactor || mMapImage.height() != keySize * keyOversamplingFactor ) ) - mMapImage = QImage( QSize( valueSize * valueOversamplingFactor, keySize * keyOversamplingFactor ), format ); - - if( mMapImage.isNull() ) + if (keyAxis->orientation() == Qt::Horizontal && (mMapImage.width() != keySize*keyOversamplingFactor || mMapImage.height() != valueSize*valueOversamplingFactor)) + mMapImage = QImage(QSize(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor), format); + else if (keyAxis->orientation() == Qt::Vertical && (mMapImage.width() != valueSize*valueOversamplingFactor || mMapImage.height() != keySize*keyOversamplingFactor)) + mMapImage = QImage(QSize(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor), format); + + if (mMapImage.isNull()) { qDebug() << Q_FUNC_INFO << "Couldn't create map image (possibly too large for memory)"; - mMapImage = QImage( QSize( 10, 10 ), format ); - mMapImage.fill( Qt::black ); - } - else + mMapImage = QImage(QSize(10, 10), format); + mMapImage.fill(Qt::black); + } else { - QImage* localMapImage = &mMapImage; // this is the image on which the colorization operates. Either the final mMapImage, or if we need oversampling, mUndersampledMapImage - if( keyOversamplingFactor > 1 || valueOversamplingFactor > 1 ) + QImage *localMapImage = &mMapImage; // this is the image on which the colorization operates. Either the final mMapImage, or if we need oversampling, mUndersampledMapImage + if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1) { // resize undersampled map image to actual key/value cell sizes: - if( keyAxis->orientation() == Qt::Horizontal && ( mUndersampledMapImage.width() != keySize || mUndersampledMapImage.height() != valueSize ) ) - mUndersampledMapImage = QImage( QSize( keySize, valueSize ), format ); - else if( keyAxis->orientation() == Qt::Vertical && ( mUndersampledMapImage.width() != valueSize || mUndersampledMapImage.height() != keySize ) ) - mUndersampledMapImage = QImage( QSize( valueSize, keySize ), format ); - localMapImage = &mUndersampledMapImage; // make the colorization run on the undersampled image - } - else if( !mUndersampledMapImage.isNull() ) - mUndersampledMapImage = QImage(); // don't need oversampling mechanism anymore (map size has changed) but mUndersampledMapImage still has nonzero size, free it - - const double* rawData = mMapData->mData; - const unsigned char* rawAlpha = mMapData->mAlpha; - if( keyAxis->orientation() == Qt::Horizontal ) + if (keyAxis->orientation() == Qt::Horizontal && (mUndersampledMapImage.width() != keySize || mUndersampledMapImage.height() != valueSize)) + mUndersampledMapImage = QImage(QSize(keySize, valueSize), format); + else if (keyAxis->orientation() == Qt::Vertical && (mUndersampledMapImage.width() != valueSize || mUndersampledMapImage.height() != keySize)) + mUndersampledMapImage = QImage(QSize(valueSize, keySize), format); + localMapImage = &mUndersampledMapImage; // make the colorization run on the undersampled image + } else if (!mUndersampledMapImage.isNull()) + mUndersampledMapImage = QImage(); // don't need oversampling mechanism anymore (map size has changed) but mUndersampledMapImage still has nonzero size, free it + + const double *rawData = mMapData->mData; + const unsigned char *rawAlpha = mMapData->mAlpha; + if (keyAxis->orientation() == Qt::Horizontal) { const int lineCount = valueSize; const int rowCount = keySize; - for( int line = 0; line < lineCount; ++line ) + for (int line=0; line( localMapImage->scanLine( lineCount - 1 - line ) ); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) - if( rawAlpha ) - mGradient.colorize( rawData + line * rowCount, rawAlpha + line * rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType == QCPAxis::stLogarithmic ); + QRgb* pixels = reinterpret_cast(localMapImage->scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + if (rawAlpha) + mGradient.colorize(rawData+line*rowCount, rawAlpha+line*rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType==QCPAxis::stLogarithmic); else - mGradient.colorize( rawData + line * rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType == QCPAxis::stLogarithmic ); + mGradient.colorize(rawData+line*rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType==QCPAxis::stLogarithmic); } - } - else // keyAxis->orientation() == Qt::Vertical + } else // keyAxis->orientation() == Qt::Vertical { const int lineCount = keySize; const int rowCount = valueSize; - for( int line = 0; line < lineCount; ++line ) + for (int line=0; line( localMapImage->scanLine( lineCount - 1 - line ) ); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) - if( rawAlpha ) - mGradient.colorize( rawData + line, rawAlpha + line, mDataRange, pixels, rowCount, lineCount, mDataScaleType == QCPAxis::stLogarithmic ); + QRgb* pixels = reinterpret_cast(localMapImage->scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + if (rawAlpha) + mGradient.colorize(rawData+line, rawAlpha+line, mDataRange, pixels, rowCount, lineCount, mDataScaleType==QCPAxis::stLogarithmic); else - mGradient.colorize( rawData + line, mDataRange, pixels, rowCount, lineCount, mDataScaleType == QCPAxis::stLogarithmic ); + mGradient.colorize(rawData+line, mDataRange, pixels, rowCount, lineCount, mDataScaleType==QCPAxis::stLogarithmic); } } - - if( keyOversamplingFactor > 1 || valueOversamplingFactor > 1 ) + + if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1) { - if( keyAxis->orientation() == Qt::Horizontal ) - mMapImage = mUndersampledMapImage.scaled( keySize * keyOversamplingFactor, valueSize * valueOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation ); + if (keyAxis->orientation() == Qt::Horizontal) + mMapImage = mUndersampledMapImage.scaled(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation); else - mMapImage = mUndersampledMapImage.scaled( valueSize * valueOversamplingFactor, keySize * keyOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation ); + mMapImage = mUndersampledMapImage.scaled(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation); } } mMapData->mDataModified = false; @@ -26663,90 +25963,85 @@ void QCPColorMap::updateMapImage() } /* inherits documentation from base class */ -void QCPColorMap::draw( QCPPainter* painter ) +void QCPColorMap::draw(QCPPainter *painter) { - if( mMapData->isEmpty() ) - return; - if( !mKeyAxis || !mValueAxis ) - return; - applyDefaultAntialiasingHint( painter ); - - if( mMapData->mDataModified || mMapImageInvalidated ) + if (mMapData->isEmpty()) return; + if (!mKeyAxis || !mValueAxis) return; + applyDefaultAntialiasingHint(painter); + + if (mMapData->mDataModified || mMapImageInvalidated) updateMapImage(); - + // use buffer if painting vectorized (PDF): - const bool useBuffer = painter->modes().testFlag( QCPPainter::pmVectorized ); - QCPPainter* localPainter = painter; // will be redirected to paint on mapBuffer if painting vectorized - QRectF mapBufferTarget; // the rect in absolute widget coordinates where the visible map portion/buffer will end up in + const bool useBuffer = painter->modes().testFlag(QCPPainter::pmVectorized); + QCPPainter *localPainter = painter; // will be redirected to paint on mapBuffer if painting vectorized + QRectF mapBufferTarget; // the rect in absolute widget coordinates where the visible map portion/buffer will end up in QPixmap mapBuffer; - if( useBuffer ) + if (useBuffer) { - const double mapBufferPixelRatio = 3; // factor by which DPI is increased in embedded bitmaps + const double mapBufferPixelRatio = 3; // factor by which DPI is increased in embedded bitmaps mapBufferTarget = painter->clipRegion().boundingRect(); - mapBuffer = QPixmap( ( mapBufferTarget.size() * mapBufferPixelRatio ).toSize() ); - mapBuffer.fill( Qt::transparent ); - localPainter = new QCPPainter( &mapBuffer ); - localPainter->scale( mapBufferPixelRatio, mapBufferPixelRatio ); - localPainter->translate( -mapBufferTarget.topLeft() ); + mapBuffer = QPixmap((mapBufferTarget.size()*mapBufferPixelRatio).toSize()); + mapBuffer.fill(Qt::transparent); + localPainter = new QCPPainter(&mapBuffer); + localPainter->scale(mapBufferPixelRatio, mapBufferPixelRatio); + localPainter->translate(-mapBufferTarget.topLeft()); } - - QRectF imageRect = QRectF( coordsToPixels( mMapData->keyRange().lower, mMapData->valueRange().lower ), - coordsToPixels( mMapData->keyRange().upper, mMapData->valueRange().upper ) ) - .normalized(); + + QRectF imageRect = QRectF(coordsToPixels(mMapData->keyRange().lower, mMapData->valueRange().lower), + coordsToPixels(mMapData->keyRange().upper, mMapData->valueRange().upper)).normalized(); // extend imageRect to contain outer halves/quarters of bordering/cornering pixels (cells are centered on map range boundary): - double halfCellWidth = 0; // in pixels - double halfCellHeight = 0; // in pixels - if( keyAxis()->orientation() == Qt::Horizontal ) + double halfCellWidth = 0; // in pixels + double halfCellHeight = 0; // in pixels + if (keyAxis()->orientation() == Qt::Horizontal) { - if( mMapData->keySize() > 1 ) - halfCellWidth = 0.5 * imageRect.width() / (double)( mMapData->keySize() - 1 ); - if( mMapData->valueSize() > 1 ) - halfCellHeight = 0.5 * imageRect.height() / (double)( mMapData->valueSize() - 1 ); - } - else // keyAxis orientation is Qt::Vertical + if (mMapData->keySize() > 1) + halfCellWidth = 0.5*imageRect.width()/(double)(mMapData->keySize()-1); + if (mMapData->valueSize() > 1) + halfCellHeight = 0.5*imageRect.height()/(double)(mMapData->valueSize()-1); + } else // keyAxis orientation is Qt::Vertical { - if( mMapData->keySize() > 1 ) - halfCellHeight = 0.5 * imageRect.height() / (double)( mMapData->keySize() - 1 ); - if( mMapData->valueSize() > 1 ) - halfCellWidth = 0.5 * imageRect.width() / (double)( mMapData->valueSize() - 1 ); + if (mMapData->keySize() > 1) + halfCellHeight = 0.5*imageRect.height()/(double)(mMapData->keySize()-1); + if (mMapData->valueSize() > 1) + halfCellWidth = 0.5*imageRect.width()/(double)(mMapData->valueSize()-1); } - imageRect.adjust( -halfCellWidth, -halfCellHeight, halfCellWidth, halfCellHeight ); - const bool mirrorX = ( keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis() )->rangeReversed(); - const bool mirrorY = ( valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis() )->rangeReversed(); - const bool smoothBackup = localPainter->renderHints().testFlag( QPainter::SmoothPixmapTransform ); - localPainter->setRenderHint( QPainter::SmoothPixmapTransform, mInterpolate ); + imageRect.adjust(-halfCellWidth, -halfCellHeight, halfCellWidth, halfCellHeight); + const bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + const bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + const bool smoothBackup = localPainter->renderHints().testFlag(QPainter::SmoothPixmapTransform); + localPainter->setRenderHint(QPainter::SmoothPixmapTransform, mInterpolate); QRegion clipBackup; - if( mTightBoundary ) + if (mTightBoundary) { clipBackup = localPainter->clipRegion(); - QRectF tightClipRect = QRectF( coordsToPixels( mMapData->keyRange().lower, mMapData->valueRange().lower ), - coordsToPixels( mMapData->keyRange().upper, mMapData->valueRange().upper ) ) - .normalized(); - localPainter->setClipRect( tightClipRect, Qt::IntersectClip ); + QRectF tightClipRect = QRectF(coordsToPixels(mMapData->keyRange().lower, mMapData->valueRange().lower), + coordsToPixels(mMapData->keyRange().upper, mMapData->valueRange().upper)).normalized(); + localPainter->setClipRect(tightClipRect, Qt::IntersectClip); } - localPainter->drawImage( imageRect, mMapImage.mirrored( mirrorX, mirrorY ) ); - if( mTightBoundary ) - localPainter->setClipRegion( clipBackup ); - localPainter->setRenderHint( QPainter::SmoothPixmapTransform, smoothBackup ); - - if( useBuffer ) // localPainter painted to mapBuffer, so now draw buffer with original painter + localPainter->drawImage(imageRect, mMapImage.mirrored(mirrorX, mirrorY)); + if (mTightBoundary) + localPainter->setClipRegion(clipBackup); + localPainter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup); + + if (useBuffer) // localPainter painted to mapBuffer, so now draw buffer with original painter { delete localPainter; - painter->drawPixmap( mapBufferTarget.toRect(), mapBuffer ); + painter->drawPixmap(mapBufferTarget.toRect(), mapBuffer); } } /* inherits documentation from base class */ -void QCPColorMap::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPColorMap::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { - applyDefaultAntialiasingHint( painter ); + applyDefaultAntialiasingHint(painter); // draw map thumbnail: - if( !mLegendIcon.isNull() ) + if (!mLegendIcon.isNull()) { - QPixmap scaledIcon = mLegendIcon.scaled( rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation ); - QRectF iconRect = QRectF( 0, 0, scaledIcon.width(), scaledIcon.height() ); - iconRect.moveCenter( rect.center() ); - painter->drawPixmap( iconRect.topLeft(), scaledIcon ); + QPixmap scaledIcon = mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation); + QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height()); + iconRect.moveCenter(rect.center()); + painter->drawPixmap(iconRect.topLeft(), scaledIcon); } /* // draw frame: @@ -26757,6 +26052,7 @@ void QCPColorMap::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) cons } /* end of 'src/plottables/plottable-colormap.cpp' */ + /* including file 'src/plottables/plottable-financial.cpp', size 42610 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -26837,19 +26133,28 @@ void QCPColorMap::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) cons /*! Constructs a data point with key and all values set to zero. */ -QCPFinancialData::QCPFinancialData() - : key( 0 ), open( 0 ), high( 0 ), low( 0 ), close( 0 ) +QCPFinancialData::QCPFinancialData() : + key(0), + open(0), + high(0), + low(0), + close(0) { } /*! Constructs a data point with the specified \a key and OHLC values. */ -QCPFinancialData::QCPFinancialData( double key, double open, double high, double low, double close ) - : key( key ), open( open ), high( high ), low( low ), close( close ) +QCPFinancialData::QCPFinancialData(double key, double open, double high, double low, double close) : + key(key), + open(open), + high(high), + low(low), + close(close) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPFinancial //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -26924,10 +26229,18 @@ QCPFinancialData::QCPFinancialData( double key, double open, double high, double keyAxis. This QCustomPlot instance takes ownership of the QCPFinancial, so do not delete it manually but use QCustomPlot::removePlottable() instead. */ -QCPFinancial::QCPFinancial( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable1D( keyAxis, valueAxis ), mChartStyle( csCandlestick ), mWidth( 0.5 ), mWidthType( wtPlotCoords ), mTwoColored( true ), mBrushPositive( QBrush( QColor( 50, 160, 0 ) ) ), mBrushNegative( QBrush( QColor( 180, 0, 15 ) ) ), mPenPositive( QPen( QColor( 40, 150, 0 ) ) ), mPenNegative( QPen( QColor( 170, 5, 5 ) ) ) +QCPFinancial::QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable1D(keyAxis, valueAxis), + mChartStyle(csCandlestick), + mWidth(0.5), + mWidthType(wtPlotCoords), + mTwoColored(true), + mBrushPositive(QBrush(QColor(50, 160, 0))), + mBrushNegative(QBrush(QColor(180, 0, 15))), + mPenPositive(QPen(QColor(40, 150, 0))), + mPenNegative(QPen(QColor(170, 5, 5))) { - mSelectionDecorator->setBrush( QBrush( QColor( 160, 160, 255 ) ) ); + mSelectionDecorator->setBrush(QBrush(QColor(160, 160, 255))); } QCPFinancial::~QCPFinancial() @@ -26949,7 +26262,7 @@ QCPFinancial::~QCPFinancial() \see addData, timeSeriesToOhlc */ -void QCPFinancial::setData( QSharedPointer data ) +void QCPFinancial::setData(QSharedPointer data) { mDataContainer = data; } @@ -26965,16 +26278,16 @@ void QCPFinancial::setData( QSharedPointer data ) \see addData, timeSeriesToOhlc */ -void QCPFinancial::setData( const QVector& keys, const QVector& open, const QVector& high, const QVector& low, const QVector& close, bool alreadySorted ) +void QCPFinancial::setData(const QVector &keys, const QVector &open, const QVector &high, const QVector &low, const QVector &close, bool alreadySorted) { mDataContainer->clear(); - addData( keys, open, high, low, close, alreadySorted ); + addData(keys, open, high, low, close, alreadySorted); } /*! Sets which representation style shall be used to display the OHLC data. */ -void QCPFinancial::setChartStyle( QCPFinancial::ChartStyle style ) +void QCPFinancial::setChartStyle(QCPFinancial::ChartStyle style) { mChartStyle = style; } @@ -26984,7 +26297,7 @@ void QCPFinancial::setChartStyle( QCPFinancial::ChartStyle style ) A typical choice is to set it to (or slightly less than) one bin interval width. */ -void QCPFinancial::setWidth( double width ) +void QCPFinancial::setWidth(double width) { mWidth = width; } @@ -26997,7 +26310,7 @@ void QCPFinancial::setWidth( double width ) \see setWidth */ -void QCPFinancial::setWidthType( QCPFinancial::WidthType widthType ) +void QCPFinancial::setWidthType(QCPFinancial::WidthType widthType) { mWidthType = widthType; } @@ -27011,7 +26324,7 @@ void QCPFinancial::setWidthType( QCPFinancial::WidthType widthType ) \see setPenPositive, setPenNegative, setBrushPositive, setBrushNegative */ -void QCPFinancial::setTwoColored( bool twoColored ) +void QCPFinancial::setTwoColored(bool twoColored) { mTwoColored = twoColored; } @@ -27025,7 +26338,7 @@ void QCPFinancial::setTwoColored( bool twoColored ) \see setBrushNegative, setPenPositive, setPenNegative */ -void QCPFinancial::setBrushPositive( const QBrush& brush ) +void QCPFinancial::setBrushPositive(const QBrush &brush) { mBrushPositive = brush; } @@ -27039,7 +26352,7 @@ void QCPFinancial::setBrushPositive( const QBrush& brush ) \see setBrushPositive, setPenNegative, setPenPositive */ -void QCPFinancial::setBrushNegative( const QBrush& brush ) +void QCPFinancial::setBrushNegative(const QBrush &brush) { mBrushNegative = brush; } @@ -27053,7 +26366,7 @@ void QCPFinancial::setBrushNegative( const QBrush& brush ) \see setPenNegative, setBrushPositive, setBrushNegative */ -void QCPFinancial::setPenPositive( const QPen& pen ) +void QCPFinancial::setPenPositive(const QPen &pen) { mPenPositive = pen; } @@ -27067,7 +26380,7 @@ void QCPFinancial::setPenPositive( const QPen& pen ) \see setPenPositive, setBrushNegative, setBrushPositive */ -void QCPFinancial::setPenNegative( const QPen& pen ) +void QCPFinancial::setPenNegative(const QPen &pen) { mPenNegative = pen; } @@ -27086,16 +26399,16 @@ void QCPFinancial::setPenNegative( const QPen& pen ) \see timeSeriesToOhlc */ -void QCPFinancial::addData( const QVector& keys, const QVector& open, const QVector& high, const QVector& low, const QVector& close, bool alreadySorted ) +void QCPFinancial::addData(const QVector &keys, const QVector &open, const QVector &high, const QVector &low, const QVector &close, bool alreadySorted) { - if( keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size() ) + if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size()) qDebug() << Q_FUNC_INFO << "keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size(); - const int n = qMin( keys.size(), qMin( open.size(), qMin( high.size(), qMin( low.size(), close.size() ) ) ) ); - QVector tempData( n ); + const int n = qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size())))); + QVector tempData(n); QVector::iterator it = tempData.begin(); const QVector::iterator itEnd = tempData.end(); int i = 0; - while( it != itEnd ) + while (it != itEnd) { it->key = keys[i]; it->open = open[i]; @@ -27105,7 +26418,7 @@ void QCPFinancial::addData( const QVector& keys, const QVector& ++it; ++i; } - mDataContainer->add( tempData, alreadySorted ); // don't modify tempData beyond this to prevent copy on write + mDataContainer->add(tempData, alreadySorted); // don't modify tempData beyond this to prevent copy on write } /*! \overload @@ -27118,90 +26431,88 @@ void QCPFinancial::addData( const QVector& keys, const QVector& \see timeSeriesToOhlc */ -void QCPFinancial::addData( double key, double open, double high, double low, double close ) +void QCPFinancial::addData(double key, double open, double high, double low, double close) { - mDataContainer->add( QCPFinancialData( key, open, high, low, close ) ); + mDataContainer->add(QCPFinancialData(key, open, high, low, close)); } /*! \copydoc QCPPlottableInterface1D::selectTestRect */ -QCPDataSelection QCPFinancial::selectTestRect( const QRectF& rect, bool onlySelectable ) const +QCPDataSelection QCPFinancial::selectTestRect(const QRectF &rect, bool onlySelectable) const { QCPDataSelection result; - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return result; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return result; - + QCPFinancialDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - - for( QCPFinancialDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + getVisibleDataBounds(visibleBegin, visibleEnd); + + for (QCPFinancialDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { - if( rect.intersects( selectionHitBox( it ) ) ) - result.addDataRange( QCPDataRange( it - mDataContainer->constBegin(), it - mDataContainer->constBegin() + 1 ), false ); + if (rect.intersects(selectionHitBox(it))) + result.addDataRange(QCPDataRange(it-mDataContainer->constBegin(), it-mDataContainer->constBegin()+1), false); } result.simplify(); return result; } /* inherits documentation from base class */ -double QCPFinancial::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPFinancial::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + Q_UNUSED(details) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { // get visible data range: QCPFinancialDataContainer::const_iterator visibleBegin, visibleEnd; QCPFinancialDataContainer::const_iterator closestDataPoint = mDataContainer->constEnd(); - getVisibleDataBounds( visibleBegin, visibleEnd ); + getVisibleDataBounds(visibleBegin, visibleEnd); // perform select test according to configured style: double result = -1; - switch( mChartStyle ) + switch (mChartStyle) { - case QCPFinancial::csOhlc: - result = ohlcSelectTest( pos, visibleBegin, visibleEnd, closestDataPoint ); - break; - case QCPFinancial::csCandlestick: - result = candlestickSelectTest( pos, visibleBegin, visibleEnd, closestDataPoint ); - break; + case QCPFinancial::csOhlc: + result = ohlcSelectTest(pos, visibleBegin, visibleEnd, closestDataPoint); break; + case QCPFinancial::csCandlestick: + result = candlestickSelectTest(pos, visibleBegin, visibleEnd, closestDataPoint); break; } - if( details ) + if (details) { - int pointIndex = closestDataPoint - mDataContainer->constBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = closestDataPoint-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } return result; } - + return -1; } /* inherits documentation from base class */ -QCPRange QCPFinancial::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPFinancial::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { - QCPRange range = mDataContainer->keyRange( foundRange, inSignDomain ); + QCPRange range = mDataContainer->keyRange(foundRange, inSignDomain); // determine exact range by including width of bars/flags: - if( foundRange ) + if (foundRange) { - if( inSignDomain != QCP::sdPositive || range.lower - mWidth * 0.5 > 0 ) - range.lower -= mWidth * 0.5; - if( inSignDomain != QCP::sdNegative || range.upper + mWidth * 0.5 < 0 ) - range.upper += mWidth * 0.5; + if (inSignDomain != QCP::sdPositive || range.lower-mWidth*0.5 > 0) + range.lower -= mWidth*0.5; + if (inSignDomain != QCP::sdNegative || range.upper+mWidth*0.5 < 0) + range.upper += mWidth*0.5; } return range; } /* inherits documentation from base class */ -QCPRange QCPFinancial::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPFinancial::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - return mDataContainer->valueRange( foundRange, inSignDomain, inKeyRange ); + return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange); } /*! @@ -27218,143 +26529,135 @@ QCPRange QCPFinancial::getValueRange( bool& foundRange, QCP::SignDomain inSignDo It merely defines the mathematical offset/phase of the bins that will be used to process the data. */ -QCPFinancialDataContainer QCPFinancial::timeSeriesToOhlc( const QVector& time, const QVector& value, double timeBinSize, double timeBinOffset ) +QCPFinancialDataContainer QCPFinancial::timeSeriesToOhlc(const QVector &time, const QVector &value, double timeBinSize, double timeBinOffset) { QCPFinancialDataContainer data; - int count = qMin( time.size(), value.size() ); - if( count == 0 ) + int count = qMin(time.size(), value.size()); + if (count == 0) return QCPFinancialDataContainer(); - - QCPFinancialData currentBinData( 0, value.first(), value.first(), value.first(), value.first() ); - int currentBinIndex = qFloor( ( time.first() - timeBinOffset ) / timeBinSize + 0.5 ); - for( int i = 0; i < count; ++i ) + + QCPFinancialData currentBinData(0, value.first(), value.first(), value.first(), value.first()); + int currentBinIndex = qFloor((time.first()-timeBinOffset)/timeBinSize+0.5); + for (int i=0; i currentBinData.high ) - currentBinData.high = value.at( i ); - if( i == count - 1 ) // last data point is in current bin, finalize bin: + if (value.at(i) < currentBinData.low) currentBinData.low = value.at(i); + if (value.at(i) > currentBinData.high) currentBinData.high = value.at(i); + if (i == count-1) // last data point is in current bin, finalize bin: { - currentBinData.close = value.at( i ); - currentBinData.key = timeBinOffset + (index)*timeBinSize; - data.add( currentBinData ); + currentBinData.close = value.at(i); + currentBinData.key = timeBinOffset+(index)*timeBinSize; + data.add(currentBinData); } - } - else // data point not anymore in current bin, set close of old and open of new bin, and add old to map: + } else // data point not anymore in current bin, set close of old and open of new bin, and add old to map: { // finalize current bin: - currentBinData.close = value.at( i - 1 ); - currentBinData.key = timeBinOffset + ( index - 1 ) * timeBinSize; - data.add( currentBinData ); + currentBinData.close = value.at(i-1); + currentBinData.key = timeBinOffset+(index-1)*timeBinSize; + data.add(currentBinData); // start next bin: currentBinIndex = index; - currentBinData.open = value.at( i ); - currentBinData.high = value.at( i ); - currentBinData.low = value.at( i ); + currentBinData.open = value.at(i); + currentBinData.high = value.at(i); + currentBinData.low = value.at(i); } } - + return data; } /* inherits documentation from base class */ -void QCPFinancial::draw( QCPPainter* painter ) +void QCPFinancial::draw(QCPPainter *painter) { // get visible data range: QCPFinancialDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd ); - + getVisibleDataBounds(visibleBegin, visibleEnd); + // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); QCPFinancialDataContainer::const_iterator begin = visibleBegin; QCPFinancialDataContainer::const_iterator end = visibleEnd; - mDataContainer->limitIteratorsToDataRange( begin, end, allSegments.at( i ) ); - if( begin == end ) + mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i)); + if (begin == end) continue; - + // draw data segment according to configured style: - switch( mChartStyle ) + switch (mChartStyle) { - case QCPFinancial::csOhlc: - drawOhlcPlot( painter, begin, end, isSelectedSegment ); - break; - case QCPFinancial::csCandlestick: - drawCandlestickPlot( painter, begin, end, isSelectedSegment ); - break; + case QCPFinancial::csOhlc: + drawOhlcPlot(painter, begin, end, isSelectedSegment); break; + case QCPFinancial::csCandlestick: + drawCandlestickPlot(painter, begin, end, isSelectedSegment); break; } } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPFinancial::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPFinancial::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { - painter->setAntialiasing( false ); // legend icon especially of csCandlestick looks better without antialiasing - if( mChartStyle == csOhlc ) + painter->setAntialiasing(false); // legend icon especially of csCandlestick looks better without antialiasing + if (mChartStyle == csOhlc) { - if( mTwoColored ) + if (mTwoColored) { // draw upper left half icon with positive color: - painter->setBrush( mBrushPositive ); - painter->setPen( mPenPositive ); - painter->setClipRegion( QRegion( QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint() ) ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.2, rect.height() * 0.3, rect.width() * 0.2, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.8, rect.height() * 0.5, rect.width() * 0.8, rect.height() * 0.7 ).translated( rect.topLeft() ) ); + painter->setBrush(mBrushPositive); + painter->setPen(mPenPositive); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); // draw bottom right half icon with negative color: - painter->setBrush( mBrushNegative ); - painter->setPen( mPenNegative ); - painter->setClipRegion( QRegion( QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint() ) ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.2, rect.height() * 0.3, rect.width() * 0.2, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.8, rect.height() * 0.5, rect.width() * 0.8, rect.height() * 0.7 ).translated( rect.topLeft() ) ); - } - else + painter->setBrush(mBrushNegative); + painter->setPen(mPenNegative); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); + } else { - painter->setBrush( mBrush ); - painter->setPen( mPen ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.2, rect.height() * 0.3, rect.width() * 0.2, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.8, rect.height() * 0.5, rect.width() * 0.8, rect.height() * 0.7 ).translated( rect.topLeft() ) ); + painter->setBrush(mBrush); + painter->setPen(mPen); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); } - } - else if( mChartStyle == csCandlestick ) + } else if (mChartStyle == csCandlestick) { - if( mTwoColored ) + if (mTwoColored) { // draw upper left half icon with positive color: - painter->setBrush( mBrushPositive ); - painter->setPen( mPenPositive ); - painter->setClipRegion( QRegion( QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint() ) ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width() * 0.25, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.75, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawRect( QRectF( rect.width() * 0.25, rect.height() * 0.25, rect.width() * 0.5, rect.height() * 0.5 ).translated( rect.topLeft() ) ); + painter->setBrush(mBrushPositive); + painter->setPen(mPenPositive); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); // draw bottom right half icon with negative color: - painter->setBrush( mBrushNegative ); - painter->setPen( mPenNegative ); - painter->setClipRegion( QRegion( QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint() ) ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width() * 0.25, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.75, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawRect( QRectF( rect.width() * 0.25, rect.height() * 0.25, rect.width() * 0.5, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - } - else + painter->setBrush(mBrushNegative); + painter->setPen(mPenNegative); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); + } else { - painter->setBrush( mBrush ); - painter->setPen( mPen ); - painter->drawLine( QLineF( 0, rect.height() * 0.5, rect.width() * 0.25, rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawLine( QLineF( rect.width() * 0.75, rect.height() * 0.5, rect.width(), rect.height() * 0.5 ).translated( rect.topLeft() ) ); - painter->drawRect( QRectF( rect.width() * 0.25, rect.height() * 0.25, rect.width() * 0.5, rect.height() * 0.5 ).translated( rect.topLeft() ) ); + painter->setBrush(mBrush); + painter->setPen(mPen); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); } } } @@ -27365,58 +26668,53 @@ void QCPFinancial::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) con This method is a helper function for \ref draw. It is used when the chart style is \ref csOhlc. */ -void QCPFinancial::drawOhlcPlot( QCPPainter* painter, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, bool isSelected ) +void QCPFinancial::drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected) { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - - if( keyAxis->orientation() == Qt::Horizontal ) - { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it) { - if( isSelected && mSelectionDecorator ) - mSelectionDecorator->applyPen( painter ); - else if( mTwoColored ) - painter->setPen( it->close >= it->open ? mPenPositive : mPenNegative ); + if (isSelected && mSelectionDecorator) + mSelectionDecorator->applyPen(painter); + else if (mTwoColored) + painter->setPen(it->close >= it->open ? mPenPositive : mPenNegative); else - painter->setPen( mPen ); - double keyPixel = keyAxis->coordToPixel( it->key ); - double openPixel = valueAxis->coordToPixel( it->open ); - double closePixel = valueAxis->coordToPixel( it->close ); + painter->setPen(mPen); + double keyPixel = keyAxis->coordToPixel(it->key); + double openPixel = valueAxis->coordToPixel(it->open); + double closePixel = valueAxis->coordToPixel(it->close); // draw backbone: - painter->drawLine( QPointF( keyPixel, valueAxis->coordToPixel( it->high ) ), QPointF( keyPixel, valueAxis->coordToPixel( it->low ) ) ); + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it->high)), QPointF(keyPixel, valueAxis->coordToPixel(it->low))); // draw open: - double pixelWidth = getPixelWidth( it->key, keyPixel ); // sign of this makes sure open/close are on correct sides - painter->drawLine( QPointF( keyPixel - pixelWidth, openPixel ), QPointF( keyPixel, openPixel ) ); + double pixelWidth = getPixelWidth(it->key, keyPixel); // sign of this makes sure open/close are on correct sides + painter->drawLine(QPointF(keyPixel-pixelWidth, openPixel), QPointF(keyPixel, openPixel)); // draw close: - painter->drawLine( QPointF( keyPixel, closePixel ), QPointF( keyPixel + pixelWidth, closePixel ) ); + painter->drawLine(QPointF(keyPixel, closePixel), QPointF(keyPixel+pixelWidth, closePixel)); } - } - else + } else { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it) { - if( isSelected && mSelectionDecorator ) - mSelectionDecorator->applyPen( painter ); - else if( mTwoColored ) - painter->setPen( it->close >= it->open ? mPenPositive : mPenNegative ); + if (isSelected && mSelectionDecorator) + mSelectionDecorator->applyPen(painter); + else if (mTwoColored) + painter->setPen(it->close >= it->open ? mPenPositive : mPenNegative); else - painter->setPen( mPen ); - double keyPixel = keyAxis->coordToPixel( it->key ); - double openPixel = valueAxis->coordToPixel( it->open ); - double closePixel = valueAxis->coordToPixel( it->close ); + painter->setPen(mPen); + double keyPixel = keyAxis->coordToPixel(it->key); + double openPixel = valueAxis->coordToPixel(it->open); + double closePixel = valueAxis->coordToPixel(it->close); // draw backbone: - painter->drawLine( QPointF( valueAxis->coordToPixel( it->high ), keyPixel ), QPointF( valueAxis->coordToPixel( it->low ), keyPixel ) ); + painter->drawLine(QPointF(valueAxis->coordToPixel(it->high), keyPixel), QPointF(valueAxis->coordToPixel(it->low), keyPixel)); // draw open: - double pixelWidth = getPixelWidth( it->key, keyPixel ); // sign of this makes sure open/close are on correct sides - painter->drawLine( QPointF( openPixel, keyPixel - pixelWidth ), QPointF( openPixel, keyPixel ) ); + double pixelWidth = getPixelWidth(it->key, keyPixel); // sign of this makes sure open/close are on correct sides + painter->drawLine(QPointF(openPixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel)); // draw close: - painter->drawLine( QPointF( closePixel, keyPixel ), QPointF( closePixel, keyPixel + pixelWidth ) ); + painter->drawLine(QPointF(closePixel, keyPixel), QPointF(closePixel, keyPixel+pixelWidth)); } } } @@ -27427,76 +26725,67 @@ void QCPFinancial::drawOhlcPlot( QCPPainter* painter, const QCPFinancialDataCont This method is a helper function for \ref draw. It is used when the chart style is \ref csCandlestick. */ -void QCPFinancial::drawCandlestickPlot( QCPPainter* painter, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, bool isSelected ) +void QCPFinancial::drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected) { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - - if( keyAxis->orientation() == Qt::Horizontal ) - { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it) { - if( isSelected && mSelectionDecorator ) + if (isSelected && mSelectionDecorator) { - mSelectionDecorator->applyPen( painter ); - mSelectionDecorator->applyBrush( painter ); - } - else if( mTwoColored ) + mSelectionDecorator->applyPen(painter); + mSelectionDecorator->applyBrush(painter); + } else if (mTwoColored) { - painter->setPen( it->close >= it->open ? mPenPositive : mPenNegative ); - painter->setBrush( it->close >= it->open ? mBrushPositive : mBrushNegative ); - } - else + painter->setPen(it->close >= it->open ? mPenPositive : mPenNegative); + painter->setBrush(it->close >= it->open ? mBrushPositive : mBrushNegative); + } else { - painter->setPen( mPen ); - painter->setBrush( mBrush ); + painter->setPen(mPen); + painter->setBrush(mBrush); } - double keyPixel = keyAxis->coordToPixel( it->key ); - double openPixel = valueAxis->coordToPixel( it->open ); - double closePixel = valueAxis->coordToPixel( it->close ); + double keyPixel = keyAxis->coordToPixel(it->key); + double openPixel = valueAxis->coordToPixel(it->open); + double closePixel = valueAxis->coordToPixel(it->close); // draw high: - painter->drawLine( QPointF( keyPixel, valueAxis->coordToPixel( it->high ) ), QPointF( keyPixel, valueAxis->coordToPixel( qMax( it->open, it->close ) ) ) ); + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it->high)), QPointF(keyPixel, valueAxis->coordToPixel(qMax(it->open, it->close)))); // draw low: - painter->drawLine( QPointF( keyPixel, valueAxis->coordToPixel( it->low ) ), QPointF( keyPixel, valueAxis->coordToPixel( qMin( it->open, it->close ) ) ) ); + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it->low)), QPointF(keyPixel, valueAxis->coordToPixel(qMin(it->open, it->close)))); // draw open-close box: - double pixelWidth = getPixelWidth( it->key, keyPixel ); - painter->drawRect( QRectF( QPointF( keyPixel - pixelWidth, closePixel ), QPointF( keyPixel + pixelWidth, openPixel ) ) ); + double pixelWidth = getPixelWidth(it->key, keyPixel); + painter->drawRect(QRectF(QPointF(keyPixel-pixelWidth, closePixel), QPointF(keyPixel+pixelWidth, openPixel))); } - } - else // keyAxis->orientation() == Qt::Vertical + } else // keyAxis->orientation() == Qt::Vertical { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it) { - if( isSelected && mSelectionDecorator ) + if (isSelected && mSelectionDecorator) { - mSelectionDecorator->applyPen( painter ); - mSelectionDecorator->applyBrush( painter ); - } - else if( mTwoColored ) + mSelectionDecorator->applyPen(painter); + mSelectionDecorator->applyBrush(painter); + } else if (mTwoColored) { - painter->setPen( it->close >= it->open ? mPenPositive : mPenNegative ); - painter->setBrush( it->close >= it->open ? mBrushPositive : mBrushNegative ); - } - else + painter->setPen(it->close >= it->open ? mPenPositive : mPenNegative); + painter->setBrush(it->close >= it->open ? mBrushPositive : mBrushNegative); + } else { - painter->setPen( mPen ); - painter->setBrush( mBrush ); + painter->setPen(mPen); + painter->setBrush(mBrush); } - double keyPixel = keyAxis->coordToPixel( it->key ); - double openPixel = valueAxis->coordToPixel( it->open ); - double closePixel = valueAxis->coordToPixel( it->close ); + double keyPixel = keyAxis->coordToPixel(it->key); + double openPixel = valueAxis->coordToPixel(it->open); + double closePixel = valueAxis->coordToPixel(it->close); // draw high: - painter->drawLine( QPointF( valueAxis->coordToPixel( it->high ), keyPixel ), QPointF( valueAxis->coordToPixel( qMax( it->open, it->close ) ), keyPixel ) ); + painter->drawLine(QPointF(valueAxis->coordToPixel(it->high), keyPixel), QPointF(valueAxis->coordToPixel(qMax(it->open, it->close)), keyPixel)); // draw low: - painter->drawLine( QPointF( valueAxis->coordToPixel( it->low ), keyPixel ), QPointF( valueAxis->coordToPixel( qMin( it->open, it->close ) ), keyPixel ) ); + painter->drawLine(QPointF(valueAxis->coordToPixel(it->low), keyPixel), QPointF(valueAxis->coordToPixel(qMin(it->open, it->close)), keyPixel)); // draw open-close box: - double pixelWidth = getPixelWidth( it->key, keyPixel ); - painter->drawRect( QRectF( QPointF( closePixel, keyPixel - pixelWidth ), QPointF( openPixel, keyPixel + pixelWidth ) ) ); + double pixelWidth = getPixelWidth(it->key, keyPixel); + painter->drawRect(QRectF(QPointF(closePixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel+pixelWidth))); } } } @@ -27513,38 +26802,37 @@ void QCPFinancial::drawCandlestickPlot( QCPPainter* painter, const QCPFinancialD horizontal axis, the return value is negative. This is important so the open/close flags on the \ref csOhlc bar are drawn to the correct side. */ -double QCPFinancial::getPixelWidth( double key, double keyPixel ) const +double QCPFinancial::getPixelWidth(double key, double keyPixel) const { double result = 0; - switch( mWidthType ) + switch (mWidthType) { - case wtAbsolute: - { - if( mKeyAxis ) - result = mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); - break; - } - case wtAxisRectRatio: - { - if( mKeyAxis && mKeyAxis.data()->axisRect() ) + case wtAbsolute: { - if( mKeyAxis.data()->orientation() == Qt::Horizontal ) - result = mKeyAxis.data()->axisRect()->width() * mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); - else - result = mKeyAxis.data()->axisRect()->height() * mWidth * 0.5 * mKeyAxis.data()->pixelOrientation(); + if (mKeyAxis) + result = mWidth*0.5*mKeyAxis.data()->pixelOrientation(); + break; + } + case wtAxisRectRatio: + { + if (mKeyAxis && mKeyAxis.data()->axisRect()) + { + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + result = mKeyAxis.data()->axisRect()->width()*mWidth*0.5*mKeyAxis.data()->pixelOrientation(); + else + result = mKeyAxis.data()->axisRect()->height()*mWidth*0.5*mKeyAxis.data()->pixelOrientation(); + } else + qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined"; + break; + } + case wtPlotCoords: + { + if (mKeyAxis) + result = mKeyAxis.data()->coordToPixel(key+mWidth*0.5)-keyPixel; + else + qDebug() << Q_FUNC_INFO << "No key axis defined"; + break; } - else - qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined"; - break; - } - case wtPlotCoords: - { - if( mKeyAxis ) - result = mKeyAxis.data()->coordToPixel( key + mWidth * 0.5 ) - keyPixel; - else - qDebug() << Q_FUNC_INFO << "No key axis defined"; - break; - } } return result; } @@ -27557,47 +26845,42 @@ double QCPFinancial::getPixelWidth( double key, double keyPixel ) const Like \ref selectTest, this method returns the shortest distance of \a pos to the graphical representation of the plottable, and \a closestDataPoint will point to the respective data point. */ -double QCPFinancial::ohlcSelectTest( const QPointF& pos, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, QCPFinancialDataContainer::const_iterator& closestDataPoint ) const +double QCPFinancial::ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const { closestDataPoint = mDataContainer->constEnd(); - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return -1; - } + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } double minDistSqr = std::numeric_limits::max(); - if( keyAxis->orientation() == Qt::Horizontal ) + if (keyAxis->orientation() == Qt::Horizontal) { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it=begin; it!=end; ++it) { - double keyPixel = keyAxis->coordToPixel( it->key ); + double keyPixel = keyAxis->coordToPixel(it->key); // calculate distance to backbone: - double currentDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( keyPixel, valueAxis->coordToPixel( it->high ) ), QCPVector2D( keyPixel, valueAxis->coordToPixel( it->low ) ) ); - if( currentDistSqr < minDistSqr ) + double currentDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(keyPixel, valueAxis->coordToPixel(it->high)), QCPVector2D(keyPixel, valueAxis->coordToPixel(it->low))); + if (currentDistSqr < minDistSqr) + { + minDistSqr = currentDistSqr; + closestDataPoint = it; + } + } + } else // keyAxis->orientation() == Qt::Vertical + { + for (QCPFinancialDataContainer::const_iterator it=begin; it!=end; ++it) + { + double keyPixel = keyAxis->coordToPixel(it->key); + // calculate distance to backbone: + double currentDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(valueAxis->coordToPixel(it->high), keyPixel), QCPVector2D(valueAxis->coordToPixel(it->low), keyPixel)); + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; closestDataPoint = it; } } } - else // keyAxis->orientation() == Qt::Vertical - { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) - { - double keyPixel = keyAxis->coordToPixel( it->key ); - // calculate distance to backbone: - double currentDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( valueAxis->coordToPixel( it->high ), keyPixel ), QCPVector2D( valueAxis->coordToPixel( it->low ), keyPixel ) ); - if( currentDistSqr < minDistSqr ) - { - minDistSqr = currentDistSqr; - closestDataPoint = it; - } - } - } - return qSqrt( minDistSqr ); + return qSqrt(minDistSqr); } /*! \internal @@ -27609,77 +26892,70 @@ double QCPFinancial::ohlcSelectTest( const QPointF& pos, const QCPFinancialDataC Like \ref selectTest, this method returns the shortest distance of \a pos to the graphical representation of the plottable, and \a closestDataPoint will point to the respective data point. */ -double QCPFinancial::candlestickSelectTest( const QPointF& pos, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, QCPFinancialDataContainer::const_iterator& closestDataPoint ) const +double QCPFinancial::candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const { closestDataPoint = mDataContainer->constEnd(); - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return -1; - } + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } double minDistSqr = std::numeric_limits::max(); - if( keyAxis->orientation() == Qt::Horizontal ) + if (keyAxis->orientation() == Qt::Horizontal) { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPFinancialDataContainer::const_iterator it=begin; it!=end; ++it) { double currentDistSqr; // determine whether pos is in open-close-box: - QCPRange boxKeyRange( it->key - mWidth * 0.5, it->key + mWidth * 0.5 ); - QCPRange boxValueRange( it->close, it->open ); + QCPRange boxKeyRange(it->key-mWidth*0.5, it->key+mWidth*0.5); + QCPRange boxValueRange(it->close, it->open); double posKey, posValue; - pixelsToCoords( pos, posKey, posValue ); - if( boxKeyRange.contains( posKey ) && boxValueRange.contains( posValue ) ) // is in open-close-box + pixelsToCoords(pos, posKey, posValue); + if (boxKeyRange.contains(posKey) && boxValueRange.contains(posValue)) // is in open-close-box { - currentDistSqr = mParentPlot->selectionTolerance() * 0.99 * mParentPlot->selectionTolerance() * 0.99; - } - else + currentDistSqr = mParentPlot->selectionTolerance()*0.99 * mParentPlot->selectionTolerance()*0.99; + } else { // calculate distance to high/low lines: - double keyPixel = keyAxis->coordToPixel( it->key ); - double highLineDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( keyPixel, valueAxis->coordToPixel( it->high ) ), QCPVector2D( keyPixel, valueAxis->coordToPixel( qMax( it->open, it->close ) ) ) ); - double lowLineDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( keyPixel, valueAxis->coordToPixel( it->low ) ), QCPVector2D( keyPixel, valueAxis->coordToPixel( qMin( it->open, it->close ) ) ) ); - currentDistSqr = qMin( highLineDistSqr, lowLineDistSqr ); + double keyPixel = keyAxis->coordToPixel(it->key); + double highLineDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(keyPixel, valueAxis->coordToPixel(it->high)), QCPVector2D(keyPixel, valueAxis->coordToPixel(qMax(it->open, it->close)))); + double lowLineDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(keyPixel, valueAxis->coordToPixel(it->low)), QCPVector2D(keyPixel, valueAxis->coordToPixel(qMin(it->open, it->close)))); + currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr); } - if( currentDistSqr < minDistSqr ) + if (currentDistSqr < minDistSqr) + { + minDistSqr = currentDistSqr; + closestDataPoint = it; + } + } + } else // keyAxis->orientation() == Qt::Vertical + { + for (QCPFinancialDataContainer::const_iterator it=begin; it!=end; ++it) + { + double currentDistSqr; + // determine whether pos is in open-close-box: + QCPRange boxKeyRange(it->key-mWidth*0.5, it->key+mWidth*0.5); + QCPRange boxValueRange(it->close, it->open); + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + if (boxKeyRange.contains(posKey) && boxValueRange.contains(posValue)) // is in open-close-box + { + currentDistSqr = mParentPlot->selectionTolerance()*0.99 * mParentPlot->selectionTolerance()*0.99; + } else + { + // calculate distance to high/low lines: + double keyPixel = keyAxis->coordToPixel(it->key); + double highLineDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(valueAxis->coordToPixel(it->high), keyPixel), QCPVector2D(valueAxis->coordToPixel(qMax(it->open, it->close)), keyPixel)); + double lowLineDistSqr = QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(valueAxis->coordToPixel(it->low), keyPixel), QCPVector2D(valueAxis->coordToPixel(qMin(it->open, it->close)), keyPixel)); + currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr); + } + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; closestDataPoint = it; } } } - else // keyAxis->orientation() == Qt::Vertical - { - for( QCPFinancialDataContainer::const_iterator it = begin; it != end; ++it ) - { - double currentDistSqr; - // determine whether pos is in open-close-box: - QCPRange boxKeyRange( it->key - mWidth * 0.5, it->key + mWidth * 0.5 ); - QCPRange boxValueRange( it->close, it->open ); - double posKey, posValue; - pixelsToCoords( pos, posKey, posValue ); - if( boxKeyRange.contains( posKey ) && boxValueRange.contains( posValue ) ) // is in open-close-box - { - currentDistSqr = mParentPlot->selectionTolerance() * 0.99 * mParentPlot->selectionTolerance() * 0.99; - } - else - { - // calculate distance to high/low lines: - double keyPixel = keyAxis->coordToPixel( it->key ); - double highLineDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( valueAxis->coordToPixel( it->high ), keyPixel ), QCPVector2D( valueAxis->coordToPixel( qMax( it->open, it->close ) ), keyPixel ) ); - double lowLineDistSqr = QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( valueAxis->coordToPixel( it->low ), keyPixel ), QCPVector2D( valueAxis->coordToPixel( qMin( it->open, it->close ) ), keyPixel ) ); - currentDistSqr = qMin( highLineDistSqr, lowLineDistSqr ); - } - if( currentDistSqr < minDistSqr ) - { - minDistSqr = currentDistSqr; - closestDataPoint = it; - } - } - } - return qSqrt( minDistSqr ); + return qSqrt(minDistSqr); } /*! \internal @@ -27696,17 +26972,17 @@ double QCPFinancial::candlestickSelectTest( const QPointF& pos, const QCPFinanci if the plottable contains no data, both \a begin and \a end point to \c constEnd. */ -void QCPFinancial::getVisibleDataBounds( QCPFinancialDataContainer::const_iterator& begin, QCPFinancialDataContainer::const_iterator& end ) const +void QCPFinancial::getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const { - if( !mKeyAxis ) + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; begin = mDataContainer->constEnd(); end = mDataContainer->constEnd(); return; } - begin = mDataContainer->findBegin( mKeyAxis.data()->range().lower - mWidth * 0.5 ); // subtract half width of ohlc/candlestick to include partially visible data points - end = mDataContainer->findEnd( mKeyAxis.data()->range().upper + mWidth * 0.5 ); // add half width of ohlc/candlestick to include partially visible data points + begin = mDataContainer->findBegin(mKeyAxis.data()->range().lower-mWidth*0.5); // subtract half width of ohlc/candlestick to include partially visible data points + end = mDataContainer->findEnd(mKeyAxis.data()->range().upper+mWidth*0.5); // add half width of ohlc/candlestick to include partially visible data points } /*! \internal @@ -27714,27 +26990,24 @@ void QCPFinancial::getVisibleDataBounds( QCPFinancialDataContainer::const_iterat Returns the hit box in pixel coordinates that will be used for data selection with the selection rect (\ref selectTestRect), of the data point given by \a it. */ -QRectF QCPFinancial::selectionHitBox( QCPFinancialDataContainer::const_iterator it ) const +QRectF QCPFinancial::selectionHitBox(QCPFinancialDataContainer::const_iterator it) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return QRectF(); - } - - double keyPixel = keyAxis->coordToPixel( it->key ); - double highPixel = valueAxis->coordToPixel( it->high ); - double lowPixel = valueAxis->coordToPixel( it->low ); - double keyWidthPixels = keyPixel - keyAxis->coordToPixel( it->key - mWidth * 0.5 ); - if( keyAxis->orientation() == Qt::Horizontal ) - return QRectF( keyPixel - keyWidthPixels, highPixel, keyWidthPixels * 2, lowPixel - highPixel ).normalized(); + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QRectF(); } + + double keyPixel = keyAxis->coordToPixel(it->key); + double highPixel = valueAxis->coordToPixel(it->high); + double lowPixel = valueAxis->coordToPixel(it->low); + double keyWidthPixels = keyPixel-keyAxis->coordToPixel(it->key-mWidth*0.5); + if (keyAxis->orientation() == Qt::Horizontal) + return QRectF(keyPixel-keyWidthPixels, highPixel, keyWidthPixels*2, lowPixel-highPixel).normalized(); else - return QRectF( highPixel, keyPixel - keyWidthPixels, lowPixel - highPixel, keyWidthPixels * 2 ).normalized(); + return QRectF(highPixel, keyPixel-keyWidthPixels, lowPixel-highPixel, keyWidthPixels*2).normalized(); } /* end of 'src/plottables/plottable-financial.cpp' */ + /* including file 'src/plottables/plottable-errorbar.cpp', size 37355 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -27760,16 +27033,18 @@ QRectF QCPFinancial::selectionHitBox( QCPFinancialDataContainer::const_iterator /*! Constructs an error bar with errors set to zero. */ -QCPErrorBarsData::QCPErrorBarsData() - : errorMinus( 0 ), errorPlus( 0 ) +QCPErrorBarsData::QCPErrorBarsData() : + errorMinus(0), + errorPlus(0) { } /*! Constructs an error bar with equal \a error in both negative and positive direction. */ -QCPErrorBarsData::QCPErrorBarsData( double error ) - : errorMinus( error ), errorPlus( error ) +QCPErrorBarsData::QCPErrorBarsData(double error) : + errorMinus(error), + errorPlus(error) { } @@ -27777,11 +27052,13 @@ QCPErrorBarsData::QCPErrorBarsData( double error ) Constructs an error bar with negative and positive errors set to \a errorMinus and \a errorPlus, respectively. */ -QCPErrorBarsData::QCPErrorBarsData( double errorMinus, double errorPlus ) - : errorMinus( errorMinus ), errorPlus( errorPlus ) +QCPErrorBarsData::QCPErrorBarsData(double errorMinus, double errorPlus) : + errorMinus(errorMinus), + errorPlus(errorPlus) { } + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPErrorBars //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -27839,11 +27116,15 @@ QCPErrorBarsData::QCPErrorBarsData( double errorMinus, double errorPlus ) from \a keyAxis. This QCustomPlot instance takes ownership of the \ref QCPErrorBars, so do not delete it manually but use \ref QCustomPlot::removePlottable() instead. */ -QCPErrorBars::QCPErrorBars( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable( keyAxis, valueAxis ), mDataContainer( new QVector ), mErrorType( etValueError ), mWhiskerWidth( 9 ), mSymbolGap( 10 ) +QCPErrorBars::QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mDataContainer(new QVector), + mErrorType(etValueError), + mWhiskerWidth(9), + mSymbolGap(10) { - setPen( QPen( Qt::black, 0 ) ); - setBrush( Qt::NoBrush ); + setPen(QPen(Qt::black, 0)); + setBrush(Qt::NoBrush); } QCPErrorBars::~QCPErrorBars() @@ -27868,7 +27149,7 @@ QCPErrorBars::~QCPErrorBars() \see addData */ -void QCPErrorBars::setData( QSharedPointer data ) +void QCPErrorBars::setData(QSharedPointer data) { mDataContainer = data; } @@ -27882,10 +27163,10 @@ void QCPErrorBars::setData( QSharedPointer data ) \see addData */ -void QCPErrorBars::setData( const QVector& error ) +void QCPErrorBars::setData(const QVector &error) { mDataContainer->clear(); - addData( error ); + addData(error); } /*! \overload @@ -27898,10 +27179,10 @@ void QCPErrorBars::setData( const QVector& error ) \see addData */ -void QCPErrorBars::setData( const QVector& errorMinus, const QVector& errorPlus ) +void QCPErrorBars::setData(const QVector &errorMinus, const QVector &errorPlus) { mDataContainer->clear(); - addData( errorMinus, errorPlus ); + addData(errorMinus, errorPlus); } /*! @@ -27918,21 +27199,21 @@ void QCPErrorBars::setData( const QVector& errorMinus, const QVector( plottable ) ) + if (plottable && qobject_cast(plottable)) { mDataPlottable = 0; qDebug() << Q_FUNC_INFO << "can't set another QCPErrorBars instance as data plottable"; return; } - if( plottable && !plottable->interface1D() ) + if (plottable && !plottable->interface1D()) { mDataPlottable = 0; qDebug() << Q_FUNC_INFO << "passed plottable doesn't implement 1d interface, can't associate with QCPErrorBars"; return; } - + mDataPlottable = plottable; } @@ -27940,7 +27221,7 @@ void QCPErrorBars::setDataPlottable( QCPAbstractPlottable* plottable ) Sets in which orientation the error bars shall appear on the data points. If your data needs both error dimensions, create two \ref QCPErrorBars with different \a type. */ -void QCPErrorBars::setErrorType( ErrorType type ) +void QCPErrorBars::setErrorType(ErrorType type) { mErrorType = type; } @@ -27949,7 +27230,7 @@ void QCPErrorBars::setErrorType( ErrorType type ) Sets the width of the whiskers (the short bars at the end of the actual error bar backbones) to \a pixels. */ -void QCPErrorBars::setWhiskerWidth( double pixels ) +void QCPErrorBars::setWhiskerWidth(double pixels) { mWhiskerWidth = pixels; } @@ -27959,7 +27240,7 @@ void QCPErrorBars::setWhiskerWidth( double pixels ) backbones. This gap prevents that error bars are drawn too close to or even through scatter points. */ -void QCPErrorBars::setSymbolGap( double pixels ) +void QCPErrorBars::setSymbolGap(double pixels) { mSymbolGap = pixels; } @@ -27973,9 +27254,9 @@ void QCPErrorBars::setSymbolGap( double pixels ) \see setData */ -void QCPErrorBars::addData( const QVector& error ) +void QCPErrorBars::addData(const QVector &error) { - addData( error, error ); + addData(error, error); } /*! \overload @@ -27988,14 +27269,14 @@ void QCPErrorBars::addData( const QVector& error ) \see setData */ -void QCPErrorBars::addData( const QVector& errorMinus, const QVector& errorPlus ) +void QCPErrorBars::addData(const QVector &errorMinus, const QVector &errorPlus) { - if( errorMinus.size() != errorPlus.size() ) + if (errorMinus.size() != errorPlus.size()) qDebug() << Q_FUNC_INFO << "minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size(); - const int n = qMin( errorMinus.size(), errorPlus.size() ); - mDataContainer->reserve( n ); - for( int i = 0; i < n; ++i ) - mDataContainer->append( QCPErrorBarsData( errorMinus.at( i ), errorPlus.at( i ) ) ); + const int n = qMin(errorMinus.size(), errorPlus.size()); + mDataContainer->reserve(n); + for (int i=0; iappend(QCPErrorBarsData(errorMinus.at(i), errorPlus.at(i))); } /*! \overload @@ -28007,9 +27288,9 @@ void QCPErrorBars::addData( const QVector& errorMinus, const QVectorappend( QCPErrorBarsData( error ) ); + mDataContainer->append(QCPErrorBarsData(error)); } /*! \overload @@ -28022,9 +27303,9 @@ void QCPErrorBars::addData( double error ) \see setData */ -void QCPErrorBars::addData( double errorMinus, double errorPlus ) +void QCPErrorBars::addData(double errorMinus, double errorPlus) { - mDataContainer->append( QCPErrorBarsData( errorMinus, errorPlus ) ); + mDataContainer->append(QCPErrorBarsData(errorMinus, errorPlus)); } /* inherits documentation from base class */ @@ -28034,47 +27315,46 @@ int QCPErrorBars::dataCount() const } /* inherits documentation from base class */ -double QCPErrorBars::dataMainKey( int index ) const +double QCPErrorBars::dataMainKey(int index) const { - if( mDataPlottable ) - return mDataPlottable->interface1D()->dataMainKey( index ); + if (mDataPlottable) + return mDataPlottable->interface1D()->dataMainKey(index); else qDebug() << Q_FUNC_INFO << "no data plottable set"; return 0; } /* inherits documentation from base class */ -double QCPErrorBars::dataSortKey( int index ) const +double QCPErrorBars::dataSortKey(int index) const { - if( mDataPlottable ) - return mDataPlottable->interface1D()->dataSortKey( index ); + if (mDataPlottable) + return mDataPlottable->interface1D()->dataSortKey(index); else qDebug() << Q_FUNC_INFO << "no data plottable set"; return 0; } /* inherits documentation from base class */ -double QCPErrorBars::dataMainValue( int index ) const +double QCPErrorBars::dataMainValue(int index) const { - if( mDataPlottable ) - return mDataPlottable->interface1D()->dataMainValue( index ); + if (mDataPlottable) + return mDataPlottable->interface1D()->dataMainValue(index); else qDebug() << Q_FUNC_INFO << "no data plottable set"; return 0; } /* inherits documentation from base class */ -QCPRange QCPErrorBars::dataValueRange( int index ) const +QCPRange QCPErrorBars::dataValueRange(int index) const { - if( mDataPlottable ) + if (mDataPlottable) { - const double value = mDataPlottable->interface1D()->dataMainValue( index ); - if( index >= 0 && index < mDataContainer->size() && mErrorType == etValueError ) - return QCPRange( value - mDataContainer->at( index ).errorMinus, value + mDataContainer->at( index ).errorPlus ); + const double value = mDataPlottable->interface1D()->dataMainValue(index); + if (index >= 0 && index < mDataContainer->size() && mErrorType == etValueError) + return QCPRange(value-mDataContainer->at(index).errorMinus, value+mDataContainer->at(index).errorPlus); else - return QCPRange( value, value ); - } - else + return QCPRange(value, value); + } else { qDebug() << Q_FUNC_INFO << "no data plottable set"; return QCPRange(); @@ -28082,10 +27362,10 @@ QCPRange QCPErrorBars::dataValueRange( int index ) const } /* inherits documentation from base class */ -QPointF QCPErrorBars::dataPixelPosition( int index ) const +QPointF QCPErrorBars::dataPixelPosition(int index) const { - if( mDataPlottable ) - return mDataPlottable->interface1D()->dataPixelPosition( index ); + if (mDataPlottable) + return mDataPlottable->interface1D()->dataPixelPosition(index); else qDebug() << Q_FUNC_INFO << "no data plottable set"; return QPointF(); @@ -28094,11 +27374,10 @@ QPointF QCPErrorBars::dataPixelPosition( int index ) const /* inherits documentation from base class */ bool QCPErrorBars::sortKeyIsMainKey() const { - if( mDataPlottable ) + if (mDataPlottable) { return mDataPlottable->interface1D()->sortKeyIsMainKey(); - } - else + } else { qDebug() << Q_FUNC_INFO << "no data plottable set"; return true; @@ -28108,30 +27387,30 @@ bool QCPErrorBars::sortKeyIsMainKey() const /*! \copydoc QCPPlottableInterface1D::selectTestRect */ -QCPDataSelection QCPErrorBars::selectTestRect( const QRectF& rect, bool onlySelectable ) const +QCPDataSelection QCPErrorBars::selectTestRect(const QRectF &rect, bool onlySelectable) const { QCPDataSelection result; - if( !mDataPlottable ) + if (!mDataPlottable) return result; - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return result; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return result; - + QCPErrorBarsDataContainer::const_iterator visibleBegin, visibleEnd; - getVisibleDataBounds( visibleBegin, visibleEnd, QCPDataRange( 0, dataCount() ) ); - + getVisibleDataBounds(visibleBegin, visibleEnd, QCPDataRange(0, dataCount())); + QVector backbones, whiskers; - for( QCPErrorBarsDataContainer::const_iterator it = visibleBegin; it != visibleEnd; ++it ) + for (QCPErrorBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it) { backbones.clear(); whiskers.clear(); - getErrorBarLines( it, backbones, whiskers ); - for( int i = 0; i < backbones.size(); ++i ) + getErrorBarLines(it, backbones, whiskers); + for (int i=0; iconstBegin(), it - mDataContainer->constBegin() + 1 ), false ); + result.addDataRange(QCPDataRange(it-mDataContainer->constBegin(), it-mDataContainer->constBegin()+1), false); break; } } @@ -28141,208 +27420,193 @@ QCPDataSelection QCPErrorBars::selectTestRect( const QRectF& rect, bool onlySele } /* inherits documentation from base class */ -int QCPErrorBars::findBegin( double sortKey, bool expandedRange ) const +int QCPErrorBars::findBegin(double sortKey, bool expandedRange) const { - if( mDataPlottable ) + if (mDataPlottable) { - if( mDataContainer->isEmpty() ) + if (mDataContainer->isEmpty()) return 0; - int beginIndex = mDataPlottable->interface1D()->findBegin( sortKey, expandedRange ); - if( beginIndex >= mDataContainer->size() ) - beginIndex = mDataContainer->size() - 1; + int beginIndex = mDataPlottable->interface1D()->findBegin(sortKey, expandedRange); + if (beginIndex >= mDataContainer->size()) + beginIndex = mDataContainer->size()-1; return beginIndex; - } - else + } else qDebug() << Q_FUNC_INFO << "no data plottable set"; return 0; } /* inherits documentation from base class */ -int QCPErrorBars::findEnd( double sortKey, bool expandedRange ) const +int QCPErrorBars::findEnd(double sortKey, bool expandedRange) const { - if( mDataPlottable ) + if (mDataPlottable) { - if( mDataContainer->isEmpty() ) + if (mDataContainer->isEmpty()) return 0; - int endIndex = mDataPlottable->interface1D()->findEnd( sortKey, expandedRange ); - if( endIndex > mDataContainer->size() ) + int endIndex = mDataPlottable->interface1D()->findEnd(sortKey, expandedRange); + if (endIndex > mDataContainer->size()) endIndex = mDataContainer->size(); return endIndex; - } - else + } else qDebug() << Q_FUNC_INFO << "no data plottable set"; return 0; } /* inherits documentation from base class */ -double QCPErrorBars::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPErrorBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( !mDataPlottable ) + if (!mDataPlottable) return -1; + + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if (!mKeyAxis || !mValueAxis) return -1; - if( !mKeyAxis || !mValueAxis ) - return -1; - - if( mKeyAxis.data()->axisRect()->rect().contains( pos.toPoint() ) ) + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) { QCPErrorBarsDataContainer::const_iterator closestDataPoint = mDataContainer->constEnd(); - double result = pointDistance( pos, closestDataPoint ); - if( details ) + double result = pointDistance(pos, closestDataPoint); + if (details) { - int pointIndex = closestDataPoint - mDataContainer->constBegin(); - details->setValue( QCPDataSelection( QCPDataRange( pointIndex, pointIndex + 1 ) ) ); + int pointIndex = closestDataPoint-mDataContainer->constBegin(); + details->setValue(QCPDataSelection(QCPDataRange(pointIndex, pointIndex+1))); } return result; - } - else + } else return -1; } /* inherits documentation from base class */ -void QCPErrorBars::draw( QCPPainter* painter ) +void QCPErrorBars::draw(QCPPainter *painter) { - if( !mDataPlottable ) - return; - if( !mKeyAxis || !mValueAxis ) - { - qDebug() << Q_FUNC_INFO << "invalid key or value axis"; - return; - } - if( mKeyAxis.data()->range().size() <= 0 || mDataContainer->isEmpty() ) - return; - + if (!mDataPlottable) return; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mKeyAxis.data()->range().size() <= 0 || mDataContainer->isEmpty()) return; + // if the sort key isn't the main key, we must check the visibility for each data point/error bar individually // (getVisibleDataBounds applies range restriction, but otherwise can only return full data range): bool checkPointVisibility = !mDataPlottable->interface1D()->sortKeyIsMainKey(); - - // check data validity if flag set: + + // check data validity if flag set: #ifdef QCUSTOMPLOT_CHECK_DATA QCPErrorBarsDataContainer::const_iterator it; - for( it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it ) + for (it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it) { - if( QCP::isInvalidData( it->errorMinus, it->errorPlus ) ) - qDebug() << Q_FUNC_INFO << "Data point at index" << it - mDataContainer->constBegin() << "invalid." - << "Plottable name:" << name(); + if (QCP::isInvalidData(it->errorMinus, it->errorPlus)) + qDebug() << Q_FUNC_INFO << "Data point at index" << it-mDataContainer->constBegin() << "invalid." << "Plottable name:" << name(); } #endif - - applyDefaultAntialiasingHint( painter ); - painter->setBrush( Qt::NoBrush ); + + applyDefaultAntialiasingHint(painter); + painter->setBrush(Qt::NoBrush); // loop over and draw segments of unselected/selected data: QList selectedSegments, unselectedSegments, allSegments; - getDataSegments( selectedSegments, unselectedSegments ); + getDataSegments(selectedSegments, unselectedSegments); allSegments << unselectedSegments << selectedSegments; QVector backbones, whiskers; - for( int i = 0; i < allSegments.size(); ++i ) + for (int i=0; i= unselectedSegments.size(); - if( isSelectedSegment && mSelectionDecorator ) - mSelectionDecorator->applyPen( painter ); + if (isSelectedSegment && mSelectionDecorator) + mSelectionDecorator->applyPen(painter); else - painter->setPen( mPen ); - if( painter->pen().capStyle() == Qt::SquareCap ) + painter->setPen(mPen); + if (painter->pen().capStyle() == Qt::SquareCap) { - QPen capFixPen( painter->pen() ); - capFixPen.setCapStyle( Qt::FlatCap ); - painter->setPen( capFixPen ); + QPen capFixPen(painter->pen()); + capFixPen.setCapStyle(Qt::FlatCap); + painter->setPen(capFixPen); } backbones.clear(); whiskers.clear(); - for( QCPErrorBarsDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it) { - if( !checkPointVisibility || errorBarVisible( it - mDataContainer->constBegin() ) ) - getErrorBarLines( it, backbones, whiskers ); + if (!checkPointVisibility || errorBarVisible(it-mDataContainer->constBegin())) + getErrorBarLines(it, backbones, whiskers); } - painter->drawLines( backbones ); - painter->drawLines( whiskers ); + painter->drawLines(backbones); + painter->drawLines(whiskers); } - + // draw other selection decoration that isn't just line/scatter pens and brushes: - if( mSelectionDecorator ) - mSelectionDecorator->drawDecoration( painter, selection() ); + if (mSelectionDecorator) + mSelectionDecorator->drawDecoration(painter, selection()); } /* inherits documentation from base class */ -void QCPErrorBars::drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const +void QCPErrorBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const { - applyDefaultAntialiasingHint( painter ); - painter->setPen( mPen ); - if( mErrorType == etValueError && mValueAxis && mValueAxis->orientation() == Qt::Vertical ) + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + if (mErrorType == etValueError && mValueAxis && mValueAxis->orientation() == Qt::Vertical) { - painter->drawLine( QLineF( rect.center().x(), rect.top() + 2, rect.center().x(), rect.bottom() - 1 ) ); - painter->drawLine( QLineF( rect.center().x() - 4, rect.top() + 2, rect.center().x() + 4, rect.top() + 2 ) ); - painter->drawLine( QLineF( rect.center().x() - 4, rect.bottom() - 1, rect.center().x() + 4, rect.bottom() - 1 ) ); - } - else + painter->drawLine(QLineF(rect.center().x(), rect.top()+2, rect.center().x(), rect.bottom()-1)); + painter->drawLine(QLineF(rect.center().x()-4, rect.top()+2, rect.center().x()+4, rect.top()+2)); + painter->drawLine(QLineF(rect.center().x()-4, rect.bottom()-1, rect.center().x()+4, rect.bottom()-1)); + } else { - painter->drawLine( QLineF( rect.left() + 2, rect.center().y(), rect.right() - 2, rect.center().y() ) ); - painter->drawLine( QLineF( rect.left() + 2, rect.center().y() - 4, rect.left() + 2, rect.center().y() + 4 ) ); - painter->drawLine( QLineF( rect.right() - 2, rect.center().y() - 4, rect.right() - 2, rect.center().y() + 4 ) ); + painter->drawLine(QLineF(rect.left()+2, rect.center().y(), rect.right()-2, rect.center().y())); + painter->drawLine(QLineF(rect.left()+2, rect.center().y()-4, rect.left()+2, rect.center().y()+4)); + painter->drawLine(QLineF(rect.right()-2, rect.center().y()-4, rect.right()-2, rect.center().y()+4)); } } /* inherits documentation from base class */ -QCPRange QCPErrorBars::getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain ) const +QCPRange QCPErrorBars::getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain) const { - if( !mDataPlottable ) + if (!mDataPlottable) { foundRange = false; return QCPRange(); } - + QCPRange range; bool haveLower = false; bool haveUpper = false; QCPErrorBarsDataContainer::const_iterator it; - for( it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it ) + for (it = mDataContainer->constBegin(); it != mDataContainer->constEnd(); ++it) { - if( mErrorType == etValueError ) + if (mErrorType == etValueError) { // error bar doesn't extend in key dimension (except whisker but we ignore that here), so only use data point center - const double current = mDataPlottable->interface1D()->dataMainKey( it - mDataContainer->constBegin() ); - if( qIsNaN( current ) ) - continue; - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + const double current = mDataPlottable->interface1D()->dataMainKey(it-mDataContainer->constBegin()); + if (qIsNaN(current)) continue; + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; } - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; } } - } - else // mErrorType == etKeyError + } else // mErrorType == etKeyError { - const double dataKey = mDataPlottable->interface1D()->dataMainKey( it - mDataContainer->constBegin() ); - if( qIsNaN( dataKey ) ) - continue; + const double dataKey = mDataPlottable->interface1D()->dataMainKey(it-mDataContainer->constBegin()); + if (qIsNaN(dataKey)) continue; // plus error: - double current = dataKey + ( qIsNaN( it->errorPlus ) ? 0 : it->errorPlus ); - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + double current = dataKey + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus); + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; } } // minus error: - current = dataKey - ( qIsNaN( it->errorMinus ) ? 0 : it->errorMinus ); - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + current = dataKey - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus); + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; @@ -28350,90 +27614,86 @@ QCPRange QCPErrorBars::getKeyRange( bool& foundRange, QCP::SignDomain inSignDoma } } } - - if( haveUpper && !haveLower ) + + if (haveUpper && !haveLower) { range.lower = range.upper; haveLower = true; - } - else if( haveLower && !haveUpper ) + } else if (haveLower && !haveUpper) { range.upper = range.lower; haveUpper = true; } - + foundRange = haveLower && haveUpper; return range; } /* inherits documentation from base class */ -QCPRange QCPErrorBars::getValueRange( bool& foundRange, QCP::SignDomain inSignDomain, const QCPRange& inKeyRange ) const +QCPRange QCPErrorBars::getValueRange(bool &foundRange, QCP::SignDomain inSignDomain, const QCPRange &inKeyRange) const { - if( !mDataPlottable ) + if (!mDataPlottable) { foundRange = false; return QCPRange(); } - + QCPRange range; const bool restrictKeyRange = inKeyRange != QCPRange(); bool haveLower = false; bool haveUpper = false; QCPErrorBarsDataContainer::const_iterator itBegin = mDataContainer->constBegin(); QCPErrorBarsDataContainer::const_iterator itEnd = mDataContainer->constEnd(); - if( mDataPlottable->interface1D()->sortKeyIsMainKey() && restrictKeyRange ) + if (mDataPlottable->interface1D()->sortKeyIsMainKey() && restrictKeyRange) { - itBegin = mDataContainer->constBegin() + findBegin( inKeyRange.lower ); - itEnd = mDataContainer->constBegin() + findEnd( inKeyRange.upper ); + itBegin = mDataContainer->constBegin()+findBegin(inKeyRange.lower); + itEnd = mDataContainer->constBegin()+findEnd(inKeyRange.upper); } - for( QCPErrorBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it ) + for (QCPErrorBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it) { - if( restrictKeyRange ) + if (restrictKeyRange) { - const double dataKey = mDataPlottable->interface1D()->dataMainKey( it - mDataContainer->constBegin() ); - if( dataKey < inKeyRange.lower || dataKey > inKeyRange.upper ) + const double dataKey = mDataPlottable->interface1D()->dataMainKey(it-mDataContainer->constBegin()); + if (dataKey < inKeyRange.lower || dataKey > inKeyRange.upper) continue; } - if( mErrorType == etValueError ) + if (mErrorType == etValueError) { - const double dataValue = mDataPlottable->interface1D()->dataMainValue( it - mDataContainer->constBegin() ); - if( qIsNaN( dataValue ) ) - continue; + const double dataValue = mDataPlottable->interface1D()->dataMainValue(it-mDataContainer->constBegin()); + if (qIsNaN(dataValue)) continue; // plus error: - double current = dataValue + ( qIsNaN( it->errorPlus ) ? 0 : it->errorPlus ); - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + double current = dataValue + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus); + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; } } // minus error: - current = dataValue - ( qIsNaN( it->errorMinus ) ? 0 : it->errorMinus ); - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + current = dataValue - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus); + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; } } - } - else // mErrorType == etKeyError + } else // mErrorType == etKeyError { // error bar doesn't extend in value dimension (except whisker but we ignore that here), so only use data point center - const double current = mDataPlottable->interface1D()->dataMainValue( it - mDataContainer->constBegin() ); - if( qIsNaN( current ) ) - continue; - if( inSignDomain == QCP::sdBoth || ( inSignDomain == QCP::sdNegative && current < 0 ) || ( inSignDomain == QCP::sdPositive && current > 0 ) ) + const double current = mDataPlottable->interface1D()->dataMainValue(it-mDataContainer->constBegin()); + if (qIsNaN(current)) continue; + if (inSignDomain == QCP::sdBoth || (inSignDomain == QCP::sdNegative && current < 0) || (inSignDomain == QCP::sdPositive && current > 0)) { - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; } - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; @@ -28441,18 +27701,17 @@ QCPRange QCPErrorBars::getValueRange( bool& foundRange, QCP::SignDomain inSignDo } } } - - if( haveUpper && !haveLower ) + + if (haveUpper && !haveLower) { range.lower = range.upper; haveLower = true; - } - else if( haveLower && !haveUpper ) + } else if (haveLower && !haveUpper) { range.upper = range.lower; haveUpper = true; } - + foundRange = haveLower && haveUpper; return range; } @@ -28468,56 +27727,53 @@ QCPRange QCPErrorBars::getValueRange( bool& foundRange, QCP::SignDomain inSignDo This method assumes that \a it is a valid iterator within the bounds of this \ref QCPErrorBars instance and within the bounds of the associated data plottable. */ -void QCPErrorBars::getErrorBarLines( QCPErrorBarsDataContainer::const_iterator it, QVector& backbones, QVector& whiskers ) const +void QCPErrorBars::getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector &backbones, QVector &whiskers) const { - if( !mDataPlottable ) + if (!mDataPlottable) return; + + int index = it-mDataContainer->constBegin(); + QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition(index); + if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y())) return; - - int index = it - mDataContainer->constBegin(); - QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition( index ); - if( qIsNaN( centerPixel.x() ) || qIsNaN( centerPixel.y() ) ) - return; - QCPAxis* errorAxis = mErrorType == etValueError ? mValueAxis.data() : mKeyAxis.data(); - QCPAxis* orthoAxis = mErrorType == etValueError ? mKeyAxis.data() : mValueAxis.data(); + QCPAxis *errorAxis = mErrorType == etValueError ? mValueAxis.data() : mKeyAxis.data(); + QCPAxis *orthoAxis = mErrorType == etValueError ? mKeyAxis.data() : mValueAxis.data(); const double centerErrorAxisPixel = errorAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y(); const double centerOrthoAxisPixel = orthoAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y(); - const double centerErrorAxisCoord = errorAxis->pixelToCoord( centerErrorAxisPixel ); // depending on plottable, this might be different from just mDataPlottable->interface1D()->dataMainKey/Value - const double symbolGap = mSymbolGap * 0.5 * errorAxis->pixelOrientation(); + const double centerErrorAxisCoord = errorAxis->pixelToCoord(centerErrorAxisPixel); // depending on plottable, this might be different from just mDataPlottable->interface1D()->dataMainKey/Value + const double symbolGap = mSymbolGap*0.5*errorAxis->pixelOrientation(); // plus error: double errorStart, errorEnd; - if( !qIsNaN( it->errorPlus ) ) + if (!qIsNaN(it->errorPlus)) { - errorStart = centerErrorAxisPixel + symbolGap; - errorEnd = errorAxis->coordToPixel( centerErrorAxisCoord + it->errorPlus ); - if( errorAxis->orientation() == Qt::Vertical ) + errorStart = centerErrorAxisPixel+symbolGap; + errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord+it->errorPlus); + if (errorAxis->orientation() == Qt::Vertical) { - if( ( errorStart > errorEnd ) != errorAxis->rangeReversed() ) - backbones.append( QLineF( centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd ) ); - whiskers.append( QLineF( centerOrthoAxisPixel - mWhiskerWidth * 0.5, errorEnd, centerOrthoAxisPixel + mWhiskerWidth * 0.5, errorEnd ) ); - } - else + if ((errorStart > errorEnd) != errorAxis->rangeReversed()) + backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd)); + whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd)); + } else { - if( ( errorStart < errorEnd ) != errorAxis->rangeReversed() ) - backbones.append( QLineF( errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel ) ); - whiskers.append( QLineF( errorEnd, centerOrthoAxisPixel - mWhiskerWidth * 0.5, errorEnd, centerOrthoAxisPixel + mWhiskerWidth * 0.5 ) ); + if ((errorStart < errorEnd) != errorAxis->rangeReversed()) + backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel)); + whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5)); } } // minus error: - if( !qIsNaN( it->errorMinus ) ) + if (!qIsNaN(it->errorMinus)) { - errorStart = centerErrorAxisPixel - symbolGap; - errorEnd = errorAxis->coordToPixel( centerErrorAxisCoord - it->errorMinus ); - if( errorAxis->orientation() == Qt::Vertical ) + errorStart = centerErrorAxisPixel-symbolGap; + errorEnd = errorAxis->coordToPixel(centerErrorAxisCoord-it->errorMinus); + if (errorAxis->orientation() == Qt::Vertical) { - if( ( errorStart < errorEnd ) != errorAxis->rangeReversed() ) - backbones.append( QLineF( centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd ) ); - whiskers.append( QLineF( centerOrthoAxisPixel - mWhiskerWidth * 0.5, errorEnd, centerOrthoAxisPixel + mWhiskerWidth * 0.5, errorEnd ) ); - } - else + if ((errorStart < errorEnd) != errorAxis->rangeReversed()) + backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd)); + whiskers.append(QLineF(centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5, errorEnd)); + } else { - if( ( errorStart > errorEnd ) != errorAxis->rangeReversed() ) - backbones.append( QLineF( errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel ) ); - whiskers.append( QLineF( errorEnd, centerOrthoAxisPixel - mWhiskerWidth * 0.5, errorEnd, centerOrthoAxisPixel + mWhiskerWidth * 0.5 ) ); + if ((errorStart > errorEnd) != errorAxis->rangeReversed()) + backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel)); + whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+mWhiskerWidth*0.5)); } } } @@ -28540,57 +27796,57 @@ void QCPErrorBars::getErrorBarLines( QCPErrorBarsDataContainer::const_iterator i range, only restricted by \a rangeRestriction. Drawing optimization then has to be done on a point-by-point basis in the \ref draw method. */ -void QCPErrorBars::getVisibleDataBounds( QCPErrorBarsDataContainer::const_iterator& begin, QCPErrorBarsDataContainer::const_iterator& end, const QCPDataRange& rangeRestriction ) const +void QCPErrorBars::getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const { - QCPAxis* keyAxis = mKeyAxis.data(); - QCPAxis* valueAxis = mValueAxis.data(); - if( !keyAxis || !valueAxis ) + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; end = mDataContainer->constEnd(); begin = end; return; } - if( !mDataPlottable || rangeRestriction.isEmpty() ) + if (!mDataPlottable || rangeRestriction.isEmpty()) { end = mDataContainer->constEnd(); begin = end; return; } - if( !mDataPlottable->interface1D()->sortKeyIsMainKey() ) + if (!mDataPlottable->interface1D()->sortKeyIsMainKey()) { // if the sort key isn't the main key, it's not possible to find a contiguous range of visible // data points, so this method then only applies the range restriction and otherwise returns // the full data range. Visibility checks must be done on a per-datapoin-basis during drawing - QCPDataRange dataRange( 0, mDataContainer->size() ); - dataRange = dataRange.bounded( rangeRestriction ); - begin = mDataContainer->constBegin() + dataRange.begin(); - end = mDataContainer->constBegin() + dataRange.end(); + QCPDataRange dataRange(0, mDataContainer->size()); + dataRange = dataRange.bounded(rangeRestriction); + begin = mDataContainer->constBegin()+dataRange.begin(); + end = mDataContainer->constBegin()+dataRange.end(); return; } - + // get visible data range via interface from data plottable, and then restrict to available error data points: - const int n = qMin( mDataContainer->size(), mDataPlottable->interface1D()->dataCount() ); - int beginIndex = mDataPlottable->interface1D()->findBegin( keyAxis->range().lower ); - int endIndex = mDataPlottable->interface1D()->findEnd( keyAxis->range().upper ); + const int n = qMin(mDataContainer->size(), mDataPlottable->interface1D()->dataCount()); + int beginIndex = mDataPlottable->interface1D()->findBegin(keyAxis->range().lower); + int endIndex = mDataPlottable->interface1D()->findEnd(keyAxis->range().upper); int i = beginIndex; - while( i > 0 && i < n && i > rangeRestriction.begin() ) + while (i > 0 && i < n && i > rangeRestriction.begin()) { - if( errorBarVisible( i ) ) + if (errorBarVisible(i)) beginIndex = i; --i; } i = endIndex; - while( i >= 0 && i < n && i < rangeRestriction.end() ) + while (i >= 0 && i < n && i < rangeRestriction.end()) { - if( errorBarVisible( i ) ) - endIndex = i + 1; + if (errorBarVisible(i)) + endIndex = i+1; ++i; } - QCPDataRange dataRange( beginIndex, endIndex ); - dataRange = dataRange.bounded( rangeRestriction.bounded( QCPDataRange( 0, mDataContainer->size() ) ) ); - begin = mDataContainer->constBegin() + dataRange.begin(); - end = mDataContainer->constBegin() + dataRange.end(); + QCPDataRange dataRange(beginIndex, endIndex); + dataRange = dataRange.bounded(rangeRestriction.bounded(QCPDataRange(0, mDataContainer->size()))); + begin = mDataContainer->constBegin()+dataRange.begin(); + end = mDataContainer->constBegin()+dataRange.end(); } /*! \internal @@ -28599,37 +27855,37 @@ void QCPErrorBars::getVisibleDataBounds( QCPErrorBarsDataContainer::const_iterat pixelPoint. This is used to determine whether the error bar was clicked or not, e.g. in \ref selectTest. The closest data point to \a pixelPoint is returned in \a closestData. */ -double QCPErrorBars::pointDistance( const QPointF& pixelPoint, QCPErrorBarsDataContainer::const_iterator& closestData ) const +double QCPErrorBars::pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const { closestData = mDataContainer->constEnd(); - if( !mDataPlottable || mDataContainer->isEmpty() ) + if (!mDataPlottable || mDataContainer->isEmpty()) return -1.0; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1.0; } - + QCPErrorBarsDataContainer::const_iterator begin, end; - getVisibleDataBounds( begin, end, QCPDataRange( 0, dataCount() ) ); - + getVisibleDataBounds(begin, end, QCPDataRange(0, dataCount())); + // calculate minimum distances to error backbones (whiskers are ignored for speed) and find closestData iterator: double minDistSqr = std::numeric_limits::max(); QVector backbones, whiskers; - for( QCPErrorBarsDataContainer::const_iterator it = begin; it != end; ++it ) + for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it) { - getErrorBarLines( it, backbones, whiskers ); - for( int i = 0; i < backbones.size(); ++i ) + getErrorBarLines(it, backbones, whiskers); + for (int i=0; i& selectedSegments, QList& unselectedSegments ) const +void QCPErrorBars::getDataSegments(QList &selectedSegments, QList &unselectedSegments) const { selectedSegments.clear(); unselectedSegments.clear(); - if( mSelectable == QCP::stWhole ) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty + if (mSelectable == QCP::stWhole) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty { - if( selected() ) - selectedSegments << QCPDataRange( 0, dataCount() ); + if (selected()) + selectedSegments << QCPDataRange(0, dataCount()); else - unselectedSegments << QCPDataRange( 0, dataCount() ); - } - else + unselectedSegments << QCPDataRange(0, dataCount()); + } else { - QCPDataSelection sel( selection() ); + QCPDataSelection sel(selection()); sel.simplify(); selectedSegments = sel.dataRanges(); - unselectedSegments = sel.inverse( QCPDataRange( 0, dataCount() ) ).dataRanges(); + unselectedSegments = sel.inverse(QCPDataRange(0, dataCount())).dataRanges(); } } @@ -28668,28 +27923,27 @@ void QCPErrorBars::getDataSegments( QList& selectedSegments, QList and the data plottable (\ref setDataPlottable) are not zero and that \a index is within valid bounds of this \ref QCPErrorBars instance and the bounds of the data plottable. */ -bool QCPErrorBars::errorBarVisible( int index ) const +bool QCPErrorBars::errorBarVisible(int index) const { - QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition( index ); + QPointF centerPixel = mDataPlottable->interface1D()->dataPixelPosition(index); const double centerKeyPixel = mKeyAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y(); - if( qIsNaN( centerKeyPixel ) ) + if (qIsNaN(centerKeyPixel)) return false; - + double keyMin, keyMax; - if( mErrorType == etKeyError ) + if (mErrorType == etKeyError) { - const double centerKey = mKeyAxis->pixelToCoord( centerKeyPixel ); - const double errorPlus = mDataContainer->at( index ).errorPlus; - const double errorMinus = mDataContainer->at( index ).errorMinus; - keyMax = centerKey + ( qIsNaN( errorPlus ) ? 0 : errorPlus ); - keyMin = centerKey - ( qIsNaN( errorMinus ) ? 0 : errorMinus ); - } - else // mErrorType == etValueError + const double centerKey = mKeyAxis->pixelToCoord(centerKeyPixel); + const double errorPlus = mDataContainer->at(index).errorPlus; + const double errorMinus = mDataContainer->at(index).errorMinus; + keyMax = centerKey+(qIsNaN(errorPlus) ? 0 : errorPlus); + keyMin = centerKey-(qIsNaN(errorMinus) ? 0 : errorMinus); + } else // mErrorType == etValueError { - keyMax = mKeyAxis->pixelToCoord( centerKeyPixel + mWhiskerWidth * 0.5 * mKeyAxis->pixelOrientation() ); - keyMin = mKeyAxis->pixelToCoord( centerKeyPixel - mWhiskerWidth * 0.5 * mKeyAxis->pixelOrientation() ); + keyMax = mKeyAxis->pixelToCoord(centerKeyPixel+mWhiskerWidth*0.5*mKeyAxis->pixelOrientation()); + keyMin = mKeyAxis->pixelToCoord(centerKeyPixel-mWhiskerWidth*0.5*mKeyAxis->pixelOrientation()); } - return ( ( keyMax > mKeyAxis->range().lower ) && ( keyMin < mKeyAxis->range().upper ) ); + return ((keyMax > mKeyAxis->range().lower) && (keyMin < mKeyAxis->range().upper)); } /*! \internal @@ -28699,21 +27953,22 @@ bool QCPErrorBars::errorBarVisible( int index ) const \a line is assumed to be either perfectly horizontal or perfectly vertical, as is the case for error bar lines. */ -bool QCPErrorBars::rectIntersectsLine( const QRectF& pixelRect, const QLineF& line ) const +bool QCPErrorBars::rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const { - if( pixelRect.left() > line.x1() && pixelRect.left() > line.x2() ) + if (pixelRect.left() > line.x1() && pixelRect.left() > line.x2()) return false; - else if( pixelRect.right() < line.x1() && pixelRect.right() < line.x2() ) + else if (pixelRect.right() < line.x1() && pixelRect.right() < line.x2()) return false; - else if( pixelRect.top() > line.y1() && pixelRect.top() > line.y2() ) + else if (pixelRect.top() > line.y1() && pixelRect.top() > line.y2()) return false; - else if( pixelRect.bottom() < line.y1() && pixelRect.bottom() < line.y2() ) + else if (pixelRect.bottom() < line.y1() && pixelRect.bottom() < line.y2()) return false; else return true; } /* end of 'src/plottables/plottable-errorbar.cpp' */ + /* including file 'src/items/item-straightline.cpp', size 7592 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -28735,14 +27990,16 @@ bool QCPErrorBars::rectIntersectsLine( const QRectF& pixelRect, const QLineF& li The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemStraightLine::QCPItemStraightLine( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), point1( createPosition( QLatin1String( "point1" ) ) ), point2( createPosition( QLatin1String( "point2" ) ) ) +QCPItemStraightLine::QCPItemStraightLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + point1(createPosition(QLatin1String("point1"))), + point2(createPosition(QLatin1String("point2"))) { - point1->setCoords( 0, 0 ); - point2->setCoords( 1, 1 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); + point1->setCoords(0, 0); + point2->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); } QCPItemStraightLine::~QCPItemStraightLine() @@ -28754,7 +28011,7 @@ QCPItemStraightLine::~QCPItemStraightLine() \see setSelectedPen */ -void QCPItemStraightLine::setPen( const QPen& pen ) +void QCPItemStraightLine::setPen(const QPen &pen) { mPen = pen; } @@ -28764,34 +28021,34 @@ void QCPItemStraightLine::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemStraightLine::setSelectedPen( const QPen& pen ) +void QCPItemStraightLine::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } /* inherits documentation from base class */ -double QCPItemStraightLine::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemStraightLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - return QCPVector2D( pos ).distanceToStraightLine( point1->pixelPosition(), point2->pixelPosition() - point1->pixelPosition() ); + + return QCPVector2D(pos).distanceToStraightLine(point1->pixelPosition(), point2->pixelPosition()-point1->pixelPosition()); } /* inherits documentation from base class */ -void QCPItemStraightLine::draw( QCPPainter* painter ) +void QCPItemStraightLine::draw(QCPPainter *painter) { - QCPVector2D start( point1->pixelPosition() ); - QCPVector2D end( point2->pixelPosition() ); + QCPVector2D start(point1->pixelPosition()); + QCPVector2D end(point2->pixelPosition()); // get visible segment of straight line inside clipRect: double clipPad = mainPen().widthF(); - QLineF line = getRectClippedStraightLine( start, end - start, clipRect().adjusted( -clipPad, -clipPad, clipPad, clipPad ) ); + QLineF line = getRectClippedStraightLine(start, end-start, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); // paint visible segment, if existent: - if( !line.isNull() ) + if (!line.isNull()) { - painter->setPen( mainPen() ); - painter->drawLine( line ); + painter->setPen(mainPen()); + painter->drawLine(line); } } @@ -28802,83 +28059,80 @@ void QCPItemStraightLine::draw( QCPPainter* painter ) This is a helper function for \ref draw. */ -QLineF QCPItemStraightLine::getRectClippedStraightLine( const QCPVector2D& base, const QCPVector2D& vec, const QRect& rect ) const +QLineF QCPItemStraightLine::getRectClippedStraightLine(const QCPVector2D &base, const QCPVector2D &vec, const QRect &rect) const { double bx, by; double gamma; QLineF result; - if( vec.x() == 0 && vec.y() == 0 ) + if (vec.x() == 0 && vec.y() == 0) return result; - if( qFuzzyIsNull( vec.x() ) ) // line is vertical + if (qFuzzyIsNull(vec.x())) // line is vertical { // check top of rect: bx = rect.left(); by = rect.top(); - gamma = base.x() - bx + ( by - base.y() ) * vec.x() / vec.y(); - if( gamma >= 0 && gamma <= rect.width() ) - result.setLine( bx + gamma, rect.top(), bx + gamma, rect.bottom() ); // no need to check bottom because we know line is vertical - } - else if( qFuzzyIsNull( vec.y() ) ) // line is horizontal + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom()); // no need to check bottom because we know line is vertical + } else if (qFuzzyIsNull(vec.y())) // line is horizontal { // check left of rect: bx = rect.left(); by = rect.top(); - gamma = base.y() - by + ( bx - base.x() ) * vec.y() / vec.x(); - if( gamma >= 0 && gamma <= rect.height() ) - result.setLine( rect.left(), by + gamma, rect.right(), by + gamma ); // no need to check right because we know line is horizontal - } - else // line is skewed + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + result.setLine(rect.left(), by+gamma, rect.right(), by+gamma); // no need to check right because we know line is horizontal + } else // line is skewed { QList pointVectors; // check top of rect: bx = rect.left(); by = rect.top(); - gamma = base.x() - bx + ( by - base.y() ) * vec.x() / vec.y(); - if( gamma >= 0 && gamma <= rect.width() ) - pointVectors.append( QCPVector2D( bx + gamma, by ) ); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QCPVector2D(bx+gamma, by)); // check bottom of rect: bx = rect.left(); by = rect.bottom(); - gamma = base.x() - bx + ( by - base.y() ) * vec.x() / vec.y(); - if( gamma >= 0 && gamma <= rect.width() ) - pointVectors.append( QCPVector2D( bx + gamma, by ) ); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QCPVector2D(bx+gamma, by)); // check left of rect: bx = rect.left(); by = rect.top(); - gamma = base.y() - by + ( bx - base.x() ) * vec.y() / vec.x(); - if( gamma >= 0 && gamma <= rect.height() ) - pointVectors.append( QCPVector2D( bx, by + gamma ) ); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QCPVector2D(bx, by+gamma)); // check right of rect: bx = rect.right(); by = rect.top(); - gamma = base.y() - by + ( bx - base.x() ) * vec.y() / vec.x(); - if( gamma >= 0 && gamma <= rect.height() ) - pointVectors.append( QCPVector2D( bx, by + gamma ) ); - + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QCPVector2D(bx, by+gamma)); + // evaluate points: - if( pointVectors.size() == 2 ) + if (pointVectors.size() == 2) { - result.setPoints( pointVectors.at( 0 ).toPointF(), pointVectors.at( 1 ).toPointF() ); - } - else if( pointVectors.size() > 2 ) + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) { // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: double distSqrMax = 0; QCPVector2D pv1, pv2; - for( int i = 0; i < pointVectors.size() - 1; ++i ) + for (int i=0; i distSqrMax ) + double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared(); + if (distSqr > distSqrMax) { - pv1 = pointVectors.at( i ); - pv2 = pointVectors.at( k ); + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); distSqrMax = distSqr; } } } - result.setPoints( pv1.toPointF(), pv2.toPointF() ); + result.setPoints(pv1.toPointF(), pv2.toPointF()); } } return result; @@ -28895,6 +28149,7 @@ QPen QCPItemStraightLine::mainPen() const } /* end of 'src/items/item-straightline.cpp' */ + /* including file 'src/items/item-line.cpp', size 8498 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -28918,14 +28173,16 @@ QPen QCPItemStraightLine::mainPen() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemLine::QCPItemLine( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), start( createPosition( QLatin1String( "start" ) ) ), end( createPosition( QLatin1String( "end" ) ) ) +QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition(QLatin1String("start"))), + end(createPosition(QLatin1String("end"))) { - start->setCoords( 0, 0 ); - end->setCoords( 1, 1 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); + start->setCoords(0, 0); + end->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); } QCPItemLine::~QCPItemLine() @@ -28937,7 +28194,7 @@ QCPItemLine::~QCPItemLine() \see setSelectedPen */ -void QCPItemLine::setPen( const QPen& pen ) +void QCPItemLine::setPen(const QPen &pen) { mPen = pen; } @@ -28947,7 +28204,7 @@ void QCPItemLine::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemLine::setSelectedPen( const QPen& pen ) +void QCPItemLine::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -28960,7 +28217,7 @@ void QCPItemLine::setSelectedPen( const QPen& pen ) \see setTail */ -void QCPItemLine::setHead( const QCPLineEnding& head ) +void QCPItemLine::setHead(const QCPLineEnding &head) { mHead = head; } @@ -28973,42 +28230,42 @@ void QCPItemLine::setHead( const QCPLineEnding& head ) \see setHead */ -void QCPItemLine::setTail( const QCPLineEnding& tail ) +void QCPItemLine::setTail(const QCPLineEnding &tail) { mTail = tail; } /* inherits documentation from base class */ -double QCPItemLine::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - return qSqrt( QCPVector2D( pos ).distanceSquaredToLine( start->pixelPosition(), end->pixelPosition() ) ); + + return qSqrt(QCPVector2D(pos).distanceSquaredToLine(start->pixelPosition(), end->pixelPosition())); } /* inherits documentation from base class */ -void QCPItemLine::draw( QCPPainter* painter ) +void QCPItemLine::draw(QCPPainter *painter) { - QCPVector2D startVec( start->pixelPosition() ); - QCPVector2D endVec( end->pixelPosition() ); - if( qFuzzyIsNull( ( startVec - endVec ).lengthSquared() ) ) + QCPVector2D startVec(start->pixelPosition()); + QCPVector2D endVec(end->pixelPosition()); + if (qFuzzyIsNull((startVec-endVec).lengthSquared())) return; // get visible segment of straight line inside clipRect: - double clipPad = qMax( mHead.boundingDistance(), mTail.boundingDistance() ); - clipPad = qMax( clipPad, (double)mainPen().widthF() ); - QLineF line = getRectClippedLine( startVec, endVec, clipRect().adjusted( -clipPad, -clipPad, clipPad, clipPad ) ); + double clipPad = qMax(mHead.boundingDistance(), mTail.boundingDistance()); + clipPad = qMax(clipPad, (double)mainPen().widthF()); + QLineF line = getRectClippedLine(startVec, endVec, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); // paint visible segment, if existent: - if( !line.isNull() ) + if (!line.isNull()) { - painter->setPen( mainPen() ); - painter->drawLine( line ); - painter->setBrush( Qt::SolidPattern ); - if( mTail.style() != QCPLineEnding::esNone ) - mTail.draw( painter, startVec, startVec - endVec ); - if( mHead.style() != QCPLineEnding::esNone ) - mHead.draw( painter, endVec, endVec - startVec ); + painter->setPen(mainPen()); + painter->drawLine(line); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, startVec, startVec-endVec); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, endVec, endVec-startVec); } } @@ -29019,96 +28276,95 @@ void QCPItemLine::draw( QCPPainter* painter ) This is a helper function for \ref draw. */ -QLineF QCPItemLine::getRectClippedLine( const QCPVector2D& start, const QCPVector2D& end, const QRect& rect ) const +QLineF QCPItemLine::getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const { - bool containsStart = rect.contains( start.x(), start.y() ); - bool containsEnd = rect.contains( end.x(), end.y() ); - if( containsStart && containsEnd ) - return QLineF( start.toPointF(), end.toPointF() ); - + bool containsStart = rect.contains(start.x(), start.y()); + bool containsEnd = rect.contains(end.x(), end.y()); + if (containsStart && containsEnd) + return QLineF(start.toPointF(), end.toPointF()); + QCPVector2D base = start; - QCPVector2D vec = end - start; + QCPVector2D vec = end-start; double bx, by; double gamma, mu; QLineF result; QList pointVectors; - if( !qFuzzyIsNull( vec.y() ) ) // line is not horizontal + if (!qFuzzyIsNull(vec.y())) // line is not horizontal { // check top of rect: bx = rect.left(); by = rect.top(); - mu = ( by - base.y() ) / vec.y(); - if( mu >= 0 && mu <= 1 ) + mu = (by-base.y())/vec.y(); + if (mu >= 0 && mu <= 1) { - gamma = base.x() - bx + mu * vec.x(); - if( gamma >= 0 && gamma <= rect.width() ) - pointVectors.append( QCPVector2D( bx + gamma, by ) ); + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QCPVector2D(bx+gamma, by)); } // check bottom of rect: bx = rect.left(); by = rect.bottom(); - mu = ( by - base.y() ) / vec.y(); - if( mu >= 0 && mu <= 1 ) + mu = (by-base.y())/vec.y(); + if (mu >= 0 && mu <= 1) { - gamma = base.x() - bx + mu * vec.x(); - if( gamma >= 0 && gamma <= rect.width() ) - pointVectors.append( QCPVector2D( bx + gamma, by ) ); + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QCPVector2D(bx+gamma, by)); } } - if( !qFuzzyIsNull( vec.x() ) ) // line is not vertical + if (!qFuzzyIsNull(vec.x())) // line is not vertical { // check left of rect: bx = rect.left(); by = rect.top(); - mu = ( bx - base.x() ) / vec.x(); - if( mu >= 0 && mu <= 1 ) + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) { - gamma = base.y() - by + mu * vec.y(); - if( gamma >= 0 && gamma <= rect.height() ) - pointVectors.append( QCPVector2D( bx, by + gamma ) ); + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QCPVector2D(bx, by+gamma)); } // check right of rect: bx = rect.right(); by = rect.top(); - mu = ( bx - base.x() ) / vec.x(); - if( mu >= 0 && mu <= 1 ) + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) { - gamma = base.y() - by + mu * vec.y(); - if( gamma >= 0 && gamma <= rect.height() ) - pointVectors.append( QCPVector2D( bx, by + gamma ) ); + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QCPVector2D(bx, by+gamma)); } } - - if( containsStart ) - pointVectors.append( start ); - if( containsEnd ) - pointVectors.append( end ); - + + if (containsStart) + pointVectors.append(start); + if (containsEnd) + pointVectors.append(end); + // evaluate points: - if( pointVectors.size() == 2 ) + if (pointVectors.size() == 2) { - result.setPoints( pointVectors.at( 0 ).toPointF(), pointVectors.at( 1 ).toPointF() ); - } - else if( pointVectors.size() > 2 ) + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) { // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: double distSqrMax = 0; QCPVector2D pv1, pv2; - for( int i = 0; i < pointVectors.size() - 1; ++i ) + for (int i=0; i distSqrMax ) + double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared(); + if (distSqr > distSqrMax) { - pv1 = pointVectors.at( i ); - pv2 = pointVectors.at( k ); + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); distSqrMax = distSqr; } } } - result.setPoints( pv1.toPointF(), pv2.toPointF() ); + result.setPoints(pv1.toPointF(), pv2.toPointF()); } return result; } @@ -29124,6 +28380,7 @@ QPen QCPItemLine::mainPen() const } /* end of 'src/items/item-line.cpp' */ + /* including file 'src/items/item-curve.cpp', size 7159 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -29154,16 +28411,20 @@ QPen QCPItemLine::mainPen() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemCurve::QCPItemCurve( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), start( createPosition( QLatin1String( "start" ) ) ), startDir( createPosition( QLatin1String( "startDir" ) ) ), endDir( createPosition( QLatin1String( "endDir" ) ) ), end( createPosition( QLatin1String( "end" ) ) ) +QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition(QLatin1String("start"))), + startDir(createPosition(QLatin1String("startDir"))), + endDir(createPosition(QLatin1String("endDir"))), + end(createPosition(QLatin1String("end"))) { - start->setCoords( 0, 0 ); - startDir->setCoords( 0.5, 0 ); - endDir->setCoords( 0, 0.5 ); - end->setCoords( 1, 1 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); + start->setCoords(0, 0); + startDir->setCoords(0.5, 0); + endDir->setCoords(0, 0.5); + end->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); } QCPItemCurve::~QCPItemCurve() @@ -29175,7 +28436,7 @@ QCPItemCurve::~QCPItemCurve() \see setSelectedPen */ -void QCPItemCurve::setPen( const QPen& pen ) +void QCPItemCurve::setPen(const QPen &pen) { mPen = pen; } @@ -29185,7 +28446,7 @@ void QCPItemCurve::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemCurve::setSelectedPen( const QPen& pen ) +void QCPItemCurve::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -29198,7 +28459,7 @@ void QCPItemCurve::setSelectedPen( const QPen& pen ) \see setTail */ -void QCPItemCurve::setHead( const QCPLineEnding& head ) +void QCPItemCurve::setHead(const QCPLineEnding &head) { mHead = head; } @@ -29211,65 +28472,65 @@ void QCPItemCurve::setHead( const QCPLineEnding& head ) \see setHead */ -void QCPItemCurve::setTail( const QCPLineEnding& tail ) +void QCPItemCurve::setTail(const QCPLineEnding &tail) { mTail = tail; } /* inherits documentation from base class */ -double QCPItemCurve::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; + + QPointF startVec(start->pixelPosition()); + QPointF startDirVec(startDir->pixelPosition()); + QPointF endDirVec(endDir->pixelPosition()); + QPointF endVec(end->pixelPosition()); - QPointF startVec( start->pixelPosition() ); - QPointF startDirVec( startDir->pixelPosition() ); - QPointF endDirVec( endDir->pixelPosition() ); - QPointF endVec( end->pixelPosition() ); - - QPainterPath cubicPath( startVec ); - cubicPath.cubicTo( startDirVec, endDirVec, endVec ); - + QPainterPath cubicPath(startVec); + cubicPath.cubicTo(startDirVec, endDirVec, endVec); + QPolygonF polygon = cubicPath.toSubpathPolygons().first(); - QCPVector2D p( pos ); + QCPVector2D p(pos); double minDistSqr = std::numeric_limits::max(); - for( int i = 1; i < polygon.size(); ++i ) + for (int i=1; ipixelPosition() ); - QCPVector2D startDirVec( startDir->pixelPosition() ); - QCPVector2D endDirVec( endDir->pixelPosition() ); - QCPVector2D endVec( end->pixelPosition() ); - if( ( endVec - startVec ).length() > 1e10 ) // too large curves cause crash + QCPVector2D startVec(start->pixelPosition()); + QCPVector2D startDirVec(startDir->pixelPosition()); + QCPVector2D endDirVec(endDir->pixelPosition()); + QCPVector2D endVec(end->pixelPosition()); + if ((endVec-startVec).length() > 1e10) // too large curves cause crash return; - QPainterPath cubicPath( startVec.toPointF() ); - cubicPath.cubicTo( startDirVec.toPointF(), endDirVec.toPointF(), endVec.toPointF() ); + QPainterPath cubicPath(startVec.toPointF()); + cubicPath.cubicTo(startDirVec.toPointF(), endDirVec.toPointF(), endVec.toPointF()); // paint visible segment, if existent: - QRect clip = clipRect().adjusted( -mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF() ); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); QRect cubicRect = cubicPath.controlPointRect().toRect(); - if( cubicRect.isEmpty() ) // may happen when start and end exactly on same x or y position - cubicRect.adjust( 0, 0, 1, 1 ); - if( clip.intersects( cubicRect ) ) + if (cubicRect.isEmpty()) // may happen when start and end exactly on same x or y position + cubicRect.adjust(0, 0, 1, 1); + if (clip.intersects(cubicRect)) { - painter->setPen( mainPen() ); - painter->drawPath( cubicPath ); - painter->setBrush( Qt::SolidPattern ); - if( mTail.style() != QCPLineEnding::esNone ) - mTail.draw( painter, startVec, M_PI - cubicPath.angleAtPercent( 0 ) / 180.0 * M_PI ); - if( mHead.style() != QCPLineEnding::esNone ) - mHead.draw( painter, endVec, -cubicPath.angleAtPercent( 1 ) / 180.0 * M_PI ); + painter->setPen(mainPen()); + painter->drawPath(cubicPath); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, startVec, M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, endVec, -cubicPath.angleAtPercent(1)/180.0*M_PI); } } @@ -29284,6 +28545,7 @@ QPen QCPItemCurve::mainPen() const } /* end of 'src/items/item-curve.cpp' */ + /* including file 'src/items/item-rect.cpp', size 6479 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -29305,16 +28567,24 @@ QPen QCPItemCurve::mainPen() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemRect::QCPItemRect( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), topLeft( createPosition( QLatin1String( "topLeft" ) ) ), bottomRight( createPosition( QLatin1String( "bottomRight" ) ) ), top( createAnchor( QLatin1String( "top" ), aiTop ) ), topRight( createAnchor( QLatin1String( "topRight" ), aiTopRight ) ), right( createAnchor( QLatin1String( "right" ), aiRight ) ), bottom( createAnchor( QLatin1String( "bottom" ), aiBottom ) ), bottomLeft( createAnchor( QLatin1String( "bottomLeft" ), aiBottomLeft ) ), left( createAnchor( QLatin1String( "left" ), aiLeft ) ) +QCPItemRect::QCPItemRect(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition(QLatin1String("topLeft"))), + bottomRight(createPosition(QLatin1String("bottomRight"))), + top(createAnchor(QLatin1String("top"), aiTop)), + topRight(createAnchor(QLatin1String("topRight"), aiTopRight)), + right(createAnchor(QLatin1String("right"), aiRight)), + bottom(createAnchor(QLatin1String("bottom"), aiBottom)), + bottomLeft(createAnchor(QLatin1String("bottomLeft"), aiBottomLeft)), + left(createAnchor(QLatin1String("left"), aiLeft)) { - topLeft->setCoords( 0, 1 ); - bottomRight->setCoords( 1, 0 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); - setBrush( Qt::NoBrush ); - setSelectedBrush( Qt::NoBrush ); + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); } QCPItemRect::~QCPItemRect() @@ -29326,7 +28596,7 @@ QCPItemRect::~QCPItemRect() \see setSelectedPen, setBrush */ -void QCPItemRect::setPen( const QPen& pen ) +void QCPItemRect::setPen(const QPen &pen) { mPen = pen; } @@ -29336,7 +28606,7 @@ void QCPItemRect::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemRect::setSelectedPen( const QPen& pen ) +void QCPItemRect::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -29347,7 +28617,7 @@ void QCPItemRect::setSelectedPen( const QPen& pen ) \see setSelectedBrush, setPen */ -void QCPItemRect::setBrush( const QBrush& brush ) +void QCPItemRect::setBrush(const QBrush &brush) { mBrush = brush; } @@ -29358,61 +28628,55 @@ void QCPItemRect::setBrush( const QBrush& brush ) \see setBrush */ -void QCPItemRect::setSelectedBrush( const QBrush& brush ) +void QCPItemRect::setSelectedBrush(const QBrush &brush) { mSelectedBrush = brush; } /* inherits documentation from base class */ -double QCPItemRect::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemRect::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - QRectF rect = QRectF( topLeft->pixelPosition(), bottomRight->pixelPosition() ).normalized(); + + QRectF rect = QRectF(topLeft->pixelPosition(), bottomRight->pixelPosition()).normalized(); bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; - return rectDistance( rect, pos, filledRect ); + return rectDistance(rect, pos, filledRect); } /* inherits documentation from base class */ -void QCPItemRect::draw( QCPPainter* painter ) +void QCPItemRect::draw(QCPPainter *painter) { QPointF p1 = topLeft->pixelPosition(); QPointF p2 = bottomRight->pixelPosition(); - if( p1.toPoint() == p2.toPoint() ) + if (p1.toPoint() == p2.toPoint()) return; - QRectF rect = QRectF( p1, p2 ).normalized(); + QRectF rect = QRectF(p1, p2).normalized(); double clipPad = mainPen().widthF(); - QRectF boundingRect = rect.adjusted( -clipPad, -clipPad, clipPad, clipPad ); - if( boundingRect.intersects( clipRect() ) ) // only draw if bounding rect of rect item is visible in cliprect + QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (boundingRect.intersects(clipRect())) // only draw if bounding rect of rect item is visible in cliprect { - painter->setPen( mainPen() ); - painter->setBrush( mainBrush() ); - painter->drawRect( rect ); + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(rect); } } /* inherits documentation from base class */ -QPointF QCPItemRect::anchorPixelPosition( int anchorId ) const +QPointF QCPItemRect::anchorPixelPosition(int anchorId) const { - QRectF rect = QRectF( topLeft->pixelPosition(), bottomRight->pixelPosition() ); - switch( anchorId ) + QRectF rect = QRectF(topLeft->pixelPosition(), bottomRight->pixelPosition()); + switch (anchorId) { - case aiTop: - return ( rect.topLeft() + rect.topRight() ) * 0.5; - case aiTopRight: - return rect.topRight(); - case aiRight: - return ( rect.topRight() + rect.bottomRight() ) * 0.5; - case aiBottom: - return ( rect.bottomLeft() + rect.bottomRight() ) * 0.5; - case aiBottomLeft: - return rect.bottomLeft(); - case aiLeft: - return ( rect.topLeft() + rect.bottomLeft() ) * 0.5; + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } @@ -29438,6 +28702,7 @@ QBrush QCPItemRect::mainBrush() const } /* end of 'src/items/item-rect.cpp' */ + /* including file 'src/items/item-text.cpp', size 13338 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -29465,17 +28730,30 @@ QBrush QCPItemRect::mainBrush() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemText::QCPItemText( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), position( createPosition( QLatin1String( "position" ) ) ), topLeft( createAnchor( QLatin1String( "topLeft" ), aiTopLeft ) ), top( createAnchor( QLatin1String( "top" ), aiTop ) ), topRight( createAnchor( QLatin1String( "topRight" ), aiTopRight ) ), right( createAnchor( QLatin1String( "right" ), aiRight ) ), bottomRight( createAnchor( QLatin1String( "bottomRight" ), aiBottomRight ) ), bottom( createAnchor( QLatin1String( "bottom" ), aiBottom ) ), bottomLeft( createAnchor( QLatin1String( "bottomLeft" ), aiBottomLeft ) ), left( createAnchor( QLatin1String( "left" ), aiLeft ) ), mText( QLatin1String( "text" ) ), mPositionAlignment( Qt::AlignCenter ), mTextAlignment( Qt::AlignTop | Qt::AlignHCenter ), mRotation( 0 ) +QCPItemText::QCPItemText(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition(QLatin1String("position"))), + topLeft(createAnchor(QLatin1String("topLeft"), aiTopLeft)), + top(createAnchor(QLatin1String("top"), aiTop)), + topRight(createAnchor(QLatin1String("topRight"), aiTopRight)), + right(createAnchor(QLatin1String("right"), aiRight)), + bottomRight(createAnchor(QLatin1String("bottomRight"), aiBottomRight)), + bottom(createAnchor(QLatin1String("bottom"), aiBottom)), + bottomLeft(createAnchor(QLatin1String("bottomLeft"), aiBottomLeft)), + left(createAnchor(QLatin1String("left"), aiLeft)), + mText(QLatin1String("text")), + mPositionAlignment(Qt::AlignCenter), + mTextAlignment(Qt::AlignTop|Qt::AlignHCenter), + mRotation(0) { - position->setCoords( 0, 0 ); - - setPen( Qt::NoPen ); - setSelectedPen( Qt::NoPen ); - setBrush( Qt::NoBrush ); - setSelectedBrush( Qt::NoBrush ); - setColor( Qt::black ); - setSelectedColor( Qt::blue ); + position->setCoords(0, 0); + + setPen(Qt::NoPen); + setSelectedPen(Qt::NoPen); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setColor(Qt::black); + setSelectedColor(Qt::blue); } QCPItemText::~QCPItemText() @@ -29485,7 +28763,7 @@ QCPItemText::~QCPItemText() /*! Sets the color of the text. */ -void QCPItemText::setColor( const QColor& color ) +void QCPItemText::setColor(const QColor &color) { mColor = color; } @@ -29493,7 +28771,7 @@ void QCPItemText::setColor( const QColor& color ) /*! Sets the color of the text that will be used when the item is selected. */ -void QCPItemText::setSelectedColor( const QColor& color ) +void QCPItemText::setSelectedColor(const QColor &color) { mSelectedColor = color; } @@ -29504,7 +28782,7 @@ void QCPItemText::setSelectedColor( const QColor& color ) \see setSelectedPen, setBrush, setPadding */ -void QCPItemText::setPen( const QPen& pen ) +void QCPItemText::setPen(const QPen &pen) { mPen = pen; } @@ -29515,7 +28793,7 @@ void QCPItemText::setPen( const QPen& pen ) \see setPen */ -void QCPItemText::setSelectedPen( const QPen& pen ) +void QCPItemText::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -29526,7 +28804,7 @@ void QCPItemText::setSelectedPen( const QPen& pen ) \see setSelectedBrush, setPen, setPadding */ -void QCPItemText::setBrush( const QBrush& brush ) +void QCPItemText::setBrush(const QBrush &brush) { mBrush = brush; } @@ -29537,7 +28815,7 @@ void QCPItemText::setBrush( const QBrush& brush ) \see setBrush */ -void QCPItemText::setSelectedBrush( const QBrush& brush ) +void QCPItemText::setSelectedBrush(const QBrush &brush) { mSelectedBrush = brush; } @@ -29547,7 +28825,7 @@ void QCPItemText::setSelectedBrush( const QBrush& brush ) \see setSelectedFont, setColor */ -void QCPItemText::setFont( const QFont& font ) +void QCPItemText::setFont(const QFont &font) { mFont = font; } @@ -29557,7 +28835,7 @@ void QCPItemText::setFont( const QFont& font ) \see setFont */ -void QCPItemText::setSelectedFont( const QFont& font ) +void QCPItemText::setSelectedFont(const QFont &font) { mSelectedFont = font; } @@ -29568,7 +28846,7 @@ void QCPItemText::setSelectedFont( const QFont& font ) \see setFont, setColor, setTextAlignment */ -void QCPItemText::setText( const QString& text ) +void QCPItemText::setText(const QString &text) { mText = text; } @@ -29585,7 +28863,7 @@ void QCPItemText::setText( const QString& text ) If you want to control the alignment of (multi-lined) text within the text rect, use \ref setTextAlignment. */ -void QCPItemText::setPositionAlignment( Qt::Alignment alignment ) +void QCPItemText::setPositionAlignment(Qt::Alignment alignment) { mPositionAlignment = alignment; } @@ -29593,7 +28871,7 @@ void QCPItemText::setPositionAlignment( Qt::Alignment alignment ) /*! Controls how (multi-lined) text is aligned inside the text rect (typically Qt::AlignLeft, Qt::AlignCenter or Qt::AlignRight). */ -void QCPItemText::setTextAlignment( Qt::Alignment alignment ) +void QCPItemText::setTextAlignment(Qt::Alignment alignment) { mTextAlignment = alignment; } @@ -29602,7 +28880,7 @@ void QCPItemText::setTextAlignment( Qt::Alignment alignment ) Sets the angle in degrees by which the text (and the text rectangle, if visible) will be rotated around \a position. */ -void QCPItemText::setRotation( double degrees ) +void QCPItemText::setRotation(double degrees) { mRotation = degrees; } @@ -29611,103 +28889,95 @@ void QCPItemText::setRotation( double degrees ) Sets the distance between the border of the text rectangle and the text. The appearance (and visibility) of the text rectangle can be controlled with \ref setPen and \ref setBrush. */ -void QCPItemText::setPadding( const QMargins& padding ) +void QCPItemText::setPadding(const QMargins &padding) { mPadding = padding; } /* inherits documentation from base class */ -double QCPItemText::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemText::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - + // The rect may be rotated, so we transform the actual clicked pos to the rotated // coordinate system, so we can use the normal rectDistance function for non-rotated rects: - QPointF positionPixels( position->pixelPosition() ); + QPointF positionPixels(position->pixelPosition()); QTransform inputTransform; - inputTransform.translate( positionPixels.x(), positionPixels.y() ); - inputTransform.rotate( -mRotation ); - inputTransform.translate( -positionPixels.x(), -positionPixels.y() ); - QPointF rotatedPos = inputTransform.map( pos ); - QFontMetrics fontMetrics( mFont ); - QRect textRect = fontMetrics.boundingRect( 0, 0, 0, 0, Qt::TextDontClip | mTextAlignment, mText ); - QRect textBoxRect = textRect.adjusted( -mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom() ); - QPointF textPos = getTextDrawPoint( positionPixels, textBoxRect, mPositionAlignment ); - textBoxRect.moveTopLeft( textPos.toPoint() ); + inputTransform.translate(positionPixels.x(), positionPixels.y()); + inputTransform.rotate(-mRotation); + inputTransform.translate(-positionPixels.x(), -positionPixels.y()); + QPointF rotatedPos = inputTransform.map(pos); + QFontMetrics fontMetrics(mFont); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(positionPixels, textBoxRect, mPositionAlignment); + textBoxRect.moveTopLeft(textPos.toPoint()); - return rectDistance( textBoxRect, rotatedPos, true ); + return rectDistance(textBoxRect, rotatedPos, true); } /* inherits documentation from base class */ -void QCPItemText::draw( QCPPainter* painter ) +void QCPItemText::draw(QCPPainter *painter) { - QPointF pos( position->pixelPosition() ); + QPointF pos(position->pixelPosition()); QTransform transform = painter->transform(); - transform.translate( pos.x(), pos.y() ); - if( !qFuzzyIsNull( mRotation ) ) - transform.rotate( mRotation ); - painter->setFont( mainFont() ); - QRect textRect = painter->fontMetrics().boundingRect( 0, 0, 0, 0, Qt::TextDontClip | mTextAlignment, mText ); - QRect textBoxRect = textRect.adjusted( -mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom() ); - QPointF textPos = getTextDrawPoint( QPointF( 0, 0 ), textBoxRect, mPositionAlignment ); // 0, 0 because the transform does the translation - textRect.moveTopLeft( textPos.toPoint() + QPoint( mPadding.left(), mPadding.top() ) ); - textBoxRect.moveTopLeft( textPos.toPoint() ); + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + painter->setFont(mainFont()); + QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textRect.moveTopLeft(textPos.toPoint()+QPoint(mPadding.left(), mPadding.top())); + textBoxRect.moveTopLeft(textPos.toPoint()); double clipPad = mainPen().widthF(); - QRect boundingRect = textBoxRect.adjusted( -clipPad, -clipPad, clipPad, clipPad ); - if( transform.mapRect( boundingRect ).intersects( painter->transform().mapRect( clipRect() ) ) ) + QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(clipRect()))) { - painter->setTransform( transform ); - if( ( mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0 ) || - ( mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0 ) ) + painter->setTransform(transform); + if ((mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) || + (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0)) { - painter->setPen( mainPen() ); - painter->setBrush( mainBrush() ); - painter->drawRect( textBoxRect ); + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(textBoxRect); } - painter->setBrush( Qt::NoBrush ); - painter->setPen( QPen( mainColor() ) ); - painter->drawText( textRect, Qt::TextDontClip | mTextAlignment, mText ); + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(mainColor())); + painter->drawText(textRect, Qt::TextDontClip|mTextAlignment, mText); } } /* inherits documentation from base class */ -QPointF QCPItemText::anchorPixelPosition( int anchorId ) const +QPointF QCPItemText::anchorPixelPosition(int anchorId) const { // get actual rect points (pretty much copied from draw function): - QPointF pos( position->pixelPosition() ); + QPointF pos(position->pixelPosition()); QTransform transform; - transform.translate( pos.x(), pos.y() ); - if( !qFuzzyIsNull( mRotation ) ) - transform.rotate( mRotation ); - QFontMetrics fontMetrics( mainFont() ); - QRect textRect = fontMetrics.boundingRect( 0, 0, 0, 0, Qt::TextDontClip | mTextAlignment, mText ); - QRectF textBoxRect = textRect.adjusted( -mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom() ); - QPointF textPos = getTextDrawPoint( QPointF( 0, 0 ), textBoxRect, mPositionAlignment ); // 0, 0 because the transform does the translation - textBoxRect.moveTopLeft( textPos.toPoint() ); - QPolygonF rectPoly = transform.map( QPolygonF( textBoxRect ) ); - - switch( anchorId ) + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + QFontMetrics fontMetrics(mainFont()); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRectF textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textBoxRect.moveTopLeft(textPos.toPoint()); + QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect)); + + switch (anchorId) { - case aiTopLeft: - return rectPoly.at( 0 ); - case aiTop: - return ( rectPoly.at( 0 ) + rectPoly.at( 1 ) ) * 0.5; - case aiTopRight: - return rectPoly.at( 1 ); - case aiRight: - return ( rectPoly.at( 1 ) + rectPoly.at( 2 ) ) * 0.5; - case aiBottomRight: - return rectPoly.at( 2 ); - case aiBottom: - return ( rectPoly.at( 2 ) + rectPoly.at( 3 ) ) * 0.5; - case aiBottomLeft: - return rectPoly.at( 3 ); - case aiLeft: - return ( rectPoly.at( 3 ) + rectPoly.at( 0 ) ) * 0.5; + case aiTopLeft: return rectPoly.at(0); + case aiTop: return (rectPoly.at(0)+rectPoly.at(1))*0.5; + case aiTopRight: return rectPoly.at(1); + case aiRight: return (rectPoly.at(1)+rectPoly.at(2))*0.5; + case aiBottomRight: return rectPoly.at(2); + case aiBottom: return (rectPoly.at(2)+rectPoly.at(3))*0.5; + case aiBottomLeft: return rectPoly.at(3); + case aiLeft: return (rectPoly.at(3)+rectPoly.at(0))*0.5; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } @@ -29722,19 +28992,19 @@ QPointF QCPItemText::anchorPixelPosition( int anchorId ) const will be shifted upward by the height of \a rect, starting from \a pos. So if the text is finally drawn at that point, the lower left corner of the resulting text rect is at \a pos. */ -QPointF QCPItemText::getTextDrawPoint( const QPointF& pos, const QRectF& rect, Qt::Alignment positionAlignment ) const +QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const { - if( positionAlignment == 0 || positionAlignment == ( Qt::AlignLeft | Qt::AlignTop ) ) + if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop)) return pos; - - QPointF result = pos; // start at top left - if( positionAlignment.testFlag( Qt::AlignHCenter ) ) - result.rx() -= rect.width() / 2.0; - else if( positionAlignment.testFlag( Qt::AlignRight ) ) + + QPointF result = pos; // start at top left + if (positionAlignment.testFlag(Qt::AlignHCenter)) + result.rx() -= rect.width()/2.0; + else if (positionAlignment.testFlag(Qt::AlignRight)) result.rx() -= rect.width(); - if( positionAlignment.testFlag( Qt::AlignVCenter ) ) - result.ry() -= rect.height() / 2.0; - else if( positionAlignment.testFlag( Qt::AlignBottom ) ) + if (positionAlignment.testFlag(Qt::AlignVCenter)) + result.ry() -= rect.height()/2.0; + else if (positionAlignment.testFlag(Qt::AlignBottom)) result.ry() -= rect.height(); return result; } @@ -29780,6 +29050,7 @@ QBrush QCPItemText::mainBrush() const } /* end of 'src/items/item-text.cpp' */ + /* including file 'src/items/item-ellipse.cpp', size 7863 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -29801,16 +29072,27 @@ QBrush QCPItemText::mainBrush() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemEllipse::QCPItemEllipse( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), topLeft( createPosition( QLatin1String( "topLeft" ) ) ), bottomRight( createPosition( QLatin1String( "bottomRight" ) ) ), topLeftRim( createAnchor( QLatin1String( "topLeftRim" ), aiTopLeftRim ) ), top( createAnchor( QLatin1String( "top" ), aiTop ) ), topRightRim( createAnchor( QLatin1String( "topRightRim" ), aiTopRightRim ) ), right( createAnchor( QLatin1String( "right" ), aiRight ) ), bottomRightRim( createAnchor( QLatin1String( "bottomRightRim" ), aiBottomRightRim ) ), bottom( createAnchor( QLatin1String( "bottom" ), aiBottom ) ), bottomLeftRim( createAnchor( QLatin1String( "bottomLeftRim" ), aiBottomLeftRim ) ), left( createAnchor( QLatin1String( "left" ), aiLeft ) ), center( createAnchor( QLatin1String( "center" ), aiCenter ) ) +QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition(QLatin1String("topLeft"))), + bottomRight(createPosition(QLatin1String("bottomRight"))), + topLeftRim(createAnchor(QLatin1String("topLeftRim"), aiTopLeftRim)), + top(createAnchor(QLatin1String("top"), aiTop)), + topRightRim(createAnchor(QLatin1String("topRightRim"), aiTopRightRim)), + right(createAnchor(QLatin1String("right"), aiRight)), + bottomRightRim(createAnchor(QLatin1String("bottomRightRim"), aiBottomRightRim)), + bottom(createAnchor(QLatin1String("bottom"), aiBottom)), + bottomLeftRim(createAnchor(QLatin1String("bottomLeftRim"), aiBottomLeftRim)), + left(createAnchor(QLatin1String("left"), aiLeft)), + center(createAnchor(QLatin1String("center"), aiCenter)) { - topLeft->setCoords( 0, 1 ); - bottomRight->setCoords( 1, 0 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); - setBrush( Qt::NoBrush ); - setSelectedBrush( Qt::NoBrush ); + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); } QCPItemEllipse::~QCPItemEllipse() @@ -29822,7 +29104,7 @@ QCPItemEllipse::~QCPItemEllipse() \see setSelectedPen, setBrush */ -void QCPItemEllipse::setPen( const QPen& pen ) +void QCPItemEllipse::setPen(const QPen &pen) { mPen = pen; } @@ -29832,7 +29114,7 @@ void QCPItemEllipse::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemEllipse::setSelectedPen( const QPen& pen ) +void QCPItemEllipse::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -29843,7 +29125,7 @@ void QCPItemEllipse::setSelectedPen( const QPen& pen ) \see setSelectedBrush, setPen */ -void QCPItemEllipse::setBrush( const QBrush& brush ) +void QCPItemEllipse::setBrush(const QBrush &brush) { mBrush = brush; } @@ -29854,93 +29136,83 @@ void QCPItemEllipse::setBrush( const QBrush& brush ) \see setBrush */ -void QCPItemEllipse::setSelectedBrush( const QBrush& brush ) +void QCPItemEllipse::setSelectedBrush(const QBrush &brush) { mSelectedBrush = brush; } /* inherits documentation from base class */ -double QCPItemEllipse::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - + QPointF p1 = topLeft->pixelPosition(); QPointF p2 = bottomRight->pixelPosition(); - QPointF center( ( p1 + p2 ) / 2.0 ); - double a = qAbs( p1.x() - p2.x() ) / 2.0; - double b = qAbs( p1.y() - p2.y() ) / 2.0; - double x = pos.x() - center.x(); - double y = pos.y() - center.y(); - + QPointF center((p1+p2)/2.0); + double a = qAbs(p1.x()-p2.x())/2.0; + double b = qAbs(p1.y()-p2.y())/2.0; + double x = pos.x()-center.x(); + double y = pos.y()-center.y(); + // distance to border: - double c = 1.0 / qSqrt( x * x / ( a * a ) + y * y / ( b * b ) ); - double result = qAbs( c - 1 ) * qSqrt( x * x + y * y ); + double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b)); + double result = qAbs(c-1)*qSqrt(x*x+y*y); // filled ellipse, allow click inside to count as hit: - if( result > mParentPlot->selectionTolerance() * 0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0 ) + if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) { - if( x * x / ( a * a ) + y * y / ( b * b ) <= 1 ) - result = mParentPlot->selectionTolerance() * 0.99; + if (x*x/(a*a) + y*y/(b*b) <= 1) + result = mParentPlot->selectionTolerance()*0.99; } return result; } /* inherits documentation from base class */ -void QCPItemEllipse::draw( QCPPainter* painter ) +void QCPItemEllipse::draw(QCPPainter *painter) { QPointF p1 = topLeft->pixelPosition(); QPointF p2 = bottomRight->pixelPosition(); - if( p1.toPoint() == p2.toPoint() ) + if (p1.toPoint() == p2.toPoint()) return; - QRectF ellipseRect = QRectF( p1, p2 ).normalized(); - QRect clip = clipRect().adjusted( -mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF() ); - if( ellipseRect.intersects( clip ) ) // only draw if bounding rect of ellipse is visible in cliprect + QRectF ellipseRect = QRectF(p1, p2).normalized(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (ellipseRect.intersects(clip)) // only draw if bounding rect of ellipse is visible in cliprect { - painter->setPen( mainPen() ); - painter->setBrush( mainBrush() ); + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); #ifdef __EXCEPTIONS - try // drawEllipse sometimes throws exceptions if ellipse is too big + try // drawEllipse sometimes throws exceptions if ellipse is too big { #endif - painter->drawEllipse( ellipseRect ); + painter->drawEllipse(ellipseRect); #ifdef __EXCEPTIONS - } - catch( ... ) + } catch (...) { qDebug() << Q_FUNC_INFO << "Item too large for memory, setting invisible"; - setVisible( false ); + setVisible(false); } #endif } } /* inherits documentation from base class */ -QPointF QCPItemEllipse::anchorPixelPosition( int anchorId ) const +QPointF QCPItemEllipse::anchorPixelPosition(int anchorId) const { - QRectF rect = QRectF( topLeft->pixelPosition(), bottomRight->pixelPosition() ); - switch( anchorId ) + QRectF rect = QRectF(topLeft->pixelPosition(), bottomRight->pixelPosition()); + switch (anchorId) { - case aiTopLeftRim: - return rect.center() + ( rect.topLeft() - rect.center() ) * 1 / qSqrt( 2 ); - case aiTop: - return ( rect.topLeft() + rect.topRight() ) * 0.5; - case aiTopRightRim: - return rect.center() + ( rect.topRight() - rect.center() ) * 1 / qSqrt( 2 ); - case aiRight: - return ( rect.topRight() + rect.bottomRight() ) * 0.5; - case aiBottomRightRim: - return rect.center() + ( rect.bottomRight() - rect.center() ) * 1 / qSqrt( 2 ); - case aiBottom: - return ( rect.bottomLeft() + rect.bottomRight() ) * 0.5; - case aiBottomLeftRim: - return rect.center() + ( rect.bottomLeft() - rect.center() ) * 1 / qSqrt( 2 ); - case aiLeft: - return ( rect.topLeft() + rect.bottomLeft() ) * 0.5; - case aiCenter: - return ( rect.topLeft() + rect.bottomRight() ) * 0.5; + case aiTopLeftRim: return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2); + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRightRim: return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottomRightRim: return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2); + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeftRim: return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; + case aiCenter: return (rect.topLeft()+rect.bottomRight())*0.5; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } @@ -29966,6 +29238,7 @@ QBrush QCPItemEllipse::mainBrush() const } /* end of 'src/items/item-ellipse.cpp' */ + /* including file 'src/items/item-pixmap.cpp', size 10615 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -29993,14 +29266,26 @@ QBrush QCPItemEllipse::mainBrush() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemPixmap::QCPItemPixmap( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), topLeft( createPosition( QLatin1String( "topLeft" ) ) ), bottomRight( createPosition( QLatin1String( "bottomRight" ) ) ), top( createAnchor( QLatin1String( "top" ), aiTop ) ), topRight( createAnchor( QLatin1String( "topRight" ), aiTopRight ) ), right( createAnchor( QLatin1String( "right" ), aiRight ) ), bottom( createAnchor( QLatin1String( "bottom" ), aiBottom ) ), bottomLeft( createAnchor( QLatin1String( "bottomLeft" ), aiBottomLeft ) ), left( createAnchor( QLatin1String( "left" ), aiLeft ) ), mScaled( false ), mScaledPixmapInvalidated( true ), mAspectRatioMode( Qt::KeepAspectRatio ), mTransformationMode( Qt::SmoothTransformation ) +QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition(QLatin1String("topLeft"))), + bottomRight(createPosition(QLatin1String("bottomRight"))), + top(createAnchor(QLatin1String("top"), aiTop)), + topRight(createAnchor(QLatin1String("topRight"), aiTopRight)), + right(createAnchor(QLatin1String("right"), aiRight)), + bottom(createAnchor(QLatin1String("bottom"), aiBottom)), + bottomLeft(createAnchor(QLatin1String("bottomLeft"), aiBottomLeft)), + left(createAnchor(QLatin1String("left"), aiLeft)), + mScaled(false), + mScaledPixmapInvalidated(true), + mAspectRatioMode(Qt::KeepAspectRatio), + mTransformationMode(Qt::SmoothTransformation) { - topLeft->setCoords( 0, 1 ); - bottomRight->setCoords( 1, 0 ); - - setPen( Qt::NoPen ); - setSelectedPen( QPen( Qt::blue ) ); + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(Qt::NoPen); + setSelectedPen(QPen(Qt::blue)); } QCPItemPixmap::~QCPItemPixmap() @@ -30010,11 +29295,11 @@ QCPItemPixmap::~QCPItemPixmap() /*! Sets the pixmap that will be displayed. */ -void QCPItemPixmap::setPixmap( const QPixmap& pixmap ) +void QCPItemPixmap::setPixmap(const QPixmap &pixmap) { mPixmap = pixmap; mScaledPixmapInvalidated = true; - if( mPixmap.isNull() ) + if (mPixmap.isNull()) qDebug() << Q_FUNC_INFO << "pixmap is null"; } @@ -30022,7 +29307,7 @@ void QCPItemPixmap::setPixmap( const QPixmap& pixmap ) Sets whether the pixmap will be scaled to fit the rectangle defined by the \a topLeft and \a bottomRight positions. */ -void QCPItemPixmap::setScaled( bool scaled, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformationMode ) +void QCPItemPixmap::setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformationMode) { mScaled = scaled; mAspectRatioMode = aspectRatioMode; @@ -30035,7 +29320,7 @@ void QCPItemPixmap::setScaled( bool scaled, Qt::AspectRatioMode aspectRatioMode, \see setSelectedPen, setBrush */ -void QCPItemPixmap::setPen( const QPen& pen ) +void QCPItemPixmap::setPen(const QPen &pen) { mPen = pen; } @@ -30045,73 +29330,66 @@ void QCPItemPixmap::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemPixmap::setSelectedPen( const QPen& pen ) +void QCPItemPixmap::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } /* inherits documentation from base class */ -double QCPItemPixmap::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemPixmap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - return rectDistance( getFinalRect(), pos, true ); + + return rectDistance(getFinalRect(), pos, true); } /* inherits documentation from base class */ -void QCPItemPixmap::draw( QCPPainter* painter ) +void QCPItemPixmap::draw(QCPPainter *painter) { bool flipHorz = false; bool flipVert = false; - QRect rect = getFinalRect( &flipHorz, &flipVert ); + QRect rect = getFinalRect(&flipHorz, &flipVert); double clipPad = mainPen().style() == Qt::NoPen ? 0 : mainPen().widthF(); - QRect boundingRect = rect.adjusted( -clipPad, -clipPad, clipPad, clipPad ); - if( boundingRect.intersects( clipRect() ) ) + QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (boundingRect.intersects(clipRect())) { - updateScaledPixmap( rect, flipHorz, flipVert ); - painter->drawPixmap( rect.topLeft(), mScaled ? mScaledPixmap : mPixmap ); + updateScaledPixmap(rect, flipHorz, flipVert); + painter->drawPixmap(rect.topLeft(), mScaled ? mScaledPixmap : mPixmap); QPen pen = mainPen(); - if( pen.style() != Qt::NoPen ) + if (pen.style() != Qt::NoPen) { - painter->setPen( pen ); - painter->setBrush( Qt::NoBrush ); - painter->drawRect( rect ); + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawRect(rect); } } } /* inherits documentation from base class */ -QPointF QCPItemPixmap::anchorPixelPosition( int anchorId ) const +QPointF QCPItemPixmap::anchorPixelPosition(int anchorId) const { bool flipHorz; bool flipVert; - QRect rect = getFinalRect( &flipHorz, &flipVert ); + QRect rect = getFinalRect(&flipHorz, &flipVert); // we actually want denormal rects (negative width/height) here, so restore // the flipped state: - if( flipHorz ) - rect.adjust( rect.width(), 0, -rect.width(), 0 ); - if( flipVert ) - rect.adjust( 0, rect.height(), 0, -rect.height() ); - - switch( anchorId ) + if (flipHorz) + rect.adjust(rect.width(), 0, -rect.width(), 0); + if (flipVert) + rect.adjust(0, rect.height(), 0, -rect.height()); + + switch (anchorId) { - case aiTop: - return ( rect.topLeft() + rect.topRight() ) * 0.5; - case aiTopRight: - return rect.topRight(); - case aiRight: - return ( rect.topRight() + rect.bottomRight() ) * 0.5; - case aiBottom: - return ( rect.bottomLeft() + rect.bottomRight() ) * 0.5; - case aiBottomLeft: - return rect.bottomLeft(); - case aiLeft: - return ( rect.topLeft() + rect.bottomLeft() ) * 0.5; - ; + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5;; } - + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); } @@ -30129,31 +29407,30 @@ QPointF QCPItemPixmap::anchorPixelPosition( int anchorId ) const If scaling is disabled, sets mScaledPixmap to a null QPixmap. */ -void QCPItemPixmap::updateScaledPixmap( QRect finalRect, bool flipHorz, bool flipVert ) +void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flipVert) { - if( mPixmap.isNull() ) + if (mPixmap.isNull()) return; - - if( mScaled ) + + if (mScaled) { #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED double devicePixelRatio = mPixmap.devicePixelRatio(); #else double devicePixelRatio = 1.0; #endif - if( finalRect.isNull() ) - finalRect = getFinalRect( &flipHorz, &flipVert ); - if( mScaledPixmapInvalidated || finalRect.size() != mScaledPixmap.size() / devicePixelRatio ) + if (finalRect.isNull()) + finalRect = getFinalRect(&flipHorz, &flipVert); + if (mScaledPixmapInvalidated || finalRect.size() != mScaledPixmap.size()/devicePixelRatio) { - mScaledPixmap = mPixmap.scaled( finalRect.size() * devicePixelRatio, mAspectRatioMode, mTransformationMode ); - if( flipHorz || flipVert ) - mScaledPixmap = QPixmap::fromImage( mScaledPixmap.toImage().mirrored( flipHorz, flipVert ) ); + mScaledPixmap = mPixmap.scaled(finalRect.size()*devicePixelRatio, mAspectRatioMode, mTransformationMode); + if (flipHorz || flipVert) + mScaledPixmap = QPixmap::fromImage(mScaledPixmap.toImage().mirrored(flipHorz, flipVert)); #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED - mScaledPixmap.setDevicePixelRatio( devicePixelRatio ); + mScaledPixmap.setDevicePixelRatio(devicePixelRatio); #endif } - } - else if( !mScaledPixmap.isNull() ) + } else if (!mScaledPixmap.isNull()) mScaledPixmap = QPixmap(); mScaledPixmapInvalidated = false; } @@ -30172,51 +29449,50 @@ void QCPItemPixmap::updateScaledPixmap( QRect finalRect, bool flipHorz, bool fli If scaling is disabled, returns a rect with size of the original pixmap and the top left corner aligned with the item position \a topLeft. The position \a bottomRight is ignored. */ -QRect QCPItemPixmap::getFinalRect( bool* flippedHorz, bool* flippedVert ) const +QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const { QRect result; bool flipHorz = false; bool flipVert = false; QPoint p1 = topLeft->pixelPosition().toPoint(); QPoint p2 = bottomRight->pixelPosition().toPoint(); - if( p1 == p2 ) - return QRect( p1, QSize( 0, 0 ) ); - if( mScaled ) + if (p1 == p2) + return QRect(p1, QSize(0, 0)); + if (mScaled) { - QSize newSize = QSize( p2.x() - p1.x(), p2.y() - p1.y() ); + QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y()); QPoint topLeft = p1; - if( newSize.width() < 0 ) + if (newSize.width() < 0) { flipHorz = true; newSize.rwidth() *= -1; - topLeft.setX( p2.x() ); + topLeft.setX(p2.x()); } - if( newSize.height() < 0 ) + if (newSize.height() < 0) { flipVert = true; newSize.rheight() *= -1; - topLeft.setY( p2.y() ); + topLeft.setY(p2.y()); } QSize scaledSize = mPixmap.size(); #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED scaledSize /= mPixmap.devicePixelRatio(); - scaledSize.scale( newSize * mPixmap.devicePixelRatio(), mAspectRatioMode ); + scaledSize.scale(newSize*mPixmap.devicePixelRatio(), mAspectRatioMode); #else - scaledSize.scale( newSize, mAspectRatioMode ); + scaledSize.scale(newSize, mAspectRatioMode); #endif - result = QRect( topLeft, scaledSize ); - } - else + result = QRect(topLeft, scaledSize); + } else { #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED - result = QRect( p1, mPixmap.size() / mPixmap.devicePixelRatio() ); + result = QRect(p1, mPixmap.size()/mPixmap.devicePixelRatio()); #else - result = QRect( p1, mPixmap.size() ); + result = QRect(p1, mPixmap.size()); #endif } - if( flippedHorz ) + if (flippedHorz) *flippedHorz = flipHorz; - if( flippedVert ) + if (flippedVert) *flippedVert = flipVert; return result; } @@ -30232,6 +29508,7 @@ QPen QCPItemPixmap::mainPen() const } /* end of 'src/items/item-pixmap.cpp' */ + /* including file 'src/items/item-tracer.cpp', size 14624 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -30275,15 +29552,21 @@ QPen QCPItemPixmap::mainPen() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemTracer::QCPItemTracer( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), position( createPosition( QLatin1String( "position" ) ) ), mSize( 6 ), mStyle( tsCrosshair ), mGraph( 0 ), mGraphKey( 0 ), mInterpolating( false ) +QCPItemTracer::QCPItemTracer(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition(QLatin1String("position"))), + mSize(6), + mStyle(tsCrosshair), + mGraph(0), + mGraphKey(0), + mInterpolating(false) { - position->setCoords( 0, 0 ); + position->setCoords(0, 0); - setBrush( Qt::NoBrush ); - setSelectedBrush( Qt::NoBrush ); - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); } QCPItemTracer::~QCPItemTracer() @@ -30295,7 +29578,7 @@ QCPItemTracer::~QCPItemTracer() \see setSelectedPen, setBrush */ -void QCPItemTracer::setPen( const QPen& pen ) +void QCPItemTracer::setPen(const QPen &pen) { mPen = pen; } @@ -30305,7 +29588,7 @@ void QCPItemTracer::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemTracer::setSelectedPen( const QPen& pen ) +void QCPItemTracer::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -30315,7 +29598,7 @@ void QCPItemTracer::setSelectedPen( const QPen& pen ) \see setSelectedBrush, setPen */ -void QCPItemTracer::setBrush( const QBrush& brush ) +void QCPItemTracer::setBrush(const QBrush &brush) { mBrush = brush; } @@ -30325,7 +29608,7 @@ void QCPItemTracer::setBrush( const QBrush& brush ) \see setBrush, setSelected */ -void QCPItemTracer::setSelectedBrush( const QBrush& brush ) +void QCPItemTracer::setSelectedBrush(const QBrush &brush) { mSelectedBrush = brush; } @@ -30334,7 +29617,7 @@ void QCPItemTracer::setSelectedBrush( const QBrush& brush ) Sets the size of the tracer in pixels, if the style supports setting a size (e.g. \ref tsSquare does, \ref tsCrosshair does not). */ -void QCPItemTracer::setSize( double size ) +void QCPItemTracer::setSize(double size) { mSize = size; } @@ -30345,7 +29628,7 @@ void QCPItemTracer::setSize( double size ) If you only want to use the tracer \a position as an anchor for other items, set \a style to \ref tsNone. */ -void QCPItemTracer::setStyle( QCPItemTracer::TracerStyle style ) +void QCPItemTracer::setStyle(QCPItemTracer::TracerStyle style) { mStyle = style; } @@ -30360,21 +29643,19 @@ void QCPItemTracer::setStyle( QCPItemTracer::TracerStyle style ) \see setGraphKey */ -void QCPItemTracer::setGraph( QCPGraph* graph ) +void QCPItemTracer::setGraph(QCPGraph *graph) { - if( graph ) + if (graph) { - if( graph->parentPlot() == mParentPlot ) + if (graph->parentPlot() == mParentPlot) { - position->setType( QCPItemPosition::ptPlotCoords ); - position->setAxes( graph->keyAxis(), graph->valueAxis() ); + position->setType(QCPItemPosition::ptPlotCoords); + position->setAxes(graph->keyAxis(), graph->valueAxis()); mGraph = graph; updatePosition(); - } - else + } else qDebug() << Q_FUNC_INFO << "graph isn't in same QCustomPlot instance as this item"; - } - else + } else { mGraph = 0; } @@ -30389,7 +29670,7 @@ void QCPItemTracer::setGraph( QCPGraph* graph ) \see setGraph, setInterpolating */ -void QCPItemTracer::setGraphKey( double key ) +void QCPItemTracer::setGraphKey(double key) { mGraphKey = key; } @@ -30405,114 +29686,112 @@ void QCPItemTracer::setGraphKey( double key ) \see setGraph, setGraphKey */ -void QCPItemTracer::setInterpolating( bool enabled ) +void QCPItemTracer::setInterpolating(bool enabled) { mInterpolating = enabled; } /* inherits documentation from base class */ -double QCPItemTracer::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemTracer::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - QPointF center( position->pixelPosition() ); - double w = mSize / 2.0; + QPointF center(position->pixelPosition()); + double w = mSize/2.0; QRect clip = clipRect(); - switch( mStyle ) + switch (mStyle) { - case tsNone: - return -1; - case tsPlus: - { - if( clipRect().intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) - return qSqrt( qMin( QCPVector2D( pos ).distanceSquaredToLine( center + QPointF( -w, 0 ), center + QPointF( w, 0 ) ), - QCPVector2D( pos ).distanceSquaredToLine( center + QPointF( 0, -w ), center + QPointF( 0, w ) ) ) ); - break; - } - case tsCrosshair: - { - return qSqrt( qMin( QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( clip.left(), center.y() ), QCPVector2D( clip.right(), center.y() ) ), - QCPVector2D( pos ).distanceSquaredToLine( QCPVector2D( center.x(), clip.top() ), QCPVector2D( center.x(), clip.bottom() ) ) ) ); - } - case tsCircle: - { - if( clip.intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) + case tsNone: return -1; + case tsPlus: { - // distance to border: - double centerDist = QCPVector2D( center - pos ).length(); - double circleLine = w; - double result = qAbs( centerDist - circleLine ); - // filled ellipse, allow click inside to count as hit: - if( result > mParentPlot->selectionTolerance() * 0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0 ) + if (clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + return qSqrt(qMin(QCPVector2D(pos).distanceSquaredToLine(center+QPointF(-w, 0), center+QPointF(w, 0)), + QCPVector2D(pos).distanceSquaredToLine(center+QPointF(0, -w), center+QPointF(0, w)))); + break; + } + case tsCrosshair: + { + return qSqrt(qMin(QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(clip.left(), center.y()), QCPVector2D(clip.right(), center.y())), + QCPVector2D(pos).distanceSquaredToLine(QCPVector2D(center.x(), clip.top()), QCPVector2D(center.x(), clip.bottom())))); + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) { - if( centerDist <= circleLine ) - result = mParentPlot->selectionTolerance() * 0.99; + // distance to border: + double centerDist = QCPVector2D(center-pos).length(); + double circleLine = w; + double result = qAbs(centerDist-circleLine); + // filled ellipse, allow click inside to count as hit: + if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) + { + if (centerDist <= circleLine) + result = mParentPlot->selectionTolerance()*0.99; + } + return result; } - return result; + break; } - break; - } - case tsSquare: - { - if( clip.intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) + case tsSquare: { - QRectF rect = QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ); - bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; - return rectDistance( rect, pos, filledRect ); + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w)); + bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; + return rectDistance(rect, pos, filledRect); + } + break; } - break; - } } return -1; } /* inherits documentation from base class */ -void QCPItemTracer::draw( QCPPainter* painter ) +void QCPItemTracer::draw(QCPPainter *painter) { updatePosition(); - if( mStyle == tsNone ) + if (mStyle == tsNone) return; - painter->setPen( mainPen() ); - painter->setBrush( mainBrush() ); - QPointF center( position->pixelPosition() ); - double w = mSize / 2.0; + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + QPointF center(position->pixelPosition()); + double w = mSize/2.0; QRect clip = clipRect(); - switch( mStyle ) + switch (mStyle) { - case tsNone: - return; - case tsPlus: - { - if( clip.intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) + case tsNone: return; + case tsPlus: { - painter->drawLine( QLineF( center + QPointF( -w, 0 ), center + QPointF( w, 0 ) ) ); - painter->drawLine( QLineF( center + QPointF( 0, -w ), center + QPointF( 0, w ) ) ); + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + painter->drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0))); + painter->drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w))); + } + break; + } + case tsCrosshair: + { + if (center.y() > clip.top() && center.y() < clip.bottom()) + painter->drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y())); + if (center.x() > clip.left() && center.x() < clip.right()) + painter->drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom())); + break; + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawEllipse(center, w, w); + break; + } + case tsSquare: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w))); + break; } - break; - } - case tsCrosshair: - { - if( center.y() > clip.top() && center.y() < clip.bottom() ) - painter->drawLine( QLineF( clip.left(), center.y(), clip.right(), center.y() ) ); - if( center.x() > clip.left() && center.x() < clip.right() ) - painter->drawLine( QLineF( center.x(), clip.top(), center.x(), clip.bottom() ) ); - break; - } - case tsCircle: - { - if( clip.intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) - painter->drawEllipse( center, w, w ); - break; - } - case tsSquare: - { - if( clip.intersects( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ).toRect() ) ) - painter->drawRect( QRectF( center - QPointF( w, w ), center + QPointF( w, w ) ) ); - break; - } } } @@ -30530,55 +29809,50 @@ void QCPItemTracer::draw( QCPPainter* painter ) */ void QCPItemTracer::updatePosition() { - if( mGraph ) + if (mGraph) { - if( mParentPlot->hasPlottable( mGraph ) ) + if (mParentPlot->hasPlottable(mGraph)) { - if( mGraph->data()->size() > 1 ) + if (mGraph->data()->size() > 1) { QCPGraphDataContainer::const_iterator first = mGraph->data()->constBegin(); - QCPGraphDataContainer::const_iterator last = mGraph->data()->constEnd() - 1; - if( mGraphKey <= first->key ) - position->setCoords( first->key, first->value ); - else if( mGraphKey >= last->key ) - position->setCoords( last->key, last->value ); + QCPGraphDataContainer::const_iterator last = mGraph->data()->constEnd()-1; + if (mGraphKey <= first->key) + position->setCoords(first->key, first->value); + else if (mGraphKey >= last->key) + position->setCoords(last->key, last->value); else { - QCPGraphDataContainer::const_iterator it = mGraph->data()->findBegin( mGraphKey ); - if( it != mGraph->data()->constEnd() ) // mGraphKey is not exactly on last iterator, but somewhere between iterators + QCPGraphDataContainer::const_iterator it = mGraph->data()->findBegin(mGraphKey); + if (it != mGraph->data()->constEnd()) // mGraphKey is not exactly on last iterator, but somewhere between iterators { QCPGraphDataContainer::const_iterator prevIt = it; - ++it; // won't advance to constEnd because we handled that case (mGraphKey >= last->key) before - if( mInterpolating ) + ++it; // won't advance to constEnd because we handled that case (mGraphKey >= last->key) before + if (mInterpolating) { // interpolate between iterators around mGraphKey: double slope = 0; - if( !qFuzzyCompare( (double)it->key, (double)prevIt->key ) ) - slope = ( it->value - prevIt->value ) / ( it->key - prevIt->key ); - position->setCoords( mGraphKey, ( mGraphKey - prevIt->key ) * slope + prevIt->value ); - } - else + if (!qFuzzyCompare((double)it->key, (double)prevIt->key)) + slope = (it->value-prevIt->value)/(it->key-prevIt->key); + position->setCoords(mGraphKey, (mGraphKey-prevIt->key)*slope+prevIt->value); + } else { // find iterator with key closest to mGraphKey: - if( mGraphKey < ( prevIt->key + it->key ) * 0.5 ) - position->setCoords( prevIt->key, prevIt->value ); + if (mGraphKey < (prevIt->key+it->key)*0.5) + position->setCoords(prevIt->key, prevIt->value); else - position->setCoords( it->key, it->value ); + position->setCoords(it->key, it->value); } - } - else // mGraphKey is exactly on last iterator (should actually be caught when comparing first/last keys, but this is a failsafe for fp uncertainty) - position->setCoords( it->key, it->value ); + } else // mGraphKey is exactly on last iterator (should actually be caught when comparing first/last keys, but this is a failsafe for fp uncertainty) + position->setCoords(it->key, it->value); } - } - else if( mGraph->data()->size() == 1 ) + } else if (mGraph->data()->size() == 1) { QCPGraphDataContainer::const_iterator it = mGraph->data()->constBegin(); - position->setCoords( it->key, it->value ); - } - else + position->setCoords(it->key, it->value); + } else qDebug() << Q_FUNC_INFO << "graph has no data"; - } - else + } else qDebug() << Q_FUNC_INFO << "graph not contained in QCustomPlot instance (anymore)"; } } @@ -30604,6 +29878,7 @@ QBrush QCPItemTracer::mainBrush() const } /* end of 'src/items/item-tracer.cpp' */ + /* including file 'src/items/item-bracket.cpp', size 10687 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -30637,14 +29912,19 @@ QBrush QCPItemTracer::mainBrush() const The created item is automatically registered with \a parentPlot. This QCustomPlot instance takes ownership of the item, so do not delete it manually but use QCustomPlot::removeItem() instead. */ -QCPItemBracket::QCPItemBracket( QCustomPlot* parentPlot ) - : QCPAbstractItem( parentPlot ), left( createPosition( QLatin1String( "left" ) ) ), right( createPosition( QLatin1String( "right" ) ) ), center( createAnchor( QLatin1String( "center" ), aiCenter ) ), mLength( 8 ), mStyle( bsCalligraphic ) +QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + left(createPosition(QLatin1String("left"))), + right(createPosition(QLatin1String("right"))), + center(createAnchor(QLatin1String("center"), aiCenter)), + mLength(8), + mStyle(bsCalligraphic) { - left->setCoords( 0, 0 ); - right->setCoords( 1, 1 ); - - setPen( QPen( Qt::black ) ); - setSelectedPen( QPen( Qt::blue, 2 ) ); + left->setCoords(0, 0); + right->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); } QCPItemBracket::~QCPItemBracket() @@ -30660,7 +29940,7 @@ QCPItemBracket::~QCPItemBracket() \see setSelectedPen */ -void QCPItemBracket::setPen( const QPen& pen ) +void QCPItemBracket::setPen(const QPen &pen) { mPen = pen; } @@ -30670,7 +29950,7 @@ void QCPItemBracket::setPen( const QPen& pen ) \see setPen, setSelected */ -void QCPItemBracket::setSelectedPen( const QPen& pen ) +void QCPItemBracket::setSelectedPen(const QPen &pen) { mSelectedPen = pen; } @@ -30683,7 +29963,7 @@ void QCPItemBracket::setSelectedPen( const QPen& pen )

    Demonstrating the effect of different values for \ref setLength, for styles \ref bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
    */ -void QCPItemBracket::setLength( double length ) +void QCPItemBracket::setLength(double length) { mLength = length; } @@ -30693,135 +29973,135 @@ void QCPItemBracket::setLength( double length ) \see setPen */ -void QCPItemBracket::setStyle( QCPItemBracket::BracketStyle style ) +void QCPItemBracket::setStyle(QCPItemBracket::BracketStyle style) { mStyle = style; } /* inherits documentation from base class */ -double QCPItemBracket::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPItemBracket::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - Q_UNUSED( details ) - if( onlySelectable && !mSelectable ) + Q_UNUSED(details) + if (onlySelectable && !mSelectable) return -1; - - QCPVector2D p( pos ); - QCPVector2D leftVec( left->pixelPosition() ); - QCPVector2D rightVec( right->pixelPosition() ); - if( leftVec.toPoint() == rightVec.toPoint() ) + + QCPVector2D p(pos); + QCPVector2D leftVec(left->pixelPosition()); + QCPVector2D rightVec(right->pixelPosition()); + if (leftVec.toPoint() == rightVec.toPoint()) return -1; - - QCPVector2D widthVec = ( rightVec - leftVec ) * 0.5; - QCPVector2D lengthVec = widthVec.perpendicular().normalized() * mLength; - QCPVector2D centerVec = ( rightVec + leftVec ) * 0.5 - lengthVec; - - switch( mStyle ) + + QCPVector2D widthVec = (rightVec-leftVec)*0.5; + QCPVector2D lengthVec = widthVec.perpendicular().normalized()*mLength; + QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; + + switch (mStyle) { - case QCPItemBracket::bsSquare: - case QCPItemBracket::bsRound: - { - double a = p.distanceSquaredToLine( centerVec - widthVec, centerVec + widthVec ); - double b = p.distanceSquaredToLine( centerVec - widthVec + lengthVec, centerVec - widthVec ); - double c = p.distanceSquaredToLine( centerVec + widthVec + lengthVec, centerVec + widthVec ); - return qSqrt( qMin( qMin( a, b ), c ) ); - } - case QCPItemBracket::bsCurly: - case QCPItemBracket::bsCalligraphic: - { - double a = p.distanceSquaredToLine( centerVec - widthVec * 0.75 + lengthVec * 0.15, centerVec + lengthVec * 0.3 ); - double b = p.distanceSquaredToLine( centerVec - widthVec + lengthVec * 0.7, centerVec - widthVec * 0.75 + lengthVec * 0.15 ); - double c = p.distanceSquaredToLine( centerVec + widthVec * 0.75 + lengthVec * 0.15, centerVec + lengthVec * 0.3 ); - double d = p.distanceSquaredToLine( centerVec + widthVec + lengthVec * 0.7, centerVec + widthVec * 0.75 + lengthVec * 0.15 ); - return qSqrt( qMin( qMin( a, b ), qMin( c, d ) ) ); - } + case QCPItemBracket::bsSquare: + case QCPItemBracket::bsRound: + { + double a = p.distanceSquaredToLine(centerVec-widthVec, centerVec+widthVec); + double b = p.distanceSquaredToLine(centerVec-widthVec+lengthVec, centerVec-widthVec); + double c = p.distanceSquaredToLine(centerVec+widthVec+lengthVec, centerVec+widthVec); + return qSqrt(qMin(qMin(a, b), c)); + } + case QCPItemBracket::bsCurly: + case QCPItemBracket::bsCalligraphic: + { + double a = p.distanceSquaredToLine(centerVec-widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3); + double b = p.distanceSquaredToLine(centerVec-widthVec+lengthVec*0.7, centerVec-widthVec*0.75+lengthVec*0.15); + double c = p.distanceSquaredToLine(centerVec+widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3); + double d = p.distanceSquaredToLine(centerVec+widthVec+lengthVec*0.7, centerVec+widthVec*0.75+lengthVec*0.15); + return qSqrt(qMin(qMin(a, b), qMin(c, d))); + } } return -1; } /* inherits documentation from base class */ -void QCPItemBracket::draw( QCPPainter* painter ) +void QCPItemBracket::draw(QCPPainter *painter) { - QCPVector2D leftVec( left->pixelPosition() ); - QCPVector2D rightVec( right->pixelPosition() ); - if( leftVec.toPoint() == rightVec.toPoint() ) + QCPVector2D leftVec(left->pixelPosition()); + QCPVector2D rightVec(right->pixelPosition()); + if (leftVec.toPoint() == rightVec.toPoint()) return; - - QCPVector2D widthVec = ( rightVec - leftVec ) * 0.5; - QCPVector2D lengthVec = widthVec.perpendicular().normalized() * mLength; - QCPVector2D centerVec = ( rightVec + leftVec ) * 0.5 - lengthVec; + + QCPVector2D widthVec = (rightVec-leftVec)*0.5; + QCPVector2D lengthVec = widthVec.perpendicular().normalized()*mLength; + QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; QPolygon boundingPoly; boundingPoly << leftVec.toPoint() << rightVec.toPoint() - << ( rightVec - lengthVec ).toPoint() << ( leftVec - lengthVec ).toPoint(); - QRect clip = clipRect().adjusted( -mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF() ); - if( clip.intersects( boundingPoly.boundingRect() ) ) + << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (clip.intersects(boundingPoly.boundingRect())) { - painter->setPen( mainPen() ); - switch( mStyle ) + painter->setPen(mainPen()); + switch (mStyle) { - case bsSquare: - { - painter->drawLine( ( centerVec + widthVec ).toPointF(), ( centerVec - widthVec ).toPointF() ); - painter->drawLine( ( centerVec + widthVec ).toPointF(), ( centerVec + widthVec + lengthVec ).toPointF() ); - painter->drawLine( ( centerVec - widthVec ).toPointF(), ( centerVec - widthVec + lengthVec ).toPointF() ); - break; - } - case bsRound: - { - painter->setBrush( Qt::NoBrush ); - QPainterPath path; - path.moveTo( ( centerVec + widthVec + lengthVec ).toPointF() ); - path.cubicTo( ( centerVec + widthVec ).toPointF(), ( centerVec + widthVec ).toPointF(), centerVec.toPointF() ); - path.cubicTo( ( centerVec - widthVec ).toPointF(), ( centerVec - widthVec ).toPointF(), ( centerVec - widthVec + lengthVec ).toPointF() ); - painter->drawPath( path ); - break; - } - case bsCurly: - { - painter->setBrush( Qt::NoBrush ); - QPainterPath path; - path.moveTo( ( centerVec + widthVec + lengthVec ).toPointF() ); - path.cubicTo( ( centerVec + widthVec - lengthVec * 0.8 ).toPointF(), ( centerVec + 0.4 * widthVec + lengthVec ).toPointF(), centerVec.toPointF() ); - path.cubicTo( ( centerVec - 0.4 * widthVec + lengthVec ).toPointF(), ( centerVec - widthVec - lengthVec * 0.8 ).toPointF(), ( centerVec - widthVec + lengthVec ).toPointF() ); - painter->drawPath( path ); - break; - } - case bsCalligraphic: - { - painter->setPen( Qt::NoPen ); - painter->setBrush( QBrush( mainPen().color() ) ); - QPainterPath path; - path.moveTo( ( centerVec + widthVec + lengthVec ).toPointF() ); - - path.cubicTo( ( centerVec + widthVec - lengthVec * 0.8 ).toPointF(), ( centerVec + 0.4 * widthVec + 0.8 * lengthVec ).toPointF(), centerVec.toPointF() ); - path.cubicTo( ( centerVec - 0.4 * widthVec + 0.8 * lengthVec ).toPointF(), ( centerVec - widthVec - lengthVec * 0.8 ).toPointF(), ( centerVec - widthVec + lengthVec ).toPointF() ); - - path.cubicTo( ( centerVec - widthVec - lengthVec * 0.5 ).toPointF(), ( centerVec - 0.2 * widthVec + 1.2 * lengthVec ).toPointF(), ( centerVec + lengthVec * 0.2 ).toPointF() ); - path.cubicTo( ( centerVec + 0.2 * widthVec + 1.2 * lengthVec ).toPointF(), ( centerVec + widthVec - lengthVec * 0.5 ).toPointF(), ( centerVec + widthVec + lengthVec ).toPointF() ); - - painter->drawPath( path ); - break; - } + case bsSquare: + { + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF()); + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + painter->drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + break; + } + case bsRound: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCurly: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCalligraphic: + { + painter->setPen(Qt::NoPen); + painter->setBrush(QBrush(mainPen().color())); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+0.8*lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4*widthVec+0.8*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec-widthVec-lengthVec*0.5).toPointF(), (centerVec-0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+lengthVec*0.2).toPointF()); + path.cubicTo((centerVec+0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + + painter->drawPath(path); + break; + } } } } /* inherits documentation from base class */ -QPointF QCPItemBracket::anchorPixelPosition( int anchorId ) const +QPointF QCPItemBracket::anchorPixelPosition(int anchorId) const { - QCPVector2D leftVec( left->pixelPosition() ); - QCPVector2D rightVec( right->pixelPosition() ); - if( leftVec.toPoint() == rightVec.toPoint() ) + QCPVector2D leftVec(left->pixelPosition()); + QCPVector2D rightVec(right->pixelPosition()); + if (leftVec.toPoint() == rightVec.toPoint()) return leftVec.toPointF(); - - QCPVector2D widthVec = ( rightVec - leftVec ) * 0.5; - QCPVector2D lengthVec = widthVec.perpendicular().normalized() * mLength; - QCPVector2D centerVec = ( rightVec + leftVec ) * 0.5 - lengthVec; - - switch( anchorId ) + + QCPVector2D widthVec = (rightVec-leftVec)*0.5; + QCPVector2D lengthVec = widthVec.perpendicular().normalized()*mLength; + QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec; + + switch (anchorId) { - case aiCenter: - return centerVec.toPointF(); + case aiCenter: + return centerVec.toPointF(); } qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; return QPointF(); @@ -30834,6 +30114,8 @@ QPointF QCPItemBracket::anchorPixelPosition( int anchorId ) const */ QPen QCPItemBracket::mainPen() const { - return mSelected ? mSelectedPen : mPen; + return mSelected ? mSelectedPen : mPen; } /* end of 'src/items/item-bracket.cpp' */ + + diff --git a/app/external/qcustomplot/qcustomplot.h b/app/external/qcustomplot/qcustomplot.h index 8580a78..278fbf8 100644 --- a/app/external/qcustomplot/qcustomplot.h +++ b/app/external/qcustomplot/qcustomplot.h @@ -30,65 +30,65 @@ // some Qt version/configuration dependent macros to include or exclude certain code paths: #ifdef QCUSTOMPLOT_USE_OPENGL -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) -#define QCP_OPENGL_PBUFFER -#else -#define QCP_OPENGL_FBO -#endif -#if QT_VERSION >= QT_VERSION_CHECK( 5, 3, 0 ) -#define QCP_OPENGL_OFFSCREENSURFACE -#endif +# if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +# define QCP_OPENGL_PBUFFER +# else +# define QCP_OPENGL_FBO +# endif +# if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) +# define QCP_OPENGL_OFFSCREENSURFACE +# endif #endif -#if QT_VERSION >= QT_VERSION_CHECK( 5, 4, 0 ) -#define QCP_DEVICEPIXELRATIO_SUPPORTED -#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) -#define QCP_DEVICEPIXELRATIO_FLOAT -#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +# define QCP_DEVICEPIXELRATIO_SUPPORTED +# if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +# define QCP_DEVICEPIXELRATIO_FLOAT +# endif #endif -#include -#include -#include -#include -#include -#include -#include #include #include #include -#include -#include #include -#include -#include -#include #include -#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #ifdef QCP_OPENGL_FBO -#include -#include -#ifdef QCP_OPENGL_OFFSCREENSURFACE -#include -#else -#include -#endif +# include +# include +# ifdef QCP_OPENGL_OFFSCREENSURFACE +# include +# else +# include +# endif #endif #ifdef QCP_OPENGL_PBUFFER -#include +# include #endif -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) -#include -#include -#include -#include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +# include +# include +# include +# include #else -#include -#include -#include +# include +# include +# include #endif class QCPPainter; @@ -116,17 +116,17 @@ class QCPBars; /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ // decl definitions for shared library compilation/usage: -#if defined( QCUSTOMPLOT_COMPILE_LIBRARY ) -#define QCP_LIB_DECL Q_DECL_EXPORT -#elif defined( QCUSTOMPLOT_USE_LIBRARY ) -#define QCP_LIB_DECL Q_DECL_IMPORT +#if defined(QCUSTOMPLOT_COMPILE_LIBRARY) +# define QCP_LIB_DECL Q_DECL_EXPORT +#elif defined(QCUSTOMPLOT_USE_LIBRARY) +# define QCP_LIB_DECL Q_DECL_IMPORT #else -#define QCP_LIB_DECL +# define QCP_LIB_DECL #endif // define empty macro for Q_DECL_OVERRIDE if it doesn't exist (Qt < 5) #ifndef Q_DECL_OVERRIDE -#define Q_DECL_OVERRIDE +# define Q_DECL_OVERRIDE #endif /*! @@ -136,25 +136,23 @@ class QCPBars; It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject. */ #ifndef Q_MOC_RUN -namespace QCP -{ +namespace QCP { #else -class QCP -{ // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace +class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace Q_GADGET - Q_ENUMS( ExportPen ) - Q_ENUMS( ResolutionUnit ) - Q_ENUMS( SignDomain ) - Q_ENUMS( MarginSide ) - Q_FLAGS( MarginSides ) - Q_ENUMS( AntialiasedElement ) - Q_FLAGS( AntialiasedElements ) - Q_ENUMS( PlottingHint ) - Q_FLAGS( PlottingHints ) - Q_ENUMS( Interaction ) - Q_FLAGS( Interactions ) - Q_ENUMS( SelectionRectMode ) - Q_ENUMS( SelectionType ) + Q_ENUMS(ExportPen) + Q_ENUMS(ResolutionUnit) + Q_ENUMS(SignDomain) + Q_ENUMS(MarginSide) + Q_FLAGS(MarginSides) + Q_ENUMS(AntialiasedElement) + Q_FLAGS(AntialiasedElements) + Q_ENUMS(PlottingHint) + Q_FLAGS(PlottingHints) + Q_ENUMS(Interaction) + Q_FLAGS(Interactions) + Q_ENUMS(SelectionRectMode) + Q_ENUMS(SelectionType) public: #endif @@ -164,26 +162,19 @@ public: \see QCustomPlot::savePng, QCustomPlot::saveJpg, QCustomPlot::saveBmp, QCustomPlot::saveRastered */ -enum ResolutionUnit -{ - ruDotsPerMeter ///< Resolution is given in dots per meter (dpm) - , - ruDotsPerCentimeter ///< Resolution is given in dots per centimeter (dpcm) - , - ruDotsPerInch ///< Resolution is given in dots per inch (DPI/PPI) -}; +enum ResolutionUnit { ruDotsPerMeter ///< Resolution is given in dots per meter (dpm) + ,ruDotsPerCentimeter ///< Resolution is given in dots per centimeter (dpcm) + ,ruDotsPerInch ///< Resolution is given in dots per inch (DPI/PPI) + }; /*! Defines how cosmetic pens (pens with numerical width 0) are handled during export. \see QCustomPlot::savePdf */ -enum ExportPen -{ - epNoCosmetic ///< Cosmetic pens are converted to pens with pixel width 1 when exporting - , - epAllowCosmetic ///< Cosmetic pens are exported normally (e.g. in PDF exports, cosmetic pens always appear as 1 pixel on screen, independent of viewer zoom level) -}; +enum ExportPen { epNoCosmetic ///< Cosmetic pens are converted to pens with pixel width 1 when exporting + ,epAllowCosmetic ///< Cosmetic pens are exported normally (e.g. in PDF exports, cosmetic pens always appear as 1 pixel on screen, independent of viewer zoom level) + }; /*! Represents negative and positive sign domain, e.g. for passing to \ref @@ -192,35 +183,24 @@ enum ExportPen This is primarily needed when working with logarithmic axis scales, since only one of the sign domains can be visible at a time. */ -enum SignDomain -{ - sdNegative ///< The negative sign domain, i.e. numbers smaller than zero - , - sdBoth ///< Both sign domains, including zero, i.e. all numbers - , - sdPositive ///< The positive sign domain, i.e. numbers greater than zero -}; +enum SignDomain { sdNegative ///< The negative sign domain, i.e. numbers smaller than zero + ,sdBoth ///< Both sign domains, including zero, i.e. all numbers + ,sdPositive ///< The positive sign domain, i.e. numbers greater than zero + }; /*! Defines the sides of a rectangular entity to which margins can be applied. \see QCPLayoutElement::setAutoMargins, QCPAxisRect::setAutoMargins */ -enum MarginSide -{ - msLeft = 0x01 ///< 0x01 left margin - , - msRight = 0x02 ///< 0x02 right margin - , - msTop = 0x04 ///< 0x04 top margin - , - msBottom = 0x08 ///< 0x08 bottom margin - , - msAll = 0xFF ///< 0xFF all margins - , - msNone = 0x00 ///< 0x00 no margin -}; -Q_DECLARE_FLAGS( MarginSides, MarginSide ) +enum MarginSide { msLeft = 0x01 ///< 0x01 left margin + ,msRight = 0x02 ///< 0x02 right margin + ,msTop = 0x04 ///< 0x04 top margin + ,msBottom = 0x08 ///< 0x08 bottom margin + ,msAll = 0xFF ///< 0xFF all margins + ,msNone = 0x00 ///< 0x00 no margin + }; +Q_DECLARE_FLAGS(MarginSides, MarginSide) /*! Defines what objects of a plot can be forcibly drawn antialiased/not antialiased. If an object is @@ -231,54 +211,35 @@ Q_DECLARE_FLAGS( MarginSides, MarginSide ) \see QCustomPlot::setAntialiasedElements, QCustomPlot::setNotAntialiasedElements */ -enum AntialiasedElement -{ - aeAxes = 0x0001 ///< 0x0001 Axis base line and tick marks - , - aeGrid = 0x0002 ///< 0x0002 Grid lines - , - aeSubGrid = 0x0004 ///< 0x0004 Sub grid lines - , - aeLegend = 0x0008 ///< 0x0008 Legend box - , - aeLegendItems = 0x0010 ///< 0x0010 Legend items - , - aePlottables = 0x0020 ///< 0x0020 Main lines of plottables - , - aeItems = 0x0040 ///< 0x0040 Main lines of items - , - aeScatters = 0x0080 ///< 0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) - , - aeFills = 0x0100 ///< 0x0100 Borders of fills (e.g. under or between graphs) - , - aeZeroLine = 0x0200 ///< 0x0200 Zero-lines, see \ref QCPGrid::setZeroLinePen - , - aeOther = 0x8000 ///< 0x8000 Other elements that don't fit into any of the existing categories - , - aeAll = 0xFFFF ///< 0xFFFF All elements - , - aeNone = 0x0000 ///< 0x0000 No elements -}; -Q_DECLARE_FLAGS( AntialiasedElements, AntialiasedElement ) +enum AntialiasedElement { aeAxes = 0x0001 ///< 0x0001 Axis base line and tick marks + ,aeGrid = 0x0002 ///< 0x0002 Grid lines + ,aeSubGrid = 0x0004 ///< 0x0004 Sub grid lines + ,aeLegend = 0x0008 ///< 0x0008 Legend box + ,aeLegendItems = 0x0010 ///< 0x0010 Legend items + ,aePlottables = 0x0020 ///< 0x0020 Main lines of plottables + ,aeItems = 0x0040 ///< 0x0040 Main lines of items + ,aeScatters = 0x0080 ///< 0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) + ,aeFills = 0x0100 ///< 0x0100 Borders of fills (e.g. under or between graphs) + ,aeZeroLine = 0x0200 ///< 0x0200 Zero-lines, see \ref QCPGrid::setZeroLinePen + ,aeOther = 0x8000 ///< 0x8000 Other elements that don't fit into any of the existing categories + ,aeAll = 0xFFFF ///< 0xFFFF All elements + ,aeNone = 0x0000 ///< 0x0000 No elements + }; +Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement) /*! Defines plotting hints that control various aspects of the quality and speed of plotting. \see QCustomPlot::setPlottingHints */ -enum PlottingHint -{ - phNone = 0x000 ///< 0x000 No hints are set - , - phFastPolylines = 0x001 ///< 0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality especially of the line segment - ///< joins, thus is most effective for pen sizes larger than 1. It is only used for solid line pens. - , - phImmediateRefresh = 0x002 ///< 0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpRefreshHint. - ///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse). - , - phCacheLabels = 0x004 ///< 0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance. -}; -Q_DECLARE_FLAGS( PlottingHints, PlottingHint ) +enum PlottingHint { phNone = 0x000 ///< 0x000 No hints are set + ,phFastPolylines = 0x001 ///< 0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality especially of the line segment + ///< joins, thus is most effective for pen sizes larger than 1. It is only used for solid line pens. + ,phImmediateRefresh = 0x002 ///< 0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpRefreshHint. + ///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse). + ,phCacheLabels = 0x004 ///< 0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance. + }; +Q_DECLARE_FLAGS(PlottingHints, PlottingHint) /*! Defines the mouse interactions possible with QCustomPlot. @@ -287,41 +248,27 @@ Q_DECLARE_FLAGS( PlottingHints, PlottingHint ) \see QCustomPlot::setInteractions */ -enum Interaction -{ - iRangeDrag = 0x001 ///< 0x001 Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes) - , - iRangeZoom = 0x002 ///< 0x002 Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes) - , - iMultiSelect = 0x004 ///< 0x004 The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking - , - iSelectPlottables = 0x008 ///< 0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) - , - iSelectAxes = 0x010 ///< 0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts) - , - iSelectLegend = 0x020 ///< 0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) - , - iSelectItems = 0x040 ///< 0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem) - , - iSelectOther = 0x080 ///< 0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements,...) -}; -Q_DECLARE_FLAGS( Interactions, Interaction ) +enum Interaction { iRangeDrag = 0x001 ///< 0x001 Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes) + ,iRangeZoom = 0x002 ///< 0x002 Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes) + ,iMultiSelect = 0x004 ///< 0x004 The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking + ,iSelectPlottables = 0x008 ///< 0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) + ,iSelectAxes = 0x010 ///< 0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts) + ,iSelectLegend = 0x020 ///< 0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) + ,iSelectItems = 0x040 ///< 0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem) + ,iSelectOther = 0x080 ///< 0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements,...) + }; +Q_DECLARE_FLAGS(Interactions, Interaction) /*! Defines the behaviour of the selection rect. \see QCustomPlot::setSelectionRectMode, QCustomPlot::selectionRect, QCPSelectionRect */ -enum SelectionRectMode -{ - srmNone ///< The selection rect is disabled, and all mouse events are forwarded to the underlying objects, e.g. for axis range dragging - , - srmZoom ///< When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently set as range zoom axes (\ref QCPAxisRect::setRangeZoomAxes) will have their ranges zoomed accordingly. - , - srmSelect ///< When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that were within the selection rect are selected, if the plottable's selectability setting permits. (See \ref dataselection "data selection mechanism" for details.) - , - srmCustom ///< When dragging the mouse, a selection rect becomes active. It is the programmer's responsibility to connect according slots to the selection rect's signals (e.g. \ref QCPSelectionRect::accepted) in order to process the user interaction. -}; +enum SelectionRectMode { srmNone ///< The selection rect is disabled, and all mouse events are forwarded to the underlying objects, e.g. for axis range dragging + ,srmZoom ///< When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently set as range zoom axes (\ref QCPAxisRect::setRangeZoomAxes) will have their ranges zoomed accordingly. + ,srmSelect ///< When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that were within the selection rect are selected, if the plottable's selectability setting permits. (See \ref dataselection "data selection mechanism" for details.) + ,srmCustom ///< When dragging the mouse, a selection rect becomes active. It is the programmer's responsibility to connect according slots to the selection rect's signals (e.g. \ref QCPSelectionRect::accepted) in order to process the user interaction. + }; /*! Defines the different ways a plottable can be selected. These images show the effect of the @@ -341,18 +288,12 @@ enum SelectionRectMode \see QCPAbstractPlottable::setSelectable, QCPDataSelection::enforceType */ -enum SelectionType -{ - stNone ///< The plottable is not selectable - , - stWhole ///< Selection behaves like \ref stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected. - , - stSingleData ///< One individual data point can be selected at a time - , - stDataRange ///< Multiple contiguous data points (a data range) can be selected - , - stMultipleDataRanges ///< Any combination of data points/ranges can be selected -}; +enum SelectionType { stNone ///< The plottable is not selectable + ,stWhole ///< Selection behaves like \ref stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected. + ,stSingleData ///< One individual data point can be selected at a time + ,stDataRange ///< Multiple contiguous data points (a data range) can be selected + ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected + }; /*! \internal @@ -360,9 +301,9 @@ enum SelectionType is \e nan or \e +/-inf). This function is used to check data validity upon replots, when the compiler flag \c QCUSTOMPLOT_CHECK_DATA is set. */ -inline bool isInvalidData( double value ) +inline bool isInvalidData(double value) { - return qIsNaN( value ) || qIsInf( value ); + return qIsNaN(value) || qIsInf(value); } /*! \internal @@ -370,9 +311,9 @@ inline bool isInvalidData( double value ) Checks two arguments instead of one. */ -inline bool isInvalidData( double value1, double value2 ) +inline bool isInvalidData(double value1, double value2) { - return isInvalidData( value1 ) || isInvalidData( value2 ); + return isInvalidData(value1) || isInvalidData(value2); } /*! \internal @@ -381,27 +322,16 @@ inline bool isInvalidData( double value1, double value2 ) \see getMarginValue */ -inline void setMarginValue( QMargins& margins, QCP::MarginSide side, int value ) +inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value) { - switch( side ) + switch (side) { - case QCP::msLeft: - margins.setLeft( value ); - break; - case QCP::msRight: - margins.setRight( value ); - break; - case QCP::msTop: - margins.setTop( value ); - break; - case QCP::msBottom: - margins.setBottom( value ); - break; - case QCP::msAll: - margins = QMargins( value, value, value, value ); - break; - default: - break; + case QCP::msLeft: margins.setLeft(value); break; + case QCP::msRight: margins.setRight(value); break; + case QCP::msTop: margins.setTop(value); break; + case QCP::msBottom: margins.setBottom(value); break; + case QCP::msAll: margins = QMargins(value, value, value, value); break; + default: break; } } @@ -412,43 +342,40 @@ inline void setMarginValue( QMargins& margins, QCP::MarginSide side, int value ) \see setMarginValue */ -inline int getMarginValue( const QMargins& margins, QCP::MarginSide side ) +inline int getMarginValue(const QMargins &margins, QCP::MarginSide side) { - switch( side ) + switch (side) { - case QCP::msLeft: - return margins.left(); - case QCP::msRight: - return margins.right(); - case QCP::msTop: - return margins.top(); - case QCP::msBottom: - return margins.bottom(); - default: - break; + case QCP::msLeft: return margins.left(); + case QCP::msRight: return margins.right(); + case QCP::msTop: return margins.top(); + case QCP::msBottom: return margins.bottom(); + default: break; } return 0; } -extern const QMetaObject staticMetaObject; // in moc-run we create a static meta object for QCP "fake" object. This line is the link to it via QCP::staticMetaObject in normal operation as namespace -} // end of namespace QCP -Q_DECLARE_OPERATORS_FOR_FLAGS( QCP::AntialiasedElements ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QCP::PlottingHints ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QCP::MarginSides ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QCP::Interactions ) -Q_DECLARE_METATYPE( QCP::ExportPen ) -Q_DECLARE_METATYPE( QCP::ResolutionUnit ) -Q_DECLARE_METATYPE( QCP::SignDomain ) -Q_DECLARE_METATYPE( QCP::MarginSide ) -Q_DECLARE_METATYPE( QCP::AntialiasedElement ) -Q_DECLARE_METATYPE( QCP::PlottingHint ) -Q_DECLARE_METATYPE( QCP::Interaction ) -Q_DECLARE_METATYPE( QCP::SelectionRectMode ) -Q_DECLARE_METATYPE( QCP::SelectionType ) +extern const QMetaObject staticMetaObject; // in moc-run we create a static meta object for QCP "fake" object. This line is the link to it via QCP::staticMetaObject in normal operation as namespace + +} // end of namespace QCP +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) +Q_DECLARE_METATYPE(QCP::ExportPen) +Q_DECLARE_METATYPE(QCP::ResolutionUnit) +Q_DECLARE_METATYPE(QCP::SignDomain) +Q_DECLARE_METATYPE(QCP::MarginSide) +Q_DECLARE_METATYPE(QCP::AntialiasedElement) +Q_DECLARE_METATYPE(QCP::PlottingHint) +Q_DECLARE_METATYPE(QCP::Interaction) +Q_DECLARE_METATYPE(QCP::SelectionRectMode) +Q_DECLARE_METATYPE(QCP::SelectionType) /* end of 'src/global.h' */ + /* including file 'src/vector2d.h', size 4928 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -456,90 +383,73 @@ class QCP_LIB_DECL QCPVector2D { public: QCPVector2D(); - QCPVector2D( double x, double y ); - QCPVector2D( const QPoint& point ); - QCPVector2D( const QPointF& point ); - + QCPVector2D(double x, double y); + QCPVector2D(const QPoint &point); + QCPVector2D(const QPointF &point); + // getters: double x() const { return mX; } double y() const { return mY; } - double& rx() { return mX; } - double& ry() { return mY; } - + double &rx() { return mX; } + double &ry() { return mY; } + // setters: - void setX( double x ) { mX = x; } - void setY( double y ) { mY = y; } - + void setX(double x) { mX = x; } + void setY(double y) { mY = y; } + // non-virtual methods: - double length() const { return qSqrt( mX * mX + mY * mY ); } - double lengthSquared() const { return mX * mX + mY * mY; } - QPoint toPoint() const { return QPoint( mX, mY ); } - QPointF toPointF() const { return QPointF( mX, mY ); } - - bool isNull() const { return qIsNull( mX ) && qIsNull( mY ); } + double length() const { return qSqrt(mX*mX+mY*mY); } + double lengthSquared() const { return mX*mX+mY*mY; } + QPoint toPoint() const { return QPoint(mX, mY); } + QPointF toPointF() const { return QPointF(mX, mY); } + + bool isNull() const { return qIsNull(mX) && qIsNull(mY); } void normalize(); QCPVector2D normalized() const; - QCPVector2D perpendicular() const { return QCPVector2D( -mY, mX ); } - double dot( const QCPVector2D& vec ) const { return mX * vec.mX + mY * vec.mY; } - double distanceSquaredToLine( const QCPVector2D& start, const QCPVector2D& end ) const; - double distanceSquaredToLine( const QLineF& line ) const; - double distanceToStraightLine( const QCPVector2D& base, const QCPVector2D& direction ) const; - - QCPVector2D& operator*=( double factor ); - QCPVector2D& operator/=( double divisor ); - QCPVector2D& operator+=( const QCPVector2D& vector ); - QCPVector2D& operator-=( const QCPVector2D& vector ); - + QCPVector2D perpendicular() const { return QCPVector2D(-mY, mX); } + double dot(const QCPVector2D &vec) const { return mX*vec.mX+mY*vec.mY; } + double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const; + double distanceSquaredToLine(const QLineF &line) const; + double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const; + + QCPVector2D &operator*=(double factor); + QCPVector2D &operator/=(double divisor); + QCPVector2D &operator+=(const QCPVector2D &vector); + QCPVector2D &operator-=(const QCPVector2D &vector); + private: // property members: double mX, mY; - - friend inline const QCPVector2D operator*( double factor, const QCPVector2D& vec ); - friend inline const QCPVector2D operator*( const QCPVector2D& vec, double factor ); - friend inline const QCPVector2D operator/( const QCPVector2D& vec, double divisor ); - friend inline const QCPVector2D operator+( const QCPVector2D& vec1, const QCPVector2D& vec2 ); - friend inline const QCPVector2D operator-( const QCPVector2D& vec1, const QCPVector2D& vec2 ); - friend inline const QCPVector2D operator-( const QCPVector2D& vec ); + + friend inline const QCPVector2D operator*(double factor, const QCPVector2D &vec); + friend inline const QCPVector2D operator*(const QCPVector2D &vec, double factor); + friend inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor); + friend inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2); + friend inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2); + friend inline const QCPVector2D operator-(const QCPVector2D &vec); }; -Q_DECLARE_TYPEINFO( QCPVector2D, Q_MOVABLE_TYPE ); +Q_DECLARE_TYPEINFO(QCPVector2D, Q_MOVABLE_TYPE); -inline const QCPVector2D operator*( double factor, const QCPVector2D& vec ) -{ - return QCPVector2D( vec.mX * factor, vec.mY * factor ); -} -inline const QCPVector2D operator*( const QCPVector2D& vec, double factor ) -{ - return QCPVector2D( vec.mX * factor, vec.mY * factor ); -} -inline const QCPVector2D operator/( const QCPVector2D& vec, double divisor ) -{ - return QCPVector2D( vec.mX / divisor, vec.mY / divisor ); -} -inline const QCPVector2D operator+( const QCPVector2D& vec1, const QCPVector2D& vec2 ) -{ - return QCPVector2D( vec1.mX + vec2.mX, vec1.mY + vec2.mY ); -} -inline const QCPVector2D operator-( const QCPVector2D& vec1, const QCPVector2D& vec2 ) -{ - return QCPVector2D( vec1.mX - vec2.mX, vec1.mY - vec2.mY ); -} -inline const QCPVector2D operator-( const QCPVector2D& vec ) -{ - return QCPVector2D( -vec.mX, -vec.mY ); -} +inline const QCPVector2D operator*(double factor, const QCPVector2D &vec) { return QCPVector2D(vec.mX*factor, vec.mY*factor); } +inline const QCPVector2D operator*(const QCPVector2D &vec, double factor) { return QCPVector2D(vec.mX*factor, vec.mY*factor); } +inline const QCPVector2D operator/(const QCPVector2D &vec, double divisor) { return QCPVector2D(vec.mX/divisor, vec.mY/divisor); } +inline const QCPVector2D operator+(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX+vec2.mX, vec1.mY+vec2.mY); } +inline const QCPVector2D operator-(const QCPVector2D &vec1, const QCPVector2D &vec2) { return QCPVector2D(vec1.mX-vec2.mX, vec1.mY-vec2.mY); } +inline const QCPVector2D operator-(const QCPVector2D &vec) { return QCPVector2D(-vec.mX, -vec.mY); } /*! \relates QCPVector2D Prints \a vec in a human readable format to the qDebug output. */ -inline QDebug operator<<( QDebug d, const QCPVector2D& vec ) +inline QDebug operator<< (QDebug d, const QCPVector2D &vec) { - d.nospace() << "QCPVector2D(" << vec.x() << ", " << vec.y() << ")"; - return d.space(); + d.nospace() << "QCPVector2D(" << vec.x() << ", " << vec.y() << ")"; + return d.space(); } /* end of 'src/vector2d.h' */ + /* including file 'src/painter.h', size 4035 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -551,162 +461,162 @@ public: Defines special modes the painter can operate in. They disable or enable certain subsets of features/fixes/workarounds, depending on whether they are wanted on the respective output device. */ - enum PainterMode - { - pmDefault = 0x00 ///< 0x00 Default mode for painting on screen devices - , - pmVectorized = 0x01 ///< 0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes. - , - pmNoCaching = 0x02 ///< 0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels - , - pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) - }; - Q_ENUMS( PainterMode ) - Q_FLAGS( PainterModes ) - Q_DECLARE_FLAGS( PainterModes, PainterMode ) - + enum PainterMode { pmDefault = 0x00 ///< 0x00 Default mode for painting on screen devices + ,pmVectorized = 0x01 ///< 0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes. + ,pmNoCaching = 0x02 ///< 0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels + ,pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) + }; + Q_ENUMS(PainterMode) + Q_FLAGS(PainterModes) + Q_DECLARE_FLAGS(PainterModes, PainterMode) + QCPPainter(); - explicit QCPPainter( QPaintDevice* device ); - + explicit QCPPainter(QPaintDevice *device); + // getters: - bool antialiasing() const { return testRenderHint( QPainter::Antialiasing ); } + bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); } PainterModes modes() const { return mModes; } // setters: - void setAntialiasing( bool enabled ); - void setMode( PainterMode mode, bool enabled = true ); - void setModes( PainterModes modes ); + void setAntialiasing(bool enabled); + void setMode(PainterMode mode, bool enabled=true); + void setModes(PainterModes modes); // methods hiding non-virtual base class functions (QPainter bug workarounds): - bool begin( QPaintDevice* device ); - void setPen( const QPen& pen ); - void setPen( const QColor& color ); - void setPen( Qt::PenStyle penStyle ); - void drawLine( const QLineF& line ); - void drawLine( const QPointF& p1, const QPointF& p2 ) { drawLine( QLineF( p1, p2 ) ); } + bool begin(QPaintDevice *device); + void setPen(const QPen &pen); + void setPen(const QColor &color); + void setPen(Qt::PenStyle penStyle); + void drawLine(const QLineF &line); + void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));} void save(); void restore(); - + // non-virtual methods: void makeNonCosmetic(); - + protected: // property members: PainterModes mModes; bool mIsAntialiasing; - + // non-property members: QStack mAntialiasingStack; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QCPPainter::PainterModes ) -Q_DECLARE_METATYPE( QCPPainter::PainterMode ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes) +Q_DECLARE_METATYPE(QCPPainter::PainterMode) /* end of 'src/painter.h' */ + /* including file 'src/paintbuffer.h', size 4958 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ class QCP_LIB_DECL QCPAbstractPaintBuffer { public: - explicit QCPAbstractPaintBuffer( const QSize& size, double devicePixelRatio ); + explicit QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio); virtual ~QCPAbstractPaintBuffer(); - + // getters: QSize size() const { return mSize; } bool invalidated() const { return mInvalidated; } double devicePixelRatio() const { return mDevicePixelRatio; } - + // setters: - void setSize( const QSize& size ); - void setInvalidated( bool invalidated = true ); - void setDevicePixelRatio( double ratio ); - + void setSize(const QSize &size); + void setInvalidated(bool invalidated=true); + void setDevicePixelRatio(double ratio); + // introduced virtual methods: - virtual QCPPainter* startPainting() = 0; + virtual QCPPainter *startPainting() = 0; virtual void donePainting() {} - virtual void draw( QCPPainter* painter ) const = 0; - virtual void clear( const QColor& color ) = 0; - + virtual void draw(QCPPainter *painter) const = 0; + virtual void clear(const QColor &color) = 0; + protected: // property members: QSize mSize; double mDevicePixelRatio; - + // non-property members: bool mInvalidated; - + // introduced virtual methods: virtual void reallocateBuffer() = 0; }; + class QCP_LIB_DECL QCPPaintBufferPixmap : public QCPAbstractPaintBuffer { public: - explicit QCPPaintBufferPixmap( const QSize& size, double devicePixelRatio ); + explicit QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio); virtual ~QCPPaintBufferPixmap(); - + // reimplemented virtual methods: - virtual QCPPainter* startPainting() Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) const Q_DECL_OVERRIDE; - void clear( const QColor& color ) Q_DECL_OVERRIDE; - + virtual QCPPainter *startPainting() Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE; + void clear(const QColor &color) Q_DECL_OVERRIDE; + protected: // non-property members: QPixmap mBuffer; - + // reimplemented virtual methods: virtual void reallocateBuffer() Q_DECL_OVERRIDE; }; + #ifdef QCP_OPENGL_PBUFFER class QCP_LIB_DECL QCPPaintBufferGlPbuffer : public QCPAbstractPaintBuffer { public: - explicit QCPPaintBufferGlPbuffer( const QSize& size, double devicePixelRatio, int multisamples ); + explicit QCPPaintBufferGlPbuffer(const QSize &size, double devicePixelRatio, int multisamples); virtual ~QCPPaintBufferGlPbuffer(); - + // reimplemented virtual methods: - virtual QCPPainter* startPainting() Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) const Q_DECL_OVERRIDE; - void clear( const QColor& color ) Q_DECL_OVERRIDE; - + virtual QCPPainter *startPainting() Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE; + void clear(const QColor &color) Q_DECL_OVERRIDE; + protected: // non-property members: - QGLPixelBuffer* mGlPBuffer; + QGLPixelBuffer *mGlPBuffer; int mMultisamples; - + // reimplemented virtual methods: virtual void reallocateBuffer() Q_DECL_OVERRIDE; }; -#endif // QCP_OPENGL_PBUFFER +#endif // QCP_OPENGL_PBUFFER + #ifdef QCP_OPENGL_FBO class QCP_LIB_DECL QCPPaintBufferGlFbo : public QCPAbstractPaintBuffer { public: - explicit QCPPaintBufferGlFbo( const QSize& size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice ); + explicit QCPPaintBufferGlFbo(const QSize &size, double devicePixelRatio, QWeakPointer glContext, QWeakPointer glPaintDevice); virtual ~QCPPaintBufferGlFbo(); - + // reimplemented virtual methods: - virtual QCPPainter* startPainting() Q_DECL_OVERRIDE; + virtual QCPPainter *startPainting() Q_DECL_OVERRIDE; virtual void donePainting() Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) const Q_DECL_OVERRIDE; - void clear( const QColor& color ) Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE; + void clear(const QColor &color) Q_DECL_OVERRIDE; + protected: // non-property members: QWeakPointer mGlContext; QWeakPointer mGlPaintDevice; - QOpenGLFramebufferObject* mGlFrameBuffer; - + QOpenGLFramebufferObject *mGlFrameBuffer; + // reimplemented virtual methods: virtual void reallocateBuffer() Q_DECL_OVERRIDE; }; -#endif // QCP_OPENGL_FBO +#endif // QCP_OPENGL_FBO /* end of 'src/paintbuffer.h' */ + /* including file 'src/layer.h', size 6885 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -714,14 +624,15 @@ class QCP_LIB_DECL QCPLayer : public QObject { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCustomPlot* parentPlot READ parentPlot ) - Q_PROPERTY( QString name READ name ) - Q_PROPERTY( int index READ index ) - Q_PROPERTY( QList children READ children ) - Q_PROPERTY( bool visible READ visible WRITE setVisible ) - Q_PROPERTY( LayerMode mode READ mode WRITE setMode ) + Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot) + Q_PROPERTY(QString name READ name) + Q_PROPERTY(int index READ index) + Q_PROPERTY(QList children READ children) + Q_PROPERTY(bool visible READ visible WRITE setVisible) + Q_PROPERTY(LayerMode mode READ mode WRITE setMode) /// \endcond public: + /*! Defines the different rendering modes of a layer. Depending on the mode, certain layers can be replotted individually, without the need to replot (possibly complex) layerables on other @@ -729,127 +640,124 @@ public: \see setMode */ - enum LayerMode - { - lmLogical ///< Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layers. - , - lmBuffered ///< Layer has its own paint buffer and may be replotted individually (see \ref replot). - }; - Q_ENUMS( LayerMode ) - - QCPLayer( QCustomPlot* parentPlot, const QString& layerName ); + enum LayerMode { lmLogical ///< Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layers. + ,lmBuffered ///< Layer has its own paint buffer and may be replotted individually (see \ref replot). + }; + Q_ENUMS(LayerMode) + + QCPLayer(QCustomPlot* parentPlot, const QString &layerName); virtual ~QCPLayer(); - + // getters: - QCustomPlot* parentPlot() const { return mParentPlot; } + QCustomPlot *parentPlot() const { return mParentPlot; } QString name() const { return mName; } int index() const { return mIndex; } QList children() const { return mChildren; } bool visible() const { return mVisible; } LayerMode mode() const { return mMode; } - + // setters: - void setVisible( bool visible ); - void setMode( LayerMode mode ); - + void setVisible(bool visible); + void setMode(LayerMode mode); + // non-virtual methods: void replot(); - + protected: // property members: - QCustomPlot* mParentPlot; + QCustomPlot *mParentPlot; QString mName; int mIndex; QList mChildren; bool mVisible; LayerMode mMode; - + // non-property members: QWeakPointer mPaintBuffer; - + // non-virtual methods: - void draw( QCPPainter* painter ); + void draw(QCPPainter *painter); void drawToPaintBuffer(); - void addChild( QCPLayerable* layerable, bool prepend ); - void removeChild( QCPLayerable* layerable ); - + void addChild(QCPLayerable *layerable, bool prepend); + void removeChild(QCPLayerable *layerable); + private: - Q_DISABLE_COPY( QCPLayer ) - + Q_DISABLE_COPY(QCPLayer) + friend class QCustomPlot; friend class QCPLayerable; }; -Q_DECLARE_METATYPE( QCPLayer::LayerMode ) +Q_DECLARE_METATYPE(QCPLayer::LayerMode) class QCP_LIB_DECL QCPLayerable : public QObject { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( bool visible READ visible WRITE setVisible ) - Q_PROPERTY( QCustomPlot* parentPlot READ parentPlot ) - Q_PROPERTY( QCPLayerable* parentLayerable READ parentLayerable ) - Q_PROPERTY( QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged ) - Q_PROPERTY( bool antialiased READ antialiased WRITE setAntialiased ) + Q_PROPERTY(bool visible READ visible WRITE setVisible) + Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot) + Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable) + Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged) + Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased) /// \endcond public: - QCPLayerable( QCustomPlot* plot, QString targetLayer = QString(), QCPLayerable* parentLayerable = 0 ); + QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0); virtual ~QCPLayerable(); - + // getters: bool visible() const { return mVisible; } - QCustomPlot* parentPlot() const { return mParentPlot; } - QCPLayerable* parentLayerable() const { return mParentLayerable.data(); } - QCPLayer* layer() const { return mLayer; } + QCustomPlot *parentPlot() const { return mParentPlot; } + QCPLayerable *parentLayerable() const { return mParentLayerable.data(); } + QCPLayer *layer() const { return mLayer; } bool antialiased() const { return mAntialiased; } - + // setters: - void setVisible( bool on ); - Q_SLOT bool setLayer( QCPLayer* layer ); - bool setLayer( const QString& layerName ); - void setAntialiased( bool enabled ); - + void setVisible(bool on); + Q_SLOT bool setLayer(QCPLayer *layer); + bool setLayer(const QString &layerName); + void setAntialiased(bool enabled); + // introduced virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; // non-property methods: bool realVisibility() const; - + signals: - void layerChanged( QCPLayer* newLayer ); - + void layerChanged(QCPLayer *newLayer); + protected: // property members: bool mVisible; - QCustomPlot* mParentPlot; + QCustomPlot *mParentPlot; QPointer mParentLayerable; - QCPLayer* mLayer; + QCPLayer *mLayer; bool mAntialiased; - + // introduced virtual methods: - virtual void parentPlotInitialized( QCustomPlot* parentPlot ); + virtual void parentPlotInitialized(QCustomPlot *parentPlot); virtual QCP::Interaction selectionCategory() const; virtual QRect clipRect() const; - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const = 0; - virtual void draw( QCPPainter* painter ) = 0; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0; + virtual void draw(QCPPainter *painter) = 0; // selection events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ); - virtual void deselectEvent( bool* selectionStateChanged ); + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); // low-level mouse events: - virtual void mousePressEvent( QMouseEvent* event, const QVariant& details ); - virtual void mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ); - virtual void mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ); - virtual void mouseDoubleClickEvent( QMouseEvent* event, const QVariant& details ); - virtual void wheelEvent( QWheelEvent* event ); - + virtual void mousePressEvent(QMouseEvent *event, const QVariant &details); + virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos); + virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos); + virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details); + virtual void wheelEvent(QWheelEvent *event); + // non-property methods: - void initializeParentPlot( QCustomPlot* parentPlot ); - void setParentLayerable( QCPLayerable* parentLayerable ); - bool moveToLayer( QCPLayer* layer, bool prepend ); - void applyAntialiasingHint( QCPPainter* painter, bool localAntialiased, QCP::AntialiasedElement overrideElement ) const; - + void initializeParentPlot(QCustomPlot *parentPlot); + void setParentLayerable(QCPLayerable* parentLayerable); + bool moveToLayer(QCPLayer *layer, bool prepend); + void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const; + private: - Q_DISABLE_COPY( QCPLayerable ) - + Q_DISABLE_COPY(QCPLayerable) + friend class QCustomPlot; friend class QCPLayer; friend class QCPAxisRect; @@ -857,6 +765,7 @@ private: /* end of 'src/layer.h' */ + /* including file 'src/axis/range.h', size 5280 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -864,83 +773,60 @@ class QCP_LIB_DECL QCPRange { public: double lower, upper; - + QCPRange(); - QCPRange( double lower, double upper ); - - bool operator==( const QCPRange& other ) const { return lower == other.lower && upper == other.upper; } - bool operator!=( const QCPRange& other ) const { return !( *this == other ); } - - QCPRange& operator+=( const double& value ) - { - lower += value; - upper += value; - return *this; - } - QCPRange& operator-=( const double& value ) - { - lower -= value; - upper -= value; - return *this; - } - QCPRange& operator*=( const double& value ) - { - lower *= value; - upper *= value; - return *this; - } - QCPRange& operator/=( const double& value ) - { - lower /= value; - upper /= value; - return *this; - } - friend inline const QCPRange operator+( const QCPRange&, double ); - friend inline const QCPRange operator+( double, const QCPRange& ); - friend inline const QCPRange operator-( const QCPRange& range, double value ); - friend inline const QCPRange operator*( const QCPRange& range, double value ); - friend inline const QCPRange operator*( double value, const QCPRange& range ); - friend inline const QCPRange operator/( const QCPRange& range, double value ); - - double size() const { return upper - lower; } - double center() const { return ( upper + lower ) * 0.5; } - void normalize() - { - if( lower > upper ) - qSwap( lower, upper ); - } - void expand( const QCPRange& otherRange ); - void expand( double includeCoord ); - QCPRange expanded( const QCPRange& otherRange ) const; - QCPRange expanded( double includeCoord ) const; - QCPRange bounded( double lowerBound, double upperBound ) const; + QCPRange(double lower, double upper); + + bool operator==(const QCPRange& other) const { return lower == other.lower && upper == other.upper; } + bool operator!=(const QCPRange& other) const { return !(*this == other); } + + QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; } + QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; } + QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; } + QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; } + friend inline const QCPRange operator+(const QCPRange&, double); + friend inline const QCPRange operator+(double, const QCPRange&); + friend inline const QCPRange operator-(const QCPRange& range, double value); + friend inline const QCPRange operator*(const QCPRange& range, double value); + friend inline const QCPRange operator*(double value, const QCPRange& range); + friend inline const QCPRange operator/(const QCPRange& range, double value); + + double size() const { return upper-lower; } + double center() const { return (upper+lower)*0.5; } + void normalize() { if (lower > upper) qSwap(lower, upper); } + void expand(const QCPRange &otherRange); + void expand(double includeCoord); + QCPRange expanded(const QCPRange &otherRange) const; + QCPRange expanded(double includeCoord) const; + QCPRange bounded(double lowerBound, double upperBound) const; QCPRange sanitizedForLogScale() const; QCPRange sanitizedForLinScale() const; - bool contains( double value ) const { return value >= lower && value <= upper; } - - static bool validRange( double lower, double upper ); - static bool validRange( const QCPRange& range ); + bool contains(double value) const { return value >= lower && value <= upper; } + + static bool validRange(double lower, double upper); + static bool validRange(const QCPRange &range); static const double minRange; static const double maxRange; + }; -Q_DECLARE_TYPEINFO( QCPRange, Q_MOVABLE_TYPE ); +Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE); /*! \relates QCPRange Prints \a range in a human readable format to the qDebug output. */ -inline QDebug operator<<( QDebug d, const QCPRange& range ) +inline QDebug operator<< (QDebug d, const QCPRange &range) { - d.nospace() << "QCPRange(" << range.lower << ", " << range.upper << ")"; - return d.space(); + d.nospace() << "QCPRange(" << range.lower << ", " << range.upper << ")"; + return d.space(); } /*! Adds \a value to both boundaries of the range. */ -inline const QCPRange operator+( const QCPRange& range, double value ) +inline const QCPRange operator+(const QCPRange& range, double value) { - QCPRange result( range ); + QCPRange result(range); result += value; return result; } @@ -948,9 +834,9 @@ inline const QCPRange operator+( const QCPRange& range, double value ) /*! Adds \a value to both boundaries of the range. */ -inline const QCPRange operator+( double value, const QCPRange& range ) +inline const QCPRange operator+(double value, const QCPRange& range) { - QCPRange result( range ); + QCPRange result(range); result += value; return result; } @@ -958,9 +844,9 @@ inline const QCPRange operator+( double value, const QCPRange& range ) /*! Subtracts \a value from both boundaries of the range. */ -inline const QCPRange operator-( const QCPRange& range, double value ) +inline const QCPRange operator-(const QCPRange& range, double value) { - QCPRange result( range ); + QCPRange result(range); result -= value; return result; } @@ -968,9 +854,9 @@ inline const QCPRange operator-( const QCPRange& range, double value ) /*! Multiplies both boundaries of the range by \a value. */ -inline const QCPRange operator*( const QCPRange& range, double value ) +inline const QCPRange operator*(const QCPRange& range, double value) { - QCPRange result( range ); + QCPRange result(range); result *= value; return result; } @@ -978,9 +864,9 @@ inline const QCPRange operator*( const QCPRange& range, double value ) /*! Multiplies both boundaries of the range by \a value. */ -inline const QCPRange operator*( double value, const QCPRange& range ) +inline const QCPRange operator*(double value, const QCPRange& range) { - QCPRange result( range ); + QCPRange result(range); result *= value; return result; } @@ -988,15 +874,16 @@ inline const QCPRange operator*( double value, const QCPRange& range ) /*! Divides both boundaries of the range by \a value. */ -inline const QCPRange operator/( const QCPRange& range, double value ) +inline const QCPRange operator/(const QCPRange& range, double value) { - QCPRange result( range ); + QCPRange result(range); result /= value; return result; } /* end of 'src/axis/range.h' */ + /* including file 'src/selection.h', size 8579 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1004,91 +891,94 @@ class QCP_LIB_DECL QCPDataRange { public: QCPDataRange(); - QCPDataRange( int begin, int end ); - - bool operator==( const QCPDataRange& other ) const { return mBegin == other.mBegin && mEnd == other.mEnd; } - bool operator!=( const QCPDataRange& other ) const { return !( *this == other ); } - + QCPDataRange(int begin, int end); + + bool operator==(const QCPDataRange& other) const { return mBegin == other.mBegin && mEnd == other.mEnd; } + bool operator!=(const QCPDataRange& other) const { return !(*this == other); } + // getters: int begin() const { return mBegin; } int end() const { return mEnd; } - int size() const { return mEnd - mBegin; } + int size() const { return mEnd-mBegin; } int length() const { return size(); } - + // setters: - void setBegin( int begin ) { mBegin = begin; } - void setEnd( int end ) { mEnd = end; } - + void setBegin(int begin) { mBegin = begin; } + void setEnd(int end) { mEnd = end; } + // non-property methods: - bool isValid() const { return ( mEnd >= mBegin ) && ( mBegin >= 0 ); } + bool isValid() const { return (mEnd >= mBegin) && (mBegin >= 0); } bool isEmpty() const { return length() == 0; } - QCPDataRange bounded( const QCPDataRange& other ) const; - QCPDataRange expanded( const QCPDataRange& other ) const; - QCPDataRange intersection( const QCPDataRange& other ) const; - QCPDataRange adjusted( int changeBegin, int changeEnd ) const { return QCPDataRange( mBegin + changeBegin, mEnd + changeEnd ); } - bool intersects( const QCPDataRange& other ) const; - bool contains( const QCPDataRange& other ) const; - + QCPDataRange bounded(const QCPDataRange &other) const; + QCPDataRange expanded(const QCPDataRange &other) const; + QCPDataRange intersection(const QCPDataRange &other) const; + QCPDataRange adjusted(int changeBegin, int changeEnd) const { return QCPDataRange(mBegin+changeBegin, mEnd+changeEnd); } + bool intersects(const QCPDataRange &other) const; + bool contains(const QCPDataRange &other) const; + private: // property members: int mBegin, mEnd; + }; -Q_DECLARE_TYPEINFO( QCPDataRange, Q_MOVABLE_TYPE ); +Q_DECLARE_TYPEINFO(QCPDataRange, Q_MOVABLE_TYPE); + class QCP_LIB_DECL QCPDataSelection { public: explicit QCPDataSelection(); - explicit QCPDataSelection( const QCPDataRange& range ); - - bool operator==( const QCPDataSelection& other ) const; - bool operator!=( const QCPDataSelection& other ) const { return !( *this == other ); } - QCPDataSelection& operator+=( const QCPDataSelection& other ); - QCPDataSelection& operator+=( const QCPDataRange& other ); - QCPDataSelection& operator-=( const QCPDataSelection& other ); - QCPDataSelection& operator-=( const QCPDataRange& other ); - friend inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDataSelection& b ); - friend inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataSelection& b ); - friend inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDataRange& b ); - friend inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataRange& b ); - friend inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDataSelection& b ); - friend inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataSelection& b ); - friend inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDataRange& b ); - friend inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataRange& b ); - + explicit QCPDataSelection(const QCPDataRange &range); + + bool operator==(const QCPDataSelection& other) const; + bool operator!=(const QCPDataSelection& other) const { return !(*this == other); } + QCPDataSelection &operator+=(const QCPDataSelection& other); + QCPDataSelection &operator+=(const QCPDataRange& other); + QCPDataSelection &operator-=(const QCPDataSelection& other); + QCPDataSelection &operator-=(const QCPDataRange& other); + friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b); + friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b); + friend inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b); + friend inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b); + friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b); + friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b); + friend inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b); + friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b); + // getters: int dataRangeCount() const { return mDataRanges.size(); } int dataPointCount() const; - QCPDataRange dataRange( int index = 0 ) const; + QCPDataRange dataRange(int index=0) const; QList dataRanges() const { return mDataRanges; } QCPDataRange span() const; - + // non-property methods: - void addDataRange( const QCPDataRange& dataRange, bool simplify = true ); + void addDataRange(const QCPDataRange &dataRange, bool simplify=true); void clear(); bool isEmpty() const { return mDataRanges.isEmpty(); } void simplify(); - void enforceType( QCP::SelectionType type ); - bool contains( const QCPDataSelection& other ) const; - QCPDataSelection intersection( const QCPDataRange& other ) const; - QCPDataSelection intersection( const QCPDataSelection& other ) const; - QCPDataSelection inverse( const QCPDataRange& outerRange ) const; - + void enforceType(QCP::SelectionType type); + bool contains(const QCPDataSelection &other) const; + QCPDataSelection intersection(const QCPDataRange &other) const; + QCPDataSelection intersection(const QCPDataSelection &other) const; + QCPDataSelection inverse(const QCPDataRange &outerRange) const; + private: // property members: QList mDataRanges; - - inline static bool lessThanDataRangeBegin( const QCPDataRange& a, const QCPDataRange& b ) { return a.begin() < b.begin(); } + + inline static bool lessThanDataRangeBegin(const QCPDataRange &a, const QCPDataRange &b) { return a.begin() < b.begin(); } }; -Q_DECLARE_METATYPE( QCPDataSelection ) +Q_DECLARE_METATYPE(QCPDataSelection) + /*! Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b. The resulting data selection is already simplified (see \ref QCPDataSelection::simplify). */ -inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDataSelection& b ) +inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataSelection& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result += b; return result; } @@ -1097,9 +987,9 @@ inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDat Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b. The resulting data selection is already simplified (see \ref QCPDataSelection::simplify). */ -inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataSelection& b ) +inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataSelection& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result += b; return result; } @@ -1108,9 +998,9 @@ inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataSel Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b. The resulting data selection is already simplified (see \ref QCPDataSelection::simplify). */ -inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDataRange& b ) +inline const QCPDataSelection operator+(const QCPDataSelection& a, const QCPDataRange& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result += b; return result; } @@ -1119,9 +1009,9 @@ inline const QCPDataSelection operator+( const QCPDataSelection& a, const QCPDat Return a \ref QCPDataSelection with the data points in \a a joined with the data points in \a b. The resulting data selection is already simplified (see \ref QCPDataSelection::simplify). */ -inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataRange& b ) +inline const QCPDataSelection operator+(const QCPDataRange& a, const QCPDataRange& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result += b; return result; } @@ -1129,9 +1019,9 @@ inline const QCPDataSelection operator+( const QCPDataRange& a, const QCPDataRan /*! Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b. */ -inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDataSelection& b ) +inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataSelection& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result -= b; return result; } @@ -1139,9 +1029,9 @@ inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDat /*! Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b. */ -inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataSelection& b ) +inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataSelection& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result -= b; return result; } @@ -1149,9 +1039,9 @@ inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataSel /*! Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b. */ -inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDataRange& b ) +inline const QCPDataSelection operator-(const QCPDataSelection& a, const QCPDataRange& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result -= b; return result; } @@ -1159,9 +1049,9 @@ inline const QCPDataSelection operator-( const QCPDataSelection& a, const QCPDat /*! Return a \ref QCPDataSelection with the data points which are in \a a but not in \a b. */ -inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataRange& b ) +inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b) { - QCPDataSelection result( a ); + QCPDataSelection result(a); result -= b; return result; } @@ -1170,31 +1060,34 @@ inline const QCPDataSelection operator-( const QCPDataRange& a, const QCPDataRan Prints \a dataRange in a human readable format to the qDebug output. */ -inline QDebug operator<<( QDebug d, const QCPDataRange& dataRange ) +inline QDebug operator<< (QDebug d, const QCPDataRange &dataRange) { - d.nospace() << "[" << dataRange.begin() << ".." << dataRange.end() - 1 << "]"; - return d.space(); + d.nospace() << "[" << dataRange.begin() << ".." << dataRange.end()-1 << "]"; + return d.space(); } /*! \relates QCPDataSelection Prints \a selection in a human readable format to the qDebug output. */ -inline QDebug operator<<( QDebug d, const QCPDataSelection& selection ) +inline QDebug operator<< (QDebug d, const QCPDataSelection &selection) { - d.nospace() << "QCPDataSelection("; - for( int i = 0; i < selection.dataRangeCount(); ++i ) - { - if( i != 0 ) - d << ", "; - d << selection.dataRange( i ); - } - d << ")"; - return d.space(); + d.nospace() << "QCPDataSelection("; + for (int i=0; i elements( QCP::MarginSide side ) const { return mChildren.value( side ); } + QList elements(QCP::MarginSide side) const { return mChildren.value(side); } bool isEmpty() const; void clear(); - + protected: // non-property members: - QCustomPlot* mParentPlot; + QCustomPlot *mParentPlot; QHash > mChildren; - + // introduced virtual methods: - virtual int commonMargin( QCP::MarginSide side ) const; - + virtual int commonMargin(QCP::MarginSide side) const; + // non-virtual methods: - void addChild( QCP::MarginSide side, QCPLayoutElement* element ); - void removeChild( QCP::MarginSide side, QCPLayoutElement* element ); - + void addChild(QCP::MarginSide side, QCPLayoutElement *element); + void removeChild(QCP::MarginSide side, QCPLayoutElement *element); + private: - Q_DISABLE_COPY( QCPMarginGroup ) - + Q_DISABLE_COPY(QCPMarginGroup) + friend class QCPLayoutElement; }; + class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCPLayout* layout READ layout ) - Q_PROPERTY( QRect rect READ rect ) - Q_PROPERTY( QRect outerRect READ outerRect WRITE setOuterRect ) - Q_PROPERTY( QMargins margins READ margins WRITE setMargins ) - Q_PROPERTY( QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins ) - Q_PROPERTY( QSize minimumSize READ minimumSize WRITE setMinimumSize ) - Q_PROPERTY( QSize maximumSize READ maximumSize WRITE setMaximumSize ) - Q_PROPERTY( SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE setSizeConstraintRect ) + Q_PROPERTY(QCPLayout* layout READ layout) + Q_PROPERTY(QRect rect READ rect) + Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect) + Q_PROPERTY(QMargins margins READ margins WRITE setMargins) + Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins) + Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize) + Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize) + Q_PROPERTY(SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE setSizeConstraintRect) /// \endcond public: /*! Defines the phases of the update process, that happens just before a replot. At each phase, \ref update is called with the according UpdatePhase value. */ - enum UpdatePhase - { - upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout - , - upMargins ///< Phase in which the margins are calculated and set - , - upLayout ///< Final phase in which the layout system places the rects of the elements - }; - Q_ENUMS( UpdatePhase ) - + enum UpdatePhase { upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout + ,upMargins ///< Phase in which the margins are calculated and set + ,upLayout ///< Final phase in which the layout system places the rects of the elements + }; + Q_ENUMS(UpdatePhase) + /*! Defines to which rect of a layout element the size constraints that can be set via \ref setMinimumSize and \ref setMaximumSize apply. The outer rect (\ref outerRect) includes the @@ -1317,19 +1208,16 @@ public: \see setSizeConstraintRect */ - enum SizeConstraintRect - { - scrInnerRect ///< Minimum/Maximum size constraints apply to inner rect - , - scrOuterRect ///< Minimum/Maximum size constraints apply to outer rect, thus include layout element margins - }; - Q_ENUMS( SizeConstraintRect ) + enum SizeConstraintRect { scrInnerRect ///< Minimum/Maximum size constraints apply to inner rect + , scrOuterRect ///< Minimum/Maximum size constraints apply to outer rect, thus include layout element margins + }; + Q_ENUMS(SizeConstraintRect) - explicit QCPLayoutElement( QCustomPlot* parentPlot = 0 ); + explicit QCPLayoutElement(QCustomPlot *parentPlot=0); virtual ~QCPLayoutElement(); - + // getters: - QCPLayout* layout() const { return mParentLayout; } + QCPLayout *layout() const { return mParentLayout; } QRect rect() const { return mRect; } QRect outerRect() const { return mOuterRect; } QMargins margins() const { return mMargins; } @@ -1338,111 +1226,114 @@ public: QSize minimumSize() const { return mMinimumSize; } QSize maximumSize() const { return mMaximumSize; } SizeConstraintRect sizeConstraintRect() const { return mSizeConstraintRect; } - QCPMarginGroup* marginGroup( QCP::MarginSide side ) const { return mMarginGroups.value( side, (QCPMarginGroup*)0 ); } + QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); } QHash marginGroups() const { return mMarginGroups; } - + // setters: - void setOuterRect( const QRect& rect ); - void setMargins( const QMargins& margins ); - void setMinimumMargins( const QMargins& margins ); - void setAutoMargins( QCP::MarginSides sides ); - void setMinimumSize( const QSize& size ); - void setMinimumSize( int width, int height ); - void setMaximumSize( const QSize& size ); - void setMaximumSize( int width, int height ); - void setSizeConstraintRect( SizeConstraintRect constraintRect ); - void setMarginGroup( QCP::MarginSides sides, QCPMarginGroup* group ); - + void setOuterRect(const QRect &rect); + void setMargins(const QMargins &margins); + void setMinimumMargins(const QMargins &margins); + void setAutoMargins(QCP::MarginSides sides); + void setMinimumSize(const QSize &size); + void setMinimumSize(int width, int height); + void setMaximumSize(const QSize &size); + void setMaximumSize(int width, int height); + void setSizeConstraintRect(SizeConstraintRect constraintRect); + void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group); + // introduced virtual methods: - virtual void update( UpdatePhase phase ); + virtual void update(UpdatePhase phase); virtual QSize minimumOuterSizeHint() const; virtual QSize maximumOuterSizeHint() const; - virtual QList elements( bool recursive ) const; - + virtual QList elements(bool recursive) const; + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + protected: // property members: - QCPLayout* mParentLayout; + QCPLayout *mParentLayout; QSize mMinimumSize, mMaximumSize; SizeConstraintRect mSizeConstraintRect; QRect mRect, mOuterRect; QMargins mMargins, mMinimumMargins; QCP::MarginSides mAutoMargins; QHash mMarginGroups; - + // introduced virtual methods: - virtual int calculateAutoMargin( QCP::MarginSide side ); + virtual int calculateAutoMargin(QCP::MarginSide side); virtual void layoutChanged(); - + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE { Q_UNUSED( painter ) } - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE { Q_UNUSED( painter ) } - virtual void parentPlotInitialized( QCustomPlot* parentPlot ) Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE { Q_UNUSED(painter) } + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE { Q_UNUSED(painter) } + virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY( QCPLayoutElement ) - + Q_DISABLE_COPY(QCPLayoutElement) + friend class QCustomPlot; friend class QCPLayout; friend class QCPMarginGroup; }; -Q_DECLARE_METATYPE( QCPLayoutElement::UpdatePhase ) +Q_DECLARE_METATYPE(QCPLayoutElement::UpdatePhase) + class QCP_LIB_DECL QCPLayout : public QCPLayoutElement { Q_OBJECT public: explicit QCPLayout(); - + // reimplemented virtual methods: - virtual void update( UpdatePhase phase ) Q_DECL_OVERRIDE; - virtual QList elements( bool recursive ) const Q_DECL_OVERRIDE; - + virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE; + virtual QList elements(bool recursive) const Q_DECL_OVERRIDE; + // introduced virtual methods: virtual int elementCount() const = 0; - virtual QCPLayoutElement* elementAt( int index ) const = 0; - virtual QCPLayoutElement* takeAt( int index ) = 0; - virtual bool take( QCPLayoutElement* element ) = 0; + virtual QCPLayoutElement* elementAt(int index) const = 0; + virtual QCPLayoutElement* takeAt(int index) = 0; + virtual bool take(QCPLayoutElement* element) = 0; virtual void simplify(); - + // non-virtual methods: - bool removeAt( int index ); - bool remove( QCPLayoutElement* element ); + bool removeAt(int index); + bool remove(QCPLayoutElement* element); void clear(); - + protected: // introduced virtual methods: virtual void updateLayout(); - + // non-virtual methods: void sizeConstraintsChanged() const; - void adoptElement( QCPLayoutElement* el ); - void releaseElement( QCPLayoutElement* el ); - QVector getSectionSizes( QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize ) const; - static QSize getFinalMinimumOuterSize( const QCPLayoutElement* el ); - static QSize getFinalMaximumOuterSize( const QCPLayoutElement* el ); - + void adoptElement(QCPLayoutElement *el); + void releaseElement(QCPLayoutElement *el); + QVector getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const; + static QSize getFinalMinimumOuterSize(const QCPLayoutElement *el); + static QSize getFinalMaximumOuterSize(const QCPLayoutElement *el); + private: - Q_DISABLE_COPY( QCPLayout ) + Q_DISABLE_COPY(QCPLayout) friend class QCPLayoutElement; }; + class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( int rowCount READ rowCount ) - Q_PROPERTY( int columnCount READ columnCount ) - Q_PROPERTY( QList columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors ) - Q_PROPERTY( QList rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors ) - Q_PROPERTY( int columnSpacing READ columnSpacing WRITE setColumnSpacing ) - Q_PROPERTY( int rowSpacing READ rowSpacing WRITE setRowSpacing ) - Q_PROPERTY( FillOrder fillOrder READ fillOrder WRITE setFillOrder ) - Q_PROPERTY( int wrap READ wrap WRITE setWrap ) + Q_PROPERTY(int rowCount READ rowCount) + Q_PROPERTY(int columnCount READ columnCount) + Q_PROPERTY(QList columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors) + Q_PROPERTY(QList rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors) + Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) + Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) + Q_PROPERTY(FillOrder fillOrder READ fillOrder WRITE setFillOrder) + Q_PROPERTY(int wrap READ wrap WRITE setWrap) /// \endcond public: + /*! Defines in which direction the grid is filled when using \ref addElement(QCPLayoutElement*). The column/row at which wrapping into the next row/column occurs can be specified with \ref @@ -1450,17 +1341,14 @@ public: \see setFillOrder */ - enum FillOrder - { - foRowsFirst ///< Rows are filled first, and a new element is wrapped to the next column if the row count would exceed \ref setWrap. - , - foColumnsFirst ///< Columns are filled first, and a new element is wrapped to the next row if the column count would exceed \ref setWrap. - }; - Q_ENUMS( FillOrder ) - + enum FillOrder { foRowsFirst ///< Rows are filled first, and a new element is wrapped to the next column if the row count would exceed \ref setWrap. + ,foColumnsFirst ///< Columns are filled first, and a new element is wrapped to the next row if the column count would exceed \ref setWrap. + }; + Q_ENUMS(FillOrder) + explicit QCPLayoutGrid(); virtual ~QCPLayoutGrid(); - + // getters: int rowCount() const { return mElements.size(); } int columnCount() const { return mElements.size() > 0 ? mElements.first().size() : 0; } @@ -1470,39 +1358,39 @@ public: int rowSpacing() const { return mRowSpacing; } int wrap() const { return mWrap; } FillOrder fillOrder() const { return mFillOrder; } - + // setters: - void setColumnStretchFactor( int column, double factor ); - void setColumnStretchFactors( const QList& factors ); - void setRowStretchFactor( int row, double factor ); - void setRowStretchFactors( const QList& factors ); - void setColumnSpacing( int pixels ); - void setRowSpacing( int pixels ); - void setWrap( int count ); - void setFillOrder( FillOrder order, bool rearrange = true ); - + void setColumnStretchFactor(int column, double factor); + void setColumnStretchFactors(const QList &factors); + void setRowStretchFactor(int row, double factor); + void setRowStretchFactors(const QList &factors); + void setColumnSpacing(int pixels); + void setRowSpacing(int pixels); + void setWrap(int count); + void setFillOrder(FillOrder order, bool rearrange=true); + // reimplemented virtual methods: virtual void updateLayout() Q_DECL_OVERRIDE; - virtual int elementCount() const Q_DECL_OVERRIDE { return rowCount() * columnCount(); } - virtual QCPLayoutElement* elementAt( int index ) const Q_DECL_OVERRIDE; - virtual QCPLayoutElement* takeAt( int index ) Q_DECL_OVERRIDE; - virtual bool take( QCPLayoutElement* element ) Q_DECL_OVERRIDE; - virtual QList elements( bool recursive ) const Q_DECL_OVERRIDE; + virtual int elementCount() const Q_DECL_OVERRIDE { return rowCount()*columnCount(); } + virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE; + virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE; + virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE; + virtual QList elements(bool recursive) const Q_DECL_OVERRIDE; virtual void simplify() Q_DECL_OVERRIDE; virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE; virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE; - + // non-virtual methods: - QCPLayoutElement* element( int row, int column ) const; - bool addElement( int row, int column, QCPLayoutElement* element ); - bool addElement( QCPLayoutElement* element ); - bool hasElement( int row, int column ); - void expandTo( int newRowCount, int newColumnCount ); - void insertRow( int newIndex ); - void insertColumn( int newIndex ); - int rowColToIndex( int row, int column ) const; - void indexToRowCol( int index, int& row, int& column ) const; - + QCPLayoutElement *element(int row, int column) const; + bool addElement(int row, int column, QCPLayoutElement *element); + bool addElement(QCPLayoutElement *element); + bool hasElement(int row, int column); + void expandTo(int newRowCount, int newColumnCount); + void insertRow(int newIndex); + void insertColumn(int newIndex); + int rowColToIndex(int row, int column) const; + void indexToRowCol(int index, int &row, int &column) const; + protected: // property members: QList > mElements; @@ -1511,15 +1399,16 @@ protected: int mColumnSpacing, mRowSpacing; int mWrap; FillOrder mFillOrder; - + // non-virtual methods: - void getMinimumRowColSizes( QVector* minColWidths, QVector* minRowHeights ) const; - void getMaximumRowColSizes( QVector* maxColWidths, QVector* maxRowHeights ) const; - + void getMinimumRowColSizes(QVector *minColWidths, QVector *minRowHeights) const; + void getMaximumRowColSizes(QVector *maxColWidths, QVector *maxRowHeights) const; + private: - Q_DISABLE_COPY( QCPLayoutGrid ) + Q_DISABLE_COPY(QCPLayoutGrid) }; -Q_DECLARE_METATYPE( QCPLayoutGrid::FillOrder ) +Q_DECLARE_METATYPE(QCPLayoutGrid::FillOrder) + class QCP_LIB_DECL QCPLayoutInset : public QCPLayout { @@ -1528,54 +1417,52 @@ public: /*! Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset. */ - enum InsetPlacement - { - ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect - , - ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment - }; - Q_ENUMS( InsetPlacement ) - + enum InsetPlacement { ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect + ,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment + }; + Q_ENUMS(InsetPlacement) + explicit QCPLayoutInset(); virtual ~QCPLayoutInset(); - + // getters: - InsetPlacement insetPlacement( int index ) const; - Qt::Alignment insetAlignment( int index ) const; - QRectF insetRect( int index ) const; - + InsetPlacement insetPlacement(int index) const; + Qt::Alignment insetAlignment(int index) const; + QRectF insetRect(int index) const; + // setters: - void setInsetPlacement( int index, InsetPlacement placement ); - void setInsetAlignment( int index, Qt::Alignment alignment ); - void setInsetRect( int index, const QRectF& rect ); - + void setInsetPlacement(int index, InsetPlacement placement); + void setInsetAlignment(int index, Qt::Alignment alignment); + void setInsetRect(int index, const QRectF &rect); + // reimplemented virtual methods: virtual void updateLayout() Q_DECL_OVERRIDE; virtual int elementCount() const Q_DECL_OVERRIDE; - virtual QCPLayoutElement* elementAt( int index ) const Q_DECL_OVERRIDE; - virtual QCPLayoutElement* takeAt( int index ) Q_DECL_OVERRIDE; - virtual bool take( QCPLayoutElement* element ) Q_DECL_OVERRIDE; + virtual QCPLayoutElement* elementAt(int index) const Q_DECL_OVERRIDE; + virtual QCPLayoutElement* takeAt(int index) Q_DECL_OVERRIDE; + virtual bool take(QCPLayoutElement* element) Q_DECL_OVERRIDE; virtual void simplify() Q_DECL_OVERRIDE {} - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + // non-virtual methods: - void addElement( QCPLayoutElement* element, Qt::Alignment alignment ); - void addElement( QCPLayoutElement* element, const QRectF& rect ); - + void addElement(QCPLayoutElement *element, Qt::Alignment alignment); + void addElement(QCPLayoutElement *element, const QRectF &rect); + protected: // property members: QList mElements; QList mInsetPlacement; QList mInsetAlignment; QList mInsetRect; - + private: - Q_DISABLE_COPY( QCPLayoutInset ) + Q_DISABLE_COPY(QCPLayoutInset) }; -Q_DECLARE_METATYPE( QCPLayoutInset::InsetPlacement ) +Q_DECLARE_METATYPE(QCPLayoutInset::InsetPlacement) /* end of 'src/layout.h' */ + /* including file 'src/lineending.h', size 4426 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1594,62 +1481,52 @@ public: \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding */ - enum EndingStyle - { - esNone ///< No ending decoration - , - esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle) - , - esSpikeArrow ///< A filled arrow head with an indented back - , - esLineArrow ///< A non-filled arrow head with open back - , - esDisc ///< A filled circle - , - esSquare ///< A filled square - , - esDiamond ///< A filled diamond (45 degrees rotated square) - , - esBar ///< A bar perpendicular to the line - , - esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted) - , - esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength) - }; - Q_ENUMS( EndingStyle ) - + enum EndingStyle { esNone ///< No ending decoration + ,esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle) + ,esSpikeArrow ///< A filled arrow head with an indented back + ,esLineArrow ///< A non-filled arrow head with open back + ,esDisc ///< A filled circle + ,esSquare ///< A filled square + ,esDiamond ///< A filled diamond (45 degrees rotated square) + ,esBar ///< A bar perpendicular to the line + ,esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted) + ,esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength) + }; + Q_ENUMS(EndingStyle) + QCPLineEnding(); - QCPLineEnding( EndingStyle style, double width = 8, double length = 10, bool inverted = false ); - + QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false); + // getters: EndingStyle style() const { return mStyle; } double width() const { return mWidth; } double length() const { return mLength; } bool inverted() const { return mInverted; } - + // setters: - void setStyle( EndingStyle style ); - void setWidth( double width ); - void setLength( double length ); - void setInverted( bool inverted ); - + void setStyle(EndingStyle style); + void setWidth(double width); + void setLength(double length); + void setInverted(bool inverted); + // non-property methods: double boundingDistance() const; double realLength() const; - void draw( QCPPainter* painter, const QCPVector2D& pos, const QCPVector2D& dir ) const; - void draw( QCPPainter* painter, const QCPVector2D& pos, double angle ) const; - + void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const; + void draw(QCPPainter *painter, const QCPVector2D &pos, double angle) const; + protected: // property members: EndingStyle mStyle; double mWidth, mLength; bool mInverted; }; -Q_DECLARE_TYPEINFO( QCPLineEnding, Q_MOVABLE_TYPE ); -Q_DECLARE_METATYPE( QCPLineEnding::EndingStyle ) +Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE); +Q_DECLARE_METATYPE(QCPLineEnding::EndingStyle) /* end of 'src/lineending.h' */ + /* including file 'src/axis/axisticker.h', size 4177 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1664,53 +1541,53 @@ public: */ enum TickStepStrategy { - tssReadability ///< A nicely readable tick step is prioritized over matching the requested number of ticks (see \ref setTickCount) - , - tssMeetTickCount ///< Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick count + tssReadability ///< A nicely readable tick step is prioritized over matching the requested number of ticks (see \ref setTickCount) + ,tssMeetTickCount ///< Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick count }; - Q_ENUMS( TickStepStrategy ) - + Q_ENUMS(TickStepStrategy) + QCPAxisTicker(); virtual ~QCPAxisTicker(); - + // getters: TickStepStrategy tickStepStrategy() const { return mTickStepStrategy; } int tickCount() const { return mTickCount; } double tickOrigin() const { return mTickOrigin; } - + // setters: - void setTickStepStrategy( TickStepStrategy strategy ); - void setTickCount( int count ); - void setTickOrigin( double origin ); - + void setTickStepStrategy(TickStepStrategy strategy); + void setTickCount(int count); + void setTickOrigin(double origin); + // introduced virtual methods: - virtual void generate( const QCPRange& range, const QLocale& locale, QChar formatChar, int precision, QVector& ticks, QVector* subTicks, QVector* tickLabels ); - + virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector &ticks, QVector *subTicks, QVector *tickLabels); + protected: // property members: TickStepStrategy mTickStepStrategy; int mTickCount; double mTickOrigin; - + // introduced virtual methods: - virtual double getTickStep( const QCPRange& range ); - virtual int getSubTickCount( double tickStep ); - virtual QString getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ); - virtual QVector createTickVector( double tickStep, const QCPRange& range ); - virtual QVector createSubTickVector( int subTickCount, const QVector& ticks ); - virtual QVector createLabelVector( const QVector& ticks, const QLocale& locale, QChar formatChar, int precision ); - + virtual double getTickStep(const QCPRange &range); + virtual int getSubTickCount(double tickStep); + virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision); + virtual QVector createTickVector(double tickStep, const QCPRange &range); + virtual QVector createSubTickVector(int subTickCount, const QVector &ticks); + virtual QVector createLabelVector(const QVector &ticks, const QLocale &locale, QChar formatChar, int precision); + // non-virtual methods: - void trimTicks( const QCPRange& range, QVector& ticks, bool keepOneOutlier ) const; - double pickClosest( double target, const QVector& candidates ) const; - double getMantissa( double input, double* magnitude = 0 ) const; - double cleanMantissa( double input ) const; + void trimTicks(const QCPRange &range, QVector &ticks, bool keepOneOutlier) const; + double pickClosest(double target, const QVector &candidates) const; + double getMantissa(double input, double *magnitude=0) const; + double cleanMantissa(double input) const; }; -Q_DECLARE_METATYPE( QCPAxisTicker::TickStepStrategy ) -Q_DECLARE_METATYPE( QSharedPointer ) +Q_DECLARE_METATYPE(QCPAxisTicker::TickStepStrategy) +Q_DECLARE_METATYPE(QSharedPointer) /* end of 'src/axis/axisticker.h' */ + /* including file 'src/axis/axistickerdatetime.h', size 3289 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1718,44 +1595,40 @@ class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker { public: QCPAxisTickerDateTime(); - + // getters: QString dateTimeFormat() const { return mDateTimeFormat; } Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; } - + // setters: - void setDateTimeFormat( const QString& format ); - void setDateTimeSpec( Qt::TimeSpec spec ); - void setTickOrigin( double origin ); // hides base class method but calls baseclass implementation ("using" throws off IDEs and doxygen) - void setTickOrigin( const QDateTime& origin ); - + void setDateTimeFormat(const QString &format); + void setDateTimeSpec(Qt::TimeSpec spec); + void setTickOrigin(double origin); // hides base class method but calls baseclass implementation ("using" throws off IDEs and doxygen) + void setTickOrigin(const QDateTime &origin); + // static methods: - static QDateTime keyToDateTime( double key ); - static double dateTimeToKey( const QDateTime dateTime ); - static double dateTimeToKey( const QDate date ); - + static QDateTime keyToDateTime(double key); + static double dateTimeToKey(const QDateTime dateTime); + static double dateTimeToKey(const QDate date); + protected: // property members: QString mDateTimeFormat; Qt::TimeSpec mDateTimeSpec; - + // non-property members: - enum DateStrategy - { - dsNone, - dsUniformTimeInDay, - dsUniformDayInMonth - } mDateStrategy; - + enum DateStrategy {dsNone, dsUniformTimeInDay, dsUniformDayInMonth} mDateStrategy; + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; - virtual int getSubTickCount( double tickStep ) Q_DECL_OVERRIDE; - virtual QString getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) Q_DECL_OVERRIDE; - virtual QVector createTickVector( double tickStep, const QCPRange& range ) Q_DECL_OVERRIDE; + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; + virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE; + virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE; + virtual QVector createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE; }; /* end of 'src/axis/axistickerdatetime.h' */ + /* including file 'src/axis/axistickertime.h', size 3542 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1768,51 +1641,46 @@ public: \see setFieldWidth, setTimeFormat */ - enum TimeUnit - { - tuMilliseconds ///< Milliseconds, one thousandth of a second (%%z in \ref setTimeFormat) - , - tuSeconds ///< Seconds (%%s in \ref setTimeFormat) - , - tuMinutes ///< Minutes (%%m in \ref setTimeFormat) - , - tuHours ///< Hours (%%h in \ref setTimeFormat) - , - tuDays ///< Days (%%d in \ref setTimeFormat) - }; - Q_ENUMS( TimeUnit ) - + enum TimeUnit { tuMilliseconds ///< Milliseconds, one thousandth of a second (%%z in \ref setTimeFormat) + ,tuSeconds ///< Seconds (%%s in \ref setTimeFormat) + ,tuMinutes ///< Minutes (%%m in \ref setTimeFormat) + ,tuHours ///< Hours (%%h in \ref setTimeFormat) + ,tuDays ///< Days (%%d in \ref setTimeFormat) + }; + Q_ENUMS(TimeUnit) + QCPAxisTickerTime(); // getters: QString timeFormat() const { return mTimeFormat; } - int fieldWidth( TimeUnit unit ) const { return mFieldWidth.value( unit ); } - + int fieldWidth(TimeUnit unit) const { return mFieldWidth.value(unit); } + // setters: - void setTimeFormat( const QString& format ); - void setFieldWidth( TimeUnit unit, int width ); - + void setTimeFormat(const QString &format); + void setFieldWidth(TimeUnit unit, int width); + protected: // property members: QString mTimeFormat; QHash mFieldWidth; - + // non-property members: TimeUnit mSmallestUnit, mBiggestUnit; QHash mFormatPattern; - + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; - virtual int getSubTickCount( double tickStep ) Q_DECL_OVERRIDE; - virtual QString getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) Q_DECL_OVERRIDE; - + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; + virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE; + virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE; + // non-virtual methods: - void replaceUnit( QString& text, TimeUnit unit, int value ) const; + void replaceUnit(QString &text, TimeUnit unit, int value) const; }; -Q_DECLARE_METATYPE( QCPAxisTickerTime::TimeUnit ) +Q_DECLARE_METATYPE(QCPAxisTickerTime::TimeUnit) /* end of 'src/axis/axistickertime.h' */ + /* including file 'src/axis/axistickerfixed.h', size 3308 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1826,38 +1694,35 @@ public: \see setScaleStrategy */ - enum ScaleStrategy - { - ssNone ///< Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high tick density and overlapping labels if the axis range is zoomed out. - , - ssMultiples ///< An integer multiple of the specified tick step is allowed. The used factor follows the base class properties of \ref setTickStepStrategy and \ref setTickCount. - , - ssPowers ///< An integer power of the specified tick step is allowed. - }; - Q_ENUMS( ScaleStrategy ) - + enum ScaleStrategy { ssNone ///< Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high tick density and overlapping labels if the axis range is zoomed out. + ,ssMultiples ///< An integer multiple of the specified tick step is allowed. The used factor follows the base class properties of \ref setTickStepStrategy and \ref setTickCount. + ,ssPowers ///< An integer power of the specified tick step is allowed. + }; + Q_ENUMS(ScaleStrategy) + QCPAxisTickerFixed(); - + // getters: double tickStep() const { return mTickStep; } ScaleStrategy scaleStrategy() const { return mScaleStrategy; } - + // setters: - void setTickStep( double step ); - void setScaleStrategy( ScaleStrategy strategy ); - + void setTickStep(double step); + void setScaleStrategy(ScaleStrategy strategy); + protected: // property members: double mTickStep; ScaleStrategy mScaleStrategy; - + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; }; -Q_DECLARE_METATYPE( QCPAxisTickerFixed::ScaleStrategy ) +Q_DECLARE_METATYPE(QCPAxisTickerFixed::ScaleStrategy) /* end of 'src/axis/axistickerfixed.h' */ + /* including file 'src/axis/axistickertext.h', size 3085 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1865,36 +1730,38 @@ class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker { public: QCPAxisTickerText(); - + // getters: - QMap& ticks() { return mTicks; } + QMap &ticks() { return mTicks; } int subTickCount() const { return mSubTickCount; } - + // setters: - void setTicks( const QMap& ticks ); - void setTicks( const QVector& positions, const QVector labels ); - void setSubTickCount( int subTicks ); - + void setTicks(const QMap &ticks); + void setTicks(const QVector &positions, const QVector labels); + void setSubTickCount(int subTicks); + // non-virtual methods: void clear(); - void addTick( double position, QString label ); - void addTicks( const QMap& ticks ); - void addTicks( const QVector& positions, const QVector& labels ); - + void addTick(double position, QString label); + void addTicks(const QMap &ticks); + void addTicks(const QVector &positions, const QVector &labels); + protected: // property members: QMap mTicks; int mSubTickCount; - + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; - virtual int getSubTickCount( double tickStep ) Q_DECL_OVERRIDE; - virtual QString getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) Q_DECL_OVERRIDE; - virtual QVector createTickVector( double tickStep, const QCPRange& range ) Q_DECL_OVERRIDE; + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; + virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE; + virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE; + virtual QVector createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE; + }; /* end of 'src/axis/axistickertext.h' */ + /* including file 'src/axis/axistickerpi.h', size 3911 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1907,56 +1774,53 @@ public: \see setFractionStyle */ - enum FractionStyle - { - fsFloatingPoint ///< Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0.125". - , - fsAsciiFractions ///< Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8" - , - fsUnicodeFractions ///< Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol. - }; - Q_ENUMS( FractionStyle ) - + enum FractionStyle { fsFloatingPoint ///< Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0.125". + ,fsAsciiFractions ///< Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8" + ,fsUnicodeFractions ///< Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol. + }; + Q_ENUMS(FractionStyle) + QCPAxisTickerPi(); - + // getters: QString piSymbol() const { return mPiSymbol; } double piValue() const { return mPiValue; } bool periodicity() const { return mPeriodicity; } FractionStyle fractionStyle() const { return mFractionStyle; } - + // setters: - void setPiSymbol( QString symbol ); - void setPiValue( double pi ); - void setPeriodicity( int multiplesOfPi ); - void setFractionStyle( FractionStyle style ); - + void setPiSymbol(QString symbol); + void setPiValue(double pi); + void setPeriodicity(int multiplesOfPi); + void setFractionStyle(FractionStyle style); + protected: // property members: QString mPiSymbol; double mPiValue; int mPeriodicity; FractionStyle mFractionStyle; - + // non-property members: - double mPiTickStep; // size of one tick step in units of mPiValue - + double mPiTickStep; // size of one tick step in units of mPiValue + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; - virtual int getSubTickCount( double tickStep ) Q_DECL_OVERRIDE; - virtual QString getTickLabel( double tick, const QLocale& locale, QChar formatChar, int precision ) Q_DECL_OVERRIDE; - + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; + virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE; + virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE; + // non-virtual methods: - void simplifyFraction( int& numerator, int& denominator ) const; - QString fractionToString( int numerator, int denominator ) const; - QString unicodeFraction( int numerator, int denominator ) const; - QString unicodeSuperscript( int number ) const; - QString unicodeSubscript( int number ) const; + void simplifyFraction(int &numerator, int &denominator) const; + QString fractionToString(int numerator, int denominator) const; + QString unicodeFraction(int numerator, int denominator) const; + QString unicodeSuperscript(int number) const; + QString unicodeSubscript(int number) const; }; -Q_DECLARE_METATYPE( QCPAxisTickerPi::FractionStyle ) +Q_DECLARE_METATYPE(QCPAxisTickerPi::FractionStyle) /* end of 'src/axis/axistickerpi.h' */ + /* including file 'src/axis/axistickerlog.h', size 2663 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -1964,48 +1828,49 @@ class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker { public: QCPAxisTickerLog(); - + // getters: double logBase() const { return mLogBase; } int subTickCount() const { return mSubTickCount; } - + // setters: - void setLogBase( double base ); - void setSubTickCount( int subTicks ); - + void setLogBase(double base); + void setSubTickCount(int subTicks); + protected: // property members: double mLogBase; int mSubTickCount; - + // non-property members: double mLogBaseLnInv; - + // reimplemented virtual methods: - virtual double getTickStep( const QCPRange& range ) Q_DECL_OVERRIDE; - virtual int getSubTickCount( double tickStep ) Q_DECL_OVERRIDE; - virtual QVector createTickVector( double tickStep, const QCPRange& range ) Q_DECL_OVERRIDE; + virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE; + virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE; + virtual QVector createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE; }; /* end of 'src/axis/axistickerlog.h' */ + /* including file 'src/axis/axis.h', size 20634 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ -class QCP_LIB_DECL QCPGrid : public QCPLayerable +class QCP_LIB_DECL QCPGrid :public QCPLayerable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( bool subGridVisible READ subGridVisible WRITE setSubGridVisible ) - Q_PROPERTY( bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid ) - Q_PROPERTY( bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine ) - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen subGridPen READ subGridPen WRITE setSubGridPen ) - Q_PROPERTY( QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen ) + Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible) + Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid) + Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen) + Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen) /// \endcond public: - explicit QCPGrid( QCPAxis* parentAxis ); - + explicit QCPGrid(QCPAxis *parentAxis); + // getters: bool subGridVisible() const { return mSubGridVisible; } bool antialiasedSubGrid() const { return mAntialiasedSubGrid; } @@ -2013,148 +1878,133 @@ public: QPen pen() const { return mPen; } QPen subGridPen() const { return mSubGridPen; } QPen zeroLinePen() const { return mZeroLinePen; } - + // setters: - void setSubGridVisible( bool visible ); - void setAntialiasedSubGrid( bool enabled ); - void setAntialiasedZeroLine( bool enabled ); - void setPen( const QPen& pen ); - void setSubGridPen( const QPen& pen ); - void setZeroLinePen( const QPen& pen ); - + void setSubGridVisible(bool visible); + void setAntialiasedSubGrid(bool enabled); + void setAntialiasedZeroLine(bool enabled); + void setPen(const QPen &pen); + void setSubGridPen(const QPen &pen); + void setZeroLinePen(const QPen &pen); + protected: // property members: bool mSubGridVisible; bool mAntialiasedSubGrid, mAntialiasedZeroLine; QPen mPen, mSubGridPen, mZeroLinePen; - + // non-property members: - QCPAxis* mParentAxis; - + QCPAxis *mParentAxis; + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + // non-virtual methods: - void drawGridLines( QCPPainter* painter ) const; - void drawSubGridLines( QCPPainter* painter ) const; - + void drawGridLines(QCPPainter *painter) const; + void drawSubGridLines(QCPPainter *painter) const; + friend class QCPAxis; }; + class QCP_LIB_DECL QCPAxis : public QCPLayerable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( AxisType axisType READ axisType ) - Q_PROPERTY( QCPAxisRect* axisRect READ axisRect ) - Q_PROPERTY( ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged ) - Q_PROPERTY( QCPRange range READ range WRITE setRange NOTIFY rangeChanged ) - Q_PROPERTY( bool rangeReversed READ rangeReversed WRITE setRangeReversed ) - Q_PROPERTY( QSharedPointer ticker READ ticker WRITE setTicker ) - Q_PROPERTY( bool ticks READ ticks WRITE setTicks ) - Q_PROPERTY( bool tickLabels READ tickLabels WRITE setTickLabels ) - Q_PROPERTY( int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding ) - Q_PROPERTY( QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont ) - Q_PROPERTY( QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor ) - Q_PROPERTY( double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation ) - Q_PROPERTY( LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide ) - Q_PROPERTY( QString numberFormat READ numberFormat WRITE setNumberFormat ) - Q_PROPERTY( int numberPrecision READ numberPrecision WRITE setNumberPrecision ) - Q_PROPERTY( QVector tickVector READ tickVector ) - Q_PROPERTY( QVector tickVectorLabels READ tickVectorLabels ) - Q_PROPERTY( int tickLengthIn READ tickLengthIn WRITE setTickLengthIn ) - Q_PROPERTY( int tickLengthOut READ tickLengthOut WRITE setTickLengthOut ) - Q_PROPERTY( bool subTicks READ subTicks WRITE setSubTicks ) - Q_PROPERTY( int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn ) - Q_PROPERTY( int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut ) - Q_PROPERTY( QPen basePen READ basePen WRITE setBasePen ) - Q_PROPERTY( QPen tickPen READ tickPen WRITE setTickPen ) - Q_PROPERTY( QPen subTickPen READ subTickPen WRITE setSubTickPen ) - Q_PROPERTY( QFont labelFont READ labelFont WRITE setLabelFont ) - Q_PROPERTY( QColor labelColor READ labelColor WRITE setLabelColor ) - Q_PROPERTY( QString label READ label WRITE setLabel ) - Q_PROPERTY( int labelPadding READ labelPadding WRITE setLabelPadding ) - Q_PROPERTY( int padding READ padding WRITE setPadding ) - Q_PROPERTY( int offset READ offset WRITE setOffset ) - Q_PROPERTY( SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged ) - Q_PROPERTY( SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged ) - Q_PROPERTY( QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont ) - Q_PROPERTY( QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont ) - Q_PROPERTY( QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor ) - Q_PROPERTY( QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor ) - Q_PROPERTY( QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen ) - Q_PROPERTY( QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen ) - Q_PROPERTY( QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen ) - Q_PROPERTY( QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding ) - Q_PROPERTY( QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding ) - Q_PROPERTY( QCPGrid* grid READ grid ) + Q_PROPERTY(AxisType axisType READ axisType) + Q_PROPERTY(QCPAxisRect* axisRect READ axisRect) + Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged) + Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged) + Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed) + Q_PROPERTY(QSharedPointer ticker READ ticker WRITE setTicker) + Q_PROPERTY(bool ticks READ ticks WRITE setTicks) + Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels) + Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding) + Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont) + Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor) + Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation) + Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide) + Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat) + Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision) + Q_PROPERTY(QVector tickVector READ tickVector) + Q_PROPERTY(QVector tickVectorLabels READ tickVectorLabels) + Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn) + Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut) + Q_PROPERTY(bool subTicks READ subTicks WRITE setSubTicks) + Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn) + Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut) + Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen) + Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen) + Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen) + Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) + Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding) + Q_PROPERTY(int padding READ padding WRITE setPadding) + Q_PROPERTY(int offset READ offset WRITE setOffset) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged) + Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont) + Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont) + Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor) + Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor) + Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen) + Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen) + Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen) + Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding) + Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding) + Q_PROPERTY(QCPGrid* grid READ grid) /// \endcond public: /*! Defines at which side of the axis rect the axis will appear. This also affects how the tick marks are drawn, on which side the labels are placed etc. */ - enum AxisType - { - atLeft = 0x01 ///< 0x01 Axis is vertical and on the left side of the axis rect - , - atRight = 0x02 ///< 0x02 Axis is vertical and on the right side of the axis rect - , - atTop = 0x04 ///< 0x04 Axis is horizontal and on the top side of the axis rect - , - atBottom = 0x08 ///< 0x08 Axis is horizontal and on the bottom side of the axis rect - }; - Q_ENUMS( AxisType ) - Q_FLAGS( AxisTypes ) - Q_DECLARE_FLAGS( AxisTypes, AxisType ) + enum AxisType { atLeft = 0x01 ///< 0x01 Axis is vertical and on the left side of the axis rect + ,atRight = 0x02 ///< 0x02 Axis is vertical and on the right side of the axis rect + ,atTop = 0x04 ///< 0x04 Axis is horizontal and on the top side of the axis rect + ,atBottom = 0x08 ///< 0x08 Axis is horizontal and on the bottom side of the axis rect + }; + Q_ENUMS(AxisType) + Q_FLAGS(AxisTypes) + Q_DECLARE_FLAGS(AxisTypes, AxisType) /*! Defines on which side of the axis the tick labels (numbers) shall appear. \see setTickLabelSide */ - enum LabelSide - { - lsInside ///< Tick labels will be displayed inside the axis rect and clipped to the inner axis rect - , - lsOutside ///< Tick labels will be displayed outside the axis rect - }; - Q_ENUMS( LabelSide ) + enum LabelSide { lsInside ///< Tick labels will be displayed inside the axis rect and clipped to the inner axis rect + ,lsOutside ///< Tick labels will be displayed outside the axis rect + }; + Q_ENUMS(LabelSide) /*! Defines the scale of an axis. \see setScaleType */ - enum ScaleType - { - stLinear ///< Linear scaling - , - stLogarithmic ///< Logarithmic scaling with correspondingly transformed axis coordinates (possibly also \ref setTicker to a \ref QCPAxisTickerLog instance). - }; - Q_ENUMS( ScaleType ) + enum ScaleType { stLinear ///< Linear scaling + ,stLogarithmic ///< Logarithmic scaling with correspondingly transformed axis coordinates (possibly also \ref setTicker to a \ref QCPAxisTickerLog instance). + }; + Q_ENUMS(ScaleType) /*! Defines the selectable parts of an axis. \see setSelectableParts, setSelectedParts */ - enum SelectablePart - { - spNone = 0 ///< None of the selectable parts - , - spAxis = 0x001 ///< The axis backbone and tick marks - , - spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually) - , - spAxisLabel = 0x004 ///< The axis label - }; - Q_ENUMS( SelectablePart ) - Q_FLAGS( SelectableParts ) - Q_DECLARE_FLAGS( SelectableParts, SelectablePart ) - - explicit QCPAxis( QCPAxisRect* parent, AxisType type ); + enum SelectablePart { spNone = 0 ///< None of the selectable parts + ,spAxis = 0x001 ///< The axis backbone and tick marks + ,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually) + ,spAxisLabel = 0x004 ///< The axis label + }; + Q_ENUMS(SelectablePart) + Q_FLAGS(SelectableParts) + Q_DECLARE_FLAGS(SelectableParts, SelectablePart) + + explicit QCPAxis(QCPAxisRect *parent, AxisType type); virtual ~QCPAxis(); - + // getters: AxisType axisType() const { return mAxisType; } - QCPAxisRect* axisRect() const { return mAxisRect; } + QCPAxisRect *axisRect() const { return mAxisRect; } ScaleType scaleType() const { return mScaleType; } const QCPRange range() const { return mRange; } bool rangeReversed() const { return mRangeReversed; } @@ -2195,88 +2045,88 @@ public: QPen selectedSubTickPen() const { return mSelectedSubTickPen; } QCPLineEnding lowerEnding() const; QCPLineEnding upperEnding() const; - QCPGrid* grid() const { return mGrid; } - + QCPGrid *grid() const { return mGrid; } + // setters: - Q_SLOT void setScaleType( QCPAxis::ScaleType type ); - Q_SLOT void setRange( const QCPRange& range ); - void setRange( double lower, double upper ); - void setRange( double position, double size, Qt::AlignmentFlag alignment ); - void setRangeLower( double lower ); - void setRangeUpper( double upper ); - void setRangeReversed( bool reversed ); - void setTicker( QSharedPointer ticker ); - void setTicks( bool show ); - void setTickLabels( bool show ); - void setTickLabelPadding( int padding ); - void setTickLabelFont( const QFont& font ); - void setTickLabelColor( const QColor& color ); - void setTickLabelRotation( double degrees ); - void setTickLabelSide( LabelSide side ); - void setNumberFormat( const QString& formatCode ); - void setNumberPrecision( int precision ); - void setTickLength( int inside, int outside = 0 ); - void setTickLengthIn( int inside ); - void setTickLengthOut( int outside ); - void setSubTicks( bool show ); - void setSubTickLength( int inside, int outside = 0 ); - void setSubTickLengthIn( int inside ); - void setSubTickLengthOut( int outside ); - void setBasePen( const QPen& pen ); - void setTickPen( const QPen& pen ); - void setSubTickPen( const QPen& pen ); - void setLabelFont( const QFont& font ); - void setLabelColor( const QColor& color ); - void setLabel( const QString& str ); - void setLabelPadding( int padding ); - void setPadding( int padding ); - void setOffset( int offset ); - void setSelectedTickLabelFont( const QFont& font ); - void setSelectedLabelFont( const QFont& font ); - void setSelectedTickLabelColor( const QColor& color ); - void setSelectedLabelColor( const QColor& color ); - void setSelectedBasePen( const QPen& pen ); - void setSelectedTickPen( const QPen& pen ); - void setSelectedSubTickPen( const QPen& pen ); - Q_SLOT void setSelectableParts( const QCPAxis::SelectableParts& selectableParts ); - Q_SLOT void setSelectedParts( const QCPAxis::SelectableParts& selectedParts ); - void setLowerEnding( const QCPLineEnding& ending ); - void setUpperEnding( const QCPLineEnding& ending ); - + Q_SLOT void setScaleType(QCPAxis::ScaleType type); + Q_SLOT void setRange(const QCPRange &range); + void setRange(double lower, double upper); + void setRange(double position, double size, Qt::AlignmentFlag alignment); + void setRangeLower(double lower); + void setRangeUpper(double upper); + void setRangeReversed(bool reversed); + void setTicker(QSharedPointer ticker); + void setTicks(bool show); + void setTickLabels(bool show); + void setTickLabelPadding(int padding); + void setTickLabelFont(const QFont &font); + void setTickLabelColor(const QColor &color); + void setTickLabelRotation(double degrees); + void setTickLabelSide(LabelSide side); + void setNumberFormat(const QString &formatCode); + void setNumberPrecision(int precision); + void setTickLength(int inside, int outside=0); + void setTickLengthIn(int inside); + void setTickLengthOut(int outside); + void setSubTicks(bool show); + void setSubTickLength(int inside, int outside=0); + void setSubTickLengthIn(int inside); + void setSubTickLengthOut(int outside); + void setBasePen(const QPen &pen); + void setTickPen(const QPen &pen); + void setSubTickPen(const QPen &pen); + void setLabelFont(const QFont &font); + void setLabelColor(const QColor &color); + void setLabel(const QString &str); + void setLabelPadding(int padding); + void setPadding(int padding); + void setOffset(int offset); + void setSelectedTickLabelFont(const QFont &font); + void setSelectedLabelFont(const QFont &font); + void setSelectedTickLabelColor(const QColor &color); + void setSelectedLabelColor(const QColor &color); + void setSelectedBasePen(const QPen &pen); + void setSelectedTickPen(const QPen &pen); + void setSelectedSubTickPen(const QPen &pen); + Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts); + Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts); + void setLowerEnding(const QCPLineEnding &ending); + void setUpperEnding(const QCPLineEnding &ending); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + // non-property methods: Qt::Orientation orientation() const { return mOrientation; } - int pixelOrientation() const { return rangeReversed() != ( orientation() == Qt::Vertical ) ? -1 : 1; } - void moveRange( double diff ); - void scaleRange( double factor ); - void scaleRange( double factor, double center ); - void setScaleRatio( const QCPAxis* otherAxis, double ratio = 1.0 ); - void rescale( bool onlyVisiblePlottables = false ); - double pixelToCoord( double value ) const; - double coordToPixel( double value ) const; - SelectablePart getPartAt( const QPointF& pos ) const; + int pixelOrientation() const { return rangeReversed() != (orientation()==Qt::Vertical) ? -1 : 1; } + void moveRange(double diff); + void scaleRange(double factor); + void scaleRange(double factor, double center); + void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0); + void rescale(bool onlyVisiblePlottables=false); + double pixelToCoord(double value) const; + double coordToPixel(double value) const; + SelectablePart getPartAt(const QPointF &pos) const; QList plottables() const; QList graphs() const; QList items() const; - - static AxisType marginSideToAxisType( QCP::MarginSide side ); - static Qt::Orientation orientation( AxisType type ) { return type == atBottom || type == atTop ? Qt::Horizontal : Qt::Vertical; } - static AxisType opposite( AxisType type ); - + + static AxisType marginSideToAxisType(QCP::MarginSide side); + static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; } + static AxisType opposite(AxisType type); + signals: - void rangeChanged( const QCPRange& newRange ); - void rangeChanged( const QCPRange& newRange, const QCPRange& oldRange ); - void scaleTypeChanged( QCPAxis::ScaleType scaleType ); - void selectionChanged( const QCPAxis::SelectableParts& parts ); - void selectableChanged( const QCPAxis::SelectableParts& parts ); + void rangeChanged(const QCPRange &newRange); + void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange); + void scaleTypeChanged(QCPAxis::ScaleType scaleType); + void selectionChanged(const QCPAxis::SelectableParts &parts); + void selectableChanged(const QCPAxis::SelectableParts &parts); protected: // property members: // axis base: AxisType mAxisType; - QCPAxisRect* mAxisRect; + QCPAxisRect *mAxisRect; //int mOffset; // in QCPAxisPainter int mPadding; Qt::Orientation mOrientation; @@ -2308,10 +2158,10 @@ protected: QCPRange mRange; bool mRangeReversed; ScaleType mScaleType; - + // non-property members: - QCPGrid* mGrid; - QCPAxisPainterPrivate* mAxisPainter; + QCPGrid *mGrid; + QCPAxisPainterPrivate *mAxisPainter; QSharedPointer mTicker; QVector mTickVector; QVector mTickVectorLabels; @@ -2321,23 +2171,23 @@ protected: bool mDragging; QCPRange mDragStartRange; QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; - + // introduced virtual methods: virtual int calculateMargin(); - + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; // mouse events: - virtual void mousePressEvent( QMouseEvent* event, const QVariant& details ); - virtual void mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ); - virtual void mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ); - virtual void wheelEvent( QWheelEvent* event ); - + virtual void mousePressEvent(QMouseEvent *event, const QVariant &details); + virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos); + virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos); + virtual void wheelEvent(QWheelEvent *event); + // non-virtual methods: void setupTickVectors(); QPen getBasePen() const; @@ -2347,61 +2197,62 @@ protected: QFont getLabelFont() const; QColor getTickLabelColor() const; QColor getLabelColor() const; - + private: - Q_DISABLE_COPY( QCPAxis ) - + Q_DISABLE_COPY(QCPAxis) + friend class QCustomPlot; friend class QCPGrid; friend class QCPAxisRect; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QCPAxis::SelectableParts ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QCPAxis::AxisTypes ) -Q_DECLARE_METATYPE( QCPAxis::AxisType ) -Q_DECLARE_METATYPE( QCPAxis::LabelSide ) -Q_DECLARE_METATYPE( QCPAxis::ScaleType ) -Q_DECLARE_METATYPE( QCPAxis::SelectablePart ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes) +Q_DECLARE_METATYPE(QCPAxis::AxisType) +Q_DECLARE_METATYPE(QCPAxis::LabelSide) +Q_DECLARE_METATYPE(QCPAxis::ScaleType) +Q_DECLARE_METATYPE(QCPAxis::SelectablePart) + class QCPAxisPainterPrivate { public: - explicit QCPAxisPainterPrivate( QCustomPlot* parentPlot ); + explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot); virtual ~QCPAxisPainterPrivate(); - - virtual void draw( QCPPainter* painter ); + + virtual void draw(QCPPainter *painter); virtual int size() const; void clearCache(); - + QRect axisSelectionBox() const { return mAxisSelectionBox; } QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; } QRect labelSelectionBox() const { return mLabelSelectionBox; } - + // public property members: QCPAxis::AxisType type; QPen basePen; - QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters - int labelPadding; // directly accessed by QCPAxis setters/getters + QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters + int labelPadding; // directly accessed by QCPAxis setters/getters QFont labelFont; QColor labelColor; QString label; - int tickLabelPadding; // directly accessed by QCPAxis setters/getters - double tickLabelRotation; // directly accessed by QCPAxis setters/getters - QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters + int tickLabelPadding; // directly accessed by QCPAxis setters/getters + double tickLabelRotation; // directly accessed by QCPAxis setters/getters + QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters bool substituteExponent; - bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters - int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters + bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters + int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters QPen tickPen, subTickPen; QFont tickLabelFont; QColor tickLabelColor; QRect axisRect, viewportRect; - double offset; // directly accessed by QCPAxis setters/getters + double offset; // directly accessed by QCPAxis setters/getters bool abbreviateDecimalPowers; bool reversedEndings; - + QVector subTickPositions; QVector tickPositions; QVector tickLabels; - + protected: struct CachedLabel { @@ -2414,22 +2265,23 @@ protected: QRect baseBounds, expBounds, suffixBounds, totalBounds, rotatedTotalBounds; QFont baseFont, expFont; }; - QCustomPlot* mParentPlot; - QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters + QCustomPlot *mParentPlot; + QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters QCache mLabelCache; QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox; - + virtual QByteArray generateLabelParameterHash() const; - - virtual void placeTickLabel( QCPPainter* painter, double position, int distanceToAxis, const QString& text, QSize* tickLabelsSize ); - virtual void drawTickLabel( QCPPainter* painter, double x, double y, const TickLabelData& labelData ) const; - virtual TickLabelData getTickLabelData( const QFont& font, const QString& text ) const; - virtual QPointF getTickLabelDrawOffset( const TickLabelData& labelData ) const; - virtual void getMaxTickLabelSize( const QFont& font, const QString& text, QSize* tickLabelsSize ) const; + + virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize); + virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const; + virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const; + virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const; + virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const; }; /* end of 'src/axis/axis.h' */ + /* including file 'src/scatterstyle.h', size 7275 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -2445,23 +2297,16 @@ public: Specific scatter properties can be transferred between \ref QCPScatterStyle instances via \ref setFromOther. */ - enum ScatterProperty - { - spNone = 0x00 ///< 0x00 None - , - spPen = 0x01 ///< 0x01 The pen property, see \ref setPen - , - spBrush = 0x02 ///< 0x02 The brush property, see \ref setBrush - , - spSize = 0x04 ///< 0x04 The size property, see \ref setSize - , - spShape = 0x08 ///< 0x08 The shape property, see \ref setShape - , - spAll = 0xFF ///< 0xFF All properties - }; - Q_ENUMS( ScatterProperty ) - Q_FLAGS( ScatterProperties ) - Q_DECLARE_FLAGS( ScatterProperties, ScatterProperty ) + enum ScatterProperty { spNone = 0x00 ///< 0x00 None + ,spPen = 0x01 ///< 0x01 The pen property, see \ref setPen + ,spBrush = 0x02 ///< 0x02 The brush property, see \ref setBrush + ,spSize = 0x04 ///< 0x04 The size property, see \ref setSize + ,spShape = 0x08 ///< 0x08 The shape property, see \ref setShape + ,spAll = 0xFF ///< 0xFF All properties + }; + Q_ENUMS(ScatterProperty) + Q_FLAGS(ScatterProperties) + Q_DECLARE_FLAGS(ScatterProperties, ScatterProperty) /*! Defines the shape used for scatter points. @@ -2470,54 +2315,35 @@ public: \ref ssDot and \ref ssPixmap) can be controlled with the \ref setSize function. Scatters are drawn with the pen and brush specified with \ref setPen and \ref setBrush. */ - enum ScatterShape - { - ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) - , - ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius) - , - ssCross ///< \enumimage{ssCross.png} a cross - , - ssPlus ///< \enumimage{ssPlus.png} a plus - , - ssCircle ///< \enumimage{ssCircle.png} a circle - , - ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) - , - ssSquare ///< \enumimage{ssSquare.png} a square - , - ssDiamond ///< \enumimage{ssDiamond.png} a diamond - , - ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus - , - ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline - , - ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner - , - ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross inside - , - ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside - , - ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross inside - , - ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside - , - ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines - , - ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the data point coordinates - , - ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath) - }; - Q_ENUMS( ScatterShape ) + enum ScatterShape { ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) + ,ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius) + ,ssCross ///< \enumimage{ssCross.png} a cross + ,ssPlus ///< \enumimage{ssPlus.png} a plus + ,ssCircle ///< \enumimage{ssCircle.png} a circle + ,ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) + ,ssSquare ///< \enumimage{ssSquare.png} a square + ,ssDiamond ///< \enumimage{ssDiamond.png} a diamond + ,ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus + ,ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline + ,ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner + ,ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross inside + ,ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside + ,ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross inside + ,ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside + ,ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines + ,ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the data point coordinates + ,ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath) + }; + Q_ENUMS(ScatterShape) QCPScatterStyle(); - QCPScatterStyle( ScatterShape shape, double size = 6 ); - QCPScatterStyle( ScatterShape shape, const QColor& color, double size ); - QCPScatterStyle( ScatterShape shape, const QColor& color, const QColor& fill, double size ); - QCPScatterStyle( ScatterShape shape, const QPen& pen, const QBrush& brush, double size ); - QCPScatterStyle( const QPixmap& pixmap ); - QCPScatterStyle( const QPainterPath& customPath, const QPen& pen, const QBrush& brush = Qt::NoBrush, double size = 6 ); - + QCPScatterStyle(ScatterShape shape, double size=6); + QCPScatterStyle(ScatterShape shape, const QColor &color, double size); + QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size); + QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size); + QCPScatterStyle(const QPixmap &pixmap); + QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6); + // getters: double size() const { return mSize; } ScatterShape shape() const { return mShape; } @@ -2527,21 +2353,21 @@ public: QPainterPath customPath() const { return mCustomPath; } // setters: - void setFromOther( const QCPScatterStyle& other, ScatterProperties properties ); - void setSize( double size ); - void setShape( ScatterShape shape ); - void setPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setPixmap( const QPixmap& pixmap ); - void setCustomPath( const QPainterPath& customPath ); + void setFromOther(const QCPScatterStyle &other, ScatterProperties properties); + void setSize(double size); + void setShape(ScatterShape shape); + void setPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setPixmap(const QPixmap &pixmap); + void setCustomPath(const QPainterPath &customPath); // non-property methods: bool isNone() const { return mShape == ssNone; } bool isPenDefined() const { return mPenDefined; } void undefinePen(); - void applyTo( QCPPainter* painter, const QPen& defaultPen ) const; - void drawShape( QCPPainter* painter, const QPointF& pos ) const; - void drawShape( QCPPainter* painter, double x, double y ) const; + void applyTo(QCPPainter *painter, const QPen &defaultPen) const; + void drawShape(QCPPainter *painter, const QPointF &pos) const; + void drawShape(QCPPainter *painter, double x, double y) const; protected: // property members: @@ -2551,17 +2377,18 @@ protected: QBrush mBrush; QPixmap mPixmap; QPainterPath mCustomPath; - + // non-property members: bool mPenDefined; }; -Q_DECLARE_TYPEINFO( QCPScatterStyle, Q_MOVABLE_TYPE ); -Q_DECLARE_OPERATORS_FOR_FLAGS( QCPScatterStyle::ScatterProperties ) -Q_DECLARE_METATYPE( QCPScatterStyle::ScatterProperty ) -Q_DECLARE_METATYPE( QCPScatterStyle::ScatterShape ) +Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE); +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPScatterStyle::ScatterProperties) +Q_DECLARE_METATYPE(QCPScatterStyle::ScatterProperty) +Q_DECLARE_METATYPE(QCPScatterStyle::ScatterShape) /* end of 'src/scatterstyle.h' */ + /* including file 'src/datacontainer.h', size 4596 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -2571,65 +2398,62 @@ Q_DECLARE_METATYPE( QCPScatterStyle::ScatterShape ) \see QCPDataContainer::sort */ template -inline bool qcpLessThanSortKey( const DataType& a, const DataType& b ) -{ - return a.sortKey() < b.sortKey(); -} +inline bool qcpLessThanSortKey(const DataType &a, const DataType &b) { return a.sortKey() < b.sortKey(); } template -class QCPDataContainer // no QCP_LIB_DECL, template class ends up in header (cpp included below) +class QCPDataContainer // no QCP_LIB_DECL, template class ends up in header (cpp included below) { public: typedef typename QVector::const_iterator const_iterator; typedef typename QVector::iterator iterator; - + QCPDataContainer(); - + // getters: - int size() const { return mData.size() - mPreallocSize; } + int size() const { return mData.size()-mPreallocSize; } bool isEmpty() const { return size() == 0; } bool autoSqueeze() const { return mAutoSqueeze; } - + // setters: - void setAutoSqueeze( bool enabled ); - + void setAutoSqueeze(bool enabled); + // non-virtual methods: - void set( const QCPDataContainer& data ); - void set( const QVector& data, bool alreadySorted = false ); - void add( const QCPDataContainer& data ); - void add( const QVector& data, bool alreadySorted = false ); - void add( const DataType& data ); - void removeBefore( double sortKey ); - void removeAfter( double sortKey ); - void remove( double sortKeyFrom, double sortKeyTo ); - void remove( double sortKey ); + void set(const QCPDataContainer &data); + void set(const QVector &data, bool alreadySorted=false); + void add(const QCPDataContainer &data); + void add(const QVector &data, bool alreadySorted=false); + void add(const DataType &data); + void removeBefore(double sortKey); + void removeAfter(double sortKey); + void remove(double sortKeyFrom, double sortKeyTo); + void remove(double sortKey); void clear(); void sort(); - void squeeze( bool preAllocation = true, bool postAllocation = true ); - - const_iterator constBegin() const { return mData.constBegin() + mPreallocSize; } + void squeeze(bool preAllocation=true, bool postAllocation=true); + + const_iterator constBegin() const { return mData.constBegin()+mPreallocSize; } const_iterator constEnd() const { return mData.constEnd(); } - iterator begin() { return mData.begin() + mPreallocSize; } + iterator begin() { return mData.begin()+mPreallocSize; } iterator end() { return mData.end(); } - const_iterator findBegin( double sortKey, bool expandedRange = true ) const; - const_iterator findEnd( double sortKey, bool expandedRange = true ) const; - const_iterator at( int index ) const { return constBegin() + qBound( 0, index, size() ); } - QCPRange keyRange( bool& foundRange, QCP::SignDomain signDomain = QCP::sdBoth ); - QCPRange valueRange( bool& foundRange, QCP::SignDomain signDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ); - QCPDataRange dataRange() const { return QCPDataRange( 0, size() ); } - void limitIteratorsToDataRange( const_iterator& begin, const_iterator& end, const QCPDataRange& dataRange ) const; - + const_iterator findBegin(double sortKey, bool expandedRange=true) const; + const_iterator findEnd(double sortKey, bool expandedRange=true) const; + const_iterator at(int index) const { return constBegin()+qBound(0, index, size()); } + QCPRange keyRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth); + QCPRange valueRange(bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()); + QCPDataRange dataRange() const { return QCPDataRange(0, size()); } + void limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const; + protected: // property members: bool mAutoSqueeze; - + // non-property memebers: QVector mData; int mPreallocSize; int mPreallocIteration; - + // non-virtual methods: - void preallocateGrow( int minimumPreallocSize ); + void preallocateGrow(int minimumPreallocSize); void performAutoSqueeze(); }; @@ -2772,8 +2596,10 @@ protected: data */ template -QCPDataContainer::QCPDataContainer() - : mAutoSqueeze( true ), mPreallocSize( 0 ), mPreallocIteration( 0 ) +QCPDataContainer::QCPDataContainer() : + mAutoSqueeze(true), + mPreallocSize(0), + mPreallocIteration(0) { } @@ -2786,12 +2612,12 @@ QCPDataContainer::QCPDataContainer() \ref squeeze. */ template -void QCPDataContainer::setAutoSqueeze( bool enabled ) +void QCPDataContainer::setAutoSqueeze(bool enabled) { - if( mAutoSqueeze != enabled ) + if (mAutoSqueeze != enabled) { mAutoSqueeze = enabled; - if( mAutoSqueeze ) + if (mAutoSqueeze) performAutoSqueeze(); } } @@ -2803,10 +2629,10 @@ void QCPDataContainer::setAutoSqueeze( bool enabled ) \see add, remove */ template -void QCPDataContainer::set( const QCPDataContainer& data ) +void QCPDataContainer::set(const QCPDataContainer &data) { clear(); - add( data ); + add(data); } /*! \overload @@ -2819,12 +2645,12 @@ void QCPDataContainer::set( const QCPDataContainer& data ) \see add, remove */ template -void QCPDataContainer::set( const QVector& data, bool alreadySorted ) +void QCPDataContainer::set(const QVector &data, bool alreadySorted) { mData = data; mPreallocSize = 0; mPreallocIteration = 0; - if( !alreadySorted ) + if (!alreadySorted) sort(); } @@ -2835,27 +2661,26 @@ void QCPDataContainer::set( const QVector& data, bool alread \see set, remove */ template -void QCPDataContainer::add( const QCPDataContainer& data ) +void QCPDataContainer::add(const QCPDataContainer &data) { - if( data.isEmpty() ) + if (data.isEmpty()) return; - + const int n = data.size(); const int oldSize = size(); - - if( oldSize > 0 && !qcpLessThanSortKey( *constBegin(), *( data.constEnd() - 1 ) ) ) // prepend if new data keys are all smaller than or equal to existing ones + + if (oldSize > 0 && !qcpLessThanSortKey(*constBegin(), *(data.constEnd()-1))) // prepend if new data keys are all smaller than or equal to existing ones { - if( mPreallocSize < n ) - preallocateGrow( n ); + if (mPreallocSize < n) + preallocateGrow(n); mPreallocSize -= n; - std::copy( data.constBegin(), data.constEnd(), begin() ); - } - else // don't need to prepend, so append and merge if necessary + std::copy(data.constBegin(), data.constEnd(), begin()); + } else // don't need to prepend, so append and merge if necessary { - mData.resize( mData.size() + n ); - std::copy( data.constBegin(), data.constEnd(), end() - n ); - if( oldSize > 0 && !qcpLessThanSortKey( *( constEnd() - n - 1 ), *( constEnd() - n ) ) ) // if appended range keys aren't all greater than existing ones, merge the two partitions - std::inplace_merge( begin(), end() - n, end(), qcpLessThanSortKey ); + mData.resize(mData.size()+n); + std::copy(data.constBegin(), data.constEnd(), end()-n); + if (oldSize > 0 && !qcpLessThanSortKey(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions + std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey); } } @@ -2868,34 +2693,33 @@ void QCPDataContainer::add( const QCPDataContainer& data ) \see set, remove */ template -void QCPDataContainer::add( const QVector& data, bool alreadySorted ) +void QCPDataContainer::add(const QVector &data, bool alreadySorted) { - if( data.isEmpty() ) + if (data.isEmpty()) return; - if( isEmpty() ) + if (isEmpty()) { - set( data, alreadySorted ); + set(data, alreadySorted); return; } - + const int n = data.size(); const int oldSize = size(); - - if( alreadySorted && oldSize > 0 && !qcpLessThanSortKey( *constBegin(), *( data.constEnd() - 1 ) ) ) // prepend if new data is sorted and keys are all smaller than or equal to existing ones + + if (alreadySorted && oldSize > 0 && !qcpLessThanSortKey(*constBegin(), *(data.constEnd()-1))) // prepend if new data is sorted and keys are all smaller than or equal to existing ones { - if( mPreallocSize < n ) - preallocateGrow( n ); + if (mPreallocSize < n) + preallocateGrow(n); mPreallocSize -= n; - std::copy( data.constBegin(), data.constEnd(), begin() ); - } - else // don't need to prepend, so append and then sort and merge if necessary + std::copy(data.constBegin(), data.constEnd(), begin()); + } else // don't need to prepend, so append and then sort and merge if necessary { - mData.resize( mData.size() + n ); - std::copy( data.constBegin(), data.constEnd(), end() - n ); - if( !alreadySorted ) // sort appended subrange if it wasn't already sorted - std::sort( end() - n, end(), qcpLessThanSortKey ); - if( oldSize > 0 && !qcpLessThanSortKey( *( constEnd() - n - 1 ), *( constEnd() - n ) ) ) // if appended range keys aren't all greater than existing ones, merge the two partitions - std::inplace_merge( begin(), end() - n, end(), qcpLessThanSortKey ); + mData.resize(mData.size()+n); + std::copy(data.constBegin(), data.constEnd(), end()-n); + if (!alreadySorted) // sort appended subrange if it wasn't already sorted + std::sort(end()-n, end(), qcpLessThanSortKey); + if (oldSize > 0 && !qcpLessThanSortKey(*(constEnd()-n-1), *(constEnd()-n))) // if appended range keys aren't all greater than existing ones, merge the two partitions + std::inplace_merge(begin(), end()-n, end(), qcpLessThanSortKey); } } @@ -2906,23 +2730,21 @@ void QCPDataContainer::add( const QVector& data, bool alread \see remove */ template -void QCPDataContainer::add( const DataType& data ) +void QCPDataContainer::add(const DataType &data) { - if( isEmpty() || !qcpLessThanSortKey( data, *( constEnd() - 1 ) ) ) // quickly handle appends if new data key is greater or equal to existing ones + if (isEmpty() || !qcpLessThanSortKey(data, *(constEnd()-1))) // quickly handle appends if new data key is greater or equal to existing ones { - mData.append( data ); - } - else if( qcpLessThanSortKey( data, *constBegin() ) ) // quickly handle prepends using preallocated space + mData.append(data); + } else if (qcpLessThanSortKey(data, *constBegin())) // quickly handle prepends using preallocated space { - if( mPreallocSize < 1 ) - preallocateGrow( 1 ); + if (mPreallocSize < 1) + preallocateGrow(1); --mPreallocSize; *begin() = data; - } - else // handle inserts, maintaining sorted keys + } else // handle inserts, maintaining sorted keys { - QCPDataContainer::iterator insertionPoint = std::lower_bound( begin(), end(), data, qcpLessThanSortKey ); - mData.insert( insertionPoint, data ); + QCPDataContainer::iterator insertionPoint = std::lower_bound(begin(), end(), data, qcpLessThanSortKey); + mData.insert(insertionPoint, data); } } @@ -2932,12 +2754,12 @@ void QCPDataContainer::add( const DataType& data ) \see removeAfter, remove, clear */ template -void QCPDataContainer::removeBefore( double sortKey ) +void QCPDataContainer::removeBefore(double sortKey) { QCPDataContainer::iterator it = begin(); - QCPDataContainer::iterator itEnd = std::lower_bound( begin(), end(), DataType::fromSortKey( sortKey ), qcpLessThanSortKey ); - mPreallocSize += itEnd - it; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it) - if( mAutoSqueeze ) + QCPDataContainer::iterator itEnd = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey); + mPreallocSize += itEnd-it; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it) + if (mAutoSqueeze) performAutoSqueeze(); } @@ -2947,12 +2769,12 @@ void QCPDataContainer::removeBefore( double sortKey ) \see removeBefore, remove, clear */ template -void QCPDataContainer::removeAfter( double sortKey ) +void QCPDataContainer::removeAfter(double sortKey) { - QCPDataContainer::iterator it = std::upper_bound( begin(), end(), DataType::fromSortKey( sortKey ), qcpLessThanSortKey ); + QCPDataContainer::iterator it = std::upper_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey); QCPDataContainer::iterator itEnd = end(); - mData.erase( it, itEnd ); // typically adds it to the postallocated block - if( mAutoSqueeze ) + mData.erase(it, itEnd); // typically adds it to the postallocated block + if (mAutoSqueeze) performAutoSqueeze(); } @@ -2964,15 +2786,15 @@ void QCPDataContainer::removeAfter( double sortKey ) \see removeBefore, removeAfter, clear */ template -void QCPDataContainer::remove( double sortKeyFrom, double sortKeyTo ) +void QCPDataContainer::remove(double sortKeyFrom, double sortKeyTo) { - if( sortKeyFrom >= sortKeyTo || isEmpty() ) + if (sortKeyFrom >= sortKeyTo || isEmpty()) return; - - QCPDataContainer::iterator it = std::lower_bound( begin(), end(), DataType::fromSortKey( sortKeyFrom ), qcpLessThanSortKey ); - QCPDataContainer::iterator itEnd = std::upper_bound( it, end(), DataType::fromSortKey( sortKeyTo ), qcpLessThanSortKey ); - mData.erase( it, itEnd ); - if( mAutoSqueeze ) + + QCPDataContainer::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKeyFrom), qcpLessThanSortKey); + QCPDataContainer::iterator itEnd = std::upper_bound(it, end(), DataType::fromSortKey(sortKeyTo), qcpLessThanSortKey); + mData.erase(it, itEnd); + if (mAutoSqueeze) performAutoSqueeze(); } @@ -2986,17 +2808,17 @@ void QCPDataContainer::remove( double sortKeyFrom, double sortKeyTo ) \see removeBefore, removeAfter, clear */ template -void QCPDataContainer::remove( double sortKey ) +void QCPDataContainer::remove(double sortKey) { - QCPDataContainer::iterator it = std::lower_bound( begin(), end(), DataType::fromSortKey( sortKey ), qcpLessThanSortKey ); - if( it != end() && it->sortKey() == sortKey ) + QCPDataContainer::iterator it = std::lower_bound(begin(), end(), DataType::fromSortKey(sortKey), qcpLessThanSortKey); + if (it != end() && it->sortKey() == sortKey) { - if( it == begin() ) - ++mPreallocSize; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it) + if (it == begin()) + ++mPreallocSize; // don't actually delete, just add it to the preallocated block (if it gets too large, squeeze will take care of it) else - mData.erase( it ); + mData.erase(it); } - if( mAutoSqueeze ) + if (mAutoSqueeze) performAutoSqueeze(); } @@ -3027,7 +2849,7 @@ void QCPDataContainer::clear() template void QCPDataContainer::sort() { - std::sort( begin(), end(), qcpLessThanSortKey ); + std::sort(begin(), end(), qcpLessThanSortKey); } /*! @@ -3041,19 +2863,19 @@ void QCPDataContainer::sort() should be freed, respectively. */ template -void QCPDataContainer::squeeze( bool preAllocation, bool postAllocation ) +void QCPDataContainer::squeeze(bool preAllocation, bool postAllocation) { - if( preAllocation ) + if (preAllocation) { - if( mPreallocSize > 0 ) + if (mPreallocSize > 0) { - std::copy( begin(), end(), mData.begin() ); - mData.resize( size() ); + std::copy(begin(), end(), mData.begin()); + mData.resize(size()); mPreallocSize = 0; } mPreallocIteration = 0; } - if( postAllocation ) + if (postAllocation) mData.squeeze(); } @@ -3073,13 +2895,13 @@ void QCPDataContainer::squeeze( bool preAllocation, bool postAllocatio \see findEnd, QCPPlottableInterface1D::findBegin */ template -typename QCPDataContainer::const_iterator QCPDataContainer::findBegin( double sortKey, bool expandedRange ) const +typename QCPDataContainer::const_iterator QCPDataContainer::findBegin(double sortKey, bool expandedRange) const { - if( isEmpty() ) + if (isEmpty()) return constEnd(); - - QCPDataContainer::const_iterator it = std::lower_bound( constBegin(), constEnd(), DataType::fromSortKey( sortKey ), qcpLessThanSortKey ); - if( expandedRange && it != constBegin() ) // also covers it == constEnd case, and we know --constEnd is valid because mData isn't empty + + QCPDataContainer::const_iterator it = std::lower_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey); + if (expandedRange && it != constBegin()) // also covers it == constEnd case, and we know --constEnd is valid because mData isn't empty --it; return it; } @@ -3100,13 +2922,13 @@ typename QCPDataContainer::const_iterator QCPDataContainer:: \see findBegin, QCPPlottableInterface1D::findEnd */ template -typename QCPDataContainer::const_iterator QCPDataContainer::findEnd( double sortKey, bool expandedRange ) const +typename QCPDataContainer::const_iterator QCPDataContainer::findEnd(double sortKey, bool expandedRange) const { - if( isEmpty() ) + if (isEmpty()) return constEnd(); - - QCPDataContainer::const_iterator it = std::upper_bound( constBegin(), constEnd(), DataType::fromSortKey( sortKey ), qcpLessThanSortKey ); - if( expandedRange && it != constEnd() ) + + QCPDataContainer::const_iterator it = std::upper_bound(constBegin(), constEnd(), DataType::fromSortKey(sortKey), qcpLessThanSortKey); + if (expandedRange && it != constEnd()) ++it; return it; } @@ -3127,9 +2949,9 @@ typename QCPDataContainer::const_iterator QCPDataContainer:: \see valueRange */ template -QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain signDomain ) +QCPRange QCPDataContainer::keyRange(bool &foundRange, QCP::SignDomain signDomain) { - if( isEmpty() ) + if (isEmpty()) { foundRange = false; return QCPRange(); @@ -3138,16 +2960,16 @@ QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain bool haveLower = false; bool haveUpper = false; double current; - + QCPDataContainer::const_iterator it = constBegin(); QCPDataContainer::const_iterator itEnd = constEnd(); - if( signDomain == QCP::sdBoth ) // range may be anywhere + if (signDomain == QCP::sdBoth) // range may be anywhere { - if( DataType::sortKeyIsMainKey() ) // if DataType is sorted by main key (e.g. QCPGraph, but not QCPCurve), use faster algorithm by finding just first and last key with non-NaN value + if (DataType::sortKeyIsMainKey()) // if DataType is sorted by main key (e.g. QCPGraph, but not QCPCurve), use faster algorithm by finding just first and last key with non-NaN value { - while( it != itEnd ) // find first non-nan going up from left + while (it != itEnd) // find first non-nan going up from left { - if( !qIsNaN( it->mainValue() ) ) + if (!qIsNaN(it->mainValue())) { range.lower = it->mainKey(); haveLower = true; @@ -3156,30 +2978,29 @@ QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain ++it; } it = itEnd; - while( it != constBegin() ) // find first non-nan going down from right + while (it != constBegin()) // find first non-nan going down from right { --it; - if( !qIsNaN( it->mainValue() ) ) + if (!qIsNaN(it->mainValue())) { range.upper = it->mainKey(); haveUpper = true; break; } } - } - else // DataType is not sorted by main key, go through all data points and accordingly expand range + } else // DataType is not sorted by main key, go through all data points and accordingly expand range { - while( it != itEnd ) + while (it != itEnd) { - if( !qIsNaN( it->mainValue() ) ) + if (!qIsNaN(it->mainValue())) { current = it->mainKey(); - if( current < range.lower || !haveLower ) + if (current < range.lower || !haveLower) { range.lower = current; haveLower = true; } - if( current > range.upper || !haveUpper ) + if (current > range.upper || !haveUpper) { range.upper = current; haveUpper = true; @@ -3188,20 +3009,39 @@ QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain ++it; } } - } - else if( signDomain == QCP::sdNegative ) // range may only be in the negative sign domain + } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain { - while( it != itEnd ) + while (it != itEnd) { - if( !qIsNaN( it->mainValue() ) ) + if (!qIsNaN(it->mainValue())) { current = it->mainKey(); - if( ( current < range.lower || !haveLower ) && current < 0 ) + if ((current < range.lower || !haveLower) && current < 0) { range.lower = current; haveLower = true; } - if( ( current > range.upper || !haveUpper ) && current < 0 ) + if ((current > range.upper || !haveUpper) && current < 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain + { + while (it != itEnd) + { + if (!qIsNaN(it->mainValue())) + { + current = it->mainKey(); + if ((current < range.lower || !haveLower) && current > 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current > 0) { range.upper = current; haveUpper = true; @@ -3210,28 +3050,7 @@ QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain ++it; } } - else if( signDomain == QCP::sdPositive ) // range may only be in the positive sign domain - { - while( it != itEnd ) - { - if( !qIsNaN( it->mainValue() ) ) - { - current = it->mainKey(); - if( ( current < range.lower || !haveLower ) && current > 0 ) - { - range.lower = current; - haveLower = true; - } - if( ( current > range.upper || !haveUpper ) && current > 0 ) - { - range.upper = current; - haveUpper = true; - } - } - ++it; - } - } - + foundRange = haveLower && haveUpper; return range; } @@ -3253,9 +3072,9 @@ QCPRange QCPDataContainer::keyRange( bool& foundRange, QCP::SignDomain \see keyRange */ template -QCPRange QCPDataContainer::valueRange( bool& foundRange, QCP::SignDomain signDomain, const QCPRange& inKeyRange ) +QCPRange QCPDataContainer::valueRange(bool &foundRange, QCP::SignDomain signDomain, const QCPRange &inKeyRange) { - if( isEmpty() ) + if (isEmpty()) { foundRange = false; return QCPRange(); @@ -3267,69 +3086,67 @@ QCPRange QCPDataContainer::valueRange( bool& foundRange, QCP::SignDoma QCPRange current; QCPDataContainer::const_iterator itBegin = constBegin(); QCPDataContainer::const_iterator itEnd = constEnd(); - if( DataType::sortKeyIsMainKey() && restrictKeyRange ) + if (DataType::sortKeyIsMainKey() && restrictKeyRange) { - itBegin = findBegin( inKeyRange.lower ); - itEnd = findEnd( inKeyRange.upper ); + itBegin = findBegin(inKeyRange.lower); + itEnd = findEnd(inKeyRange.upper); } - if( signDomain == QCP::sdBoth ) // range may be anywhere + if (signDomain == QCP::sdBoth) // range may be anywhere { - for( QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it ) + for (QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it) { - if( restrictKeyRange && ( it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper ) ) + if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) continue; current = it->valueRange(); - if( ( current.lower < range.lower || !haveLower ) && !qIsNaN( current.lower ) ) + if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower)) { range.lower = current.lower; haveLower = true; } - if( ( current.upper > range.upper || !haveUpper ) && !qIsNaN( current.upper ) ) + if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper)) + { + range.upper = current.upper; + haveUpper = true; + } + } + } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain + { + for (QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it) + { + if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) + continue; + current = it->valueRange(); + if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower)) + { + range.lower = current.lower; + haveLower = true; + } + if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper)) + { + range.upper = current.upper; + haveUpper = true; + } + } + } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain + { + for (QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it) + { + if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) + continue; + current = it->valueRange(); + if ((current.lower < range.lower || !haveLower) && current.lower > 0 && !qIsNaN(current.lower)) + { + range.lower = current.lower; + haveLower = true; + } + if ((current.upper > range.upper || !haveUpper) && current.upper > 0 && !qIsNaN(current.upper)) { range.upper = current.upper; haveUpper = true; } } } - else if( signDomain == QCP::sdNegative ) // range may only be in the negative sign domain - { - for( QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it ) - { - if( restrictKeyRange && ( it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper ) ) - continue; - current = it->valueRange(); - if( ( current.lower < range.lower || !haveLower ) && current.lower < 0 && !qIsNaN( current.lower ) ) - { - range.lower = current.lower; - haveLower = true; - } - if( ( current.upper > range.upper || !haveUpper ) && current.upper < 0 && !qIsNaN( current.upper ) ) - { - range.upper = current.upper; - haveUpper = true; - } - } - } - else if( signDomain == QCP::sdPositive ) // range may only be in the positive sign domain - { - for( QCPDataContainer::const_iterator it = itBegin; it != itEnd; ++it ) - { - if( restrictKeyRange && ( it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper ) ) - continue; - current = it->valueRange(); - if( ( current.lower < range.lower || !haveLower ) && current.lower > 0 && !qIsNaN( current.lower ) ) - { - range.lower = current.lower; - haveLower = true; - } - if( ( current.upper > range.upper || !haveUpper ) && current.upper > 0 && !qIsNaN( current.upper ) ) - { - range.upper = current.upper; - haveUpper = true; - } - } - } - + foundRange = haveLower && haveUpper; return range; } @@ -3343,12 +3160,12 @@ QCPRange QCPDataContainer::valueRange( bool& foundRange, QCP::SignDoma valid range. */ template -void QCPDataContainer::limitIteratorsToDataRange( const_iterator& begin, const_iterator& end, const QCPDataRange& dataRange ) const +void QCPDataContainer::limitIteratorsToDataRange(const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const { - QCPDataRange iteratorRange( begin - constBegin(), end - constBegin() ); - iteratorRange = iteratorRange.bounded( dataRange.bounded( this->dataRange() ) ); - begin = constBegin() + iteratorRange.begin(); - end = constBegin() + iteratorRange.end(); + QCPDataRange iteratorRange(begin-constBegin(), end-constBegin()); + iteratorRange = iteratorRange.bounded(dataRange.bounded(this->dataRange())); + begin = constBegin()+iteratorRange.begin(); + end = constBegin()+iteratorRange.end(); } /*! \internal @@ -3361,18 +3178,18 @@ void QCPDataContainer::limitIteratorsToDataRange( const_iterator& begi method does nothing. */ template -void QCPDataContainer::preallocateGrow( int minimumPreallocSize ) +void QCPDataContainer::preallocateGrow(int minimumPreallocSize) { - if( minimumPreallocSize <= mPreallocSize ) + if (minimumPreallocSize <= mPreallocSize) return; - + int newPreallocSize = minimumPreallocSize; - newPreallocSize += ( 1u << qBound( 4, mPreallocIteration + 4, 15 ) ) - 12; // do 4 up to 32768-12 preallocation, doubling in each intermediate iteration + newPreallocSize += (1u< void QCPDataContainer::performAutoSqueeze() { const int totalAlloc = mData.capacity(); - const int postAllocSize = totalAlloc - mData.size(); + const int postAllocSize = totalAlloc-mData.size(); const int usedSize = size(); bool shrinkPostAllocation = false; bool shrinkPreAllocation = false; - if( totalAlloc > 650000 ) // if allocation is larger, shrink earlier with respect to total used size + if (totalAlloc > 650000) // if allocation is larger, shrink earlier with respect to total used size { - shrinkPostAllocation = postAllocSize > usedSize * 1.5; // QVector grow strategy is 2^n for static data. Watch out not to oscillate! - shrinkPreAllocation = mPreallocSize * 10 > usedSize; - } - else if( totalAlloc > 1000 ) // below 10 MiB raw data be generous with preallocated memory, below 1k points don't even bother + shrinkPostAllocation = postAllocSize > usedSize*1.5; // QVector grow strategy is 2^n for static data. Watch out not to oscillate! + shrinkPreAllocation = mPreallocSize*10 > usedSize; + } else if (totalAlloc > 1000) // below 10 MiB raw data be generous with preallocated memory, below 1k points don't even bother { - shrinkPostAllocation = postAllocSize > usedSize * 5; - shrinkPreAllocation = mPreallocSize > usedSize * 1.5; // preallocation can grow into postallocation, so can be smaller + shrinkPostAllocation = postAllocSize > usedSize*5; + shrinkPreAllocation = mPreallocSize > usedSize*1.5; // preallocation can grow into postallocation, so can be smaller } - - if( shrinkPreAllocation || shrinkPostAllocation ) - squeeze( shrinkPreAllocation, shrinkPostAllocation ); + + if (shrinkPreAllocation || shrinkPostAllocation) + squeeze(shrinkPreAllocation, shrinkPostAllocation); } /* end of 'src/datacontainer.cpp' */ + /* end of 'src/datacontainer.h' */ + /* including file 'src/plottable.h', size 8312 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -3425,28 +3243,28 @@ class QCP_LIB_DECL QCPSelectionDecorator public: QCPSelectionDecorator(); virtual ~QCPSelectionDecorator(); - + // getters: QPen pen() const { return mPen; } QBrush brush() const { return mBrush; } QCPScatterStyle scatterStyle() const { return mScatterStyle; } QCPScatterStyle::ScatterProperties usedScatterProperties() const { return mUsedScatterProperties; } - + // setters: - void setPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setScatterStyle( const QCPScatterStyle& scatterStyle, QCPScatterStyle::ScatterProperties usedProperties = QCPScatterStyle::spPen ); - void setUsedScatterProperties( const QCPScatterStyle::ScatterProperties& properties ); - + void setPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen); + void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties); + // non-virtual methods: - void applyPen( QCPPainter* painter ) const; - void applyBrush( QCPPainter* painter ) const; - QCPScatterStyle getFinalScatterStyle( const QCPScatterStyle& unselectedStyle ) const; - + void applyPen(QCPPainter *painter) const; + void applyBrush(QCPPainter *painter) const; + QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const; + // introduced virtual methods: - virtual void copyFrom( const QCPSelectionDecorator* other ); - virtual void drawDecoration( QCPPainter* painter, QCPDataSelection selection ); - + virtual void copyFrom(const QCPSelectionDecorator *other); + virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection); + protected: // property members: QPen mPen; @@ -3454,85 +3272,86 @@ protected: QCPScatterStyle mScatterStyle; QCPScatterStyle::ScatterProperties mUsedScatterProperties; // non-property members: - QCPAbstractPlottable* mPlottable; - + QCPAbstractPlottable *mPlottable; + // introduced virtual methods: - virtual bool registerWithPlottable( QCPAbstractPlottable* plottable ); - + virtual bool registerWithPlottable(QCPAbstractPlottable *plottable); + private: - Q_DISABLE_COPY( QCPSelectionDecorator ) + Q_DISABLE_COPY(QCPSelectionDecorator) friend class QCPAbstractPlottable; }; -Q_DECLARE_METATYPE( QCPSelectionDecorator* ) +Q_DECLARE_METATYPE(QCPSelectionDecorator*) + class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QString name READ name WRITE setName ) - Q_PROPERTY( bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill ) - Q_PROPERTY( bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters ) - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis ) - Q_PROPERTY( QCPAxis* valueAxis READ valueAxis WRITE setValueAxis ) - Q_PROPERTY( QCP::SelectionType selectable READ selectable WRITE setSelectable NOTIFY selectableChanged ) - Q_PROPERTY( QCPDataSelection selection READ selection WRITE setSelection NOTIFY selectionChanged ) - Q_PROPERTY( QCPSelectionDecorator* selectionDecorator READ selectionDecorator WRITE setSelectionDecorator ) + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill) + Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis) + Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis) + Q_PROPERTY(QCP::SelectionType selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(QCPDataSelection selection READ selection WRITE setSelection NOTIFY selectionChanged) + Q_PROPERTY(QCPSelectionDecorator* selectionDecorator READ selectionDecorator WRITE setSelectionDecorator) /// \endcond public: - QCPAbstractPlottable( QCPAxis* keyAxis, QCPAxis* valueAxis ); + QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPAbstractPlottable(); - + // getters: QString name() const { return mName; } bool antialiasedFill() const { return mAntialiasedFill; } bool antialiasedScatters() const { return mAntialiasedScatters; } QPen pen() const { return mPen; } QBrush brush() const { return mBrush; } - QCPAxis* keyAxis() const { return mKeyAxis.data(); } - QCPAxis* valueAxis() const { return mValueAxis.data(); } + QCPAxis *keyAxis() const { return mKeyAxis.data(); } + QCPAxis *valueAxis() const { return mValueAxis.data(); } QCP::SelectionType selectable() const { return mSelectable; } bool selected() const { return !mSelection.isEmpty(); } QCPDataSelection selection() const { return mSelection; } - QCPSelectionDecorator* selectionDecorator() const { return mSelectionDecorator; } - + QCPSelectionDecorator *selectionDecorator() const { return mSelectionDecorator; } + // setters: - void setName( const QString& name ); - void setAntialiasedFill( bool enabled ); - void setAntialiasedScatters( bool enabled ); - void setPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setKeyAxis( QCPAxis* axis ); - void setValueAxis( QCPAxis* axis ); - Q_SLOT void setSelectable( QCP::SelectionType selectable ); - Q_SLOT void setSelection( QCPDataSelection selection ); - void setSelectionDecorator( QCPSelectionDecorator* decorator ); + void setName(const QString &name); + void setAntialiasedFill(bool enabled); + void setAntialiasedScatters(bool enabled); + void setPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setKeyAxis(QCPAxis *axis); + void setValueAxis(QCPAxis *axis); + Q_SLOT void setSelectable(QCP::SelectionType selectable); + Q_SLOT void setSelection(QCPDataSelection selection); + void setSelectionDecorator(QCPSelectionDecorator *decorator); // introduced virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const = 0; - virtual QCPPlottableInterface1D* interface1D() { return 0; } - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const = 0; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const = 0; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0; + virtual QCPPlottableInterface1D *interface1D() { return 0; } + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const = 0; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const = 0; + // non-property methods: - void coordsToPixels( double key, double value, double& x, double& y ) const; - const QPointF coordsToPixels( double key, double value ) const; - void pixelsToCoords( double x, double y, double& key, double& value ) const; - void pixelsToCoords( const QPointF& pixelPos, double& key, double& value ) const; - void rescaleAxes( bool onlyEnlarge = false ) const; - void rescaleKeyAxis( bool onlyEnlarge = false ) const; - void rescaleValueAxis( bool onlyEnlarge = false, bool inKeyRange = false ) const; - bool addToLegend( QCPLegend* legend ); + void coordsToPixels(double key, double value, double &x, double &y) const; + const QPointF coordsToPixels(double key, double value) const; + void pixelsToCoords(double x, double y, double &key, double &value) const; + void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const; + void rescaleAxes(bool onlyEnlarge=false) const; + void rescaleKeyAxis(bool onlyEnlarge=false) const; + void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const; + bool addToLegend(QCPLegend *legend); bool addToLegend(); - bool removeFromLegend( QCPLegend* legend ) const; + bool removeFromLegend(QCPLegend *legend) const; bool removeFromLegend() const; - + signals: - void selectionChanged( bool selected ); - void selectionChanged( const QCPDataSelection& selection ); - void selectableChanged( QCP::SelectionType selectable ); - + void selectionChanged(bool selected); + void selectionChanged(const QCPDataSelection &selection); + void selectableChanged(QCP::SelectionType selectable); + protected: // property members: QString mName; @@ -3542,34 +3361,36 @@ protected: QPointer mKeyAxis, mValueAxis; QCP::SelectionType mSelectable; QCPDataSelection mSelection; - QCPSelectionDecorator* mSelectionDecorator; - + QCPSelectionDecorator *mSelectionDecorator; + // reimplemented virtual methods: virtual QRect clipRect() const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE = 0; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0; virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE; - void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; + void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; - + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const = 0; - + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0; + // non-virtual methods: - void applyFillAntialiasingHint( QCPPainter* painter ) const; - void applyScattersAntialiasingHint( QCPPainter* painter ) const; + void applyFillAntialiasingHint(QCPPainter *painter) const; + void applyScattersAntialiasingHint(QCPPainter *painter) const; private: - Q_DISABLE_COPY( QCPAbstractPlottable ) - + Q_DISABLE_COPY(QCPAbstractPlottable) + friend class QCustomPlot; friend class QCPAxis; friend class QCPPlottableLegendItem; }; + /* end of 'src/plottable.h' */ + /* including file 'src/item.h', size 9384 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -3577,38 +3398,40 @@ class QCP_LIB_DECL QCPItemAnchor { Q_GADGET public: - QCPItemAnchor( QCustomPlot* parentPlot, QCPAbstractItem* parentItem, const QString& name, int anchorId = -1 ); + QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1); virtual ~QCPItemAnchor(); - + // getters: QString name() const { return mName; } virtual QPointF pixelPosition() const; - + protected: // property members: QString mName; - + // non-property members: - QCustomPlot* mParentPlot; - QCPAbstractItem* mParentItem; + QCustomPlot *mParentPlot; + QCPAbstractItem *mParentItem; int mAnchorId; QSet mChildrenX, mChildrenY; - + // introduced virtual methods: - virtual QCPItemPosition* toQCPItemPosition() { return 0; } - + virtual QCPItemPosition *toQCPItemPosition() { return 0; } + // non-virtual methods: - void addChildX( QCPItemPosition* pos ); // called from pos when this anchor is set as parent - void removeChildX( QCPItemPosition* pos ); // called from pos when its parent anchor is reset or pos deleted - void addChildY( QCPItemPosition* pos ); // called from pos when this anchor is set as parent - void removeChildY( QCPItemPosition* pos ); // called from pos when its parent anchor is reset or pos deleted - + void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent + void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted + void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent + void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted + private: - Q_DISABLE_COPY( QCPItemAnchor ) - + Q_DISABLE_COPY(QCPItemAnchor) + friend class QCPItemPosition; }; + + class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor { Q_GADGET @@ -3619,53 +3442,48 @@ public: \see setType */ - enum PositionType - { - ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget. - , - ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top - ///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and - ///< vertically at the top of the viewport/widget, etc. - , - ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top - ///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and - ///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1. - , - ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes). - }; - Q_ENUMS( PositionType ) - - QCPItemPosition( QCustomPlot* parentPlot, QCPAbstractItem* parentItem, const QString& name ); + enum PositionType { ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget. + ,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the viewport/widget, etc. + ,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1. + ,ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes). + }; + Q_ENUMS(PositionType) + + QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name); virtual ~QCPItemPosition(); - + // getters: PositionType type() const { return typeX(); } PositionType typeX() const { return mPositionTypeX; } PositionType typeY() const { return mPositionTypeY; } - QCPItemAnchor* parentAnchor() const { return parentAnchorX(); } - QCPItemAnchor* parentAnchorX() const { return mParentAnchorX; } - QCPItemAnchor* parentAnchorY() const { return mParentAnchorY; } + QCPItemAnchor *parentAnchor() const { return parentAnchorX(); } + QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; } + QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; } double key() const { return mKey; } double value() const { return mValue; } - QPointF coords() const { return QPointF( mKey, mValue ); } - QCPAxis* keyAxis() const { return mKeyAxis.data(); } - QCPAxis* valueAxis() const { return mValueAxis.data(); } - QCPAxisRect* axisRect() const; + QPointF coords() const { return QPointF(mKey, mValue); } + QCPAxis *keyAxis() const { return mKeyAxis.data(); } + QCPAxis *valueAxis() const { return mValueAxis.data(); } + QCPAxisRect *axisRect() const; virtual QPointF pixelPosition() const Q_DECL_OVERRIDE; - + // setters: - void setType( PositionType type ); - void setTypeX( PositionType type ); - void setTypeY( PositionType type ); - bool setParentAnchor( QCPItemAnchor* parentAnchor, bool keepPixelPosition = false ); - bool setParentAnchorX( QCPItemAnchor* parentAnchor, bool keepPixelPosition = false ); - bool setParentAnchorY( QCPItemAnchor* parentAnchor, bool keepPixelPosition = false ); - void setCoords( double key, double value ); - void setCoords( const QPointF& coords ); - void setAxes( QCPAxis* keyAxis, QCPAxis* valueAxis ); - void setAxisRect( QCPAxisRect* axisRect ); - void setPixelPosition( const QPointF& pixelPosition ); - + void setType(PositionType type); + void setTypeX(PositionType type); + void setTypeY(PositionType type); + bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + void setCoords(double key, double value); + void setCoords(const QPointF &coords); + void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis); + void setAxisRect(QCPAxisRect *axisRect); + void setPixelPosition(const QPointF &pixelPosition); + protected: // property members: PositionType mPositionTypeX, mPositionTypeY; @@ -3673,54 +3491,56 @@ protected: QPointer mAxisRect; double mKey, mValue; QCPItemAnchor *mParentAnchorX, *mParentAnchorY; - + // reimplemented virtual methods: - virtual QCPItemPosition* toQCPItemPosition() Q_DECL_OVERRIDE { return this; } - + virtual QCPItemPosition *toQCPItemPosition() Q_DECL_OVERRIDE { return this; } + private: - Q_DISABLE_COPY( QCPItemPosition ) + Q_DISABLE_COPY(QCPItemPosition) + }; -Q_DECLARE_METATYPE( QCPItemPosition::PositionType ) +Q_DECLARE_METATYPE(QCPItemPosition::PositionType) + class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect ) - Q_PROPERTY( QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect ) - Q_PROPERTY( bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged ) - Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectionChanged ) + Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect) + Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) /// \endcond public: - explicit QCPAbstractItem( QCustomPlot* parentPlot ); + explicit QCPAbstractItem(QCustomPlot *parentPlot); virtual ~QCPAbstractItem(); - + // getters: bool clipToAxisRect() const { return mClipToAxisRect; } - QCPAxisRect* clipAxisRect() const; + QCPAxisRect *clipAxisRect() const; bool selectable() const { return mSelectable; } bool selected() const { return mSelected; } - + // setters: - void setClipToAxisRect( bool clip ); - void setClipAxisRect( QCPAxisRect* rect ); - Q_SLOT void setSelectable( bool selectable ); - Q_SLOT void setSelected( bool selected ); - + void setClipToAxisRect(bool clip); + void setClipAxisRect(QCPAxisRect *rect); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE = 0; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE = 0; + // non-virtual methods: QList positions() const { return mPositions; } QList anchors() const { return mAnchors; } - QCPItemPosition* position( const QString& name ) const; - QCPItemAnchor* anchor( const QString& name ) const; - bool hasAnchor( const QString& name ) const; - + QCPItemPosition *position(const QString &name) const; + QCPItemAnchor *anchor(const QString &name) const; + bool hasAnchor(const QString &name) const; + signals: - void selectionChanged( bool selected ); - void selectableChanged( bool selectable ); - + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + protected: // property members: bool mClipToAxisRect; @@ -3728,33 +3548,34 @@ protected: QList mPositions; QList mAnchors; bool mSelectable, mSelected; - + // reimplemented virtual methods: virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE; virtual QRect clipRect() const Q_DECL_OVERRIDE; - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE = 0; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; - + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual QPointF anchorPixelPosition( int anchorId ) const; - + virtual QPointF anchorPixelPosition(int anchorId) const; + // non-virtual methods: - double rectDistance( const QRectF& rect, const QPointF& pos, bool filledRect ) const; - QCPItemPosition* createPosition( const QString& name ); - QCPItemAnchor* createAnchor( const QString& name, int anchorId ); - + double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const; + QCPItemPosition *createPosition(const QString &name); + QCPItemAnchor *createAnchor(const QString &name, int anchorId); + private: - Q_DISABLE_COPY( QCPAbstractItem ) - + Q_DISABLE_COPY(QCPAbstractItem) + friend class QCustomPlot; friend class QCPItemAnchor; }; /* end of 'src/item.h' */ + /* including file 'src/core.h', size 14886 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -3762,16 +3583,16 @@ class QCP_LIB_DECL QCustomPlot : public QWidget { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QRect viewport READ viewport WRITE setViewport ) - Q_PROPERTY( QPixmap background READ background WRITE setBackground ) - Q_PROPERTY( bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled ) - Q_PROPERTY( Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode ) - Q_PROPERTY( QCPLayoutGrid* plotLayout READ plotLayout ) - Q_PROPERTY( bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend ) - Q_PROPERTY( int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance ) - Q_PROPERTY( bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag ) - Q_PROPERTY( Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier ) - Q_PROPERTY( bool openGl READ openGl WRITE setOpenGl ) + Q_PROPERTY(QRect viewport READ viewport WRITE setViewport) + Q_PROPERTY(QPixmap background READ background WRITE setBackground) + Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) + Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) + Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout) + Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend) + Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance) + Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag) + Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier) + Q_PROPERTY(bool openGl READ openGl WRITE setOpenGl) /// \endcond public: /*! @@ -3779,41 +3600,33 @@ public: \see addLayer, moveLayer */ - enum LayerInsertMode - { - limBelow ///< Layer is inserted below other layer - , - limAbove ///< Layer is inserted above other layer - }; - Q_ENUMS( LayerInsertMode ) - + enum LayerInsertMode { limBelow ///< Layer is inserted below other layer + ,limAbove ///< Layer is inserted above other layer + }; + Q_ENUMS(LayerInsertMode) + /*! Defines with what timing the QCustomPlot surface is refreshed after a replot. \see replot */ - enum RefreshPriority - { - rpImmediateRefresh ///< Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replot - , - rpQueuedRefresh ///< Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot. This way multiple redundant widget repaints can be avoided. - , - rpRefreshHint ///< Whether to use immediate or queued refresh depends on whether the plotting hint \ref QCP::phImmediateRefresh is set, see \ref setPlottingHints. - , - rpQueuedReplot ///< Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with \ref rpRefreshHint priority. - }; - Q_ENUMS( RefreshPriority ) - - explicit QCustomPlot( QWidget* parent = 0 ); + enum RefreshPriority { rpImmediateRefresh ///< Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replot + ,rpQueuedRefresh ///< Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot. This way multiple redundant widget repaints can be avoided. + ,rpRefreshHint ///< Whether to use immediate or queued refresh depends on whether the plotting hint \ref QCP::phImmediateRefresh is set, see \ref setPlottingHints. + ,rpQueuedReplot ///< Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with \ref rpRefreshHint priority. + }; + Q_ENUMS(RefreshPriority) + + explicit QCustomPlot(QWidget *parent = 0); virtual ~QCustomPlot(); - + // getters: QRect viewport() const { return mViewport; } double bufferDevicePixelRatio() const { return mBufferDevicePixelRatio; } QPixmap background() const { return mBackgroundPixmap; } bool backgroundScaled() const { return mBackgroundScaled; } Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } - QCPLayoutGrid* plotLayout() const { return mPlotLayout; } + QCPLayoutGrid *plotLayout() const { return mPlotLayout; } QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; } QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; } bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; } @@ -3823,129 +3636,129 @@ public: QCP::PlottingHints plottingHints() const { return mPlottingHints; } Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; } QCP::SelectionRectMode selectionRectMode() const { return mSelectionRectMode; } - QCPSelectionRect* selectionRect() const { return mSelectionRect; } + QCPSelectionRect *selectionRect() const { return mSelectionRect; } bool openGl() const { return mOpenGl; } - + // setters: - void setViewport( const QRect& rect ); - void setBufferDevicePixelRatio( double ratio ); - void setBackground( const QPixmap& pm ); - void setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding ); - void setBackground( const QBrush& brush ); - void setBackgroundScaled( bool scaled ); - void setBackgroundScaledMode( Qt::AspectRatioMode mode ); - void setAntialiasedElements( const QCP::AntialiasedElements& antialiasedElements ); - void setAntialiasedElement( QCP::AntialiasedElement antialiasedElement, bool enabled = true ); - void setNotAntialiasedElements( const QCP::AntialiasedElements& notAntialiasedElements ); - void setNotAntialiasedElement( QCP::AntialiasedElement notAntialiasedElement, bool enabled = true ); - void setAutoAddPlottableToLegend( bool on ); - void setInteractions( const QCP::Interactions& interactions ); - void setInteraction( const QCP::Interaction& interaction, bool enabled = true ); - void setSelectionTolerance( int pixels ); - void setNoAntialiasingOnDrag( bool enabled ); - void setPlottingHints( const QCP::PlottingHints& hints ); - void setPlottingHint( QCP::PlottingHint hint, bool enabled = true ); - void setMultiSelectModifier( Qt::KeyboardModifier modifier ); - void setSelectionRectMode( QCP::SelectionRectMode mode ); - void setSelectionRect( QCPSelectionRect* selectionRect ); - void setOpenGl( bool enabled, int multisampling = 16 ); - + void setViewport(const QRect &rect); + void setBufferDevicePixelRatio(double ratio); + void setBackground(const QPixmap &pm); + void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); + void setBackground(const QBrush &brush); + void setBackgroundScaled(bool scaled); + void setBackgroundScaledMode(Qt::AspectRatioMode mode); + void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements); + void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true); + void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements); + void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true); + void setAutoAddPlottableToLegend(bool on); + void setInteractions(const QCP::Interactions &interactions); + void setInteraction(const QCP::Interaction &interaction, bool enabled=true); + void setSelectionTolerance(int pixels); + void setNoAntialiasingOnDrag(bool enabled); + void setPlottingHints(const QCP::PlottingHints &hints); + void setPlottingHint(QCP::PlottingHint hint, bool enabled=true); + void setMultiSelectModifier(Qt::KeyboardModifier modifier); + void setSelectionRectMode(QCP::SelectionRectMode mode); + void setSelectionRect(QCPSelectionRect *selectionRect); + void setOpenGl(bool enabled, int multisampling=16); + // non-property methods: // plottable interface: - QCPAbstractPlottable* plottable( int index ); - QCPAbstractPlottable* plottable(); - bool removePlottable( QCPAbstractPlottable* plottable ); - bool removePlottable( int index ); + QCPAbstractPlottable *plottable(int index); + QCPAbstractPlottable *plottable(); + bool removePlottable(QCPAbstractPlottable *plottable); + bool removePlottable(int index); int clearPlottables(); int plottableCount() const; QList selectedPlottables() const; - QCPAbstractPlottable* plottableAt( const QPointF& pos, bool onlySelectable = false ) const; - bool hasPlottable( QCPAbstractPlottable* plottable ) const; - + QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const; + bool hasPlottable(QCPAbstractPlottable *plottable) const; + // specialized interface for QCPGraph: - QCPGraph* graph( int index ) const; - QCPGraph* graph() const; - QCPGraph* addGraph( QCPAxis* keyAxis = 0, QCPAxis* valueAxis = 0 ); - bool removeGraph( QCPGraph* graph ); - bool removeGraph( int index ); + QCPGraph *graph(int index) const; + QCPGraph *graph() const; + QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0); + bool removeGraph(QCPGraph *graph); + bool removeGraph(int index); int clearGraphs(); int graphCount() const; QList selectedGraphs() const; // item interface: - QCPAbstractItem* item( int index ) const; - QCPAbstractItem* item() const; - bool removeItem( QCPAbstractItem* item ); - bool removeItem( int index ); + QCPAbstractItem *item(int index) const; + QCPAbstractItem *item() const; + bool removeItem(QCPAbstractItem *item); + bool removeItem(int index); int clearItems(); int itemCount() const; QList selectedItems() const; - QCPAbstractItem* itemAt( const QPointF& pos, bool onlySelectable = false ) const; - bool hasItem( QCPAbstractItem* item ) const; - + QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const; + bool hasItem(QCPAbstractItem *item) const; + // layer interface: - QCPLayer* layer( const QString& name ) const; - QCPLayer* layer( int index ) const; - QCPLayer* currentLayer() const; - bool setCurrentLayer( const QString& name ); - bool setCurrentLayer( QCPLayer* layer ); + QCPLayer *layer(const QString &name) const; + QCPLayer *layer(int index) const; + QCPLayer *currentLayer() const; + bool setCurrentLayer(const QString &name); + bool setCurrentLayer(QCPLayer *layer); int layerCount() const; - bool addLayer( const QString& name, QCPLayer* otherLayer = 0, LayerInsertMode insertMode = limAbove ); - bool removeLayer( QCPLayer* layer ); - bool moveLayer( QCPLayer* layer, QCPLayer* otherLayer, LayerInsertMode insertMode = limAbove ); - + bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove); + bool removeLayer(QCPLayer *layer); + bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove); + // axis rect/layout interface: int axisRectCount() const; - QCPAxisRect* axisRect( int index = 0 ) const; + QCPAxisRect* axisRect(int index=0) const; QList axisRects() const; - QCPLayoutElement* layoutElementAt( const QPointF& pos ) const; - QCPAxisRect* axisRectAt( const QPointF& pos ) const; - Q_SLOT void rescaleAxes( bool onlyVisiblePlottables = false ); - + QCPLayoutElement* layoutElementAt(const QPointF &pos) const; + QCPAxisRect* axisRectAt(const QPointF &pos) const; + Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false); + QList selectedAxes() const; QList selectedLegends() const; Q_SLOT void deselectAll(); - - bool savePdf( const QString& fileName, int width = 0, int height = 0, QCP::ExportPen exportPen = QCP::epAllowCosmetic, const QString& pdfCreator = QString(), const QString& pdfTitle = QString() ); - bool savePng( const QString& fileName, int width = 0, int height = 0, double scale = 1.0, int quality = -1, int resolution = 96, QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch ); - bool saveJpg( const QString& fileName, int width = 0, int height = 0, double scale = 1.0, int quality = -1, int resolution = 96, QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch ); - bool saveBmp( const QString& fileName, int width = 0, int height = 0, double scale = 1.0, int resolution = 96, QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch ); - bool saveRastered( const QString& fileName, int width, int height, double scale, const char* format, int quality = -1, int resolution = 96, QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch ); - QPixmap toPixmap( int width = 0, int height = 0, double scale = 1.0 ); - void toPainter( QCPPainter* painter, int width = 0, int height = 0 ); - Q_SLOT void replot( QCustomPlot::RefreshPriority refreshPriority = QCustomPlot::rpRefreshHint ); - + + bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString()); + bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); + bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); + bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); + bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch); + QPixmap toPixmap(int width=0, int height=0, double scale=1.0); + void toPainter(QCPPainter *painter, int width=0, int height=0); + Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint); + QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; - QCPLegend* legend; - + QCPLegend *legend; + signals: - void mouseDoubleClick( QMouseEvent* event ); - void mousePress( QMouseEvent* event ); - void mouseMove( QMouseEvent* event ); - void mouseRelease( QMouseEvent* event ); - void mouseWheel( QWheelEvent* event ); - - void plottableClick( QCPAbstractPlottable* plottable, int dataIndex, QMouseEvent* event ); - void plottableDoubleClick( QCPAbstractPlottable* plottable, int dataIndex, QMouseEvent* event ); - void itemClick( QCPAbstractItem* item, QMouseEvent* event ); - void itemDoubleClick( QCPAbstractItem* item, QMouseEvent* event ); - void axisClick( QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event ); - void axisDoubleClick( QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event ); - void legendClick( QCPLegend* legend, QCPAbstractLegendItem* item, QMouseEvent* event ); - void legendDoubleClick( QCPLegend* legend, QCPAbstractLegendItem* item, QMouseEvent* event ); - + void mouseDoubleClick(QMouseEvent *event); + void mousePress(QMouseEvent *event); + void mouseMove(QMouseEvent *event); + void mouseRelease(QMouseEvent *event); + void mouseWheel(QWheelEvent *event); + + void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event); + void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event); + void itemClick(QCPAbstractItem *item, QMouseEvent *event); + void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event); + void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event); + void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event); + void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event); + void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event); + void selectionChangedByUser(); void beforeReplot(); void afterReplot(); - + protected: // property members: QRect mViewport; double mBufferDevicePixelRatio; - QCPLayoutGrid* mPlotLayout; + QCPLayoutGrid *mPlotLayout; bool mAutoAddPlottableToLegend; QList mPlottables; - QList mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph + QList mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph QList mItems; QList mLayers; QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements; @@ -3957,13 +3770,13 @@ protected: QPixmap mScaledBackgroundPixmap; bool mBackgroundScaled; Qt::AspectRatioMode mBackgroundScaledMode; - QCPLayer* mCurrentLayer; + QCPLayer *mCurrentLayer; QCP::PlottingHints mPlottingHints; Qt::KeyboardModifier mMultiSelectModifier; QCP::SelectionRectMode mSelectionRectMode; - QCPSelectionRect* mSelectionRect; + QCPSelectionRect *mSelectionRect; bool mOpenGl; - + // non-property members: QList > mPaintBuffers; QPoint mMousePressPos; @@ -3982,41 +3795,41 @@ protected: QSharedPointer mGlSurface; QSharedPointer mGlPaintDevice; #endif - + // reimplemented virtual methods: virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; virtual QSize sizeHint() const Q_DECL_OVERRIDE; - virtual void paintEvent( QPaintEvent* event ) Q_DECL_OVERRIDE; - virtual void resizeEvent( QResizeEvent* event ) Q_DECL_OVERRIDE; - virtual void mouseDoubleClickEvent( QMouseEvent* event ) Q_DECL_OVERRIDE; - virtual void mousePressEvent( QMouseEvent* event ) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent( QMouseEvent* event ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* event ) Q_DECL_OVERRIDE; - virtual void wheelEvent( QWheelEvent* event ) Q_DECL_OVERRIDE; - + virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual void draw( QCPPainter* painter ); + virtual void draw(QCPPainter *painter); virtual void updateLayout(); - virtual void axisRemoved( QCPAxis* axis ); - virtual void legendRemoved( QCPLegend* legend ); - Q_SLOT virtual void processRectSelection( QRect rect, QMouseEvent* event ); - Q_SLOT virtual void processRectZoom( QRect rect, QMouseEvent* event ); - Q_SLOT virtual void processPointSelection( QMouseEvent* event ); - + virtual void axisRemoved(QCPAxis *axis); + virtual void legendRemoved(QCPLegend *legend); + Q_SLOT virtual void processRectSelection(QRect rect, QMouseEvent *event); + Q_SLOT virtual void processRectZoom(QRect rect, QMouseEvent *event); + Q_SLOT virtual void processPointSelection(QMouseEvent *event); + // non-virtual methods: - bool registerPlottable( QCPAbstractPlottable* plottable ); - bool registerGraph( QCPGraph* graph ); - bool registerItem( QCPAbstractItem* item ); + bool registerPlottable(QCPAbstractPlottable *plottable); + bool registerGraph(QCPGraph *graph); + bool registerItem(QCPAbstractItem* item); void updateLayerIndices() const; - QCPLayerable* layerableAt( const QPointF& pos, bool onlySelectable, QVariant* selectionDetails = 0 ) const; - QList layerableListAt( const QPointF& pos, bool onlySelectable, QList* selectionDetails = 0 ) const; - void drawBackground( QCPPainter* painter ); + QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const; + QList layerableListAt(const QPointF &pos, bool onlySelectable, QList *selectionDetails=0) const; + void drawBackground(QCPPainter *painter); void setupPaintBuffers(); - QCPAbstractPaintBuffer* createPaintBuffer(); + QCPAbstractPaintBuffer *createPaintBuffer(); bool hasInvalidatedPaintBuffers(); bool setupOpenGl(); void freeOpenGl(); - + friend class QCPLegend; friend class QCPAxis; friend class QCPLayer; @@ -4025,11 +3838,12 @@ protected: friend class QCPGraph; friend class QCPAbstractItem; }; -Q_DECLARE_METATYPE( QCustomPlot::LayerInsertMode ) -Q_DECLARE_METATYPE( QCustomPlot::RefreshPriority ) +Q_DECLARE_METATYPE(QCustomPlot::LayerInsertMode) +Q_DECLARE_METATYPE(QCustomPlot::RefreshPriority) /* end of 'src/core.h' */ + /* including file 'src/plottable1d.h', size 4544 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -4039,52 +3853,53 @@ public: virtual ~QCPPlottableInterface1D() {} // introduced pure virtual methods: virtual int dataCount() const = 0; - virtual double dataMainKey( int index ) const = 0; - virtual double dataSortKey( int index ) const = 0; - virtual double dataMainValue( int index ) const = 0; - virtual QCPRange dataValueRange( int index ) const = 0; - virtual QPointF dataPixelPosition( int index ) const = 0; + virtual double dataMainKey(int index) const = 0; + virtual double dataSortKey(int index) const = 0; + virtual double dataMainValue(int index) const = 0; + virtual QCPRange dataValueRange(int index) const = 0; + virtual QPointF dataPixelPosition(int index) const = 0; virtual bool sortKeyIsMainKey() const = 0; - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const = 0; - virtual int findBegin( double sortKey, bool expandedRange = true ) const = 0; - virtual int findEnd( double sortKey, bool expandedRange = true ) const = 0; + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const = 0; + virtual int findBegin(double sortKey, bool expandedRange=true) const = 0; + virtual int findEnd(double sortKey, bool expandedRange=true) const = 0; }; template -class QCPAbstractPlottable1D : public QCPAbstractPlottable, public QCPPlottableInterface1D // no QCP_LIB_DECL, template class ends up in header (cpp included below) +class QCPAbstractPlottable1D : public QCPAbstractPlottable, public QCPPlottableInterface1D // no QCP_LIB_DECL, template class ends up in header (cpp included below) { // No Q_OBJECT macro due to template class - + public: - QCPAbstractPlottable1D( QCPAxis* keyAxis, QCPAxis* valueAxis ); + QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPAbstractPlottable1D(); - + // virtual methods of 1d plottable interface: virtual int dataCount() const Q_DECL_OVERRIDE; - virtual double dataMainKey( int index ) const Q_DECL_OVERRIDE; - virtual double dataSortKey( int index ) const Q_DECL_OVERRIDE; - virtual double dataMainValue( int index ) const Q_DECL_OVERRIDE; - virtual QCPRange dataValueRange( int index ) const Q_DECL_OVERRIDE; - virtual QPointF dataPixelPosition( int index ) const Q_DECL_OVERRIDE; + virtual double dataMainKey(int index) const Q_DECL_OVERRIDE; + virtual double dataSortKey(int index) const Q_DECL_OVERRIDE; + virtual double dataMainValue(int index) const Q_DECL_OVERRIDE; + virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE; + virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE; virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE; - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const Q_DECL_OVERRIDE; - virtual int findBegin( double sortKey, bool expandedRange = true ) const Q_DECL_OVERRIDE; - virtual int findEnd( double sortKey, bool expandedRange = true ) const Q_DECL_OVERRIDE; - + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE; + virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE; + virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE; + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPPlottableInterface1D* interface1D() Q_DECL_OVERRIDE { return this; } - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; } + protected: // property members: QSharedPointer > mDataContainer; - + // helpers for subclasses: - void getDataSegments( QList& selectedSegments, QList& unselectedSegments ) const; - void drawPolyline( QCPPainter* painter, const QVector& lineData ) const; + void getDataSegments(QList &selectedSegments, QList &unselectedSegments) const; + void drawPolyline(QCPPainter *painter, const QVector &lineData) const; private: - Q_DISABLE_COPY( QCPAbstractPlottable1D ) + Q_DISABLE_COPY(QCPAbstractPlottable1D) + }; // include implementation in header since it is a class template: @@ -4232,6 +4047,7 @@ private: /* end documentation of pure virtual functions */ + //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractPlottable1D //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4277,8 +4093,9 @@ private: "QCPAbstractPlottable" constructor and allocates the \a mDataContainer. */ template -QCPAbstractPlottable1D::QCPAbstractPlottable1D( QCPAxis* keyAxis, QCPAxis* valueAxis ) - : QCPAbstractPlottable( keyAxis, valueAxis ), mDataContainer( new QCPDataContainer ) +QCPAbstractPlottable1D::QCPAbstractPlottable1D(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mDataContainer(new QCPDataContainer) { } @@ -4300,13 +4117,12 @@ int QCPAbstractPlottable1D::dataCount() const \copydoc QCPPlottableInterface1D::dataMainKey */ template -double QCPAbstractPlottable1D::dataMainKey( int index ) const +double QCPAbstractPlottable1D::dataMainKey(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - return ( mDataContainer->constBegin() + index )->mainKey(); - } - else + return (mDataContainer->constBegin()+index)->mainKey(); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; return 0; @@ -4317,13 +4133,12 @@ double QCPAbstractPlottable1D::dataMainKey( int index ) const \copydoc QCPPlottableInterface1D::dataSortKey */ template -double QCPAbstractPlottable1D::dataSortKey( int index ) const +double QCPAbstractPlottable1D::dataSortKey(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - return ( mDataContainer->constBegin() + index )->sortKey(); - } - else + return (mDataContainer->constBegin()+index)->sortKey(); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; return 0; @@ -4334,13 +4149,12 @@ double QCPAbstractPlottable1D::dataSortKey( int index ) const \copydoc QCPPlottableInterface1D::dataMainValue */ template -double QCPAbstractPlottable1D::dataMainValue( int index ) const +double QCPAbstractPlottable1D::dataMainValue(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - return ( mDataContainer->constBegin() + index )->mainValue(); - } - else + return (mDataContainer->constBegin()+index)->mainValue(); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; return 0; @@ -4351,16 +4165,15 @@ double QCPAbstractPlottable1D::dataMainValue( int index ) const \copydoc QCPPlottableInterface1D::dataValueRange */ template -QCPRange QCPAbstractPlottable1D::dataValueRange( int index ) const +QCPRange QCPAbstractPlottable1D::dataValueRange(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - return ( mDataContainer->constBegin() + index )->valueRange(); - } - else + return (mDataContainer->constBegin()+index)->valueRange(); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; - return QCPRange( 0, 0 ); + return QCPRange(0, 0); } } @@ -4368,14 +4181,13 @@ QCPRange QCPAbstractPlottable1D::dataValueRange( int index ) const \copydoc QCPPlottableInterface1D::dataPixelPosition */ template -QPointF QCPAbstractPlottable1D::dataPixelPosition( int index ) const +QPointF QCPAbstractPlottable1D::dataPixelPosition(int index) const { - if( index >= 0 && index < mDataContainer->size() ) + if (index >= 0 && index < mDataContainer->size()) { - const typename QCPDataContainer::const_iterator it = mDataContainer->constBegin() + index; - return coordsToPixels( it->mainKey(), it->mainValue() ); - } - else + const typename QCPDataContainer::const_iterator it = mDataContainer->constBegin()+index; + return coordsToPixels(it->mainKey(), it->mainValue()); + } else { qDebug() << Q_FUNC_INFO << "Index out of bounds" << index; return QPointF(); @@ -4399,48 +4211,47 @@ bool QCPAbstractPlottable1D::sortKeyIsMainKey() const \seebaseclassmethod */ template -QCPDataSelection QCPAbstractPlottable1D::selectTestRect( const QRectF& rect, bool onlySelectable ) const +QCPDataSelection QCPAbstractPlottable1D::selectTestRect(const QRectF &rect, bool onlySelectable) const { QCPDataSelection result; - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return result; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return result; - + // convert rect given in pixels to ranges given in plot coordinates: double key1, value1, key2, value2; - pixelsToCoords( rect.topLeft(), key1, value1 ); - pixelsToCoords( rect.bottomRight(), key2, value2 ); - QCPRange keyRange( key1, key2 ); // QCPRange normalizes internally so we don't have to care about whether key1 < key2 - QCPRange valueRange( value1, value2 ); + pixelsToCoords(rect.topLeft(), key1, value1); + pixelsToCoords(rect.bottomRight(), key2, value2); + QCPRange keyRange(key1, key2); // QCPRange normalizes internally so we don't have to care about whether key1 < key2 + QCPRange valueRange(value1, value2); typename QCPDataContainer::const_iterator begin = mDataContainer->constBegin(); typename QCPDataContainer::const_iterator end = mDataContainer->constEnd(); - if( DataType::sortKeyIsMainKey() ) // we can assume that data is sorted by main key, so can reduce the searched key interval: + if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval: { - begin = mDataContainer->findBegin( keyRange.lower, false ); - end = mDataContainer->findEnd( keyRange.upper, false ); + begin = mDataContainer->findBegin(keyRange.lower, false); + end = mDataContainer->findEnd(keyRange.upper, false); } - if( begin == end ) + if (begin == end) return result; - - int currentSegmentBegin = -1; // -1 means we're currently not in a segment that's contained in rect - for( typename QCPDataContainer::const_iterator it = begin; it != end; ++it ) + + int currentSegmentBegin = -1; // -1 means we're currently not in a segment that's contained in rect + for (typename QCPDataContainer::const_iterator it=begin; it!=end; ++it) { - if( currentSegmentBegin == -1 ) + if (currentSegmentBegin == -1) { - if( valueRange.contains( it->mainValue() ) && keyRange.contains( it->mainKey() ) ) // start segment - currentSegmentBegin = it - mDataContainer->constBegin(); - } - else if( !valueRange.contains( it->mainValue() ) || !keyRange.contains( it->mainKey() ) ) // segment just ended + if (valueRange.contains(it->mainValue()) && keyRange.contains(it->mainKey())) // start segment + currentSegmentBegin = it-mDataContainer->constBegin(); + } else if (!valueRange.contains(it->mainValue()) || !keyRange.contains(it->mainKey())) // segment just ended { - result.addDataRange( QCPDataRange( currentSegmentBegin, it - mDataContainer->constBegin() ), false ); + result.addDataRange(QCPDataRange(currentSegmentBegin, it-mDataContainer->constBegin()), false); currentSegmentBegin = -1; } } // process potential last segment: - if( currentSegmentBegin != -1 ) - result.addDataRange( QCPDataRange( currentSegmentBegin, end - mDataContainer->constBegin() ), false ); - + if (currentSegmentBegin != -1) + result.addDataRange(QCPDataRange(currentSegmentBegin, end-mDataContainer->constBegin()), false); + result.simplify(); return result; } @@ -4449,18 +4260,18 @@ QCPDataSelection QCPAbstractPlottable1D::selectTestRect( const QRectF& \copydoc QCPPlottableInterface1D::findBegin */ template -int QCPAbstractPlottable1D::findBegin( double sortKey, bool expandedRange ) const +int QCPAbstractPlottable1D::findBegin(double sortKey, bool expandedRange) const { - return mDataContainer->findBegin( sortKey, expandedRange ) - mDataContainer->constBegin(); + return mDataContainer->findBegin(sortKey, expandedRange)-mDataContainer->constBegin(); } /*! \copydoc QCPPlottableInterface1D::findEnd */ template -int QCPAbstractPlottable1D::findEnd( double sortKey, bool expandedRange ) const +int QCPAbstractPlottable1D::findEnd(double sortKey, bool expandedRange) const { - return mDataContainer->findEnd( sortKey, expandedRange ) - mDataContainer->constBegin(); + return mDataContainer->findEnd(sortKey, expandedRange)-mDataContainer->constBegin(); } /*! @@ -4471,55 +4282,55 @@ int QCPAbstractPlottable1D::findEnd( double sortKey, bool expandedRang \seebaseclassmethod */ template -double QCPAbstractPlottable1D::selectTest( const QPointF& pos, bool onlySelectable, QVariant* details ) const +double QCPAbstractPlottable1D::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const { - if( ( onlySelectable && mSelectable == QCP::stNone ) || mDataContainer->isEmpty() ) + if ((onlySelectable && mSelectable == QCP::stNone) || mDataContainer->isEmpty()) return -1; - if( !mKeyAxis || !mValueAxis ) + if (!mKeyAxis || !mValueAxis) return -1; - + QCPDataSelection selectionResult; double minDistSqr = std::numeric_limits::max(); int minDistIndex = mDataContainer->size(); - + typename QCPDataContainer::const_iterator begin = mDataContainer->constBegin(); typename QCPDataContainer::const_iterator end = mDataContainer->constEnd(); - if( DataType::sortKeyIsMainKey() ) // we can assume that data is sorted by main key, so can reduce the searched key interval: + if (DataType::sortKeyIsMainKey()) // we can assume that data is sorted by main key, so can reduce the searched key interval: { // determine which key range comes into question, taking selection tolerance around pos into account: double posKeyMin, posKeyMax, dummy; - pixelsToCoords( pos - QPointF( mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance() ), posKeyMin, dummy ); - pixelsToCoords( pos + QPointF( mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance() ), posKeyMax, dummy ); - if( posKeyMin > posKeyMax ) - qSwap( posKeyMin, posKeyMax ); - begin = mDataContainer->findBegin( posKeyMin, true ); - end = mDataContainer->findEnd( posKeyMax, true ); + pixelsToCoords(pos-QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMin, dummy); + pixelsToCoords(pos+QPointF(mParentPlot->selectionTolerance(), mParentPlot->selectionTolerance()), posKeyMax, dummy); + if (posKeyMin > posKeyMax) + qSwap(posKeyMin, posKeyMax); + begin = mDataContainer->findBegin(posKeyMin, true); + end = mDataContainer->findEnd(posKeyMax, true); } - if( begin == end ) + if (begin == end) return -1; - QCPRange keyRange( mKeyAxis->range() ); - QCPRange valueRange( mValueAxis->range() ); - for( typename QCPDataContainer::const_iterator it = begin; it != end; ++it ) + QCPRange keyRange(mKeyAxis->range()); + QCPRange valueRange(mValueAxis->range()); + for (typename QCPDataContainer::const_iterator it=begin; it!=end; ++it) { const double mainKey = it->mainKey(); const double mainValue = it->mainValue(); - if( keyRange.contains( mainKey ) && valueRange.contains( mainValue ) ) // make sure data point is inside visible range, for speedup in cases where sort key isn't main key and we iterate over all points + if (keyRange.contains(mainKey) && valueRange.contains(mainValue)) // make sure data point is inside visible range, for speedup in cases where sort key isn't main key and we iterate over all points { - const double currentDistSqr = QCPVector2D( coordsToPixels( mainKey, mainValue ) - pos ).lengthSquared(); - if( currentDistSqr < minDistSqr ) + const double currentDistSqr = QCPVector2D(coordsToPixels(mainKey, mainValue)-pos).lengthSquared(); + if (currentDistSqr < minDistSqr) { minDistSqr = currentDistSqr; - minDistIndex = it - mDataContainer->constBegin(); + minDistIndex = it-mDataContainer->constBegin(); } } } - if( minDistIndex != mDataContainer->size() ) - selectionResult.addDataRange( QCPDataRange( minDistIndex, minDistIndex + 1 ), false ); - + if (minDistIndex != mDataContainer->size()) + selectionResult.addDataRange(QCPDataRange(minDistIndex, minDistIndex+1), false); + selectionResult.simplify(); - if( details ) - details->setValue( selectionResult ); - return qSqrt( minDistSqr ); + if (details) + details->setValue(selectionResult); + return qSqrt(minDistSqr); } /*! @@ -4533,23 +4344,22 @@ double QCPAbstractPlottable1D::selectTest( const QPointF& pos, bool on \see setSelection */ template -void QCPAbstractPlottable1D::getDataSegments( QList& selectedSegments, QList& unselectedSegments ) const +void QCPAbstractPlottable1D::getDataSegments(QList &selectedSegments, QList &unselectedSegments) const { selectedSegments.clear(); unselectedSegments.clear(); - if( mSelectable == QCP::stWhole ) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty + if (mSelectable == QCP::stWhole) // stWhole selection type draws the entire plottable with selected style if mSelection isn't empty { - if( selected() ) - selectedSegments << QCPDataRange( 0, dataCount() ); + if (selected()) + selectedSegments << QCPDataRange(0, dataCount()); else - unselectedSegments << QCPDataRange( 0, dataCount() ); - } - else + unselectedSegments << QCPDataRange(0, dataCount()); + } else { - QCPDataSelection sel( selection() ); + QCPDataSelection sel(selection()); sel.simplify(); selectedSegments = sel.dataRanges(); - unselectedSegments = sel.inverse( QCPDataRange( 0, dataCount() ) ).dataRanges(); + unselectedSegments = sel.inverse(QCPDataRange(0, dataCount())).dataRanges(); } } @@ -4564,56 +4374,56 @@ void QCPAbstractPlottable1D::getDataSegments( QList& sel style allows. */ template -void QCPAbstractPlottable1D::drawPolyline( QCPPainter* painter, const QVector& lineData ) const +void QCPAbstractPlottable1D::drawPolyline(QCPPainter *painter, const QVector &lineData) const { // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: - if( mParentPlot->plottingHints().testFlag( QCP::phFastPolylines ) && + if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && painter->pen().style() == Qt::SolidLine && - !painter->modes().testFlag( QCPPainter::pmVectorized ) && - !painter->modes().testFlag( QCPPainter::pmNoCaching ) ) + !painter->modes().testFlag(QCPPainter::pmVectorized) && + !painter->modes().testFlag(QCPPainter::pmNoCaching)) { int i = 0; bool lastIsNan = false; const int lineDataSize = lineData.size(); - while( i < lineDataSize && ( qIsNaN( lineData.at( i ).y() ) || qIsNaN( lineData.at( i ).x() ) ) ) // make sure first point is not NaN + while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN ++i; - ++i; // because drawing works in 1 point retrospect - while( i < lineDataSize ) + ++i; // because drawing works in 1 point retrospect + while (i < lineDataSize) { - if( !qIsNaN( lineData.at( i ).y() ) && !qIsNaN( lineData.at( i ).x() ) ) // NaNs create a gap in the line + if (!qIsNaN(lineData.at(i).y()) && !qIsNaN(lineData.at(i).x())) // NaNs create a gap in the line { - if( !lastIsNan ) - painter->drawLine( lineData.at( i - 1 ), lineData.at( i ) ); + if (!lastIsNan) + painter->drawLine(lineData.at(i-1), lineData.at(i)); else lastIsNan = false; - } - else + } else lastIsNan = true; ++i; } - } - else + } else { int segmentStart = 0; int i = 0; const int lineDataSize = lineData.size(); - while( i < lineDataSize ) + while (i < lineDataSize) { - if( qIsNaN( lineData.at( i ).y() ) || qIsNaN( lineData.at( i ).x() ) || qIsInf( lineData.at( i ).y() ) ) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block + if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block { - painter->drawPolyline( lineData.constData() + segmentStart, i - segmentStart ); // i, because we don't want to include the current NaN point - segmentStart = i + 1; + painter->drawPolyline(lineData.constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point + segmentStart = i+1; } ++i; } // draw last segment: - painter->drawPolyline( lineData.constData() + segmentStart, lineDataSize - segmentStart ); + painter->drawPolyline(lineData.constData()+segmentStart, lineDataSize-segmentStart); } } /* end of 'src/plottable1d.cpp' */ + /* end of 'src/plottable1d.h' */ + /* including file 'src/colorgradient.h', size 6243 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -4626,92 +4436,77 @@ public: \see setColorInterpolation */ - enum ColorInterpolation - { - ciRGB ///< Color channels red, green and blue are linearly interpolated - , - ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance) - }; - Q_ENUMS( ColorInterpolation ) - + enum ColorInterpolation { ciRGB ///< Color channels red, green and blue are linearly interpolated + ,ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance) + }; + Q_ENUMS(ColorInterpolation) + /*! Defines the available presets that can be loaded with \ref loadPreset. See the documentation there for an image of the presets. */ - enum GradientPreset - { - gpGrayscale ///< Continuous lightness from black to white (suited for non-biased data representation) - , - gpHot ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation) - , - gpCold ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation) - , - gpNight ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation) - , - gpCandy ///< Blue over pink to white - , - gpGeography ///< Colors suitable to represent different elevations on geographical maps - , - gpIon ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates) - , - gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white - , - gpPolar ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values - , - gpSpectrum ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates) - , - gpJet ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates) - , - gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic) - }; - Q_ENUMS( GradientPreset ) - + enum GradientPreset { gpGrayscale ///< Continuous lightness from black to white (suited for non-biased data representation) + ,gpHot ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation) + ,gpCold ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation) + ,gpNight ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation) + ,gpCandy ///< Blue over pink to white + ,gpGeography ///< Colors suitable to represent different elevations on geographical maps + ,gpIon ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates) + ,gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white + ,gpPolar ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values + ,gpSpectrum ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates) + ,gpJet ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates) + ,gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic) + }; + Q_ENUMS(GradientPreset) + QCPColorGradient(); - QCPColorGradient( GradientPreset preset ); - bool operator==( const QCPColorGradient& other ) const; - bool operator!=( const QCPColorGradient& other ) const { return !( *this == other ); } - + QCPColorGradient(GradientPreset preset); + bool operator==(const QCPColorGradient &other) const; + bool operator!=(const QCPColorGradient &other) const { return !(*this == other); } + // getters: int levelCount() const { return mLevelCount; } QMap colorStops() const { return mColorStops; } ColorInterpolation colorInterpolation() const { return mColorInterpolation; } bool periodic() const { return mPeriodic; } - + // setters: - void setLevelCount( int n ); - void setColorStops( const QMap& colorStops ); - void setColorStopAt( double position, const QColor& color ); - void setColorInterpolation( ColorInterpolation interpolation ); - void setPeriodic( bool enabled ); - + void setLevelCount(int n); + void setColorStops(const QMap &colorStops); + void setColorStopAt(double position, const QColor &color); + void setColorInterpolation(ColorInterpolation interpolation); + void setPeriodic(bool enabled); + // non-property methods: - void colorize( const double* data, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor = 1, bool logarithmic = false ); - void colorize( const double* data, const unsigned char* alpha, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor = 1, bool logarithmic = false ); - QRgb color( double position, const QCPRange& range, bool logarithmic = false ); - void loadPreset( GradientPreset preset ); + void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false); + void colorize(const double *data, const unsigned char *alpha, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false); + QRgb color(double position, const QCPRange &range, bool logarithmic=false); + void loadPreset(GradientPreset preset); void clearColorStops(); QCPColorGradient inverted() const; - + protected: // property members: int mLevelCount; QMap mColorStops; ColorInterpolation mColorInterpolation; bool mPeriodic; - + // non-property members: - QVector mColorBuffer; // have colors premultiplied with alpha (for usage with QImage::Format_ARGB32_Premultiplied) + QVector mColorBuffer; // have colors premultiplied with alpha (for usage with QImage::Format_ARGB32_Premultiplied) bool mColorBufferInvalidated; - + // non-virtual methods: bool stopsUseAlpha() const; void updateColorBuffer(); }; -Q_DECLARE_METATYPE( QCPColorGradient::ColorInterpolation ) -Q_DECLARE_METATYPE( QCPColorGradient::GradientPreset ) +Q_DECLARE_METATYPE(QCPColorGradient::ColorInterpolation) +Q_DECLARE_METATYPE(QCPColorGradient::GradientPreset) /* end of 'src/colorgradient.h' */ + /* including file 'src/selectiondecorator-bracket.h', size 4442 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -4719,29 +4514,24 @@ class QCP_LIB_DECL QCPSelectionDecoratorBracket : public QCPSelectionDecorator { Q_GADGET public: + /*! Defines which shape is drawn at the boundaries of selected data ranges. Some of the bracket styles further allow specifying a height and/or width, see \ref setBracketHeight and \ref setBracketWidth. */ - enum BracketStyle - { - bsSquareBracket ///< A square bracket is drawn. - , - bsHalfEllipse ///< A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties. - , - bsEllipse ///< An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties. - , - bsPlus ///< A plus is drawn. - , - bsUserStyle ///< Start custom bracket styles at this index when subclassing and reimplementing \ref drawBracket. + enum BracketStyle { bsSquareBracket ///< A square bracket is drawn. + ,bsHalfEllipse ///< A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties. + ,bsEllipse ///< An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties. + ,bsPlus ///< A plus is drawn. + ,bsUserStyle ///< Start custom bracket styles at this index when subclassing and reimplementing \ref drawBracket. }; - Q_ENUMS( BracketStyle ) - + Q_ENUMS(BracketStyle) + QCPSelectionDecoratorBracket(); virtual ~QCPSelectionDecoratorBracket(); - + // getters: QPen bracketPen() const { return mBracketPen; } QBrush bracketBrush() const { return mBracketBrush; } @@ -4750,22 +4540,22 @@ public: BracketStyle bracketStyle() const { return mBracketStyle; } bool tangentToData() const { return mTangentToData; } int tangentAverage() const { return mTangentAverage; } - + // setters: - void setBracketPen( const QPen& pen ); - void setBracketBrush( const QBrush& brush ); - void setBracketWidth( int width ); - void setBracketHeight( int height ); - void setBracketStyle( BracketStyle style ); - void setTangentToData( bool enabled ); - void setTangentAverage( int pointCount ); - + void setBracketPen(const QPen &pen); + void setBracketBrush(const QBrush &brush); + void setBracketWidth(int width); + void setBracketHeight(int height); + void setBracketStyle(BracketStyle style); + void setTangentToData(bool enabled); + void setTangentAverage(int pointCount); + // introduced virtual methods: - virtual void drawBracket( QCPPainter* painter, int direction ) const; - + virtual void drawBracket(QCPPainter *painter, int direction) const; + // virtual methods: - virtual void drawDecoration( QCPPainter* painter, QCPDataSelection selection ) Q_DECL_OVERRIDE; - + virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection) Q_DECL_OVERRIDE; + protected: // property members: QPen mBracketPen; @@ -4775,15 +4565,17 @@ protected: BracketStyle mBracketStyle; bool mTangentToData; int mTangentAverage; - + // non-virtual methods: - double getTangentAngle( const QCPPlottableInterface1D* interface1d, int dataIndex, int direction ) const; - QPointF getPixelCoordinates( const QCPPlottableInterface1D* interface1d, int dataIndex ) const; + double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const; + QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const; + }; -Q_DECLARE_METATYPE( QCPSelectionDecoratorBracket::BracketStyle ) +Q_DECLARE_METATYPE(QCPSelectionDecoratorBracket::BracketStyle) /* end of 'src/selectiondecorator-bracket.h' */ + /* including file 'src/layoutelements/layoutelement-axisrect.h', size 7507 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -4791,16 +4583,16 @@ class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPixmap background READ background WRITE setBackground ) - Q_PROPERTY( bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled ) - Q_PROPERTY( Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode ) - Q_PROPERTY( Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag ) - Q_PROPERTY( Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom ) + Q_PROPERTY(QPixmap background READ background WRITE setBackground) + Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) + Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) + Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom) /// \endcond public: - explicit QCPAxisRect( QCustomPlot* parentPlot, bool setupDefaultAxes = true ); + explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true); virtual ~QCPAxisRect(); - + // getters: QPixmap background() const { return mBackgroundPixmap; } QBrush backgroundBrush() const { return mBackgroundBrush; } @@ -4808,46 +4600,46 @@ public: Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } Qt::Orientations rangeDrag() const { return mRangeDrag; } Qt::Orientations rangeZoom() const { return mRangeZoom; } - QCPAxis* rangeDragAxis( Qt::Orientation orientation ); - QCPAxis* rangeZoomAxis( Qt::Orientation orientation ); - QList rangeDragAxes( Qt::Orientation orientation ); - QList rangeZoomAxes( Qt::Orientation orientation ); - double rangeZoomFactor( Qt::Orientation orientation ); - + QCPAxis *rangeDragAxis(Qt::Orientation orientation); + QCPAxis *rangeZoomAxis(Qt::Orientation orientation); + QList rangeDragAxes(Qt::Orientation orientation); + QList rangeZoomAxes(Qt::Orientation orientation); + double rangeZoomFactor(Qt::Orientation orientation); + // setters: - void setBackground( const QPixmap& pm ); - void setBackground( const QPixmap& pm, bool scaled, Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding ); - void setBackground( const QBrush& brush ); - void setBackgroundScaled( bool scaled ); - void setBackgroundScaledMode( Qt::AspectRatioMode mode ); - void setRangeDrag( Qt::Orientations orientations ); - void setRangeZoom( Qt::Orientations orientations ); - void setRangeDragAxes( QCPAxis* horizontal, QCPAxis* vertical ); - void setRangeDragAxes( QList axes ); - void setRangeDragAxes( QList horizontal, QList vertical ); - void setRangeZoomAxes( QCPAxis* horizontal, QCPAxis* vertical ); - void setRangeZoomAxes( QList axes ); - void setRangeZoomAxes( QList horizontal, QList vertical ); - void setRangeZoomFactor( double horizontalFactor, double verticalFactor ); - void setRangeZoomFactor( double factor ); - + void setBackground(const QPixmap &pm); + void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); + void setBackground(const QBrush &brush); + void setBackgroundScaled(bool scaled); + void setBackgroundScaledMode(Qt::AspectRatioMode mode); + void setRangeDrag(Qt::Orientations orientations); + void setRangeZoom(Qt::Orientations orientations); + void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeDragAxes(QList axes); + void setRangeDragAxes(QList horizontal, QList vertical); + void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeZoomAxes(QList axes); + void setRangeZoomAxes(QList horizontal, QList vertical); + void setRangeZoomFactor(double horizontalFactor, double verticalFactor); + void setRangeZoomFactor(double factor); + // non-property methods: - int axisCount( QCPAxis::AxisType type ) const; - QCPAxis* axis( QCPAxis::AxisType type, int index = 0 ) const; - QList axes( QCPAxis::AxisTypes types ) const; + int axisCount(QCPAxis::AxisType type) const; + QCPAxis *axis(QCPAxis::AxisType type, int index=0) const; + QList axes(QCPAxis::AxisTypes types) const; QList axes() const; - QCPAxis* addAxis( QCPAxis::AxisType type, QCPAxis* axis = 0 ); - QList addAxes( QCPAxis::AxisTypes types ); - bool removeAxis( QCPAxis* axis ); - QCPLayoutInset* insetLayout() const { return mInsetLayout; } - - void zoom( const QRectF& pixelRect ); - void zoom( const QRectF& pixelRect, const QList& affectedAxes ); - void setupFullAxesBox( bool connectRanges = false ); + QCPAxis *addAxis(QCPAxis::AxisType type, QCPAxis *axis=0); + QList addAxes(QCPAxis::AxisTypes types); + bool removeAxis(QCPAxis *axis); + QCPLayoutInset *insetLayout() const { return mInsetLayout; } + + void zoom(const QRectF &pixelRect); + void zoom(const QRectF &pixelRect, const QList &affectedAxes); + void setupFullAxesBox(bool connectRanges=false); QList plottables() const; QList graphs() const; QList items() const; - + // read-only interface imitating a QRect: int left() const { return mRect.left(); } int right() const { return mRect.right(); } @@ -4861,10 +4653,10 @@ public: QPoint bottomLeft() const { return mRect.bottomLeft(); } QPoint bottomRight() const { return mRect.bottomRight(); } QPoint center() const { return mRect.center(); } - + // reimplemented virtual methods: - virtual void update( UpdatePhase phase ) Q_DECL_OVERRIDE; - virtual QList elements( bool recursive ) const Q_DECL_OVERRIDE; + virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE; + virtual QList elements(bool recursive) const Q_DECL_OVERRIDE; protected: // property members: @@ -4873,41 +4665,43 @@ protected: QPixmap mScaledBackgroundPixmap; bool mBackgroundScaled; Qt::AspectRatioMode mBackgroundScaledMode; - QCPLayoutInset* mInsetLayout; + QCPLayoutInset *mInsetLayout; Qt::Orientations mRangeDrag, mRangeZoom; QList > mRangeDragHorzAxis, mRangeDragVertAxis; QList > mRangeZoomHorzAxis, mRangeZoomVertAxis; double mRangeZoomFactorHorz, mRangeZoomFactorVert; - + // non-property members: QList mDragStartHorzRange, mDragStartVertRange; QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; bool mDragging; QHash > mAxes; - + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual int calculateAutoMargin( QCP::MarginSide side ) Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE; virtual void layoutChanged() Q_DECL_OVERRIDE; // events: - virtual void mousePressEvent( QMouseEvent* event, const QVariant& details ) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) Q_DECL_OVERRIDE; - virtual void wheelEvent( QWheelEvent* event ) Q_DECL_OVERRIDE; - + virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE; + virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; + // non-property methods: - void drawBackground( QCPPainter* painter ); - void updateAxesOffset( QCPAxis::AxisType type ); - + void drawBackground(QCPPainter *painter); + void updateAxesOffset(QCPAxis::AxisType type); + private: - Q_DISABLE_COPY( QCPAxisRect ) - + Q_DISABLE_COPY(QCPAxisRect) + friend class QCustomPlot; }; + /* end of 'src/layoutelements/layoutelement-axisrect.h' */ + /* including file 'src/layoutelements/layoutelement-legend.h', size 10397 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -4915,106 +4709,108 @@ class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCPLegend* parentLegend READ parentLegend ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) - Q_PROPERTY( QFont selectedFont READ selectedFont WRITE setSelectedFont ) - Q_PROPERTY( QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor ) - Q_PROPERTY( bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged ) - Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectableChanged ) + Q_PROPERTY(QCPLegend* parentLegend READ parentLegend) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged) /// \endcond public: - explicit QCPAbstractLegendItem( QCPLegend* parent ); - + explicit QCPAbstractLegendItem(QCPLegend *parent); + // getters: - QCPLegend* parentLegend() const { return mParentLegend; } + QCPLegend *parentLegend() const { return mParentLegend; } QFont font() const { return mFont; } QColor textColor() const { return mTextColor; } QFont selectedFont() const { return mSelectedFont; } QColor selectedTextColor() const { return mSelectedTextColor; } bool selectable() const { return mSelectable; } bool selected() const { return mSelected; } - + // setters: - void setFont( const QFont& font ); - void setTextColor( const QColor& color ); - void setSelectedFont( const QFont& font ); - void setSelectedTextColor( const QColor& color ); - Q_SLOT void setSelectable( bool selectable ); - Q_SLOT void setSelected( bool selected ); - + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + signals: - void selectionChanged( bool selected ); - void selectableChanged( bool selectable ); - + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + protected: // property members: - QCPLegend* mParentLegend; + QCPLegend *mParentLegend; QFont mFont; QColor mTextColor; QFont mSelectedFont; QColor mSelectedTextColor; bool mSelectable, mSelected; - + // reimplemented virtual methods: virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE; - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; virtual QRect clipRect() const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE = 0; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE = 0; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; - + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; + private: - Q_DISABLE_COPY( QCPAbstractLegendItem ) - + Q_DISABLE_COPY(QCPAbstractLegendItem) + friend class QCPLegend; }; + class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem { Q_OBJECT public: - QCPPlottableLegendItem( QCPLegend* parent, QCPAbstractPlottable* plottable ); - + QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable); + // getters: - QCPAbstractPlottable* plottable() { return mPlottable; } - + QCPAbstractPlottable *plottable() { return mPlottable; } + protected: // property members: - QCPAbstractPlottable* mPlottable; - + QCPAbstractPlottable *mPlottable; + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE; - + // non-virtual methods: QPen getIconBorderPen() const; QColor getTextColor() const; QFont getFont() const; }; + class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen borderPen READ borderPen WRITE setBorderPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) - Q_PROPERTY( QSize iconSize READ iconSize WRITE setIconSize ) - Q_PROPERTY( int iconTextPadding READ iconTextPadding WRITE setIconTextPadding ) - Q_PROPERTY( QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen ) - Q_PROPERTY( SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged ) - Q_PROPERTY( SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged ) - Q_PROPERTY( QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen ) - Q_PROPERTY( QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen ) - Q_PROPERTY( QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush ) - Q_PROPERTY( QFont selectedFont READ selectedFont WRITE setSelectedFont ) - Q_PROPERTY( QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor ) + Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) + Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding) + Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged) + Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen) + Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) /// \endcond public: /*! @@ -5022,21 +4818,17 @@ public: \see setSelectedParts, setSelectableParts */ - enum SelectablePart - { - spNone = 0x000 ///< 0x000 None - , - spLegendBox = 0x001 ///< 0x001 The legend box (frame) - , - spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) - }; - Q_ENUMS( SelectablePart ) - Q_FLAGS( SelectableParts ) - Q_DECLARE_FLAGS( SelectableParts, SelectablePart ) - + enum SelectablePart { spNone = 0x000 ///< 0x000 None + ,spLegendBox = 0x001 ///< 0x001 The legend box (frame) + ,spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) + }; + Q_ENUMS(SelectablePart) + Q_FLAGS(SelectableParts) + Q_DECLARE_FLAGS(SelectableParts, SelectablePart) + explicit QCPLegend(); virtual ~QCPLegend(); - + // getters: QPen borderPen() const { return mBorderPen; } QBrush brush() const { return mBrush; } @@ -5052,43 +4844,43 @@ public: QBrush selectedBrush() const { return mSelectedBrush; } QFont selectedFont() const { return mSelectedFont; } QColor selectedTextColor() const { return mSelectedTextColor; } - + // setters: - void setBorderPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setFont( const QFont& font ); - void setTextColor( const QColor& color ); - void setIconSize( const QSize& size ); - void setIconSize( int width, int height ); - void setIconTextPadding( int padding ); - void setIconBorderPen( const QPen& pen ); - Q_SLOT void setSelectableParts( const SelectableParts& selectableParts ); - Q_SLOT void setSelectedParts( const SelectableParts& selectedParts ); - void setSelectedBorderPen( const QPen& pen ); - void setSelectedIconBorderPen( const QPen& pen ); - void setSelectedBrush( const QBrush& brush ); - void setSelectedFont( const QFont& font ); - void setSelectedTextColor( const QColor& color ); - + void setBorderPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setIconSize(const QSize &size); + void setIconSize(int width, int height); + void setIconTextPadding(int padding); + void setIconBorderPen(const QPen &pen); + Q_SLOT void setSelectableParts(const SelectableParts &selectableParts); + Q_SLOT void setSelectedParts(const SelectableParts &selectedParts); + void setSelectedBorderPen(const QPen &pen); + void setSelectedIconBorderPen(const QPen &pen); + void setSelectedBrush(const QBrush &brush); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + // non-virtual methods: - QCPAbstractLegendItem* item( int index ) const; - QCPPlottableLegendItem* itemWithPlottable( const QCPAbstractPlottable* plottable ) const; + QCPAbstractLegendItem *item(int index) const; + QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const; int itemCount() const; - bool hasItem( QCPAbstractLegendItem* item ) const; - bool hasItemWithPlottable( const QCPAbstractPlottable* plottable ) const; - bool addItem( QCPAbstractLegendItem* item ); - bool removeItem( int index ); - bool removeItem( QCPAbstractLegendItem* item ); + bool hasItem(QCPAbstractLegendItem *item) const; + bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const; + bool addItem(QCPAbstractLegendItem *item); + bool removeItem(int index); + bool removeItem(QCPAbstractLegendItem *item); void clearItems(); QList selectedItems() const; - + signals: - void selectionChanged( QCPLegend::SelectableParts parts ); - void selectableChanged( QCPLegend::SelectableParts parts ); - + void selectionChanged(QCPLegend::SelectableParts parts); + void selectableChanged(QCPLegend::SelectableParts parts); + protected: // property members: QPen mBorderPen, mIconBorderPen; @@ -5102,31 +4894,32 @@ protected: QBrush mSelectedBrush; QFont mSelectedFont; QColor mSelectedTextColor; - + // reimplemented virtual methods: - virtual void parentPlotInitialized( QCustomPlot* parentPlot ) Q_DECL_OVERRIDE; + virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE; virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE; - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; - + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; + // non-virtual methods: QPen getBorderPen() const; QBrush getBrush() const; - + private: - Q_DISABLE_COPY( QCPLegend ) - + Q_DISABLE_COPY(QCPLegend) + friend class QCustomPlot; friend class QCPAbstractLegendItem; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QCPLegend::SelectableParts ) -Q_DECLARE_METATYPE( QCPLegend::SelectablePart ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts) +Q_DECLARE_METATYPE(QCPLegend::SelectablePart) /* end of 'src/layoutelements/layoutelement-legend.h' */ + /* including file 'src/layoutelements/layoutelement-textelement.h', size 5353 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5134,21 +4927,21 @@ class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QString text READ text WRITE setText ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) - Q_PROPERTY( QFont selectedFont READ selectedFont WRITE setSelectedFont ) - Q_PROPERTY( QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor ) - Q_PROPERTY( bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged ) - Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectionChanged ) + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) /// \endcond public: - explicit QCPTextElement( QCustomPlot* parentPlot ); - QCPTextElement( QCustomPlot* parentPlot, const QString& text ); - QCPTextElement( QCustomPlot* parentPlot, const QString& text, double pointSize ); - QCPTextElement( QCustomPlot* parentPlot, const QString& text, const QString& fontFamily, double pointSize ); - QCPTextElement( QCustomPlot* parentPlot, const QString& text, const QFont& font ); - + explicit QCPTextElement(QCustomPlot *parentPlot); + QCPTextElement(QCustomPlot *parentPlot, const QString &text); + QCPTextElement(QCustomPlot *parentPlot, const QString &text, double pointSize); + QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize); + QCPTextElement(QCustomPlot *parentPlot, const QString &text, const QFont &font); + // getters: QString text() const { return mText; } int textFlags() const { return mTextFlags; } @@ -5158,29 +4951,29 @@ public: QColor selectedTextColor() const { return mSelectedTextColor; } bool selectable() const { return mSelectable; } bool selected() const { return mSelected; } - + // setters: - void setText( const QString& text ); - void setTextFlags( int flags ); - void setFont( const QFont& font ); - void setTextColor( const QColor& color ); - void setSelectedFont( const QFont& font ); - void setSelectedTextColor( const QColor& color ); - Q_SLOT void setSelectable( bool selectable ); - Q_SLOT void setSelected( bool selected ); - + void setText(const QString &text); + void setTextFlags(int flags); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual void mousePressEvent( QMouseEvent* event, const QVariant& details ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) Q_DECL_OVERRIDE; - virtual void mouseDoubleClickEvent( QMouseEvent* event, const QVariant& details ) Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE; + signals: - void selectionChanged( bool selected ); - void selectableChanged( bool selectable ); - void clicked( QMouseEvent* event ); - void doubleClicked( QMouseEvent* event ); - + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + void clicked(QMouseEvent *event); + void doubleClicked(QMouseEvent *event); + protected: // property members: QString mText; @@ -5191,102 +4984,106 @@ protected: QColor mSelectedTextColor; QRect mTextBoundingRect; bool mSelectable, mSelected; - + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE; virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE; // events: - virtual void selectEvent( QMouseEvent* event, bool additive, const QVariant& details, bool* selectionStateChanged ) Q_DECL_OVERRIDE; - virtual void deselectEvent( bool* selectionStateChanged ) Q_DECL_OVERRIDE; - + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE; + virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE; + // non-virtual methods: QFont mainFont() const; QColor mainTextColor() const; - + private: - Q_DISABLE_COPY( QCPTextElement ) + Q_DISABLE_COPY(QCPTextElement) }; + + /* end of 'src/layoutelements/layoutelement-textelement.h' */ + /* including file 'src/layoutelements/layoutelement-colorscale.h', size 5923 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ + class QCPColorScaleAxisRectPrivate : public QCPAxisRect { Q_OBJECT public: - explicit QCPColorScaleAxisRectPrivate( QCPColorScale* parentColorScale ); - + explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale); protected: - QCPColorScale* mParentColorScale; + QCPColorScale *mParentColorScale; QImage mGradientImage; bool mGradientImageInvalidated; // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale using QCPAxisRect::calculateAutoMargin; - using QCPAxisRect::mouseMoveEvent; using QCPAxisRect::mousePressEvent; + using QCPAxisRect::mouseMoveEvent; using QCPAxisRect::mouseReleaseEvent; - using QCPAxisRect::update; using QCPAxisRect::wheelEvent; - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + using QCPAxisRect::update; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; void updateGradientImage(); - Q_SLOT void axisSelectionChanged( QCPAxis::SelectableParts selectedParts ); - Q_SLOT void axisSelectableChanged( QCPAxis::SelectableParts selectableParts ); + Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts); + Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts); friend class QCPColorScale; }; + class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCPAxis::AxisType type READ type WRITE setType ) - Q_PROPERTY( QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged ) - Q_PROPERTY( QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged ) - Q_PROPERTY( QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged ) - Q_PROPERTY( QString label READ label WRITE setLabel ) - Q_PROPERTY( int barWidth READ barWidth WRITE setBarWidth ) - Q_PROPERTY( bool rangeDrag READ rangeDrag WRITE setRangeDrag ) - Q_PROPERTY( bool rangeZoom READ rangeZoom WRITE setRangeZoom ) + Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType) + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth) + Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom) /// \endcond public: - explicit QCPColorScale( QCustomPlot* parentPlot ); + explicit QCPColorScale(QCustomPlot *parentPlot); virtual ~QCPColorScale(); - + // getters: - QCPAxis* axis() const { return mColorAxis.data(); } + QCPAxis *axis() const { return mColorAxis.data(); } QCPAxis::AxisType type() const { return mType; } QCPRange dataRange() const { return mDataRange; } QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } QCPColorGradient gradient() const { return mGradient; } QString label() const; - int barWidth() const { return mBarWidth; } + int barWidth () const { return mBarWidth; } bool rangeDrag() const; bool rangeZoom() const; - + // setters: - void setType( QCPAxis::AxisType type ); - Q_SLOT void setDataRange( const QCPRange& dataRange ); - Q_SLOT void setDataScaleType( QCPAxis::ScaleType scaleType ); - Q_SLOT void setGradient( const QCPColorGradient& gradient ); - void setLabel( const QString& str ); - void setBarWidth( int width ); - void setRangeDrag( bool enabled ); - void setRangeZoom( bool enabled ); - + void setType(QCPAxis::AxisType type); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setLabel(const QString &str); + void setBarWidth(int width); + void setRangeDrag(bool enabled); + void setRangeZoom(bool enabled); + // non-property methods: QList colorMaps() const; - void rescaleDataRange( bool onlyVisibleMaps ); - + void rescaleDataRange(bool onlyVisibleMaps); + // reimplemented virtual methods: - virtual void update( UpdatePhase phase ) Q_DECL_OVERRIDE; - + virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE; + signals: - void dataRangeChanged( const QCPRange& newRange ); - void dataScaleTypeChanged( QCPAxis::ScaleType scaleType ); - void gradientChanged( const QCPColorGradient& newGradient ); + void dataRangeChanged(const QCPRange &newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(const QCPColorGradient &newGradient); protected: // property members: @@ -5295,27 +5092,29 @@ protected: QCPAxis::ScaleType mDataScaleType; QCPColorGradient mGradient; int mBarWidth; - + // non-property members: QPointer mAxisRect; QPointer mColorAxis; - + // reimplemented virtual methods: - virtual void applyDefaultAntialiasingHint( QCPPainter* painter ) const Q_DECL_OVERRIDE; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE; // events: - virtual void mousePressEvent( QMouseEvent* event, const QVariant& details ) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent( QMouseEvent* event, const QPointF& startPos ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* event, const QPointF& startPos ) Q_DECL_OVERRIDE; - virtual void wheelEvent( QWheelEvent* event ) Q_DECL_OVERRIDE; - + virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE; + virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; + private: - Q_DISABLE_COPY( QCPColorScale ) - + Q_DISABLE_COPY(QCPColorScale) + friend class QCPColorScaleAxisRectPrivate; }; + /* end of 'src/layoutelements/layoutelement-colorscale.h' */ + /* including file 'src/plottables/plottable-graph.h', size 9294 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5323,20 +5122,21 @@ class QCP_LIB_DECL QCPGraphData { public: QCPGraphData(); - QCPGraphData( double key, double value ); - + QCPGraphData(double key, double value); + inline double sortKey() const { return key; } - inline static QCPGraphData fromSortKey( double sortKey ) { return QCPGraphData( sortKey, 0 ); } + inline static QCPGraphData fromSortKey(double sortKey) { return QCPGraphData(sortKey, 0); } inline static bool sortKeyIsMainKey() { return true; } - + inline double mainKey() const { return key; } inline double mainValue() const { return value; } - - inline QCPRange valueRange() const { return QCPRange( value, value ); } - + + inline QCPRange valueRange() const { return QCPRange(value, value); } + double key, value; }; -Q_DECLARE_TYPEINFO( QCPGraphData, Q_PRIMITIVE_TYPE ); +Q_DECLARE_TYPEINFO(QCPGraphData, Q_PRIMITIVE_TYPE); + /*! \typedef QCPGraphDataContainer @@ -5353,11 +5153,11 @@ class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable1D { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( LineStyle lineStyle READ lineStyle WRITE setLineStyle ) - Q_PROPERTY( QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle ) - Q_PROPERTY( int scatterSkip READ scatterSkip WRITE setScatterSkip ) - Q_PROPERTY( QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph ) - Q_PROPERTY( bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling ) + Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) + Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) + Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip) + Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph) + Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling) /// \endcond public: /*! @@ -5365,52 +5165,45 @@ public: current pen of the graph (\ref setPen). \see setLineStyle */ - enum LineStyle - { - lsNone ///< data points are not connected with any lines (e.g. data only represented - ///< with symbols according to the scatter style, see \ref setScatterStyle) - , - lsLine ///< data points are connected by a straight line - , - lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point - , - lsStepRight ///< line is drawn as steps where the step height is the value of the right data point - , - lsStepCenter ///< line is drawn as steps where the step is in between two data points - , - lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line - }; - Q_ENUMS( LineStyle ) - - explicit QCPGraph( QCPAxis* keyAxis, QCPAxis* valueAxis ); + enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented + ///< with symbols according to the scatter style, see \ref setScatterStyle) + ,lsLine ///< data points are connected by a straight line + ,lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point + ,lsStepRight ///< line is drawn as steps where the step height is the value of the right data point + ,lsStepCenter ///< line is drawn as steps where the step is in between two data points + ,lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line + }; + Q_ENUMS(LineStyle) + + explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPGraph(); - + // getters: QSharedPointer data() const { return mDataContainer; } LineStyle lineStyle() const { return mLineStyle; } QCPScatterStyle scatterStyle() const { return mScatterStyle; } int scatterSkip() const { return mScatterSkip; } - QCPGraph* channelFillGraph() const { return mChannelFillGraph.data(); } + QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); } bool adaptiveSampling() const { return mAdaptiveSampling; } - + // setters: - void setData( QSharedPointer data ); - void setData( const QVector& keys, const QVector& values, bool alreadySorted = false ); - void setLineStyle( LineStyle ls ); - void setScatterStyle( const QCPScatterStyle& style ); - void setScatterSkip( int skip ); - void setChannelFillGraph( QCPGraph* targetGraph ); - void setAdaptiveSampling( bool enabled ); - + void setData(QSharedPointer data); + void setData(const QVector &keys, const QVector &values, bool alreadySorted=false); + void setLineStyle(LineStyle ls); + void setScatterStyle(const QCPScatterStyle &style); + void setScatterSkip(int skip); + void setChannelFillGraph(QCPGraph *targetGraph); + void setAdaptiveSampling(bool enabled); + // non-property methods: - void addData( const QVector& keys, const QVector& values, bool alreadySorted = false ); - void addData( double key, double value ); - + void addData(const QVector &keys, const QVector &values, bool alreadySorted=false); + void addData(double key, double value); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + protected: // property members: LineStyle mLineStyle; @@ -5418,48 +5211,49 @@ protected: int mScatterSkip; QPointer mChannelFillGraph; bool mAdaptiveSampling; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual void drawFill( QCPPainter* painter, QVector* lines ) const; - virtual void drawScatterPlot( QCPPainter* painter, const QVector& scatters, const QCPScatterStyle& style ) const; - virtual void drawLinePlot( QCPPainter* painter, const QVector& lines ) const; - virtual void drawImpulsePlot( QCPPainter* painter, const QVector& lines ) const; - - virtual void getOptimizedLineData( QVector* lineData, const QCPGraphDataContainer::const_iterator& begin, const QCPGraphDataContainer::const_iterator& end ) const; - virtual void getOptimizedScatterData( QVector* scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end ) const; - + virtual void drawFill(QCPPainter *painter, QVector *lines) const; + virtual void drawScatterPlot(QCPPainter *painter, const QVector &scatters, const QCPScatterStyle &style) const; + virtual void drawLinePlot(QCPPainter *painter, const QVector &lines) const; + virtual void drawImpulsePlot(QCPPainter *painter, const QVector &lines) const; + + virtual void getOptimizedLineData(QVector *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const; + virtual void getOptimizedScatterData(QVector *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const; + // non-virtual methods: - void getVisibleDataBounds( QCPGraphDataContainer::const_iterator& begin, QCPGraphDataContainer::const_iterator& end, const QCPDataRange& rangeRestriction ) const; - void getLines( QVector* lines, const QCPDataRange& dataRange ) const; - void getScatters( QVector* scatters, const QCPDataRange& dataRange ) const; - QVector dataToLines( const QVector& data ) const; - QVector dataToStepLeftLines( const QVector& data ) const; - QVector dataToStepRightLines( const QVector& data ) const; - QVector dataToStepCenterLines( const QVector& data ) const; - QVector dataToImpulseLines( const QVector& data ) const; - QVector getNonNanSegments( const QVector* lineData, Qt::Orientation keyOrientation ) const; - QVector > getOverlappingSegments( QVector thisSegments, const QVector* thisData, QVector otherSegments, const QVector* otherData ) const; - bool segmentsIntersect( double aLower, double aUpper, double bLower, double bUpper, int& bPrecedence ) const; - QPointF getFillBasePoint( QPointF matchingDataPoint ) const; - const QPolygonF getFillPolygon( const QVector* lineData, QCPDataRange segment ) const; - const QPolygonF getChannelFillPolygon( const QVector* lineData, QCPDataRange thisSegment, const QVector* otherData, QCPDataRange otherSegment ) const; - int findIndexBelowX( const QVector* data, double x ) const; - int findIndexAboveX( const QVector* data, double x ) const; - int findIndexBelowY( const QVector* data, double y ) const; - int findIndexAboveY( const QVector* data, double y ) const; - double pointDistance( const QPointF& pixelPoint, QCPGraphDataContainer::const_iterator& closestData ) const; - + void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const; + void getLines(QVector *lines, const QCPDataRange &dataRange) const; + void getScatters(QVector *scatters, const QCPDataRange &dataRange) const; + QVector dataToLines(const QVector &data) const; + QVector dataToStepLeftLines(const QVector &data) const; + QVector dataToStepRightLines(const QVector &data) const; + QVector dataToStepCenterLines(const QVector &data) const; + QVector dataToImpulseLines(const QVector &data) const; + QVector getNonNanSegments(const QVector *lineData, Qt::Orientation keyOrientation) const; + QVector > getOverlappingSegments(QVector thisSegments, const QVector *thisData, QVector otherSegments, const QVector *otherData) const; + bool segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const; + QPointF getFillBasePoint(QPointF matchingDataPoint) const; + const QPolygonF getFillPolygon(const QVector *lineData, QCPDataRange segment) const; + const QPolygonF getChannelFillPolygon(const QVector *lineData, QCPDataRange thisSegment, const QVector *otherData, QCPDataRange otherSegment) const; + int findIndexBelowX(const QVector *data, double x) const; + int findIndexAboveX(const QVector *data, double x) const; + int findIndexBelowY(const QVector *data, double y) const; + int findIndexAboveY(const QVector *data, double y) const; + double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const; + friend class QCustomPlot; friend class QCPLegend; }; -Q_DECLARE_METATYPE( QCPGraph::LineStyle ) +Q_DECLARE_METATYPE(QCPGraph::LineStyle) /* end of 'src/plottables/plottable-graph.h' */ + /* including file 'src/plottables/plottable-curve.h', size 7409 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5467,20 +5261,21 @@ class QCP_LIB_DECL QCPCurveData { public: QCPCurveData(); - QCPCurveData( double t, double key, double value ); - + QCPCurveData(double t, double key, double value); + inline double sortKey() const { return t; } - inline static QCPCurveData fromSortKey( double sortKey ) { return QCPCurveData( sortKey, 0, 0 ); } + inline static QCPCurveData fromSortKey(double sortKey) { return QCPCurveData(sortKey, 0, 0); } inline static bool sortKeyIsMainKey() { return false; } - + inline double mainKey() const { return key; } inline double mainValue() const { return value; } - - inline QCPRange valueRange() const { return QCPRange( value, value ); } - + + inline QCPRange valueRange() const { return QCPRange(value, value); } + double t, key, value; }; -Q_DECLARE_TYPEINFO( QCPCurveData, Q_PRIMITIVE_TYPE ); +Q_DECLARE_TYPEINFO(QCPCurveData, Q_PRIMITIVE_TYPE); + /*! \typedef QCPCurveDataContainer @@ -5498,9 +5293,9 @@ class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable1D { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle ) - Q_PROPERTY( int scatterSkip READ scatterSkip WRITE setScatterSkip ) - Q_PROPERTY( LineStyle lineStyle READ lineStyle WRITE setLineStyle ) + Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) + Q_PROPERTY(int scatterSkip READ scatterSkip WRITE setScatterSkip) + Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) /// \endcond public: /*! @@ -5508,74 +5303,72 @@ public: current pen of the curve (\ref setPen). \see setLineStyle */ - enum LineStyle - { - lsNone ///< No line is drawn between data points (e.g. only scatters) - , - lsLine ///< Data points are connected with a straight line - }; - Q_ENUMS( LineStyle ) - - explicit QCPCurve( QCPAxis* keyAxis, QCPAxis* valueAxis ); + enum LineStyle { lsNone ///< No line is drawn between data points (e.g. only scatters) + ,lsLine ///< Data points are connected with a straight line + }; + Q_ENUMS(LineStyle) + + explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPCurve(); - + // getters: QSharedPointer data() const { return mDataContainer; } QCPScatterStyle scatterStyle() const { return mScatterStyle; } int scatterSkip() const { return mScatterSkip; } LineStyle lineStyle() const { return mLineStyle; } - + // setters: - void setData( QSharedPointer data ); - void setData( const QVector& t, const QVector& keys, const QVector& values, bool alreadySorted = false ); - void setData( const QVector& keys, const QVector& values ); - void setScatterStyle( const QCPScatterStyle& style ); - void setScatterSkip( int skip ); - void setLineStyle( LineStyle style ); - + void setData(QSharedPointer data); + void setData(const QVector &t, const QVector &keys, const QVector &values, bool alreadySorted=false); + void setData(const QVector &keys, const QVector &values); + void setScatterStyle(const QCPScatterStyle &style); + void setScatterSkip(int skip); + void setLineStyle(LineStyle style); + // non-property methods: - void addData( const QVector& t, const QVector& keys, const QVector& values, bool alreadySorted = false ); - void addData( const QVector& keys, const QVector& values ); - void addData( double t, double key, double value ); - void addData( double key, double value ); - + void addData(const QVector &t, const QVector &keys, const QVector &values, bool alreadySorted=false); + void addData(const QVector &keys, const QVector &values); + void addData(double t, double key, double value); + void addData(double key, double value); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + protected: // property members: QCPScatterStyle mScatterStyle; int mScatterSkip; LineStyle mLineStyle; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual void drawCurveLine( QCPPainter* painter, const QVector& lines ) const; - virtual void drawScatterPlot( QCPPainter* painter, const QVector& points, const QCPScatterStyle& style ) const; - + virtual void drawCurveLine(QCPPainter *painter, const QVector &lines) const; + virtual void drawScatterPlot(QCPPainter *painter, const QVector &points, const QCPScatterStyle &style) const; + // non-virtual methods: - void getCurveLines( QVector* lines, const QCPDataRange& dataRange, double penWidth ) const; - void getScatters( QVector* scatters, const QCPDataRange& dataRange, double scatterWidth ) const; - int getRegion( double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const; - QPointF getOptimizedPoint( int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const; - QVector getOptimizedCornerPoints( int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin ) const; - bool mayTraverse( int prevRegion, int currentRegion ) const; - bool getTraverse( double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF& crossA, QPointF& crossB ) const; - void getTraverseCornerPoints( int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector& beforeTraverse, QVector& afterTraverse ) const; - double pointDistance( const QPointF& pixelPoint, QCPCurveDataContainer::const_iterator& closestData ) const; - + void getCurveLines(QVector *lines, const QCPDataRange &dataRange, double penWidth) const; + void getScatters(QVector *scatters, const QCPDataRange &dataRange, double scatterWidth) const; + int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const; + QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const; + QVector getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const; + bool mayTraverse(int prevRegion, int currentRegion) const; + bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const; + void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector &beforeTraverse, QVector &afterTraverse) const; + double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const; + friend class QCustomPlot; friend class QCPLegend; }; -Q_DECLARE_METATYPE( QCPCurve::LineStyle ) +Q_DECLARE_METATYPE(QCPCurve::LineStyle) /* end of 'src/plottables/plottable-curve.h' */ + /* including file 'src/plottables/plottable-bars.h', size 8924 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5583,8 +5376,8 @@ class QCP_LIB_DECL QCPBarsGroup : public QObject { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( SpacingType spacingType READ spacingType WRITE setSpacingType ) - Q_PROPERTY( double spacing READ spacing WRITE setSpacing ) + Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType) + Q_PROPERTY(double spacing READ spacing WRITE setSpacing) /// \endcond public: /*! @@ -5593,78 +5386,76 @@ public: \see setSpacingType, setSpacing */ - enum SpacingType - { - stAbsolute ///< Bar spacing is in absolute pixels - , - stAxisRectRatio ///< Bar spacing is given by a fraction of the axis rect size - , - stPlotCoords ///< Bar spacing is in key coordinates and thus scales with the key axis range - }; - Q_ENUMS( SpacingType ) - - QCPBarsGroup( QCustomPlot* parentPlot ); + enum SpacingType { stAbsolute ///< Bar spacing is in absolute pixels + ,stAxisRectRatio ///< Bar spacing is given by a fraction of the axis rect size + ,stPlotCoords ///< Bar spacing is in key coordinates and thus scales with the key axis range + }; + Q_ENUMS(SpacingType) + + QCPBarsGroup(QCustomPlot *parentPlot); virtual ~QCPBarsGroup(); - + // getters: SpacingType spacingType() const { return mSpacingType; } double spacing() const { return mSpacing; } - + // setters: - void setSpacingType( SpacingType spacingType ); - void setSpacing( double spacing ); - + void setSpacingType(SpacingType spacingType); + void setSpacing(double spacing); + // non-virtual methods: QList bars() const { return mBars; } - QCPBars* bars( int index ) const; + QCPBars* bars(int index) const; int size() const { return mBars.size(); } bool isEmpty() const { return mBars.isEmpty(); } void clear(); - bool contains( QCPBars* bars ) const { return mBars.contains( bars ); } - void append( QCPBars* bars ); - void insert( int i, QCPBars* bars ); - void remove( QCPBars* bars ); - + bool contains(QCPBars *bars) const { return mBars.contains(bars); } + void append(QCPBars *bars); + void insert(int i, QCPBars *bars); + void remove(QCPBars *bars); + protected: // non-property members: - QCustomPlot* mParentPlot; + QCustomPlot *mParentPlot; SpacingType mSpacingType; double mSpacing; QList mBars; - + // non-virtual methods: - void registerBars( QCPBars* bars ); - void unregisterBars( QCPBars* bars ); - + void registerBars(QCPBars *bars); + void unregisterBars(QCPBars *bars); + // virtual methods: - double keyPixelOffset( const QCPBars* bars, double keyCoord ); - double getPixelSpacing( const QCPBars* bars, double keyCoord ); - + double keyPixelOffset(const QCPBars *bars, double keyCoord); + double getPixelSpacing(const QCPBars *bars, double keyCoord); + private: - Q_DISABLE_COPY( QCPBarsGroup ) - + Q_DISABLE_COPY(QCPBarsGroup) + friend class QCPBars; }; -Q_DECLARE_METATYPE( QCPBarsGroup::SpacingType ) +Q_DECLARE_METATYPE(QCPBarsGroup::SpacingType) + class QCP_LIB_DECL QCPBarsData { public: QCPBarsData(); - QCPBarsData( double key, double value ); - + QCPBarsData(double key, double value); + inline double sortKey() const { return key; } - inline static QCPBarsData fromSortKey( double sortKey ) { return QCPBarsData( sortKey, 0 ); } - inline static bool sortKeyIsMainKey() { return true; } - + inline static QCPBarsData fromSortKey(double sortKey) { return QCPBarsData(sortKey, 0); } + inline static bool sortKeyIsMainKey() { return true; } + inline double mainKey() const { return key; } inline double mainValue() const { return value; } - - inline QCPRange valueRange() const { return QCPRange( value, value ); } // note that bar base value isn't held in each QCPBarsData and thus can't/shouldn't be returned here - + + inline QCPRange valueRange() const { return QCPRange(value, value); } // note that bar base value isn't held in each QCPBarsData and thus can't/shouldn't be returned here + double key, value; }; -Q_DECLARE_TYPEINFO( QCPBarsData, Q_PRIMITIVE_TYPE ); +Q_DECLARE_TYPEINFO(QCPBarsData, Q_PRIMITIVE_TYPE); + /*! \typedef QCPBarsDataContainer @@ -5681,13 +5472,13 @@ class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable1D { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( double width READ width WRITE setWidth ) - Q_PROPERTY( WidthType widthType READ widthType WRITE setWidthType ) - Q_PROPERTY( QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup ) - Q_PROPERTY( double baseValue READ baseValue WRITE setBaseValue ) - Q_PROPERTY( double stackingGap READ stackingGap WRITE setStackingGap ) - Q_PROPERTY( QCPBars* barBelow READ barBelow ) - Q_PROPERTY( QCPBars* barAbove READ barAbove ) + Q_PROPERTY(double width READ width WRITE setWidth) + Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType) + Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup) + Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue) + Q_PROPERTY(double stackingGap READ stackingGap WRITE setStackingGap) + Q_PROPERTY(QCPBars* barBelow READ barBelow) + Q_PROPERTY(QCPBars* barAbove READ barAbove) /// \endcond public: /*! @@ -5696,79 +5487,76 @@ public: \see setWidthType, setWidth */ - enum WidthType - { - wtAbsolute ///< Bar width is in absolute pixels - , - wtAxisRectRatio ///< Bar width is given by a fraction of the axis rect size - , - wtPlotCoords ///< Bar width is in key coordinates and thus scales with the key axis range - }; - Q_ENUMS( WidthType ) - - explicit QCPBars( QCPAxis* keyAxis, QCPAxis* valueAxis ); + enum WidthType { wtAbsolute ///< Bar width is in absolute pixels + ,wtAxisRectRatio ///< Bar width is given by a fraction of the axis rect size + ,wtPlotCoords ///< Bar width is in key coordinates and thus scales with the key axis range + }; + Q_ENUMS(WidthType) + + explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPBars(); - + // getters: double width() const { return mWidth; } WidthType widthType() const { return mWidthType; } - QCPBarsGroup* barsGroup() const { return mBarsGroup; } + QCPBarsGroup *barsGroup() const { return mBarsGroup; } double baseValue() const { return mBaseValue; } double stackingGap() const { return mStackingGap; } - QCPBars* barBelow() const { return mBarBelow.data(); } - QCPBars* barAbove() const { return mBarAbove.data(); } + QCPBars *barBelow() const { return mBarBelow.data(); } + QCPBars *barAbove() const { return mBarAbove.data(); } QSharedPointer data() const { return mDataContainer; } - + // setters: - void setData( QSharedPointer data ); - void setData( const QVector& keys, const QVector& values, bool alreadySorted = false ); - void setWidth( double width ); - void setWidthType( WidthType widthType ); - void setBarsGroup( QCPBarsGroup* barsGroup ); - void setBaseValue( double baseValue ); - void setStackingGap( double pixels ); - + void setData(QSharedPointer data); + void setData(const QVector &keys, const QVector &values, bool alreadySorted=false); + void setWidth(double width); + void setWidthType(WidthType widthType); + void setBarsGroup(QCPBarsGroup *barsGroup); + void setBaseValue(double baseValue); + void setStackingGap(double pixels); + // non-property methods: - void addData( const QVector& keys, const QVector& values, bool alreadySorted = false ); - void addData( double key, double value ); - void moveBelow( QCPBars* bars ); - void moveAbove( QCPBars* bars ); - + void addData(const QVector &keys, const QVector &values, bool alreadySorted=false); + void addData(double key, double value); + void moveBelow(QCPBars *bars); + void moveAbove(QCPBars *bars); + // reimplemented virtual methods: - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const Q_DECL_OVERRIDE; - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - virtual QPointF dataPixelPosition( int index ) const Q_DECL_OVERRIDE; - + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE; + protected: // property members: double mWidth; WidthType mWidthType; - QCPBarsGroup* mBarsGroup; + QCPBarsGroup *mBarsGroup; double mBaseValue; double mStackingGap; QPointer mBarBelow, mBarAbove; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + // non-virtual methods: - void getVisibleDataBounds( QCPBarsDataContainer::const_iterator& begin, QCPBarsDataContainer::const_iterator& end ) const; - QRectF getBarRect( double key, double value ) const; - void getPixelWidth( double key, double& lower, double& upper ) const; - double getStackedBaseValue( double key, bool positive ) const; - static void connectBars( QCPBars* lower, QCPBars* upper ); - + void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const; + QRectF getBarRect(double key, double value) const; + void getPixelWidth(double key, double &lower, double &upper) const; + double getStackedBaseValue(double key, bool positive) const; + static void connectBars(QCPBars* lower, QCPBars* upper); + friend class QCustomPlot; friend class QCPLegend; friend class QCPBarsGroup; }; -Q_DECLARE_METATYPE( QCPBars::WidthType ) +Q_DECLARE_METATYPE(QCPBars::WidthType) /* end of 'src/plottables/plottable-bars.h' */ + /* including file 'src/plottables/plottable-statisticalbox.h', size 7516 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -5776,27 +5564,28 @@ class QCP_LIB_DECL QCPStatisticalBoxData { public: QCPStatisticalBoxData(); - QCPStatisticalBoxData( double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector& outliers = QVector() ); - + QCPStatisticalBoxData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector& outliers=QVector()); + inline double sortKey() const { return key; } - inline static QCPStatisticalBoxData fromSortKey( double sortKey ) { return QCPStatisticalBoxData( sortKey, 0, 0, 0, 0, 0 ); } + inline static QCPStatisticalBoxData fromSortKey(double sortKey) { return QCPStatisticalBoxData(sortKey, 0, 0, 0, 0, 0); } inline static bool sortKeyIsMainKey() { return true; } - + inline double mainKey() const { return key; } inline double mainValue() const { return median; } - + inline QCPRange valueRange() const { - QCPRange result( minimum, maximum ); - for( QVector::const_iterator it = outliers.constBegin(); it != outliers.constEnd(); ++it ) - result.expand( *it ); + QCPRange result(minimum, maximum); + for (QVector::const_iterator it = outliers.constBegin(); it != outliers.constEnd(); ++it) + result.expand(*it); return result; } - + double key, minimum, lowerQuartile, median, upperQuartile, maximum; QVector outliers; }; -Q_DECLARE_TYPEINFO( QCPStatisticalBoxData, Q_MOVABLE_TYPE ); +Q_DECLARE_TYPEINFO(QCPStatisticalBoxData, Q_MOVABLE_TYPE); + /*! \typedef QCPStatisticalBoxDataContainer @@ -5814,17 +5603,17 @@ class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable1D data() const { return mDataContainer; } double width() const { return mWidth; } @@ -5836,26 +5625,26 @@ public: QCPScatterStyle outlierStyle() const { return mOutlierStyle; } // setters: - void setData( QSharedPointer data ); - void setData( const QVector& keys, const QVector& minimum, const QVector& lowerQuartile, const QVector& median, const QVector& upperQuartile, const QVector& maximum, bool alreadySorted = false ); - void setWidth( double width ); - void setWhiskerWidth( double width ); - void setWhiskerPen( const QPen& pen ); - void setWhiskerBarPen( const QPen& pen ); - void setWhiskerAntialiased( bool enabled ); - void setMedianPen( const QPen& pen ); - void setOutlierStyle( const QCPScatterStyle& style ); - + void setData(QSharedPointer data); + void setData(const QVector &keys, const QVector &minimum, const QVector &lowerQuartile, const QVector &median, const QVector &upperQuartile, const QVector &maximum, bool alreadySorted=false); + void setWidth(double width); + void setWhiskerWidth(double width); + void setWhiskerPen(const QPen &pen); + void setWhiskerBarPen(const QPen &pen); + void setWhiskerAntialiased(bool enabled); + void setMedianPen(const QPen &pen); + void setOutlierStyle(const QCPScatterStyle &style); + // non-property methods: - void addData( const QVector& keys, const QVector& minimum, const QVector& lowerQuartile, const QVector& median, const QVector& upperQuartile, const QVector& maximum, bool alreadySorted = false ); - void addData( double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector& outliers = QVector() ); - + void addData(const QVector &keys, const QVector &minimum, const QVector &lowerQuartile, const QVector &median, const QVector &upperQuartile, const QVector &maximum, bool alreadySorted=false); + void addData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum, const QVector &outliers=QVector()); + // reimplemented virtual methods: - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const Q_DECL_OVERRIDE; - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + protected: // property members: double mWidth; @@ -5864,160 +5653,163 @@ protected: bool mWhiskerAntialiased; QPen mMedianPen; QCPScatterStyle mOutlierStyle; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + // introduced virtual methods: - virtual void drawStatisticalBox( QCPPainter* painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle& outlierStyle ) const; - + virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const; + // non-virtual methods: - void getVisibleDataBounds( QCPStatisticalBoxDataContainer::const_iterator& begin, QCPStatisticalBoxDataContainer::const_iterator& end ) const; - QRectF getQuartileBox( QCPStatisticalBoxDataContainer::const_iterator it ) const; - QVector getWhiskerBackboneLines( QCPStatisticalBoxDataContainer::const_iterator it ) const; - QVector getWhiskerBarLines( QCPStatisticalBoxDataContainer::const_iterator it ) const; - + void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const; + QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const; + QVector getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const; + QVector getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const; + friend class QCustomPlot; friend class QCPLegend; }; /* end of 'src/plottables/plottable-statisticalbox.h' */ + /* including file 'src/plottables/plottable-colormap.h', size 7070 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ class QCP_LIB_DECL QCPColorMapData { public: - QCPColorMapData( int keySize, int valueSize, const QCPRange& keyRange, const QCPRange& valueRange ); + QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange); ~QCPColorMapData(); - QCPColorMapData( const QCPColorMapData& other ); - QCPColorMapData& operator=( const QCPColorMapData& other ); - + QCPColorMapData(const QCPColorMapData &other); + QCPColorMapData &operator=(const QCPColorMapData &other); + // getters: int keySize() const { return mKeySize; } int valueSize() const { return mValueSize; } QCPRange keyRange() const { return mKeyRange; } QCPRange valueRange() const { return mValueRange; } QCPRange dataBounds() const { return mDataBounds; } - double data( double key, double value ); - double cell( int keyIndex, int valueIndex ); - unsigned char alpha( int keyIndex, int valueIndex ); - + double data(double key, double value); + double cell(int keyIndex, int valueIndex); + unsigned char alpha(int keyIndex, int valueIndex); + // setters: - void setSize( int keySize, int valueSize ); - void setKeySize( int keySize ); - void setValueSize( int valueSize ); - void setRange( const QCPRange& keyRange, const QCPRange& valueRange ); - void setKeyRange( const QCPRange& keyRange ); - void setValueRange( const QCPRange& valueRange ); - void setData( double key, double value, double z ); - void setCell( int keyIndex, int valueIndex, double z ); - void setAlpha( int keyIndex, int valueIndex, unsigned char alpha ); - + void setSize(int keySize, int valueSize); + void setKeySize(int keySize); + void setValueSize(int valueSize); + void setRange(const QCPRange &keyRange, const QCPRange &valueRange); + void setKeyRange(const QCPRange &keyRange); + void setValueRange(const QCPRange &valueRange); + void setData(double key, double value, double z); + void setCell(int keyIndex, int valueIndex, double z); + void setAlpha(int keyIndex, int valueIndex, unsigned char alpha); + // non-property methods: void recalculateDataBounds(); void clear(); void clearAlpha(); - void fill( double z ); - void fillAlpha( unsigned char alpha ); + void fill(double z); + void fillAlpha(unsigned char alpha); bool isEmpty() const { return mIsEmpty; } - void coordToCell( double key, double value, int* keyIndex, int* valueIndex ) const; - void cellToCoord( int keyIndex, int valueIndex, double* key, double* value ) const; - + void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const; + void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const; + protected: // property members: int mKeySize, mValueSize; QCPRange mKeyRange, mValueRange; bool mIsEmpty; - + // non-property members: - double* mData; - unsigned char* mAlpha; + double *mData; + unsigned char *mAlpha; QCPRange mDataBounds; bool mDataModified; - - bool createAlpha( bool initializeOpaque = true ); - + + bool createAlpha(bool initializeOpaque=true); + friend class QCPColorMap; }; + class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged ) - Q_PROPERTY( QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged ) - Q_PROPERTY( QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged ) - Q_PROPERTY( bool interpolate READ interpolate WRITE setInterpolate ) - Q_PROPERTY( bool tightBoundary READ tightBoundary WRITE setTightBoundary ) - Q_PROPERTY( QCPColorScale* colorScale READ colorScale WRITE setColorScale ) + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate) + Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary) + Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale) /// \endcond public: - explicit QCPColorMap( QCPAxis* keyAxis, QCPAxis* valueAxis ); + explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPColorMap(); - + // getters: - QCPColorMapData* data() const { return mMapData; } + QCPColorMapData *data() const { return mMapData; } QCPRange dataRange() const { return mDataRange; } QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } bool interpolate() const { return mInterpolate; } bool tightBoundary() const { return mTightBoundary; } QCPColorGradient gradient() const { return mGradient; } - QCPColorScale* colorScale() const { return mColorScale.data(); } - + QCPColorScale *colorScale() const { return mColorScale.data(); } + // setters: - void setData( QCPColorMapData* data, bool copy = false ); - Q_SLOT void setDataRange( const QCPRange& dataRange ); - Q_SLOT void setDataScaleType( QCPAxis::ScaleType scaleType ); - Q_SLOT void setGradient( const QCPColorGradient& gradient ); - void setInterpolate( bool enabled ); - void setTightBoundary( bool enabled ); - void setColorScale( QCPColorScale* colorScale ); - + void setData(QCPColorMapData *data, bool copy=false); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setInterpolate(bool enabled); + void setTightBoundary(bool enabled); + void setColorScale(QCPColorScale *colorScale); + // non-property methods: - void rescaleDataRange( bool recalculateDataBounds = false ); - Q_SLOT void updateLegendIcon( Qt::TransformationMode transformMode = Qt::SmoothTransformation, const QSize& thumbSize = QSize( 32, 18 ) ); - + void rescaleDataRange(bool recalculateDataBounds=false); + Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18)); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + signals: - void dataRangeChanged( const QCPRange& newRange ); - void dataScaleTypeChanged( QCPAxis::ScaleType scaleType ); - void gradientChanged( const QCPColorGradient& newGradient ); - + void dataRangeChanged(const QCPRange &newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(const QCPColorGradient &newGradient); + protected: // property members: QCPRange mDataRange; QCPAxis::ScaleType mDataScaleType; - QCPColorMapData* mMapData; + QCPColorMapData *mMapData; QCPColorGradient mGradient; bool mInterpolate; bool mTightBoundary; QPointer mColorScale; - + // non-property members: QImage mMapImage, mUndersampledMapImage; QPixmap mLegendIcon; bool mMapImageInvalidated; - + // introduced virtual methods: virtual void updateMapImage(); - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + friend class QCustomPlot; friend class QCPLegend; }; /* end of 'src/plottables/plottable-colormap.h' */ + /* including file 'src/plottables/plottable-financial.h', size 8622 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6025,20 +5817,21 @@ class QCP_LIB_DECL QCPFinancialData { public: QCPFinancialData(); - QCPFinancialData( double key, double open, double high, double low, double close ); - + QCPFinancialData(double key, double open, double high, double low, double close); + inline double sortKey() const { return key; } - inline static QCPFinancialData fromSortKey( double sortKey ) { return QCPFinancialData( sortKey, 0, 0, 0, 0 ); } - inline static bool sortKeyIsMainKey() { return true; } - + inline static QCPFinancialData fromSortKey(double sortKey) { return QCPFinancialData(sortKey, 0, 0, 0, 0); } + inline static bool sortKeyIsMainKey() { return true; } + inline double mainKey() const { return key; } inline double mainValue() const { return open; } - - inline QCPRange valueRange() const { return QCPRange( low, high ); } // open and close must lie between low and high, so we don't need to check them - + + inline QCPRange valueRange() const { return QCPRange(low, high); } // open and close must lie between low and high, so we don't need to check them + double key, open, high, low, close; }; -Q_DECLARE_TYPEINFO( QCPFinancialData, Q_PRIMITIVE_TYPE ); +Q_DECLARE_TYPEINFO(QCPFinancialData, Q_PRIMITIVE_TYPE); + /*! \typedef QCPFinancialDataContainer @@ -6055,14 +5848,14 @@ class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable1D data() const { return mDataContainer; } ChartStyle chartStyle() const { return mChartStyle; } @@ -6107,32 +5893,32 @@ public: QBrush brushNegative() const { return mBrushNegative; } QPen penPositive() const { return mPenPositive; } QPen penNegative() const { return mPenNegative; } - + // setters: - void setData( QSharedPointer data ); - void setData( const QVector& keys, const QVector& open, const QVector& high, const QVector& low, const QVector& close, bool alreadySorted = false ); - void setChartStyle( ChartStyle style ); - void setWidth( double width ); - void setWidthType( WidthType widthType ); - void setTwoColored( bool twoColored ); - void setBrushPositive( const QBrush& brush ); - void setBrushNegative( const QBrush& brush ); - void setPenPositive( const QPen& pen ); - void setPenNegative( const QPen& pen ); - + void setData(QSharedPointer data); + void setData(const QVector &keys, const QVector &open, const QVector &high, const QVector &low, const QVector &close, bool alreadySorted=false); + void setChartStyle(ChartStyle style); + void setWidth(double width); + void setWidthType(WidthType widthType); + void setTwoColored(bool twoColored); + void setBrushPositive(const QBrush &brush); + void setBrushNegative(const QBrush &brush); + void setPenPositive(const QPen &pen); + void setPenNegative(const QPen &pen); + // non-property methods: - void addData( const QVector& keys, const QVector& open, const QVector& high, const QVector& low, const QVector& close, bool alreadySorted = false ); - void addData( double key, double open, double high, double low, double close ); - + void addData(const QVector &keys, const QVector &open, const QVector &high, const QVector &low, const QVector &close, bool alreadySorted=false); + void addData(double key, double open, double high, double low, double close); + // reimplemented virtual methods: - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const Q_DECL_OVERRIDE; - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + // static methods: - static QCPFinancialDataContainer timeSeriesToOhlc( const QVector& time, const QVector& value, double timeBinSize, double timeBinOffset = 0 ); - + static QCPFinancialDataContainer timeSeriesToOhlc(const QVector &time, const QVector &value, double timeBinSize, double timeBinOffset = 0); + protected: // property members: ChartStyle mChartStyle; @@ -6141,27 +5927,28 @@ protected: bool mTwoColored; QBrush mBrushPositive, mBrushNegative; QPen mPenPositive, mPenNegative; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + // non-virtual methods: - void drawOhlcPlot( QCPPainter* painter, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, bool isSelected ); - void drawCandlestickPlot( QCPPainter* painter, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, bool isSelected ); - double getPixelWidth( double key, double keyPixel ) const; - double ohlcSelectTest( const QPointF& pos, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, QCPFinancialDataContainer::const_iterator& closestDataPoint ) const; - double candlestickSelectTest( const QPointF& pos, const QCPFinancialDataContainer::const_iterator& begin, const QCPFinancialDataContainer::const_iterator& end, QCPFinancialDataContainer::const_iterator& closestDataPoint ) const; - void getVisibleDataBounds( QCPFinancialDataContainer::const_iterator& begin, QCPFinancialDataContainer::const_iterator& end ) const; - QRectF selectionHitBox( QCPFinancialDataContainer::const_iterator it ) const; - + void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected); + void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected); + double getPixelWidth(double key, double keyPixel) const; + double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const; + double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const; + void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const; + QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const; + friend class QCustomPlot; friend class QCPLegend; }; -Q_DECLARE_METATYPE( QCPFinancial::ChartStyle ) +Q_DECLARE_METATYPE(QCPFinancial::ChartStyle) /* end of 'src/plottables/plottable-financial.h' */ + /* including file 'src/plottables/plottable-errorbar.h', size 7727 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6169,12 +5956,13 @@ class QCP_LIB_DECL QCPErrorBarsData { public: QCPErrorBarsData(); - explicit QCPErrorBarsData( double error ); - QCPErrorBarsData( double errorMinus, double errorPlus ); - + explicit QCPErrorBarsData(double error); + QCPErrorBarsData(double errorMinus, double errorPlus); + double errorMinus, errorPlus; }; -Q_DECLARE_TYPEINFO( QCPErrorBarsData, Q_PRIMITIVE_TYPE ); +Q_DECLARE_TYPEINFO(QCPErrorBarsData, Q_PRIMITIVE_TYPE); + /*! \typedef QCPErrorBarsDataContainer @@ -6197,67 +5985,65 @@ class QCP_LIB_DECL QCPErrorBars : public QCPAbstractPlottable, public QCPPlottab { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QSharedPointer data READ data WRITE setData ) - Q_PROPERTY( QCPAbstractPlottable* dataPlottable READ dataPlottable WRITE setDataPlottable ) - Q_PROPERTY( ErrorType errorType READ errorType WRITE setErrorType ) - Q_PROPERTY( double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth ) - Q_PROPERTY( double symbolGap READ symbolGap WRITE setSymbolGap ) + Q_PROPERTY(QSharedPointer data READ data WRITE setData) + Q_PROPERTY(QCPAbstractPlottable* dataPlottable READ dataPlottable WRITE setDataPlottable) + Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType) + Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth) + Q_PROPERTY(double symbolGap READ symbolGap WRITE setSymbolGap) /// \endcond public: + /*! Defines in which orientation the error bars shall appear. If your data needs both error dimensions, create two \ref QCPErrorBars with different \ref ErrorType. \see setErrorType */ - enum ErrorType - { - etKeyError ///< The errors are for the key dimension (bars appear parallel to the key axis) - , - etValueError ///< The errors are for the value dimension (bars appear parallel to the value axis) + enum ErrorType { etKeyError ///< The errors are for the key dimension (bars appear parallel to the key axis) + ,etValueError ///< The errors are for the value dimension (bars appear parallel to the value axis) }; - Q_ENUMS( ErrorType ) - - explicit QCPErrorBars( QCPAxis* keyAxis, QCPAxis* valueAxis ); + Q_ENUMS(ErrorType) + + explicit QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis); virtual ~QCPErrorBars(); // getters: QSharedPointer data() const { return mDataContainer; } - QCPAbstractPlottable* dataPlottable() const { return mDataPlottable.data(); } + QCPAbstractPlottable *dataPlottable() const { return mDataPlottable.data(); } ErrorType errorType() const { return mErrorType; } double whiskerWidth() const { return mWhiskerWidth; } double symbolGap() const { return mSymbolGap; } - + // setters: - void setData( QSharedPointer data ); - void setData( const QVector& error ); - void setData( const QVector& errorMinus, const QVector& errorPlus ); - void setDataPlottable( QCPAbstractPlottable* plottable ); - void setErrorType( ErrorType type ); - void setWhiskerWidth( double pixels ); - void setSymbolGap( double pixels ); - + void setData(QSharedPointer data); + void setData(const QVector &error); + void setData(const QVector &errorMinus, const QVector &errorPlus); + void setDataPlottable(QCPAbstractPlottable* plottable); + void setErrorType(ErrorType type); + void setWhiskerWidth(double pixels); + void setSymbolGap(double pixels); + // non-property methods: - void addData( const QVector& error ); - void addData( const QVector& errorMinus, const QVector& errorPlus ); - void addData( double error ); - void addData( double errorMinus, double errorPlus ); - + void addData(const QVector &error); + void addData(const QVector &errorMinus, const QVector &errorPlus); + void addData(double error); + void addData(double errorMinus, double errorPlus); + // virtual methods of 1d plottable interface: virtual int dataCount() const Q_DECL_OVERRIDE; - virtual double dataMainKey( int index ) const Q_DECL_OVERRIDE; - virtual double dataSortKey( int index ) const Q_DECL_OVERRIDE; - virtual double dataMainValue( int index ) const Q_DECL_OVERRIDE; - virtual QCPRange dataValueRange( int index ) const Q_DECL_OVERRIDE; - virtual QPointF dataPixelPosition( int index ) const Q_DECL_OVERRIDE; + virtual double dataMainKey(int index) const Q_DECL_OVERRIDE; + virtual double dataSortKey(int index) const Q_DECL_OVERRIDE; + virtual double dataMainValue(int index) const Q_DECL_OVERRIDE; + virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE; + virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE; virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE; - virtual QCPDataSelection selectTestRect( const QRectF& rect, bool onlySelectable ) const Q_DECL_OVERRIDE; - virtual int findBegin( double sortKey, bool expandedRange = true ) const Q_DECL_OVERRIDE; - virtual int findEnd( double sortKey, bool expandedRange = true ) const Q_DECL_OVERRIDE; - + virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE; + virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE; + virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE; + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - virtual QCPPlottableInterface1D* interface1D() Q_DECL_OVERRIDE { return this; } - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + virtual QCPPlottableInterface1D *interface1D() Q_DECL_OVERRIDE { return this; } + protected: // property members: QSharedPointer mDataContainer; @@ -6265,28 +6051,29 @@ protected: ErrorType mErrorType; double mWhiskerWidth; double mSymbolGap; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual void drawLegendIcon( QCPPainter* painter, const QRectF& rect ) const Q_DECL_OVERRIDE; - virtual QCPRange getKeyRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth ) const Q_DECL_OVERRIDE; - virtual QCPRange getValueRange( bool& foundRange, QCP::SignDomain inSignDomain = QCP::sdBoth, const QCPRange& inKeyRange = QCPRange() ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE; + virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE; + virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE; + // non-virtual methods: - void getErrorBarLines( QCPErrorBarsDataContainer::const_iterator it, QVector& backbones, QVector& whiskers ) const; - void getVisibleDataBounds( QCPErrorBarsDataContainer::const_iterator& begin, QCPErrorBarsDataContainer::const_iterator& end, const QCPDataRange& rangeRestriction ) const; - double pointDistance( const QPointF& pixelPoint, QCPErrorBarsDataContainer::const_iterator& closestData ) const; + void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector &backbones, QVector &whiskers) const; + void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const; + double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const; // helpers: - void getDataSegments( QList& selectedSegments, QList& unselectedSegments ) const; - bool errorBarVisible( int index ) const; - bool rectIntersectsLine( const QRectF& pixelRect, const QLineF& line ) const; - + void getDataSegments(QList &selectedSegments, QList &unselectedSegments) const; + bool errorBarVisible(int index) const; + bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const; + friend class QCustomPlot; friend class QCPLegend; }; /* end of 'src/plottables/plottable-errorbar.h' */ + /* including file 'src/items/item-straightline.h', size 3117 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6294,41 +6081,42 @@ class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) /// \endcond public: - explicit QCPItemStraightLine( QCustomPlot* parentPlot ); + explicit QCPItemStraightLine(QCustomPlot *parentPlot); virtual ~QCPItemStraightLine(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const point1; - QCPItemPosition* const point2; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const point1; + QCPItemPosition * const point2; + protected: // property members: QPen mPen, mSelectedPen; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + // non-virtual methods: - QLineF getRectClippedStraightLine( const QCPVector2D& point1, const QCPVector2D& vec, const QRect& rect ) const; + QLineF getRectClippedStraightLine(const QCPVector2D &point1, const QCPVector2D &vec, const QRect &rect) const; QPen mainPen() const; }; /* end of 'src/items/item-straightline.h' */ + /* including file 'src/items/item-line.h', size 3407 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6336,48 +6124,49 @@ class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QCPLineEnding head READ head WRITE setHead ) - Q_PROPERTY( QCPLineEnding tail READ tail WRITE setTail ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) /// \endcond public: - explicit QCPItemLine( QCustomPlot* parentPlot ); + explicit QCPItemLine(QCustomPlot *parentPlot); virtual ~QCPItemLine(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } QCPLineEnding head() const { return mHead; } QCPLineEnding tail() const { return mTail; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setHead( const QCPLineEnding& head ); - void setTail( const QCPLineEnding& tail ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const start; - QCPItemPosition* const end; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const start; + QCPItemPosition * const end; + protected: // property members: QPen mPen, mSelectedPen; QCPLineEnding mHead, mTail; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + // non-virtual methods: - QLineF getRectClippedLine( const QCPVector2D& start, const QCPVector2D& end, const QRect& rect ) const; + QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const; QPen mainPen() const; }; /* end of 'src/items/item-line.h' */ + /* including file 'src/items/item-curve.h', size 3379 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6385,49 +6174,50 @@ class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QCPLineEnding head READ head WRITE setHead ) - Q_PROPERTY( QCPLineEnding tail READ tail WRITE setTail ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) /// \endcond public: - explicit QCPItemCurve( QCustomPlot* parentPlot ); + explicit QCPItemCurve(QCustomPlot *parentPlot); virtual ~QCPItemCurve(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } QCPLineEnding head() const { return mHead; } QCPLineEnding tail() const { return mTail; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setHead( const QCPLineEnding& head ); - void setTail( const QCPLineEnding& tail ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const start; - QCPItemPosition* const startDir; - QCPItemPosition* const endDir; - QCPItemPosition* const end; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const start; + QCPItemPosition * const startDir; + QCPItemPosition * const endDir; + QCPItemPosition * const end; + protected: // property members: QPen mPen, mSelectedPen; QCPLineEnding mHead, mTail; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + // non-virtual methods: QPen mainPen() const; }; /* end of 'src/items/item-curve.h' */ + /* including file 'src/items/item-rect.h', size 3688 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6435,58 +6225,50 @@ class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) /// \endcond public: - explicit QCPItemRect( QCustomPlot* parentPlot ); + explicit QCPItemRect(QCustomPlot *parentPlot); virtual ~QCPItemRect(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } QBrush brush() const { return mBrush; } QBrush selectedBrush() const { return mSelectedBrush; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setSelectedBrush( const QBrush& brush ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const topLeft; - QCPItemPosition* const bottomRight; - QCPItemAnchor* const top; - QCPItemAnchor* const topRight; - QCPItemAnchor* const right; - QCPItemAnchor* const bottom; - QCPItemAnchor* const bottomLeft; - QCPItemAnchor* const left; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + protected: - enum AnchorIndex - { - aiTop, - aiTopRight, - aiRight, - aiBottom, - aiBottomLeft, - aiLeft - }; - + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: QPen mPen, mSelectedPen; QBrush mBrush, mSelectedBrush; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual QPointF anchorPixelPosition( int anchorId ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE; + // non-virtual methods: QPen mainPen() const; QBrush mainBrush() const; @@ -6494,6 +6276,7 @@ protected: /* end of 'src/items/item-rect.h' */ + /* including file 'src/items/item-text.h', size 5554 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6501,24 +6284,24 @@ class QCP_LIB_DECL QCPItemText : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QColor color READ color WRITE setColor ) - Q_PROPERTY( QColor selectedColor READ selectedColor WRITE setSelectedColor ) - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush ) - Q_PROPERTY( QFont font READ font WRITE setFont ) - Q_PROPERTY( QFont selectedFont READ selectedFont WRITE setSelectedFont ) - Q_PROPERTY( QString text READ text WRITE setText ) - Q_PROPERTY( Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment ) - Q_PROPERTY( Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment ) - Q_PROPERTY( double rotation READ rotation WRITE setRotation ) - Q_PROPERTY( QMargins padding READ padding WRITE setPadding ) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment) + Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment) + Q_PROPERTY(double rotation READ rotation WRITE setRotation) + Q_PROPERTY(QMargins padding READ padding WRITE setPadding) /// \endcond public: - explicit QCPItemText( QCustomPlot* parentPlot ); + explicit QCPItemText(QCustomPlot *parentPlot); virtual ~QCPItemText(); - + // getters: QColor color() const { return mColor; } QColor selectedColor() const { return mSelectedColor; } @@ -6533,48 +6316,38 @@ public: Qt::Alignment textAlignment() const { return mTextAlignment; } double rotation() const { return mRotation; } QMargins padding() const { return mPadding; } - + // setters; - void setColor( const QColor& color ); - void setSelectedColor( const QColor& color ); - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setSelectedBrush( const QBrush& brush ); - void setFont( const QFont& font ); - void setSelectedFont( const QFont& font ); - void setText( const QString& text ); - void setPositionAlignment( Qt::Alignment alignment ); - void setTextAlignment( Qt::Alignment alignment ); - void setRotation( double degrees ); - void setPadding( const QMargins& padding ); - + void setColor(const QColor &color); + void setSelectedColor(const QColor &color); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setFont(const QFont &font); + void setSelectedFont(const QFont &font); + void setText(const QString &text); + void setPositionAlignment(Qt::Alignment alignment); + void setTextAlignment(Qt::Alignment alignment); + void setRotation(double degrees); + void setPadding(const QMargins &padding); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const position; - QCPItemAnchor* const topLeft; - QCPItemAnchor* const top; - QCPItemAnchor* const topRight; - QCPItemAnchor* const right; - QCPItemAnchor* const bottomRight; - QCPItemAnchor* const bottom; - QCPItemAnchor* const bottomLeft; - QCPItemAnchor* const left; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const position; + QCPItemAnchor * const topLeft; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRight; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + protected: - enum AnchorIndex - { - aiTopLeft, - aiTop, - aiTopRight, - aiRight, - aiBottomRight, - aiBottom, - aiBottomLeft, - aiLeft - }; - + enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: QColor mColor, mSelectedColor; QPen mPen, mSelectedPen; @@ -6585,13 +6358,13 @@ protected: Qt::Alignment mTextAlignment; double mRotation; QMargins mPadding; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual QPointF anchorPixelPosition( int anchorId ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE; + // non-virtual methods: - QPointF getTextDrawPoint( const QPointF& pos, const QRectF& rect, Qt::Alignment positionAlignment ) const; + QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const; QFont mainFont() const; QColor mainColor() const; QPen mainPen() const; @@ -6600,6 +6373,7 @@ protected: /* end of 'src/items/item-text.h' */ + /* including file 'src/items/item-ellipse.h', size 3868 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6607,64 +6381,53 @@ class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) /// \endcond public: - explicit QCPItemEllipse( QCustomPlot* parentPlot ); + explicit QCPItemEllipse(QCustomPlot *parentPlot); virtual ~QCPItemEllipse(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } QBrush brush() const { return mBrush; } QBrush selectedBrush() const { return mSelectedBrush; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setSelectedBrush( const QBrush& brush ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const topLeft; - QCPItemPosition* const bottomRight; - QCPItemAnchor* const topLeftRim; - QCPItemAnchor* const top; - QCPItemAnchor* const topRightRim; - QCPItemAnchor* const right; - QCPItemAnchor* const bottomRightRim; - QCPItemAnchor* const bottom; - QCPItemAnchor* const bottomLeftRim; - QCPItemAnchor* const left; - QCPItemAnchor* const center; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const topLeftRim; + QCPItemAnchor * const top; + QCPItemAnchor * const topRightRim; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRightRim; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeftRim; + QCPItemAnchor * const left; + QCPItemAnchor * const center; + protected: - enum AnchorIndex - { - aiTopLeftRim, - aiTop, - aiTopRightRim, - aiRight, - aiBottomRightRim, - aiBottom, - aiBottomLeftRim, - aiLeft, - aiCenter - }; - + enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter}; + // property members: QPen mPen, mSelectedPen; QBrush mBrush, mSelectedBrush; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual QPointF anchorPixelPosition( int anchorId ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE; + // non-virtual methods: QPen mainPen() const; QBrush mainBrush() const; @@ -6672,6 +6435,7 @@ protected: /* end of 'src/items/item-ellipse.h' */ + /* including file 'src/items/item-pixmap.h', size 4373 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6679,17 +6443,17 @@ class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap ) - Q_PROPERTY( bool scaled READ scaled WRITE setScaled ) - Q_PROPERTY( Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode ) - Q_PROPERTY( Qt::TransformationMode transformationMode READ transformationMode ) - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) + Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) + Q_PROPERTY(bool scaled READ scaled WRITE setScaled) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode) + Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) /// \endcond public: - explicit QCPItemPixmap( QCustomPlot* parentPlot ); + explicit QCPItemPixmap(QCustomPlot *parentPlot); virtual ~QCPItemPixmap(); - + // getters: QPixmap pixmap() const { return mPixmap; } bool scaled() const { return mScaled; } @@ -6697,36 +6461,28 @@ public: Qt::TransformationMode transformationMode() const { return mTransformationMode; } QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } - + // setters; - void setPixmap( const QPixmap& pixmap ); - void setScaled( bool scaled, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio, Qt::TransformationMode transformationMode = Qt::SmoothTransformation ); - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - + void setPixmap(const QPixmap &pixmap); + void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const topLeft; - QCPItemPosition* const bottomRight; - QCPItemAnchor* const top; - QCPItemAnchor* const topRight; - QCPItemAnchor* const right; - QCPItemAnchor* const bottom; - QCPItemAnchor* const bottomLeft; - QCPItemAnchor* const left; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + protected: - enum AnchorIndex - { - aiTop, - aiTopRight, - aiRight, - aiBottom, - aiBottomLeft, - aiLeft - }; - + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + // property members: QPixmap mPixmap; QPixmap mScaledPixmap; @@ -6735,19 +6491,20 @@ protected: Qt::AspectRatioMode mAspectRatioMode; Qt::TransformationMode mTransformationMode; QPen mPen, mSelectedPen; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual QPointF anchorPixelPosition( int anchorId ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE; + // non-virtual methods: - void updateScaledPixmap( QRect finalRect = QRect(), bool flipHorz = false, bool flipVert = false ); - QRect getFinalRect( bool* flippedHorz = 0, bool* flippedVert = 0 ) const; + void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false); + QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const; QPen mainPen() const; }; /* end of 'src/items/item-pixmap.h' */ + /* including file 'src/items/item-tracer.h', size 4762 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6755,15 +6512,15 @@ class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( QBrush brush READ brush WRITE setBrush ) - Q_PROPERTY( QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush ) - Q_PROPERTY( double size READ size WRITE setSize ) - Q_PROPERTY( TracerStyle style READ style WRITE setStyle ) - Q_PROPERTY( QCPGraph* graph READ graph WRITE setGraph ) - Q_PROPERTY( double graphKey READ graphKey WRITE setGraphKey ) - Q_PROPERTY( bool interpolating READ interpolating WRITE setInterpolating ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(double size READ size WRITE setSize) + Q_PROPERTY(TracerStyle style READ style WRITE setStyle) + Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph) + Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey) + Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating) /// \endcond public: /*! @@ -6771,21 +6528,15 @@ public: \see setStyle */ - enum TracerStyle - { - tsNone ///< The tracer is not visible - , - tsPlus ///< A plus shaped crosshair with limited size - , - tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect - , - tsCircle ///< A circle - , - tsSquare ///< A square - }; - Q_ENUMS( TracerStyle ) + enum TracerStyle { tsNone ///< The tracer is not visible + ,tsPlus ///< A plus shaped crosshair with limited size + ,tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect + ,tsCircle ///< A circle + ,tsSquare ///< A square + }; + Q_ENUMS(TracerStyle) - explicit QCPItemTracer( QCustomPlot* parentPlot ); + explicit QCPItemTracer(QCustomPlot *parentPlot); virtual ~QCPItemTracer(); // getters: @@ -6795,28 +6546,28 @@ public: QBrush selectedBrush() const { return mSelectedBrush; } double size() const { return mSize; } TracerStyle style() const { return mStyle; } - QCPGraph* graph() const { return mGraph; } + QCPGraph *graph() const { return mGraph; } double graphKey() const { return mGraphKey; } bool interpolating() const { return mInterpolating; } // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setBrush( const QBrush& brush ); - void setSelectedBrush( const QBrush& brush ); - void setSize( double size ); - void setStyle( TracerStyle style ); - void setGraph( QCPGraph* graph ); - void setGraphKey( double key ); - void setInterpolating( bool enabled ); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setSize(double size); + void setStyle(TracerStyle style); + void setGraph(QCPGraph *graph); + void setGraphKey(double key); + void setInterpolating(bool enabled); // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + // non-virtual methods: void updatePosition(); - QCPItemPosition* const position; + QCPItemPosition * const position; protected: // property members: @@ -6824,21 +6575,22 @@ protected: QBrush mBrush, mSelectedBrush; double mSize; TracerStyle mStyle; - QCPGraph* mGraph; + QCPGraph *mGraph; double mGraphKey; bool mInterpolating; // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; // non-virtual methods: QPen mainPen() const; QBrush mainBrush() const; }; -Q_DECLARE_METATYPE( QCPItemTracer::TracerStyle ) +Q_DECLARE_METATYPE(QCPItemTracer::TracerStyle) /* end of 'src/items/item-tracer.h' */ + /* including file 'src/items/item-bracket.h', size 3969 */ /* commit 9868e55d3b412f2f89766bb482fcf299e93a0988 2017-09-04 01:56:22 +0200 */ @@ -6846,10 +6598,10 @@ class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem { Q_OBJECT /// \cond INCLUDE_QPROPERTIES - Q_PROPERTY( QPen pen READ pen WRITE setPen ) - Q_PROPERTY( QPen selectedPen READ selectedPen WRITE setSelectedPen ) - Q_PROPERTY( double length READ length WRITE setLength ) - Q_PROPERTY( BracketStyle style READ style WRITE setStyle ) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(double length READ length WRITE setLength) + Q_PROPERTY(BracketStyle style READ style WRITE setStyle) /// \endcond public: /*! @@ -6858,59 +6610,53 @@ public: \see setStyle */ - enum BracketStyle - { - bsSquare ///< A brace with angled edges - , - bsRound ///< A brace with round edges - , - bsCurly ///< A curly brace - , - bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression + enum BracketStyle { bsSquare ///< A brace with angled edges + ,bsRound ///< A brace with round edges + ,bsCurly ///< A curly brace + ,bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression }; - Q_ENUMS( BracketStyle ) + Q_ENUMS(BracketStyle) - explicit QCPItemBracket( QCustomPlot* parentPlot ); + explicit QCPItemBracket(QCustomPlot *parentPlot); virtual ~QCPItemBracket(); - + // getters: QPen pen() const { return mPen; } QPen selectedPen() const { return mSelectedPen; } double length() const { return mLength; } BracketStyle style() const { return mStyle; } - + // setters; - void setPen( const QPen& pen ); - void setSelectedPen( const QPen& pen ); - void setLength( double length ); - void setStyle( BracketStyle style ); - + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setLength(double length); + void setStyle(BracketStyle style); + // reimplemented virtual methods: - virtual double selectTest( const QPointF& pos, bool onlySelectable, QVariant* details = 0 ) const Q_DECL_OVERRIDE; - - QCPItemPosition* const left; - QCPItemPosition* const right; - QCPItemAnchor* const center; - + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE; + + QCPItemPosition * const left; + QCPItemPosition * const right; + QCPItemAnchor * const center; + protected: // property members: - enum AnchorIndex - { - aiCenter - }; + enum AnchorIndex {aiCenter}; QPen mPen, mSelectedPen; double mLength; BracketStyle mStyle; - + // reimplemented virtual methods: - virtual void draw( QCPPainter* painter ) Q_DECL_OVERRIDE; - virtual QPointF anchorPixelPosition( int anchorId ) const Q_DECL_OVERRIDE; - + virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE; + virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE; + // non-virtual methods: QPen mainPen() const; }; -Q_DECLARE_METATYPE( QCPItemBracket::BracketStyle ) +Q_DECLARE_METATYPE(QCPItemBracket::BracketStyle) /* end of 'src/items/item-bracket.h' */ -#endif // QCUSTOMPLOT_H + +#endif // QCUSTOMPLOT_H + diff --git a/app/main.cpp b/app/main.cpp index 219ed92..6bd4fdd 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -22,13 +22,13 @@ * \brief main file */ +#include "CommonDefs.h" #include "ConfigureFormatDialog.h" -#include "PlaYUVerApp.h" -#include "PlaYUVerAppDefs.h" +#include "MainWindow.h" #include "VideoSubWindow.h" #include "config.h" #ifdef USE_QTDBUS -#include "PlaYUVerAppAdaptor.h" +#include "DBusAppAdaptor.h" #endif #include #ifdef USE_FERVOR @@ -41,26 +41,26 @@ int main( int argc, char* argv[] ) { - qRegisterMetaType(); - qRegisterMetaTypeStreamOperators(); - qRegisterMetaType(); - qRegisterMetaTypeStreamOperators(); + qRegisterMetaType(); + qRegisterMetaTypeStreamOperators(); + qRegisterMetaType(); + qRegisterMetaTypeStreamOperators(); QApplication application( argc, argv ); - QApplication::setApplicationName( "PlaYUVer" ); - QApplication::setApplicationVersion( PLAYUVER_VERSION_STRING ); + QApplication::setApplicationName( "Calyp" ); + QApplication::setApplicationVersion( CALYP_VERSION_STRING ); QApplication::setOrganizationName( "PixLRA" ); #ifdef USE_QTDBUS /** * use dbus, if available - * allows for resuse of running Kate instances + * allows for resuse of running Calyp instances */ - if( QDBusConnectionInterface* const sessionBusInterface = QDBusConnection::sessionBus().interface() ) + if( QDBusConnectionInterface* const sessionBusinterface = QDBusConnection::sessionBus().interface() ) { - Bool force_new = false; + bool force_new = false; QStringList filenameList; - for( Int i = 1; i < argc; i++ ) + for( int i = 1; i < argc; i++ ) { filenameList.append( QFileInfo( QString( argv[i] ) ).absoluteFilePath() ); } @@ -73,7 +73,7 @@ int main( int argc, char* argv[] ) bool foundRunningService = false; if( !force_new ) { - QDBusReply there = sessionBusInterface->isServiceRegistered( PLAYUVER_DBUS_SESSION_NAME ); + QDBusReply there = sessionBusinterface->isServiceRegistered( CALYP_DBUS_SESSION_NAME ); foundRunningService = there.isValid() && there.value(); if( foundRunningService ) @@ -82,8 +82,8 @@ int main( int argc, char* argv[] ) // open given session QDBusMessage m = QDBusMessage::createMethodCall( - PLAYUVER_DBUS_SESSION_NAME, QStringLiteral( PLAYUVER_DBUS_PATH ), - QStringLiteral( PLAYUVER_DBUS_SESSION_NAME ), QStringLiteral( "activate" ) ); + CALYP_DBUS_SESSION_NAME, QStringLiteral( CALYP_DBUS_PATH ), + QStringLiteral( CALYP_DBUS_SESSION_NAME ), QStringLiteral( "activate" ) ); QDBusConnection::sessionBus().call( m ); @@ -96,8 +96,8 @@ int main( int argc, char* argv[] ) foreach( const QString& file, filenameList ) { QDBusMessage m = QDBusMessage::createMethodCall( - PLAYUVER_DBUS_SESSION_NAME, QStringLiteral( PLAYUVER_DBUS_PATH ), - QStringLiteral( PLAYUVER_DBUS_SESSION_NAME ), QStringLiteral( "loadFile" ) ); + CALYP_DBUS_SESSION_NAME, QStringLiteral( CALYP_DBUS_PATH ), + QStringLiteral( CALYP_DBUS_SESSION_NAME ), QStringLiteral( "loadFile" ) ); QList dbusargs; dbusargs.append( file ); @@ -128,11 +128,11 @@ int main( int argc, char* argv[] ) } /** - * if we arrive here, we need to start a new playuver instance! + * if we arrive here, we need to start a new calyp instance! */ - QDBusConnection::sessionBus().registerService( PLAYUVER_DBUS_SESSION_NAME ); + QDBusConnection::sessionBus().registerService( CALYP_DBUS_SESSION_NAME ); #endif - PlaYUVerApp mainwindow; + MainWindow mainwindow; mainwindow.show(); if( mainwindow.parseArgs( argc, argv ) ) { @@ -140,8 +140,8 @@ int main( int argc, char* argv[] ) } #ifdef USE_FERVOR - FvUpdater::sharedUpdater()->SetFeedURL( "http://192.168.96.201/share/PlaYUVerProject/" - "PlaYUVerUpdate-" UPDATE_CHANNEL ".xml" ); + FvUpdater::sharedUpdater()->SetFeedURL( "http://192.168.96.201/share/CalypProject/" + "CalypUpdate-" UPDATE_CHANNEL ".xml" ); FvUpdater::sharedUpdater()->SetDependencies( "ALL" ); #endif diff --git a/app/resources/calyp-logo.png b/app/resources/calyp-logo.png new file mode 100644 index 0000000..dd05916 Binary files /dev/null and b/app/resources/calyp-logo.png differ diff --git a/app/resources/playuver.desktop b/app/resources/calyp.desktop similarity index 85% rename from app/resources/playuver.desktop rename to app/resources/calyp.desktop index 7d52b74..567424b 100755 --- a/app/resources/playuver.desktop +++ b/app/resources/calyp.desktop @@ -1,9 +1,9 @@ #!/usr/bin/env xdg-open [Desktop Entry] Type=Application -Name=PlaYUVer -Exec=playuver %U -Icon=playuver +Name=Calyp +Exec=calyp %U +Icon=calyp Terminal=false MimeType=video/x-raw;image/jpeg;image/png;image/bmp;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap Categories=AudioVideo;Video;Player; diff --git a/app/resources/calyp.ico b/app/resources/calyp.ico new file mode 100644 index 0000000..bafe0a0 Binary files /dev/null and b/app/resources/calyp.ico differ diff --git a/app/resources/calyp.png b/app/resources/calyp.png new file mode 100644 index 0000000..41e9731 Binary files /dev/null and b/app/resources/calyp.png differ diff --git a/app/resources/playuver.qrc b/app/resources/calyp.qrc similarity index 90% rename from app/resources/playuver.qrc rename to app/resources/calyp.qrc index e624c9d..3039570 100755 --- a/app/resources/playuver.qrc +++ b/app/resources/calyp.qrc @@ -1,22 +1,22 @@ - playuver.png - playuver-background-logo.png + calyp-logo.png + calyp.png icons/open.png icons/save.png icons/close.png icons/exit.png icons/configuredialog.png - + icons/windowstile.png icons/windowscascade.png - + icons/zoomin.png icons/zoomout.png icons/zoomtonormal.png icons/fittowindow.png - + icons/histogram-log.png icons/histogram-lin.png icons/image-selection.png @@ -27,7 +27,7 @@ icons/channel-green-16.png icons/channel-blue-16.png icons/channel-all-16.png - + icons/copy.png icons/paste.png icons/saveas.png diff --git a/app/resources/calyp.rc b/app/resources/calyp.rc new file mode 100755 index 0000000..07f126f --- /dev/null +++ b/app/resources/calyp.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "calyp.ico" diff --git a/app/resources/playuver.xml b/app/resources/calyp.xml similarity index 100% rename from app/resources/playuver.xml rename to app/resources/calyp.xml diff --git a/app/resources/playuver-background-logo.png b/app/resources/playuver-background-logo.png deleted file mode 100644 index 6792338..0000000 Binary files a/app/resources/playuver-background-logo.png and /dev/null differ diff --git a/app/resources/playuver.ico b/app/resources/playuver.ico deleted file mode 100644 index fdff297..0000000 Binary files a/app/resources/playuver.ico and /dev/null differ diff --git a/app/resources/playuver.png b/app/resources/playuver.png deleted file mode 100755 index ad3794b..0000000 Binary files a/app/resources/playuver.png and /dev/null differ diff --git a/app/resources/playuver.rc b/app/resources/playuver.rc deleted file mode 100755 index 23ff060..0000000 --- a/app/resources/playuver.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "playuver.ico" \ No newline at end of file diff --git a/app/WidgetFrameNumber.cpp b/app/widgets/FrameNumberWidget.cpp similarity index 88% rename from app/WidgetFrameNumber.cpp rename to app/widgets/FrameNumberWidget.cpp index 509a4cf..cab8398 100644 --- a/app/WidgetFrameNumber.cpp +++ b/app/widgets/FrameNumberWidget.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -22,13 +22,13 @@ * \brief Frame number widget */ -#include "WidgetFrameNumber.h" +#include "FrameNumberWidget.h" #include #include #include -WidgetFrameNumber::WidgetFrameNumber( QWidget* parent ) +FrameNumberWidget::FrameNumberWidget( QWidget* parent ) : QWidget( parent ) { QHBoxLayout* mainlayout = new QHBoxLayout; @@ -49,15 +49,15 @@ WidgetFrameNumber::WidgetFrameNumber( QWidget* parent ) mainlayout->addWidget( m_pcTotalFrameNumLabel ); setLayout( mainlayout ); } -Void WidgetFrameNumber::setCurrFrameNum( Int number ) +void FrameNumberWidget::setCurrFrameNum( int number ) { m_pcCurrFrameNumLabel->setText( QString( tr( "%1" ) ).arg( number ) ); } -Void WidgetFrameNumber::setTotalFrameNum( Int number ) +void FrameNumberWidget::setTotalFrameNum( int number ) { m_pcTotalFrameNumLabel->setText( QString( tr( "%1" ) ).arg( number ) ); } -Void WidgetFrameNumber::clear() +void FrameNumberWidget::clear() { m_pcCurrFrameNumLabel->setText( "-" ); m_pcTotalFrameNumLabel->setText( "-" ); diff --git a/app/WidgetFrameNumber.h b/app/widgets/FrameNumberWidget.h similarity index 82% rename from app/WidgetFrameNumber.h rename to app/widgets/FrameNumberWidget.h index 3f4be08..afcea68 100644 --- a/app/WidgetFrameNumber.h +++ b/app/widgets/FrameNumberWidget.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,20 +25,20 @@ #ifndef __WIDGETFRAMENUMBER_H__ #define __WIDGETFRAMENUMBER_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" #include class QLabel; -class WidgetFrameNumber : public QWidget +class FrameNumberWidget : public QWidget { public: - WidgetFrameNumber( QWidget* parent = 0 ); - Void setCurrFrameNum( Int number ); - Void setTotalFrameNum( Int number ); - Void clear(); + FrameNumberWidget( QWidget* parent = 0 ); + void setCurrFrameNum( int number ); + void setTotalFrameNum( int number ); + void clear(); private: QLabel* m_pcCurrFrameNumLabel; diff --git a/app/HistogramWidget.cpp b/app/widgets/HistogramWidget.cpp similarity index 90% rename from app/HistogramWidget.cpp rename to app/widgets/HistogramWidget.cpp index b8c46e3..2fa4276 100644 --- a/app/HistogramWidget.cpp +++ b/app/widgets/HistogramWidget.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -41,7 +41,7 @@ class HistogramWorker : public QThread { private: QObject* m_parent; - PlaYUVerFrame* m_pcFrame; + CalypFrame* m_pcFrame; public: HistogramWorker( QObject* parent ) @@ -50,13 +50,13 @@ public: m_parent = parent; } - Void setup( PlaYUVerFrame* frame ) + void setup( CalypFrame* frame ) { m_pcFrame = frame; // run(); start(); } - Void run() + void run() { if( m_pcFrame && m_parent ) { @@ -94,7 +94,7 @@ public: bool starting; bool success; - PlaYUVerFrame* frame; + CalypFrame* frame; }; }; @@ -142,13 +142,13 @@ public: double xmin; double xminOrg; double xmax; - Int range; - Int clearFlag; // Clear drawing zone with message. + int range; + int clearFlag; // Clear drawing zone with message. // Image informations - Int imageChannels; - Int imageColorSpace; - Int imageBits; + int imageChannels; + int imageColorSpace; + int imageBits; bool guideVisible; // Display color guide. bool statisticsVisible; // Display tooltip histogram statistics. @@ -173,14 +173,14 @@ public: //////////////////////////////////////////////////////////////////////////////// // Constructor without image data -HistogramWidget::HistogramWidget( Int width, Int height, QWidget* parent ) +HistogramWidget::HistogramWidget( int width, int height, QWidget* parent ) : QWidget( parent ) { setAttribute( Qt::WA_DeleteOnClose ); d = new HistogramWidgetPrivate; - m_channelType = PlaYUVerFrame::HIST_LUMA; + m_channelType = CalypFrame::HIST_LUMA; m_scaleType = LogScaleHistogram; m_colorType = -1; m_renderingType = FullImageHistogram; @@ -219,7 +219,7 @@ HistogramWidget::~HistogramWidget() // Setup Functions //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::setOptions( HistogramOptions options ) +void HistogramWidget::setOptions( HistogramOptions options ) { d->statisticsVisible = (bool)( options & ShowStatistics ); d->selectMode = (bool)( options & SelectMode ); @@ -227,14 +227,14 @@ Void HistogramWidget::setOptions( HistogramOptions options ) d->lumaChannel = (bool)( options & ShowLumaChannel ); } -Void HistogramWidget::setHistogramGuideByColor( QColor color ) +void HistogramWidget::setHistogramGuideByColor( QColor color ) { d->guideVisible = true; d->colorGuide = color; update(); } -Void HistogramWidget::reset() +void HistogramWidget::reset() { d->guideVisible = false; d->clearFlag = HistogramWidgetPrivate::HistogramNone; @@ -248,7 +248,7 @@ Void HistogramWidget::reset() // Custom Event Handler //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::customEvent( QEvent* event ) +void HistogramWidget::customEvent( QEvent* event ) { if( !event ) { @@ -300,7 +300,7 @@ Void HistogramWidget::customEvent( QEvent* event ) unsetCursor(); // Send signals to refresh information if necessary. - // The signals may trigger multiple repaints, aVoid this, + // The signals may trigger multiple repaints, avoid this, // we repaint once afterwards. setUpdatesEnabled( false ); @@ -330,7 +330,7 @@ Void HistogramWidget::customEvent( QEvent* event ) // Data Loading Functions //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::setDataLoading() +void HistogramWidget::setDataLoading() { if( d->clearFlag != HistogramWidgetPrivate::HistogramDataLoading ) { @@ -344,7 +344,7 @@ Void HistogramWidget::setDataLoading() } } -Void HistogramWidget::setLoadingSkipped() +void HistogramWidget::setLoadingSkipped() { d->clearFlag = HistogramWidgetPrivate::HistogramSkipped; d->blinkTimer->stop(); @@ -353,7 +353,7 @@ Void HistogramWidget::setLoadingSkipped() unsetCursor(); } -Void HistogramWidget::setLoadingFailed() +void HistogramWidget::setLoadingFailed() { d->clearFlag = HistogramWidgetPrivate::HistogramFailed; d->blinkTimer->stop(); @@ -364,7 +364,7 @@ Void HistogramWidget::setLoadingFailed() //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::stopHistogramComputation() +void HistogramWidget::stopHistogramComputation() { // if( m_imageHistogram ) // m_imageHistogram->setRunningFlag( false ); @@ -379,17 +379,17 @@ Void HistogramWidget::stopHistogramComputation() // Update Data Methods //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrameSelection ) +void HistogramWidget::updateData( CalypFrame* pcFrame, CalypFrame* pcFrameSelection ) { d->imageBits = pcFrame->getBitsPel(); switch( pcFrame->getColorSpace() ) { - case PlaYUVerPixel::COLOR_YUV: - case PlaYUVerPixel::COLOR_GRAY: + case CLP_COLOR_YUV: + case CLP_COLOR_GRAY: d->imageColorSpace = 0; break; - case PlaYUVerPixel::COLOR_RGB: - case PlaYUVerPixel::COLOR_RGBA: + case CLP_COLOR_RGB: + case CLP_COLOR_RGBA: d->imageColorSpace = 0; break; default: @@ -401,7 +401,7 @@ Void HistogramWidget::updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrame // so we must not use it to draw any more. d->clearFlag = HistogramWidgetPrivate::HistogramNone; - // Do not using PlaYUVerFrameStatistics::getHistogramSegment() + // Do not using CalypFrameStatistics::getHistogramSegment() // method here because histogram hasn't yet been computed. d->range = ( 1 << d->imageBits ) - 1; @@ -416,7 +416,7 @@ Void HistogramWidget::updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrame //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::slotBlinkTimerDone() +void HistogramWidget::slotBlinkTimerDone() { d->blinkFlag = !d->blinkFlag; d->inInitialRepaintWait = false; @@ -428,7 +428,7 @@ Void HistogramWidget::slotBlinkTimerDone() // Paint Event //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::paintEvent( QPaintEvent* ) +void HistogramWidget::paintEvent( QPaintEvent* ) { int maxX = size().width() - 1; int maxY = size().height() - 1; @@ -497,7 +497,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) int wWidth = width() - 1; int wHeight = height() - 1; double max; - PlaYUVerFrame* frame; + CalypFrame* frame; if( m_renderingType == ImageSelectionHistogram && m_selectionImage ) frame = m_selectionImage; @@ -530,9 +530,9 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // From Qt 4.0, QWidget automatically double-buffers its painting, // so there's no need to write double-buffering code in paintEvent() - // to aVoid flicker. + // to avoid flicker. QPainter p1( this ); - Int pallet = d->imageColorSpace; + int pallet = d->imageColorSpace; // Drawing selection or all histogram values. @@ -555,11 +555,11 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) vg = 0.0; vb = 0.0; - if( m_channelType == PlaYUVerFrame::HIST_ALL_CHANNELS ) + if( m_channelType == CalypFrame::HIST_ALL_CHANNELS ) { - vr = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_ONE, i ); - vg = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_TWO, i ); - vb = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_THREE, i ); + vr = frame->getHistogramValue( CalypFrame::HIST_CHAN_ONE, i ); + vg = frame->getHistogramValue( CalypFrame::HIST_CHAN_TWO, i ); + vb = frame->getHistogramValue( CalypFrame::HIST_CHAN_THREE, i ); if( vr > value_r ) value_r = vr; @@ -577,7 +577,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) i++; } while( i < j ); - if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS ) + if( m_channelType != CalypFrame::HIST_ALL_CHANNELS ) { switch( m_scaleType ) { @@ -628,7 +628,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // Drawing the histogram + selection or only the histogram. - if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS ) + if( m_channelType != CalypFrame::HIST_ALL_CHANNELS ) { if( d->selectMode == true ) // Selection mode enable ? { @@ -681,18 +681,18 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // colors channel mode? switch( m_colorType ) { - case PlaYUVerFrame::HIST_LUMA: - case PlaYUVerFrame::HIST_COLOR_R: + case CalypFrame::HIST_LUMA: + case CalypFrame::HIST_COLOR_R: p1.drawLine( x, wHeight, x, wHeight - yr ); break; - case PlaYUVerFrame::HIST_CHROMA_U: - case PlaYUVerFrame::HIST_COLOR_G: + case CalypFrame::HIST_CHROMA_U: + case CalypFrame::HIST_COLOR_G: p1.drawLine( x, wHeight, x, wHeight - yg ); break; - case PlaYUVerFrame::HIST_CHROMA_V: - case PlaYUVerFrame::HIST_COLOR_B: + case CalypFrame::HIST_CHROMA_V: + case CalypFrame::HIST_COLOR_B: p1.drawLine( x, wHeight, x, wHeight - yb ); break; @@ -706,8 +706,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // colors channel mode? switch( m_colorType ) { - case PlaYUVerFrame::HIST_LUMA: - case PlaYUVerFrame::HIST_COLOR_R: + case CalypFrame::HIST_LUMA: + case CalypFrame::HIST_COLOR_R: p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yg ); p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) ); @@ -724,8 +724,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) break; - case PlaYUVerFrame::HIST_CHROMA_U: - case PlaYUVerFrame::HIST_COLOR_G: + case CalypFrame::HIST_CHROMA_U: + case CalypFrame::HIST_COLOR_G: p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yb ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) ); @@ -741,8 +741,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg ); break; - case PlaYUVerFrame::HIST_CHROMA_V: - case PlaYUVerFrame::HIST_COLOR_B: + case CalypFrame::HIST_CHROMA_V: + case CalypFrame::HIST_COLOR_B: p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yr ); p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) ); @@ -775,8 +775,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // colors channel mode? switch( m_colorType ) { - case PlaYUVerFrame::HIST_LUMA: - case PlaYUVerFrame::HIST_COLOR_R: + case CalypFrame::HIST_LUMA: + case CalypFrame::HIST_COLOR_R: p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yg ); @@ -796,8 +796,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) break; - case PlaYUVerFrame::HIST_CHROMA_U: - case PlaYUVerFrame::HIST_COLOR_G: + case CalypFrame::HIST_CHROMA_U: + case CalypFrame::HIST_COLOR_G: p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yb ); @@ -817,8 +817,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) break; - case PlaYUVerFrame::HIST_CHROMA_V: - case PlaYUVerFrame::HIST_COLOR_B: + case CalypFrame::HIST_CHROMA_V: + case CalypFrame::HIST_COLOR_B: p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) ); p1.drawLine( x, wHeight, x, wHeight - yr ); @@ -859,21 +859,21 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) { switch( m_channelType ) { - case PlaYUVerFrame::HIST_CHROMA_V: - case PlaYUVerFrame::HIST_COLOR_R: + case CalypFrame::HIST_CHROMA_V: + case CalypFrame::HIST_COLOR_R: guidePos = d->colorGuide.red(); break; - case PlaYUVerFrame::HIST_COLOR_G: + case CalypFrame::HIST_COLOR_G: guidePos = d->colorGuide.green(); break; - case PlaYUVerFrame::HIST_CHROMA_U: - case PlaYUVerFrame::HIST_COLOR_B: + case CalypFrame::HIST_CHROMA_U: + case CalypFrame::HIST_COLOR_B: guidePos = d->colorGuide.blue(); break; - case PlaYUVerFrame::HIST_LUMA: + case CalypFrame::HIST_LUMA: guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() ); break; @@ -961,7 +961,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* ) // Mouse Events //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::mousePressEvent( QMouseEvent* e ) +void HistogramWidget::mousePressEvent( QMouseEvent* e ) { if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted ) { @@ -979,7 +979,7 @@ Void HistogramWidget::mousePressEvent( QMouseEvent* e ) } } -Void HistogramWidget::mouseReleaseEvent( QMouseEvent* ) +void HistogramWidget::mouseReleaseEvent( QMouseEvent* ) { if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted ) @@ -997,7 +997,7 @@ Void HistogramWidget::mouseReleaseEvent( QMouseEvent* ) } } -Void HistogramWidget::mouseMoveEvent( QMouseEvent* e ) +void HistogramWidget::mouseMoveEvent( QMouseEvent* e ) { if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted ) { @@ -1032,12 +1032,12 @@ Void HistogramWidget::mouseMoveEvent( QMouseEvent* e ) //////////////////////////////////////////////////////////////////////////////// -Void HistogramWidget::notifyValuesChanged() +void HistogramWidget::notifyValuesChanged() { - emit signalIntervalChanged( (int)( d->xmin * d->range ), d->xmax == 0.0 ? d->range : (int)( d->xmax * d->range ) ); + emit signalintervalChanged( (int)( d->xmin * d->range ), d->xmax == 0.0 ? d->range : (int)( d->xmax * d->range ) ); } -Void HistogramWidget::slotMinValueChanged( int min ) +void HistogramWidget::slotMinValueChanged( int min ) { if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted ) { @@ -1055,7 +1055,7 @@ Void HistogramWidget::slotMinValueChanged( int min ) } } -Void HistogramWidget::slotMaxValueChanged( int max ) +void HistogramWidget::slotMaxValueChanged( int max ) { if( d->selectMode == true && d->clearFlag == HistogramWidgetPrivate::HistogramCompleted ) { diff --git a/app/HistogramWidget.h b/app/widgets/HistogramWidget.h similarity index 76% rename from app/HistogramWidget.h rename to app/widgets/HistogramWidget.h index dcf79cf..6ac40a5 100644 --- a/app/HistogramWidget.h +++ b/app/widgets/HistogramWidget.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -26,9 +26,9 @@ #ifndef __HISTOGRAMWIDGET_H__ #define __HISTOGRAMWIDGET_H__ -#include "PlaYUVerAppDefs.h" +#include "CommonDefs.h" #include "config.h" -#include "lib/PlaYUVerFrame.h" +#include "lib/CalypFrame.h" #include #include @@ -82,46 +82,46 @@ public: * @param height of the widget * @param parent the histogram widget parent */ - HistogramWidget( Int width, Int height, QWidget* parent = 0 ); + HistogramWidget( int width, int height, QWidget* parent = 0 ); ~HistogramWidget(); /** Stop current histogram computations.*/ - Void stopHistogramComputation(); + void stopHistogramComputation(); /** Update full image histogram data. */ - Void updateData( PlaYUVerFrame* pcFrame, PlaYUVerFrame* pcFrameSelection ); + void updateData( CalypFrame* pcFrame, CalypFrame* pcFrameSelection ); /** @see @p HistogramOption */ - Void setOptions( HistogramOptions options = AllOptions ); - Void setDataLoading(); - Void setLoadingSkipped(); - Void setLoadingFailed(); - Void setHistogramGuideByColor( QColor color ); + void setOptions( HistogramOptions options = AllOptions ); + void setDataLoading(); + void setLoadingSkipped(); + void setLoadingFailed(); + void setHistogramGuideByColor( QColor color ); - Void reset(); + void reset(); public: /** Channel type to draw */ - Int m_channelType; + int m_channelType; /** Scale to use for drawing */ - Int m_scaleType; + int m_scaleType; /** Color to use for drawing in All Colors Channel mode */ - Int m_colorType; + int m_colorType; /** Using full image or image selection for histogram rendering */ - Int m_renderingType; + int m_renderingType; /** Full image */ HistogramWorker* m_imageWorker; - // PlaYUVerFrameStats* m_imageHistogram; - PlaYUVerFrame* m_fullImage; + // CalypFrameStats* m_imageHistogram; + CalypFrame* m_fullImage; /** Histogram area selection */ HistogramWorker* m_selectionWorker; - // PlaYUVerFrameStats* m_selectionHistogram; - PlaYUVerFrame* m_selectionImage; + // CalypFrameStats* m_selectionHistogram; + CalypFrame* m_selectionImage; Q_SIGNALS: - void signalIntervalChanged( int min, int max ); + void signalintervalChanged( int min, int max ); void signalMaximumValueChanged( int ); void signalHistogramComputationDone( int ); void signalHistogramComputationFailed( void ); @@ -134,14 +134,14 @@ protected slots: void slotBlinkTimerDone( void ); protected: - Void paintEvent( QPaintEvent* ); - Void mousePressEvent( QMouseEvent* e ); - Void mouseReleaseEvent( QMouseEvent* e ); - Void mouseMoveEvent( QMouseEvent* e ); + void paintEvent( QPaintEvent* ); + void mousePressEvent( QMouseEvent* e ); + void mouseReleaseEvent( QMouseEvent* e ); + void mouseMoveEvent( QMouseEvent* e ); private: - Void customEvent( QEvent* event ); - Void notifyValuesChanged(); + void customEvent( QEvent* event ); + void notifyValuesChanged(); private: HistogramWidgetPrivate* d; diff --git a/cmake/ModulesFct.cmake b/cmake/ModulesFct.cmake index 5dd24a8..bcf175d 100644 --- a/cmake/ModulesFct.cmake +++ b/cmake/ModulesFct.cmake @@ -5,7 +5,7 @@ MACRO(ADD_MODULE name file ) OPTION(MODULE_${name} "Use module ${name}" ON ) ADD_FEATURE_INFO(${name} MODULE_${name} "Module ${name}" ) if( MODULE_${name} ) - list(APPEND plaYUver_Mod_SRCS ${file} ) + list(APPEND Calyp_Mod_SRCS ${file} ) LIST(APPEND MODULES_LIST_NAME ${name} ) LIST(APPEND MODULES_LIST_FILES ${file} ) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#include \"${file}.h\"\n") diff --git a/config.h.in b/config.h.in index 32b23d0..911ff59 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -17,21 +17,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - /** +/** * \file config.h.in * \brief definition of the building options */ - -#ifndef __CONFIG_PLAYUVER_H__ -#define __CONFIG_PLAYUVER_H__ +#ifndef __CONFIG_CALYP_H__ +#define __CONFIG_CALYP_H__ /* Version definition */ -#define PLAYUVER_VERSION_MAJOR @PLAYUVER_VERSION_MAJOR@ -#define PLAYUVER_VERSION_MINOR @PLAYUVER_VERSION_MINOR@ -#define PLAYUVER_VERSION_PATCH @PLAYUVER_VERSION_PATCH@ -#define PLAYUVER_VERSION @PLAYUVER_VERSION@ -#define PLAYUVER_VERSION_STRING "@PLAYUVER_VERSION_STRING@" +#define CALYP_VERSION_MAJOR @CALYP_VERSION_MAJOR @ +#define CALYP_VERSION_MINOR @CALYP_VERSION_MINOR @ +#define CALYP_VERSION_PATCH @CALYP_VERSION_PATCH @ +#define CALYP_VERSION @CALYP_VERSION @ +#define CALYP_VERSION_STRING "@CALYP_VERSION_STRING@" #define UPDATE_CHANNEL "@UPDATE_CHANNEL@" @@ -45,7 +44,7 @@ #cmakedefine USE_DYNLOAD /* Use modules in a different thread */ -#cmakedefine PLAYUVER_THREADED_MODULES +#cmakedefine CALYP_THREADED_MODULES /* OpenCV */ #cmakedefine USE_OPENCV @@ -56,5 +55,4 @@ /* Fervor update lib */ #cmakedefine USE_FERVOR - -#endif // __CONFIG_PLAYUVER_H__ +#endif // __CONFIG_CALYP_H__ diff --git a/examples/modules/AbsoluteFrameDifferenceExample.cpp b/examples/modules/AbsoluteFrameDifferenceExample.cpp index 216cafd..002ee52 100644 --- a/examples/modules/AbsoluteFrameDifferenceExample.cpp +++ b/examples/modules/AbsoluteFrameDifferenceExample.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -30,46 +30,46 @@ REGISTER_CLASS_MAKER( AbsoluteFrameDifferenceExample ) AbsoluteFrameDifferenceExample::AbsoluteFrameDifferenceExample() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; // Use API version 2 (recommended). - // See this example for details on the functions prototype - m_iModuleType = FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence. - m_pchModuleCategory = "Measurements"; // Category (sub-menu) - m_pchModuleName = "AbsoluteDifferenceExample"; // Name - m_pchModuleLongName = "Absolute Difference Example"; // Name - m_pchModuleTooltip = "Measure the absolute difference " // Description - "between two images (Y plane), e. g., abs( Y1 - Y2 )"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; // Module requirements (check PlaYUVerModulesIf.h). - // Several requirements should be "or" between each others. + m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended). + // See this example for details on the functions prototype + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence. + m_pchModuleCategory = "Measurements"; // Category (sub-menu) + m_pchModuleName = "AbsoluteDifferenceExample"; // Name + m_pchModuleLongName = "Absolute Difference Example"; // Name + m_pchModuleTooltip = "Measure the absolute difference " // Description + "between two images (Y plane), e. g., abs( Y1 - Y2 )"; + m_uiNumberOfFrames = 2; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; // Module requirements (check CalypModulesIf.h). + // Several requirements should be "or" between each others. m_pcFrameDifference = NULL; } -Bool AbsoluteFrameDifferenceExample::create( std::vector apcFrameList ) +bool AbsoluteFrameDifferenceExample::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) return false; m_pcFrameDifference = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CalypFrame::GRAY ); return true; } -PlaYUVerFrame* AbsoluteFrameDifferenceExample::process( std::vector apcFrameList ) +CalypFrame* AbsoluteFrameDifferenceExample::process( std::vector apcFrameList ) { - PlaYUVerFrame* Input1 = apcFrameList[0]; - PlaYUVerFrame* Input2 = apcFrameList[1]; - Pel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; - Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; - Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; - Int aux_pel_1, aux_pel_2; + CalypFrame* Input1 = apcFrameList[0]; + CalypFrame* Input2 = apcFrameList[1]; + ClpPel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; + ClpPel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; + ClpPel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; + int aux_pel_1, aux_pel_2; - for( UInt y = 0; y < m_pcFrameDifference->getHeight(); y++ ) - for( UInt x = 0; x < m_pcFrameDifference->getWidth(); x++ ) + for( unsigned int y = 0; y < m_pcFrameDifference->getHeight(); y++ ) + for( unsigned int x = 0; x < m_pcFrameDifference->getWidth(); x++ ) { aux_pel_1 = *pInput1PelYUV++; aux_pel_2 = *pInput2PelYUV++; @@ -78,7 +78,7 @@ PlaYUVerFrame* AbsoluteFrameDifferenceExample::process( std::vector -class AbsoluteFrameDifferenceExample : public PlaYUVerModuleIf +class AbsoluteFrameDifferenceExample : public CalypModuleIf { REGISTER_CLASS_FACTORY( AbsoluteFrameDifferenceExample ) - private: - PlaYUVerFrame* m_pcFrameDifference; +private: + CalypFrame* m_pcFrameDifference; - public: +public: AbsoluteFrameDifferenceExample(); virtual ~AbsoluteFrameDifferenceExample() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __ABSOLUTEFRAMEDIFFERENCEEXAMPLE_H__ diff --git a/examples/modules/CMakeLists.txt b/examples/modules/CMakeLists.txt index f3c10b7..4f19c21 100644 --- a/examples/modules/CMakeLists.txt +++ b/examples/modules/CMakeLists.txt @@ -7,13 +7,13 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.8.9 ) PROJECT( "modules_example" ) -# FIND_PACKAGE( PlaYUVer ) +# FIND_PACKAGE( Calyp ) -INCLUDE_DIRECTORIES( ${PLAYUVER_INCLUDE_DIRS} ) +INCLUDE_DIRECTORIES( ${CALYP_INCLUDE_DIRS} ) ADD_LIBRARY(FrameBinarization SHARED FrameBinarization_APIv1.cpp) -TARGET_LINK_LIBRARIES( FrameBinarization ${PLAYUVER_LINKER_LIBS} ) +TARGET_LINK_LIBRARIES( FrameBinarization ${CALYP_LINKER_LIBS} ) ADD_LIBRARY(AbsoluteFrameDifferenceExample SHARED AbsoluteFrameDifferenceExample.cpp) -TARGET_LINK_LIBRARIES( AbsoluteFrameDifferenceExample ${PLAYUVER_LINKER_LIBS} ) +TARGET_LINK_LIBRARIES( AbsoluteFrameDifferenceExample ${CALYP_LINKER_LIBS} ) diff --git a/examples/modules/FrameBinarization_APIv1.cpp b/examples/modules/FrameBinarization_APIv1.cpp index dcead39..3528ca2 100644 --- a/examples/modules/FrameBinarization_APIv1.cpp +++ b/examples/modules/FrameBinarization_APIv1.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,13 +29,13 @@ REGISTER_CLASS_MAKER( FrameBinarization_APIv1 ) FrameBinarization_APIv1::FrameBinarization_APIv1() { /* Module Definition */ - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleName = "FrameBinarization_APIv1"; m_pchModuleLongName = "Frame Binarization API v1"; m_pchModuleTooltip = "Binarize frame"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" ); @@ -44,25 +44,25 @@ FrameBinarization_APIv1::FrameBinarization_APIv1() m_uiThreshold = 128; } -Void FrameBinarization_APIv1::create( PlaYUVerFrame* frame ) +void FrameBinarization_APIv1::create( CalypFrame* frame ) { m_pcBinFrame = NULL; - m_pcBinFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), PlaYUVerFrame::GRAY, 8 ); + m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), CalypFrame::GRAY, 8 ); } -PlaYUVerFrame* FrameBinarization_APIv1::process( PlaYUVerFrame* frame ) +CalypFrame* FrameBinarization_APIv1::process( CalypFrame* frame ) { - Pel* pPelInput = frame->getPelBufferYUV()[0][0]; - Pel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0]; - for( UInt y = 0; y < frame->getHeight(); y++ ) - for( UInt x = 0; x < frame->getWidth(); x++ ) + const ClpPel* pPelInput = frame->getPelBufferYUV()[0][0]; + ClpPel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0]; + for( unsigned int y = 0; y < frame->getHeight(); y++ ) + for( unsigned int x = 0; x < frame->getWidth(); x++ ) { *pPelBin++ = *pPelInput++ >= m_uiThreshold ? 255 : 0; } return m_pcBinFrame; } -Void FrameBinarization_APIv1::destroy() +void FrameBinarization_APIv1::destroy() { if( m_pcBinFrame ) delete m_pcBinFrame; diff --git a/examples/modules/FrameBinarization_APIv1.h b/examples/modules/FrameBinarization_APIv1.h index 1b139e0..459bbd4 100644 --- a/examples/modules/FrameBinarization_APIv1.h +++ b/examples/modules/FrameBinarization_APIv1.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,22 +25,22 @@ #ifndef __FRAMEBINARIZATION_APIV1_H__ #define __FRAMEBINARIZATION_APIV1_H__ -#include "PlaYUVerModuleIf.h" +#include "CalypModuleIf.h" -class FrameBinarization_APIv1 : public PlaYUVerModuleIf +class FrameBinarization_APIv1 : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameBinarization_APIv1 ) - private: - PlaYUVerFrame* m_pcBinFrame; - UInt m_uiThreshold; +private: + CalypFrame* m_pcBinFrame; + unsigned int m_uiThreshold; - public: - FrameBinarization_APIv1(); - virtual ~FrameBinarization_APIv1() {} - Void create( PlaYUVerFrame* ); - PlaYUVerFrame* process( PlaYUVerFrame* ); - Void destroy(); +public: + FrameBinarization_APIv1(); + virtual ~FrameBinarization_APIv1() {} + void create( CalypFrame* ); + CalypFrame* process( CalypFrame* ); + void destroy(); }; #endif // __FRAMEBINARIZATION_APIV1_H__ diff --git a/format_source_files.sh b/format_source_files.sh new file mode 100755 index 0000000..980c1c9 --- /dev/null +++ b/format_source_files.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +export LC_ALL=en_GB.utf8 +export LANG=C +CLANG_FORMAT="clang-format" +MY_NAME="$(basename "$0")" + +SET_VERBOSE=0 +ALL_FILES=0 + +function parsearguments { + local ARGS=$(getopt -o "h" -l "verbose,all,help" -n "${MY_NAME}" -- "$@") + local PRINT_HELP=0 + + #Bad arguments + if [ $? -ne 0 ] ; then + exit 1 + fi + + # A little magic + eval set -- "$ARGS" + + while true ; do + case "$1" in + -h|--help) + PRINT_HELP=1 + shift + ;; + --verbose ) + SET_VERBOSE=1 + shift + ;; + --all ) + ALL_FILES=1 + shift + ;; + --) + shift + break + esac + done + + if [[ ${PRINT_HELP} -ne 0 ]] ; then + echo "Usage: ${MY_NAME} [--all] [--verbose]" >&2 + echo "Format C++ source code and headers in a git-controlled directory structure." >&2 + echo >&2 + echo "Options:" >&2 + echo " --help" >&2 + echo " Show this help" >&2 + echo " --verbose" >&2 + echo " Show verbose (more) output" >&2 + echo " --all" >&2 + echo " Format all .cpp/.h files, not just those marked by git as added or modified">&2 + exit 1 + fi +} + +parsearguments "$@" + +git_branch=$(git status | head -1 | awk '{print $3}') + +if [[ ${ALL_FILES} -eq 0 ]] ; then + # Format only files seen by git as added or modified, + # filter for .cpp or .h files. + # Trying to handle filenames with spaces correctly (not tested) + git status --untracked-files=no --porcelain | awk '/^\s*[AM]+\s+.*[.](cpp|h)$/ {for(i=2;i&2 + continue + fi + + if [[ ! -z $( echo ${filename} | grep "\/external\/" ) ]]; then + echo "${MY_NAME}: Skip external source: \"${filename}\"" >&2 + continue + fi + + TEMPFILE=$(mktemp -t 'calyp_formatted_source_XXXXXXXXXXX.cpp') + + echo "Processing \"${filename}\"" +# astyle -n --align-reference=name --align-pointer=name --indent=spaces=4 --indent-labels --pad-oper --unpad-paren --pad-header --keep-one-line-statements --convert-tabs --indent-preprocessor <"${filename}" >${TEMPFILE} + $CLANG_FORMAT -style=file ${filename} > ${TEMPFILE} + +# # Astyle has problem with 'foreach' statements +# sed -i -e 's/\bforeach(/foreach (/g' ${TEMPFILE} + + # normalize SIGNAL statements as recommended at + # http://marcmutz.wordpress.com/effective-qt/prefer-to-use-normalised-signalslot-signatures/ + # astyle would insert spaces etc + grep -Po '(SIGNAL|SLOT)\([^(]+\([^)]*\)\)' "${TEMPFILE}" | while read original ; do + normalized="$(sed -e 's/const //g;s/&//g;s/ //g;s/\//\\\//g' <<<${original})" + originalregexpized="$(sed -e 's/\*/\\*/g;s/\//\\\//g' <<<${original})" + sed -i -e 's/'"${originalregexpized}"'/'"${normalized}"'/g' ${TEMPFILE} + done + +# # correct some astyle mis-formattings +# if [[ "${filename}" != "${filename/%.h/}" ]] ; then +# sed -i -e 's/^\([ ]*\)\(:[ ][a-zA-Z]\)/\1 \2/g' ${TEMPFILE} +# elif [[ "${filename}" != "${filename/%.cpp/}" ]] ; then +# sed -i -e 's/^\([ ]*\)\(:[ ][a-zA-Z]\)/\1 \2/g;s/\(foreach([^)]*\) \([&*]\) /\1 \2/g' ${TEMPFILE} +# fi + + # In const_cast operations, ensure space before ampersand + sed -i -r 's!( : const_cast<[^(;]+[^ ])&>[(]!\1 \&>(!g' ${TEMPFILE} + + # Remove superfluous empty lines at file's end + # http://unix.stackexchange.com/a/81687 + # http://sed.sourceforge.net/sed1line.txt + sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' ${TEMPFILE} + + # Check if copyright year is up to date + head -n 5 ${TEMPFILE} | grep -Eo --color=NEVER '20[0-9][0-9] by ' | head -n 1 | while read year rest ; do + [ "${year}" = $(date '+%Y') ] || echo "File '${filename}' has an outdated copyright year: ${year}" + done + + # only change/touch original file if it has been changed + diff -q ${TEMPFILE} "${filename}" >/dev/null || { echo "Updating \"${filename}\"" ; cp -p ${TEMPFILE} "${filename}" || echo "Cannot copy \"${TEMPFILE}\" \"${filename}\"" ; } + + rm -f ${TEMPFILE} +done diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 757dcd3..e8d1bb0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,79 +1,91 @@ ### -### CMakeLists for playuver lib component +### CMakeLists for calyp lib component ### INCLUDE(GNUInstallDirs) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) -set(PlaYUVer_Lib_SRCS +set(Calyp_Lib_SRCS LibMemory.h - PlaYUVerLib.h + CalypLib.h + CalypDefs.h # Frame - PlaYUVerFrame.h - PlaYUVerFrame.cpp - PlaYUVerFramePixelFormats.h - PlaYUVerFramePixelFormats.cpp + CalypFrame.h + CalypFrame.cpp + CalypPixel.cpp + PixelFormats.h + PixelFormats.cpp # Stream - PlaYUVerStream.h - PlaYUVerStream.cpp - PlaYUVerStreamHandlerIf.h + CalypStream.h + CalypStream.cpp + CalypStreamHandlerIf.h StreamHandlerRaw.h StreamHandlerRaw.cpp StreamHandlerPortableMap.h StreamHandlerPortableMap.cpp # Options Parser - PlaYUVerOptions.h - PlaYUVerOptions.cpp + CalypOptions.h + CalypOptions.cpp # Modules - PlaYUVerModuleIf.h + CalypModuleIf.h ) +LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${PROJECT_LIBRARY} ) +LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR} ) + + IF( USE_FFMPEG ) - LIST( APPEND PlaYUVer_Lib_SRCS StreamHandlerLibav.h ) - LIST( APPEND PlaYUVer_Lib_SRCS StreamHandlerLibav.cpp ) + LIST( APPEND Calyp_Lib_SRCS StreamHandlerLibav.h ) + LIST( APPEND Calyp_Lib_SRCS StreamHandlerLibav.cpp ) + + LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${FFMPEG_LIBRARIES} ) + LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ) ENDIF() IF( USE_OPENCV ) - LIST( APPEND PlaYUVer_Lib_SRCS StreamHandlerOpenCV.h ) - LIST( APPEND PlaYUVer_Lib_SRCS StreamHandlerOpenCV.cpp ) + LIST( APPEND Calyp_Lib_SRCS StreamHandlerOpenCV.h ) + LIST( APPEND Calyp_Lib_SRCS StreamHandlerOpenCV.cpp ) + + LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${OpenCV_LIBRARIES} ) + LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS} ) ENDIF() -set(PlaYUVer_Lib_HEADERS - PlaYUVerDefs.h - PlaYUVerFrame.h - PlaYUVerStream.h - PlaYUVerOptions.h - PlaYUVerModuleIf.h +set(Calyp_Lib_HEADERS + CalypDefs.h + CalypFrame.h + CalypStream.h + CalypOptions.h + CalypModuleIf.h ) -CONFIGURE_FILE( PlaYUVerConfig.cmake.in PlaYUVerConfig.cmake @ONLY) +CONFIGURE_FILE( CalypConfig.cmake.in CalypConfig.cmake @ONLY) INCLUDE_DIRECTORIES( ${FFMPEG_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ) IF( USE_STATIC ) - ADD_LIBRARY( PlaYUVerLib STATIC ${PlaYUVer_Lib_SRCS} ) + ADD_LIBRARY( ${PROJECT_LIBRARY} STATIC ${Calyp_Lib_SRCS} ) ELSE() - ADD_LIBRARY( PlaYUVerLib SHARED ${PlaYUVer_Lib_SRCS} ) + ADD_LIBRARY( ${PROJECT_LIBRARY} SHARED ${Calyp_Lib_SRCS} ) ENDIF() -TARGET_LINK_LIBRARIES( PlaYUVerLib +TARGET_LINK_LIBRARIES( ${PROJECT_LIBRARY} ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES} ) -SET_TARGET_PROPERTIES( PlaYUVerLib - PROPERTIES VERSION ${PLAYUVER_VERSION} - SOVERSION ${PLAYUVER_VERSION_MAJOR} +SET_TARGET_PROPERTIES( ${PROJECT_LIBRARY} + PROPERTIES VERSION ${CALYP_VERSION} + SOVERSION ${CALYP_VERSION_MAJOR} ) IF( NOT USE_STATIC ) - INSTALL( TARGETS PlaYUVerLib + INSTALL( TARGETS ${PROJECT_LIBRARY} RUNTIME DESTINATION bin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) - INSTALL(FILES ${PlaYUVer_Lib_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/PlaYUVerConfig.cmake DESTINATION share/playuver ) + INSTALL(FILES ${Calyp_Lib_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CalypConfig.cmake DESTINATION share/calyp ) ENDIF() diff --git a/lib/CalypConfig.cmake.in b/lib/CalypConfig.cmake.in new file mode 100644 index 0000000..c5239bd --- /dev/null +++ b/lib/CalypConfig.cmake.in @@ -0,0 +1,36 @@ +# =================================================================================================================== +# The Calyp Libs CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(Calyp REQUIRED) +# include_directories(${CALYP_INCLUDE_DIRS}) +# target_link_libraries(MY_TARGET_NAME ${CALYP_LINKER_LIBS}) +# +# +# This file will define the following variables: +# - CALYP_LINKER_LIBS : The list of all imported targets for OpenCV modules. +# - CALYP_CXX_FLAGS +# - CALYP_INCLUDE_DIRS : The Calyp include directories. +# - CALYP_VERSION : The version of this Calyp build: "@CALYP_VERSION@" +# - CALYP_VERSION_MAJOR : Major version part of CALYP_VERSION: "@CALYP_VERSION_MAJOR@" +# - CALYP_VERSION_MINOR : Minor version part of CALYP_VERSION: "@CALYP_VERSION_MINOR@" +# - CALYP_VERSION_PATCH : Patch version part of CALYP_VERSION: "@CALYP_VERSION_PATCH@" +# +# =================================================================================================================== + + +# ====================================================== +# Variables: +# ====================================================== +SET(CALYP_VERSION @CALYP_VERSION@) +SET(CALYP_VERSION_MAJOR @CALYP_VERSION_MAJOR@) +SET(CALYP_VERSION_MINOR @CALYP_VERSION_MINOR@) +SET(CALYP_VERSION_PATCH @CALYP_VERSION_PATCH@) + +SET( CALYP_CXX_FLAGS "" ) +SET( CALYP_INCLUDE_DIRS "@CMAKE_CFG_INCLUDE_DIRS@" ) +SET( CALYP_LINKER_LIBS "@CMAKE_CFG_LINKER_LIBSS@" ) diff --git a/lib/CalypDefs.h b/lib/CalypDefs.h new file mode 100644 index 0000000..90440af --- /dev/null +++ b/lib/CalypDefs.h @@ -0,0 +1,135 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypDefs.h + * \ingroup CalypLibGrp + * \brief Define basic types, new types and enumerations + */ + +#ifndef __CALYPDEFS_H__ +#define __CALYPDEFS_H__ + +#include +#include +#include + +typedef unsigned short ClpPel; ///< 16-bit pixel type +typedef unsigned char ClpByte; + +typedef std::string ClpString; + +enum CLP_LOG_LEVEL +{ + CLP_LOG_INFO = 1, + CLP_LOG_WARNINGS = 2, + CLP_LOG_RESULT = 3, + CLP_LOG_ERROR = 4, +}; + +/** + * \enum CalypColorSpace + * \brief List of supported color spaces + * \ingroup CalypLibGrp + */ +enum CalypColorSpace +{ + CLP_COLOR_INVALID = -1, //!< Invalid + CLP_COLOR_YUV = 0, //!< YUV + CLP_COLOR_RGB = 1, //!< RGB + CLP_COLOR_GRAY = 2, //!< Grayscale + CLP_COLOR_RGBA = 3, //!< RGB + Alpha + CLP_COLOR_MAX = 255, //!< Account for future formats +}; + +/** + * \enum CalypPixelFormats + * \brief List of supported pixel formats + * \ingroup CalypLibGrp + */ +enum CalypPixelFormats +{ + CLP_INVALID_FMT = -1, //!< Invalid + CLP_YUV420P = 0, //!< YUV 420 progressive + CLP_YUV422P, //!< YUV 422 progressive + CLP_YUV444P, //!< YUV 444 progressive + CLP_YUYV422, //!< YUV 422 interleaved + CLP_GRAY, //!< Grayscale + CLP_RGB24P, //!< RGB 32 bpp progressive + CLP_RGB24, //!< RGB 32 bpp + CLP_BGR24, //!< BGR 32 bpp + CLP_RGBA32, //!< RGBA 32 bpp + CLP_BGRA32, //!< BGRA 32 bpp + CLP_MAX_FMT = 255, //!< Account for future formats +}; + +enum CLP_YUV_Components +{ + CLP_LUMA = 0, + CLP_CHROMA_U, + CLP_CHROMA_V, +}; + +enum CLP_RGB_Components +{ + CLP_COLOR_R = 0, + CLP_COLOR_G, + CLP_COLOR_B, + CLP_COLOR_A, +}; + +enum CLP_Endianness +{ + CLP_BIG_ENDIAN = 0, + CLP_LITTLE_ENDIAN = 1, +}; + +inline ClpString clpLowercase( const ClpString& in ) +{ + ClpString out; + transform( in.begin(), in.end(), std::back_inserter( out ), tolower ); + return out; +} + +inline ClpString clpUppercase( const ClpString& in ) +{ + ClpString out; + transform( in.begin(), in.end(), std::back_inserter( out ), toupper ); + return out; +} + +struct CalypFailure : public std::exception +{ + ClpString m_class_name; + ClpString m_error_msg; + CalypFailure( ClpString error_msg ) throw() + : m_error_msg( error_msg ) {} + CalypFailure( ClpString class_name, ClpString error_msg ) throw() + : m_class_name( class_name ), m_error_msg( error_msg ) + { + } + ~CalypFailure() throw() {} + const char* what() const throw() + { + ClpString* msg = new ClpString( "[" + m_class_name + "] " + m_error_msg ); + return msg->c_str(); + } +}; + +#endif // __CALYPDEFS_H__ diff --git a/lib/PlaYUVerFrame.cpp b/lib/CalypFrame.cpp similarity index 50% rename from lib/PlaYUVerFrame.cpp rename to lib/CalypFrame.cpp index 0a63833..b1b1854 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/CalypFrame.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,26 +18,26 @@ */ /** - * \file PlaYUVerFrame.cpp + * \file CalypFrame.cpp * \brief Video Frame handling */ -#include "PlaYUVerFrame.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFramePixelFormats.h" +#include "PixelFormats.h" #include "config.h" +#include #include + #ifdef USE_OPENCV #include #endif -#define MAX_NUMBER_COMPONENTS 4 - -std::vector PlaYUVerFrame::supportedColorSpacesListNames() +std::vector CalypFrame::supportedColorSpacesListNames() { - return std::vector{ + return std::vector{ "YUV", "RGB", "GRAY", @@ -45,324 +45,71 @@ std::vector PlaYUVerFrame::supportedColorSpacesListNames() }; } -std::vector PlaYUVerFrame::supportedPixelFormatListNames() +std::vector CalypFrame::supportedPixelFormatListNames() { - std::vector formatsList; - for( Int i = 0; i < numberOfFormats(); i++ ) + std::vector formatsList; + for( int i = 0; i < numberOfFormats(); i++ ) { - formatsList.push_back( g_PlaYUVerPixFmtDescriptorsMap.at( i ).name ); + formatsList.push_back( g_CalypPixFmtDescriptorsMap.at( i ).name ); } return formatsList; } -std::vector PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace ) +std::vector CalypFrame::supportedPixelFormatListNames( int colorSpace ) { - std::vector formatsList; - for( Int i = 0; i < numberOfFormats(); i++ ) + std::vector formatsList; + for( int i = 0; i < numberOfFormats(); i++ ) { - if( g_PlaYUVerPixFmtDescriptorsMap.at( i ).colorSpace == colorSpace ) - formatsList.push_back( g_PlaYUVerPixFmtDescriptorsMap.at( i ).name ); + if( g_CalypPixFmtDescriptorsMap.at( i ).colorSpace == colorSpace ) + formatsList.push_back( g_CalypPixFmtDescriptorsMap.at( i ).name ); } return formatsList; } -Int PlaYUVerFrame::numberOfFormats() +int CalypFrame::numberOfFormats() { - return g_PlaYUVerPixFmtDescriptorsMap.size(); + return g_CalypPixFmtDescriptorsMap.size(); } -Int PlaYUVerFrame::findPixelFormat( const String& name ) +int CalypFrame::findPixelFormat( const ClpString& name ) { - for( Int i = 0; i < numberOfFormats(); i++ ) + for( int i = 0; i < numberOfFormats(); i++ ) { - if( g_PlaYUVerPixFmtDescriptorsMap.at( i ).name == name ) + if( g_CalypPixFmtDescriptorsMap.at( i ).name == name ) return i; } return -1; } -struct PlaYUVerPixelPrivate +struct CalypFramePrivate { - PlaYUVerPixelPrivate( const Int& ColorSpace ) - { - iColorSpace = ColorSpace == PlaYUVerPixel::COLOR_GRAY ? - PlaYUVerPixel::COLOR_YUV : - ColorSpace; - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - PixelComponents[i] = 0; - } - } - - Int iColorSpace; - Pel PixelComponents[MAX_NUMBER_COMPONENTS]; -}; - -static inline Void yuvToRgb( const Int& iY, const Int& iU, const Int& iV, Int& iR, Int& iG, Int& iB ) -{ - iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ); - iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ); - iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ); - iR = iR < 0 ? 0 : iR > 255 ? 255 : iR; - iG = iG < 0 ? 0 : iG > 255 ? 255 : iG; - iB = iB < 0 ? 0 : iB > 255 ? 255 : iB; -} - -static inline Void rgbToYuv( const Int& iR, const Int& iG, const Int& iB, Int& iY, Int& iU, Int& iV ) -{ - iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; - iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; - iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; -} - -Int PlaYUVerPixel::getMaxNumberOfComponents() -{ - return MAX_NUMBER_COMPONENTS; -} - -PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace ) - : d( new PlaYUVerPixelPrivate( ColorSpace ) ) -{ -} - -PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0 ) - : d( new PlaYUVerPixelPrivate( ColorSpace ) ) -{ - d->PixelComponents[0] = c0; -} - -PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 ) - : d( new PlaYUVerPixelPrivate( ColorSpace ) ) -{ - d->PixelComponents[0] = c0; - d->PixelComponents[1] = c1; - d->PixelComponents[2] = c2; -} - -PlaYUVerPixel::PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2, const Pel& c3 ) - : d( new PlaYUVerPixelPrivate( ColorSpace ) ) -{ - d->PixelComponents[0] = c0; - d->PixelComponents[1] = c1; - d->PixelComponents[2] = c2; - d->PixelComponents[3] = c3; -} - -PlaYUVerPixel::PlaYUVerPixel( const PlaYUVerPixel& other ) - : d( new PlaYUVerPixelPrivate( other.colorSpace() ) ) -{ - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - d->PixelComponents[i] = other[i]; - } -} - -PlaYUVerPixel::~PlaYUVerPixel() -{ - delete d; -} - -Int PlaYUVerPixel::colorSpace() const -{ - return d->iColorSpace; -} - -Pel PlaYUVerPixel::Y() const -{ - return d->PixelComponents[0]; -} -Pel PlaYUVerPixel::Cb() const -{ - return d->PixelComponents[1]; -} -Pel PlaYUVerPixel::Cr() const -{ - return d->PixelComponents[2]; -} -Pel PlaYUVerPixel::R() const -{ - return d->PixelComponents[0]; -} -Pel PlaYUVerPixel::G() const -{ - return d->PixelComponents[1]; -} -Pel PlaYUVerPixel::B() const -{ - return d->PixelComponents[2]; -} -Pel PlaYUVerPixel::A() const -{ - return d->PixelComponents[3]; -} - -Pel& PlaYUVerPixel::Y() -{ - return d->PixelComponents[0]; -} -Pel& PlaYUVerPixel::Cb() -{ - return d->PixelComponents[1]; -} -Pel& PlaYUVerPixel::Cr() -{ - return d->PixelComponents[2]; -} -Pel& PlaYUVerPixel::R() -{ - return d->PixelComponents[0]; -} -Pel& PlaYUVerPixel::G() -{ - return d->PixelComponents[1]; -} -Pel& PlaYUVerPixel::B() -{ - return d->PixelComponents[2]; -} -Pel& PlaYUVerPixel::A() -{ - return d->PixelComponents[3]; -} - -Pel PlaYUVerPixel::operator[]( const Int& channel ) const -{ - return d->PixelComponents[channel]; -} -Pel& PlaYUVerPixel::operator[]( const Int& channel ) -{ - return d->PixelComponents[channel]; -} - -PlaYUVerPixel PlaYUVerPixel::operator=( const PlaYUVerPixel& other ) -{ - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - d->PixelComponents[i] = other[i]; - } - return *this; -} - -PlaYUVerPixel PlaYUVerPixel::operator+( const PlaYUVerPixel& in ) -{ - PlaYUVerPixel result; - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - result[i] = d->PixelComponents[i] + in[i]; - } - return result; -} - -PlaYUVerPixel PlaYUVerPixel::operator+=( const PlaYUVerPixel& in ) -{ - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - d->PixelComponents[i] += in[i]; - } - return *this; -} - -PlaYUVerPixel PlaYUVerPixel::operator-( const PlaYUVerPixel& in ) -{ - PlaYUVerPixel result; - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - result[i] = d->PixelComponents[i] - in[i]; - } - return result; -} - -PlaYUVerPixel PlaYUVerPixel::operator-=( const PlaYUVerPixel& in ) -{ - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - d->PixelComponents[i] -= in[i]; - } - return *this; -} - -PlaYUVerPixel PlaYUVerPixel::operator*( const Double& op ) -{ - PlaYUVerPixel result; - for( Int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) - { - result[i] = d->PixelComponents[i] * op; - } - return result; -} - -PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace ) -{ - if( d->iColorSpace == eOutputSpace ) - return *this; - - Int outA = 0; - Int outB = 0; - Int outC = 0; - Int outD = 0; - if( d->iColorSpace == COLOR_YUV ) - { - switch( eOutputSpace ) - { - case COLOR_GRAY: - outA = Y(); - break; - case COLOR_RGBA: - outD = 255; - case COLOR_RGB: - yuvToRgb( Y(), Cb(), Cr(), outA, outB, outC ); - break; - default: - break; - } - } - if( d->iColorSpace == COLOR_RGB ) - { - switch( eOutputSpace ) - { - case COLOR_GRAY: - rgbToYuv( R(), G(), B(), outA, outB, outC ); - case COLOR_YUV: - rgbToYuv( R(), G(), B(), outA, outB, outC ); - break; - case COLOR_RGBA: - outD = 255; - break; - default: - break; - } - } - return PlaYUVerPixel( eOutputSpace, outA, outB, outC, outD ); -} - -struct PlaYUVerFramePrivate -{ - Bool m_bInit; +public: + bool m_bInit; //! Struct with the pixel format description. - const PlaYUVerPixFmtDescriptor* m_pcPelFormat; - String m_cPelFmtName; + const CalypPixelFormatDescriptor* m_pcPelFormat; + ClpString m_cPelFmtName; - UInt m_uiWidth; //!< Width of the frame - UInt m_uiHeight; //!< Height of the frame - Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats) - UInt m_uiBitsPel; //!< Bits per pixel/channel - UInt m_uiHalfPelValue; //!< Bits per pixel/channel + unsigned int m_uiWidth; //!< Width of the frame + unsigned int m_uiHeight; //!< Height of the frame + int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats) + unsigned int m_uiBitsPel; //!< Bits per pixel/channel + unsigned int m_uiHalfPelValue; //!< Bits per pixel/channel - Pel*** m_pppcInputPel; + ClpPel*** m_pppcInputPel; - Bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed - UChar* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs + bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed + unsigned char* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs /** Histogram control variables **/ - Bool m_bHasHistogram; - Bool m_bHistogramRunning; + bool m_bHasHistogram; + bool m_bHistogramRunning; /** The histogram data.*/ - UInt* m_puiHistogram; + unsigned int* m_puiHistogram; /** If the image is RGB and calcLuma is true, we have 1 more channel */ - UInt m_uiHistoChannels; + unsigned int m_uiHistoChannels; /** Numbers of histogram segments depending of image bytes depth*/ - UInt m_uiHistoSegments; + unsigned int m_uiHistoSegments; /** * Common constructor function of a frame @@ -372,7 +119,7 @@ struct PlaYUVerFramePrivate * @param pel_format pixel format index (always use PixelFormats enum) * */ - Void init( UInt width, UInt height, Int pel_format, Int bitsPixel ) + void init( unsigned int width, unsigned int height, int pel_format, int bitsPixel ) { m_bInit = false; m_bHasRGBPel = false; @@ -386,35 +133,35 @@ struct PlaYUVerFramePrivate if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 ) { - throw PlaYUVerFailure( "PlaYUVerFrame", "Cannot create a PlYUVerFrame of this type" ); + throw CalypFailure( "CalypFrame", "Cannot create a PlYUVerFrame of this type" ); } - m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsMap.at( pel_format ) ); - Int iNumberChannels = m_pcPelFormat->numberChannels; + m_pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( pel_format ) ); + int iNumberChannels = m_pcPelFormat->numberChannels; std::size_t mem_size = 0; std::size_t num_of_ptrs = 0; - for( Int ch = 0; ch < iNumberChannels; ch++ ) + for( int ch = 0; ch < iNumberChannels; ch++ ) { - Int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0; - Int ratioH = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0; + int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0; + int ratioH = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0; // Add pointers mem num_of_ptrs += CHROMASHIFT( m_uiHeight, ratioH ); // Add pixel mem - mem_size += CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * sizeof( Pel ); + mem_size += CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * sizeof( ClpPel ); } - mem_size += num_of_ptrs * sizeof( Pel* ) + sizeof( Pel** ) * iNumberChannels; + mem_size += num_of_ptrs * sizeof( ClpPel* ) + sizeof( ClpPel** ) * iNumberChannels; - m_pppcInputPel = (Pel***)xMallocMem( mem_size ); + m_pppcInputPel = (ClpPel***)xMallocMem( mem_size ); - Pel** pelPtrMem = (Pel**)( m_pppcInputPel + iNumberChannels ); - Pel* pelMem = (Pel*)( pelPtrMem + num_of_ptrs ); - for( Int ch = 0; ch < iNumberChannels; ch++ ) + ClpPel** pelPtrMem = (ClpPel**)( m_pppcInputPel + iNumberChannels ); + ClpPel* pelMem = (ClpPel*)( pelPtrMem + num_of_ptrs ); + for( int ch = 0; ch < iNumberChannels; ch++ ) { - Int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0; - Int ratioH = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0; + int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0; + int ratioH = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0; m_pppcInputPel[ch] = pelPtrMem; - for( UInt h = 0; h < CHROMASHIFT( m_uiHeight, ratioH ); h++ ) + for( unsigned int h = 0; h < CHROMASHIFT( m_uiHeight, ratioH ); h++ ) { *pelPtrMem = pelMem; pelPtrMem++; @@ -431,23 +178,23 @@ struct PlaYUVerFramePrivate m_uiHistoSegments = 1 << m_uiBitsPel; - if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB || - m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA ) + if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || + m_pcPelFormat->colorSpace == CLP_COLOR_RGBA ) m_uiHistoChannels = m_pcPelFormat->numberChannels + 1; else m_uiHistoChannels = m_pcPelFormat->numberChannels; - getMem1D( &( m_puiHistogram ), m_uiHistoSegments * m_uiHistoChannels ); + getMem1D( &( m_puiHistogram ), m_uiHistoSegments * m_uiHistoChannels ); - m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); + m_cPelFmtName = CalypFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); m_bInit = true; } - Int getRealHistogramChannel( Int channel ) + int getRealHistogramChannel( int channel ) { - Int realChannel = -1; - if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS ) + int realChannel = -1; + if( channel == CalypFrame::HIST_ALL_CHANNELS ) { realChannel = channel; } @@ -455,23 +202,23 @@ struct PlaYUVerFramePrivate { realChannel = channel; } - else if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) + else if( m_pcPelFormat->colorSpace == CLP_COLOR_GRAY ) { if( channel >= 10 && channel < 11 ) { realChannel = channel - 10; } } - else if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV ) + else if( m_pcPelFormat->colorSpace == CLP_COLOR_YUV ) { if( channel >= 10 && channel < 13 ) { realChannel = channel - 10; } } - else if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB || m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA ) + else if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || m_pcPelFormat->colorSpace == CLP_COLOR_RGBA ) { - if( channel == PlaYUVerFrame::HIST_LUMA ) + if( channel == CalypFrame::HIST_LUMA ) { realChannel = m_uiHistoChannels - 1; } @@ -480,12 +227,12 @@ struct PlaYUVerFramePrivate realChannel = channel - 20; } } - if( realChannel > (Int)m_uiHistoChannels ) + if( realChannel > (int)m_uiHistoChannels ) realChannel = -1; return realChannel; } - ~PlaYUVerFramePrivate() + ~CalypFramePrivate() { while( m_bHistogramRunning ) ; @@ -505,21 +252,21 @@ struct PlaYUVerFramePrivate * \brief Constructors */ -PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel ) - : d( new PlaYUVerFramePrivate ) +CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, int bitsPixel ) + : d( new CalypFramePrivate ) { d->init( width, height, pelFormat, bitsPixel ); } -PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other ) - : d( new PlaYUVerFramePrivate ) +CalypFrame::CalypFrame( const CalypFrame& other ) + : d( new CalypFramePrivate ) { d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel() ); copyFrom( &other ); } -PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other ) - : d( new PlaYUVerFramePrivate ) +CalypFrame::CalypFrame( const CalypFrame* other ) + : d( new CalypFramePrivate ) { if( other ) { @@ -528,10 +275,10 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other ) } } -PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt width, UInt height ) - : d( new PlaYUVerFramePrivate ) +CalypFrame::CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height ) + : d( new CalypFramePrivate ) { - const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsMap.at( other.getPelFormat() ) ); + const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( other.getPelFormat() ) ); if( pcPelFormat->log2ChromaWidth ) { if( x % ( 1 << pcPelFormat->log2ChromaWidth ) ) @@ -553,13 +300,13 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt w copyFrom( other, x, y ); } -PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight ) - : d( new PlaYUVerFramePrivate ) +CalypFrame::CalypFrame( const CalypFrame* other, unsigned int posX, unsigned int posY, unsigned int areaWidth, unsigned int areaHeight ) + : d( new CalypFramePrivate ) { if( !other ) return; - const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsMap.at( other->getPelFormat() ) ); + const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( other->getPelFormat() ) ); if( pcPelFormat->log2ChromaWidth ) { if( posX % ( 1 << pcPelFormat->log2ChromaWidth ) ) @@ -581,14 +328,14 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame* other, UInt posX, UInt posY, copyFrom( other, posX, posY ); } -PlaYUVerFrame::~PlaYUVerFrame() +CalypFrame::~CalypFrame() { delete d; } -Bool PlaYUVerFrame::haveSameFmt( const PlaYUVerFrame& other, UInt match ) const +bool CalypFrame::haveSameFmt( const CalypFrame& other, unsigned int match ) const { - Bool bRet = true; + bool bRet = true; if( match & MATCH_COLOR_SPACE ) bRet &= ( getColorSpace() == other.getColorSpace() ); if( match & MATCH_RESOLUTION ) @@ -598,13 +345,13 @@ Bool PlaYUVerFrame::haveSameFmt( const PlaYUVerFrame& other, UInt match ) const if( match & MATCH_BITS ) bRet &= ( getBitsPel() == other.getBitsPel() ); if( match & MATCH_COLOR_SPACE_IGNORE_GRAY ) - bRet &= ( getColorSpace() == PlaYUVerPixel::COLOR_GRAY || getColorSpace() == other.getColorSpace() ); + bRet &= ( getColorSpace() == CLP_COLOR_GRAY || getColorSpace() == other.getColorSpace() ); return bRet; } -Bool PlaYUVerFrame::haveSameFmt( const PlaYUVerFrame* other, UInt match ) const +bool CalypFrame::haveSameFmt( const CalypFrame* other, unsigned int match ) const { - Bool bRet = false; + bool bRet = false; if( other ) { bRet = haveSameFmt( *other, match ); @@ -612,109 +359,110 @@ Bool PlaYUVerFrame::haveSameFmt( const PlaYUVerFrame* other, UInt match ) const return bRet; } -Int PlaYUVerFrame::getPelFormat() const +int CalypFrame::getPelFormat() const { return d->m_iPixelFormat; } -String PlaYUVerFrame::getPelFmtName() +ClpString CalypFrame::getPelFmtName() { return d->m_pcPelFormat->name; } -Int PlaYUVerFrame::getColorSpace() const +int CalypFrame::getColorSpace() const { return d->m_pcPelFormat->colorSpace; } -UInt PlaYUVerFrame::getNumberChannels() const +unsigned int CalypFrame::getNumberChannels() const { return d->m_pcPelFormat->numberChannels; } -UInt PlaYUVerFrame::getWidth( Int channel ) const +unsigned int CalypFrame::getWidth( int channel ) const { return CHROMASHIFT( d->m_uiWidth, channel > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0 ); } -UInt PlaYUVerFrame::getHeight( Int channel ) const +unsigned int CalypFrame::getHeight( int channel ) const { return CHROMASHIFT( d->m_uiHeight, channel > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0 ); } -UInt PlaYUVerFrame::getPixels( Int channel ) const +unsigned int CalypFrame::getPixels( int channel ) const { return getWidth( channel ) * getWidth( channel ); } -UInt8 PlaYUVerFrame::getChromaWidthRatio() const +unsigned char CalypFrame::getChromaWidthRatio() const { return d->m_pcPelFormat->log2ChromaWidth; } -UInt8 PlaYUVerFrame::getChromaHeightRatio() const +unsigned char CalypFrame::getChromaHeightRatio() const { return d->m_pcPelFormat->log2ChromaHeight; } -UInt PlaYUVerFrame::getChromaLength() const +unsigned int CalypFrame::getChromaLength() const { return getWidth( 1 ) * getHeight( 1 ); } -UInt PlaYUVerFrame::getBitsPel() const +unsigned int CalypFrame::getBitsPel() const { return d->m_uiBitsPel; } -UInt64 PlaYUVerFrame::getBytesPerFrame() +unsigned long CalypFrame::getBytesPerFrame() { return getBytesPerFrame( d->m_uiWidth, d->m_uiHeight, d->m_iPixelFormat, d->m_uiBitsPel ); } -UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel ) +unsigned long CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel ) { - const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsMap.at( iPixelFormat ) ); - UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1; - UInt64 numberBytes = uiWidth * uiHeight; + const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( iPixelFormat ) ); + unsigned int bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1; + unsigned long long int numberBytes = uiWidth * uiHeight; if( pcPelFormat->numberChannels > 1 ) { - UInt64 numberBytesChroma = + unsigned long long int numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight ); numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma; } return numberBytes * bytesPerPixel; } -Void PlaYUVerFrame::clear() +void CalypFrame::reset() { - Pel* pPel; - Pel uiValue = 128; - Int ratioH, ratioW; - UInt i; - for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) + ClpPel* pPel; + ClpPel pelValue = 1 << ( d->m_uiBitsPel - 1 ); + int ratioH, ratioW; + unsigned int i; + for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) { ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; pPel = d->m_pppcInputPel[ch][0]; for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ ) { - *pPel++ = uiValue; + *pPel++ = pelValue; } } } -Pel*** PlaYUVerFrame::getPelBufferYUV() const +ClpPel*** CalypFrame::getPelBufferYUV() const { return d->m_pppcInputPel; } -Pel*** PlaYUVerFrame::getPelBufferYUV() + +ClpPel*** CalypFrame::getPelBufferYUV() { d->m_bHasHistogram = false; d->m_bHasRGBPel = false; return d->m_pppcInputPel; } -UChar* PlaYUVerFrame::getRGBBuffer() const +unsigned char* CalypFrame::getRGBBuffer() const { if( d->m_bHasRGBPel ) { @@ -722,105 +470,89 @@ UChar* PlaYUVerFrame::getRGBBuffer() const } return NULL; } -//UChar* PlaYUVerFrame::getRGBBuffer() -//{ -// if( !d->m_bHasRGBPel ) -// { -// fillRGBBuffer(); -// } -// return d->m_pcARGB32; -//} -Pel PlaYUVerFrame::operator()( UInt ch, UInt xPos, UInt yPos ) +ClpPel CalypFrame::operator()( unsigned int ch, unsigned int xPos, unsigned int yPos ) { if( ch < d->m_pcPelFormat->numberChannels ) return d->m_pppcInputPel[ch][yPos][xPos]; return 0; } -PlaYUVerPixel PlaYUVerFrame::operator()( UInt xPos, UInt yPos ) +CalypPixel CalypFrame::operator()( unsigned int xPos, unsigned int yPos ) { return getPixel( xPos, yPos ); } -PlaYUVerPixel PlaYUVerFrame::getPixel( UInt xPos, UInt yPos ) +CalypPixel CalypFrame::getPixel( unsigned int xPos, unsigned int yPos ) { - PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace ); - for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) + CalypPixel PixelValue( d->m_pcPelFormat->colorSpace ); + for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) { - Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; - Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; + int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; + int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; PixelValue[ch] = d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )]; } return PixelValue; } -PlaYUVerPixel PlaYUVerFrame::getPixel( UInt xPos, UInt yPos, PlaYUVerPixel::ColorSpace eColorSpace ) +CalypPixel CalypFrame::getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) { - PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace ); - for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) - { - Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; - Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; - PixelValue[ch] = d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )]; - } - PixelValue = PixelValue.ConvertPixel( eColorSpace ); - return PixelValue; + return getPixel( xPos, yPos ).convertPixel( eColorSpace ); } -Void PlaYUVerFrame::setPixel( UInt xPos, UInt yPos, PlaYUVerPixel pixel ) +void CalypFrame::setPixel( unsigned int xPos, unsigned int yPos, CalypPixel pixel ) { - for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) + for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) { - Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; - Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; + int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; + int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; d->m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )] = pixel[ch]; } d->m_bHasHistogram = false; d->m_bHasRGBPel = false; } -Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame& other ) +void CalypFrame::copyFrom( const CalypFrame& other ) { if( haveSameFmt( other, MATCH_ALL ) ) return; d->m_bHasRGBPel = false; d->m_bHasHistogram = false; - memcpy( *d->m_pppcInputPel[LUMA], other.getPelBufferYUV()[LUMA][0], getBytesPerFrame() * sizeof( Pel ) ); + memcpy( *d->m_pppcInputPel[CLP_LUMA], other.getPelBufferYUV()[CLP_LUMA][0], getBytesPerFrame() * sizeof( ClpPel ) ); } -Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame* other ) +void CalypFrame::copyFrom( const CalypFrame* other ) { if( other ) copyFrom( *other ); } -Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame& other, UInt xPos, UInt yPos ) +void CalypFrame::copyFrom( const CalypFrame& other, unsigned int xPos, unsigned int yPos ) { if( haveSameFmt( other, MATCH_ALL ) ) return; - Pel*** pInput = other.getPelBufferYUV(); - for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) + ClpPel*** pInput = other.getPelBufferYUV(); + for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) { - Int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; - Int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; - for( UInt i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ); i++ ) + int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0; + int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0; + for( unsigned int i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ); i++ ) { memcpy( d->m_pppcInputPel[ch][i], &( pInput[ch][( yPos >> ratioH ) + i][( xPos >> ratioW )] ), - ( d->m_uiWidth >> ratioW ) * sizeof( Pel ) ); + ( d->m_uiWidth >> ratioW ) * sizeof( ClpPel ) ); } } d->m_bHasRGBPel = false; d->m_bHasHistogram = false; } -Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame* other, UInt x, UInt y ) +void CalypFrame::copyFrom( const CalypFrame* other, unsigned int x, unsigned int y ) { if( other ) copyFrom( *other, x, y ); } -Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness, UInt64 uiBuffSize ) +void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness, unsigned long uiBuffSize ) { if( uiBuffSize != getBytesPerFrame() ) return; @@ -828,19 +560,19 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness, UInt64 uiBuffS frameFromBuffer( Buff, iEndianness ); } -Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness ) +void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness ) { - Byte* ppBuff[MAX_NUMBER_PLANES]; - Byte* pTmpBuff; - Pel* pPel; - UInt bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1; - Int ratioH, ratioW, step; - UInt i, ch; - Int startByte = 0; - Int endByte = bytesPixel; - Int incByte = 1; - Int b; - Int maxval = pow( 2, d->m_uiBitsPel ) - 1; + ClpByte* ppBuff[MAX_NUMBER_PLANES]; + ClpByte* pTmpBuff; + ClpPel* pPel; + unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1; + int ratioH, ratioW, step; + unsigned int i, ch; + int startByte = 0; + int endByte = bytesPixel; + int incByte = 1; + int b; + int maxval = pow( 2, d->m_uiBitsPel ) - 1; if( iEndianness == 0 ) { @@ -887,18 +619,18 @@ Void PlaYUVerFrame::frameFromBuffer( Byte* Buff, Int iEndianness ) d->m_bHasHistogram = false; } -Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness ) +void CalypFrame::frameToBuffer( ClpByte* output_buffer, int iEndianness ) { - UInt bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1; - Byte* ppBuff[MAX_NUMBER_PLANES]; - Byte* pTmpBuff; - Pel* pTmpPel; - Int ratioH, ratioW, step; - UInt i, ch; - Int startByte = 0; - Int endByte = bytesPixel; - Int incByte = 1; - Int b; + unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1; + ClpByte* ppBuff[MAX_NUMBER_PLANES]; + ClpByte* pTmpBuff; + ClpPel* pTmpPel; + int ratioH, ratioW, step; + unsigned int i, ch; + int startByte = 0; + int endByte = bytesPixel; + int incByte = 1; + int b; if( iEndianness == 0 ) { @@ -908,7 +640,7 @@ Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness ) } ppBuff[0] = output_buffer; - for( Int i = 1; i < MAX_NUMBER_PLANES; i++ ) + for( int i = 1; i < MAX_NUMBER_PLANES; i++ ) { ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0; ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0; @@ -937,7 +669,7 @@ Void PlaYUVerFrame::frameToBuffer( Byte* output_buffer, Int iEndianness ) } } -Void PlaYUVerFrame::fillRGBBuffer() +void CalypFrame::fillRGBBuffer() { #define PEL_ARGB( a, r, g, b ) ( ( a & 0xff ) << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff ) #define PEL_RGB( r, g, b ) PEL_ARGB( 0xffu, r, g, b ) @@ -952,49 +684,49 @@ Void PlaYUVerFrame::fillRGBBuffer() if( d->m_bHasRGBPel ) return; - Int shiftBits = d->m_uiBitsPel - 8; - UInt* pARGB = (UInt*)d->m_pcARGB32; - if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) + int shiftBits = d->m_uiBitsPel - 8; + unsigned int* pARGB = (unsigned int*)d->m_pcARGB32; + if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY ) { - Pel* pY = d->m_pppcInputPel[LUMA][0]; - for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) + ClpPel* pY = d->m_pppcInputPel[CLP_LUMA][0]; + for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) { *pARGB++ = PEL_RGB( *pY, *pY, *pY ); pY++; } } - else if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ) + else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_RGB ) { - Pel* pR = d->m_pppcInputPel[COLOR_R][0]; - Pel* pG = d->m_pppcInputPel[COLOR_G][0]; - Pel* pB = d->m_pppcInputPel[COLOR_B][0]; - for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) + ClpPel* pR = d->m_pppcInputPel[CLP_COLOR_R][0]; + ClpPel* pG = d->m_pppcInputPel[CLP_COLOR_G][0]; + ClpPel* pB = d->m_pppcInputPel[CLP_COLOR_B][0]; + for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) *pARGB++ = PEL_RGB( ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits ); } - else if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA ) + else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_RGBA ) { - Pel* pR = d->m_pppcInputPel[COLOR_R][0]; - Pel* pG = d->m_pppcInputPel[COLOR_G][0]; - Pel* pB = d->m_pppcInputPel[COLOR_B][0]; - Pel* pA = d->m_pppcInputPel[COLOR_A][0]; - for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) + ClpPel* pR = d->m_pppcInputPel[CLP_COLOR_R][0]; + ClpPel* pG = d->m_pppcInputPel[CLP_COLOR_G][0]; + ClpPel* pB = d->m_pppcInputPel[CLP_COLOR_B][0]; + ClpPel* pA = d->m_pppcInputPel[CLP_COLOR_A][0]; + for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) *pARGB++ = PEL_ARGB( ( *pA++ ) >> shiftBits, ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits ); } - else if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV ) + else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_YUV ) { - Pel* pLineY = d->m_pppcInputPel[LUMA][0]; - Pel* pLineU = d->m_pppcInputPel[CHROMA_U][0]; - Pel* pLineV = d->m_pppcInputPel[CHROMA_V][0]; - UInt uiChromaStride = CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); - Pel* pY; - Pel* pU; - Pel* pV; - Int iY, iU, iV, iR, iG, iB; - UInt* pARGBLine = pARGB; - UInt* pARGB; + ClpPel* pLineY = d->m_pppcInputPel[CLP_LUMA][0]; + ClpPel* pLineU = d->m_pppcInputPel[CLP_CHROMA_U][0]; + ClpPel* pLineV = d->m_pppcInputPel[CLP_CHROMA_V][0]; + unsigned int uiChromaStride = CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); + ClpPel* pY; + ClpPel* pU; + ClpPel* pV; + int iY, iU, iV, iR, iG, iB; + unsigned int* pARGBLine = pARGB; + unsigned int* pARGB; - UInt y, x; - Int i, j; + unsigned int y, x; + int i, j; for( y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ ) { for( i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ ) @@ -1031,36 +763,36 @@ Void PlaYUVerFrame::fillRGBBuffer() * Histogram */ -Void PlaYUVerFrame::calcHistogram() +void CalypFrame::calcHistogram() { if( d->m_bHasHistogram || !d->m_puiHistogram ) return; d->m_bHistogramRunning = true; - xMemSet( UInt, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram ); + xMemSet( unsigned int, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram ); - UInt numberChannels = d->m_pcPelFormat->numberChannels; - for( UInt ch = 0; ch < numberChannels; ch++ ) + unsigned int numberChannels = d->m_pcPelFormat->numberChannels; + for( unsigned int ch = 0; ch < numberChannels; ch++ ) { - UInt size = CHROMASHIFT( d->m_uiWidth, ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0 ) * - CHROMASHIFT( d->m_uiHeight, ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0 ); + unsigned int size = CHROMASHIFT( d->m_uiWidth, ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0 ) * + CHROMASHIFT( d->m_uiHeight, ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0 ); - Pel* chPel = &( d->m_pppcInputPel[ch][0][0] ); - for( UInt i = 0; i < size; i++ ) + ClpPel* chPel = &( d->m_pppcInputPel[ch][0][0] ); + for( unsigned int i = 0; i < size; i++ ) { d->m_puiHistogram[*chPel + ch * d->m_uiHistoSegments]++; chPel++; } } - if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB || - d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA ) + if( d->m_pcPelFormat->colorSpace == CLP_COLOR_RGB || + d->m_pcPelFormat->colorSpace == CLP_COLOR_RGBA ) { - for( UInt y = 0; y < d->m_uiHeight; y++ ) - for( UInt x = 0; x < d->m_uiWidth; x++ ) + for( unsigned int y = 0; y < d->m_uiHeight; y++ ) + for( unsigned int x = 0; x < d->m_uiWidth; x++ ) { - Pel luma = getPixel( x, y ).ConvertPixel( PlaYUVerPixel::COLOR_YUV ).Y(); + ClpPel luma = getPixel( x, y ).convertPixel( CLP_COLOR_YUV )[0]; d->m_puiHistogram[luma + ( d->m_uiHistoChannels - 1 ) * d->m_uiHistoSegments]++; } } @@ -1068,12 +800,12 @@ Void PlaYUVerFrame::calcHistogram() d->m_bHistogramRunning = false; } -Int PlaYUVerFrame::getNumHistogramSegment() +int CalypFrame::getNumHistogramSegment() { return d->m_uiHistoSegments; } -UInt PlaYUVerFrame::getMinimumPelValue( Int channel ) +unsigned int CalypFrame::getMinimumPelValue( int channel ) { if( !d->m_bHasHistogram ) return 0; @@ -1082,8 +814,8 @@ UInt PlaYUVerFrame::getMinimumPelValue( Int channel ) if( channel < 0 ) return 0; - Int indexStart; - Int indexEnd; + int indexStart; + int indexEnd; if( channel == HIST_ALL_CHANNELS ) { indexStart = 0; @@ -1095,7 +827,7 @@ UInt PlaYUVerFrame::getMinimumPelValue( Int channel ) indexEnd = indexStart + d->m_uiHistoSegments; } - for( Int i = indexStart; i < indexEnd; i++ ) + for( int i = indexStart; i < indexEnd; i++ ) { if( d->m_puiHistogram[i] > 0 ) { @@ -1105,7 +837,7 @@ UInt PlaYUVerFrame::getMinimumPelValue( Int channel ) return 0; } -UInt PlaYUVerFrame::getMaximumPelValue( Int channel ) +unsigned int CalypFrame::getMaximumPelValue( int channel ) { if( !d->m_bHasHistogram ) return 0; @@ -1114,8 +846,8 @@ UInt PlaYUVerFrame::getMaximumPelValue( Int channel ) if( channel < 0 ) return 0; - Int indexStart; - Int indexEnd; + int indexStart; + int indexEnd; if( channel == HIST_ALL_CHANNELS ) { indexStart = d->m_uiHistoChannels * d->m_uiHistoSegments; @@ -1127,7 +859,7 @@ UInt PlaYUVerFrame::getMaximumPelValue( Int channel ) indexEnd = indexStart - d->m_uiHistoSegments; } - for( Int i = indexStart; i > indexEnd; i-- ) + for( int i = indexStart; i > indexEnd; i-- ) { if( d->m_puiHistogram[i] > 0 ) { @@ -1137,7 +869,7 @@ UInt PlaYUVerFrame::getMaximumPelValue( Int channel ) return 0; } -UInt PlaYUVerFrame::getMaximum( Int channel ) +unsigned int CalypFrame::getMaximum( int channel ) { if( !d->m_bHasHistogram ) return 0; @@ -1146,9 +878,9 @@ UInt PlaYUVerFrame::getMaximum( Int channel ) if( channel < 0 ) return 0; - UInt maxValue = 0; - Int indexStart; - Int indexEnd; + unsigned int maxValue = 0; + int indexStart; + int indexEnd; if( channel == HIST_ALL_CHANNELS ) { indexStart = 0; @@ -1160,7 +892,7 @@ UInt PlaYUVerFrame::getMaximum( Int channel ) indexEnd = indexStart + d->m_uiHistoSegments; } - for( Int x = indexStart; x < indexEnd; x++ ) + for( int x = indexStart; x < indexEnd; x++ ) { if( d->m_puiHistogram[x] > maxValue ) { @@ -1170,7 +902,7 @@ UInt PlaYUVerFrame::getMaximum( Int channel ) return maxValue; } -UInt PlaYUVerFrame::getNumPixelsRange( Int channel, UInt start, UInt end ) +unsigned int CalypFrame::getNumPixelsRange( int channel, unsigned int start, unsigned int end ) { if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) { @@ -1182,17 +914,17 @@ UInt PlaYUVerFrame::getNumPixelsRange( Int channel, UInt start, UInt end ) return 0; } - UInt count = 0; - Int indexStart; + unsigned int count = 0; + int indexStart; indexStart = channel * d->m_uiHistoSegments; - for( UInt i = start; i <= end; i++ ) + for( unsigned int i = start; i <= end; i++ ) { count += d->m_puiHistogram[indexStart + i]; } return count; } -Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end ) +double CalypFrame::getMean( int channel, unsigned int start, unsigned int end ) { if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) { @@ -1204,10 +936,10 @@ Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end ) return 0.0; } - Double mean = 0.0; - Double count; - Int indexStart = channel * d->m_uiHistoSegments; - for( UInt i = start; i <= end; i++ ) + double mean = 0.0; + double count; + int indexStart = channel * d->m_uiHistoSegments; + for( unsigned int i = start; i <= end; i++ ) { mean += i * d->m_puiHistogram[indexStart + i]; } @@ -1222,7 +954,7 @@ Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end ) return mean; } -Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end ) +int CalypFrame::getMedian( int channel, unsigned int start, unsigned int end ) { if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) { @@ -1235,10 +967,10 @@ Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end ) return 0; } - Double sum = 0.0; - Int indexStart = channel * d->m_uiHistoSegments; - Double count = getNumPixelsRange( channel, start, end ); - for( UInt i = start; i <= end; i++ ) + double sum = 0.0; + int indexStart = channel * d->m_uiHistoSegments; + double count = getNumPixelsRange( channel, start, end ); + for( unsigned int i = start; i <= end; i++ ) { sum += d->m_puiHistogram[indexStart + i]; if( sum * 2 > count ) @@ -1248,7 +980,7 @@ Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end ) return 0; } -Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end ) +double CalypFrame::getStdDev( int channel, unsigned int start, unsigned int end ) { if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) { @@ -1261,10 +993,10 @@ Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end ) return 0.0; } - Int indexStart = channel * d->m_uiHistoSegments; - Double mean = getMean( channel, start, end ); - Double count = getNumPixelsRange( channel, start, end ); - Double dev = 0.0; + int indexStart = channel * d->m_uiHistoSegments; + double mean = getMean( channel, start, end ); + double count = getNumPixelsRange( channel, start, end ); + double dev = 0.0; if( count == 0.0 ) count = 1.0; @@ -1279,7 +1011,7 @@ Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end ) -----------------------*/ - for( UInt i = start; i <= end; i++ ) + for( unsigned int i = start; i <= end; i++ ) { dev += ( i * i ) * d->m_puiHistogram[indexStart + i]; } @@ -1287,7 +1019,7 @@ Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end ) return sqrt( ( dev - count * mean * mean ) / ( count - 1 ) ); } -Double PlaYUVerFrame::getHistogramValue( Int channel, UInt bin ) +double CalypFrame::getHistogramValue( int channel, unsigned int bin ) { if( !d->m_bHasHistogram || bin < 0 || bin > d->m_uiHistoSegments - 1 ) return 0.0; @@ -1298,34 +1030,34 @@ Double PlaYUVerFrame::getHistogramValue( Int channel, UInt bin ) return 0; } - Int indexStart = channel * d->m_uiHistoSegments; + int indexStart = channel * d->m_uiHistoSegments; return d->m_puiHistogram[indexStart + bin]; } /* ************************************************************** - * Interface to other libs + * interface to other libs ************************************************************** */ -Bool PlaYUVerFrame::toMat( cv::Mat& cvMat, Bool convertToGray ) +bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray ) { - Bool bRet = false; + bool bRet = false; #ifdef USE_OPENCV - if( convertToGray && !( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV || - d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) ) + if( convertToGray && !( d->m_pcPelFormat->colorSpace == CLP_COLOR_YUV || + d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY ) ) { return bRet; } - Int cvType = CV_MAKETYPE( CV_8U, convertToGray ? 1 : d->m_pcPelFormat->numberChannels ); + int cvType = CV_MAKETYPE( CV_8U, convertToGray ? 1 : d->m_pcPelFormat->numberChannels ); cvMat.create( d->m_uiHeight, d->m_uiWidth, cvType ); - UChar* pCvPel = cvMat.data; - if( !convertToGray && ( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV || - d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ) ) + unsigned char* pCvPel = cvMat.data; + if( !convertToGray && ( d->m_pcPelFormat->colorSpace == CLP_COLOR_YUV || + d->m_pcPelFormat->colorSpace == CLP_COLOR_RGB ) ) { fillRGBBuffer(); - UChar* pARGB = d->m_pcARGB32; - for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) + unsigned char* pARGB = d->m_pcARGB32; + for( unsigned int i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) { *pCvPel++ = *pARGB++; *pCvPel++ = *pARGB++; @@ -1334,10 +1066,10 @@ Bool PlaYUVerFrame::toMat( cv::Mat& cvMat, Bool convertToGray ) } bRet = true; } - else if( convertToGray || d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_GRAY ) + else if( convertToGray || d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY ) { - Pel* pPel = d->m_pppcInputPel[LUMA][0]; - for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) + ClpPel* pPel = d->m_pppcInputPel[CLP_LUMA][0]; + for( unsigned int i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) { *pCvPel++ = *pPel++; } @@ -1351,13 +1083,13 @@ Bool PlaYUVerFrame::toMat( cv::Mat& cvMat, Bool convertToGray ) return bRet; } -Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat ) +bool CalypFrame::fromMat( cv::Mat& cvMat ) { - Bool bRet = false; + bool bRet = false; #ifdef USE_OPENCV if( !d->m_bInit ) { - if( d->m_iPixelFormat == NO_FMT ) + if( d->m_iPixelFormat == CLP_INVALID_FMT ) { switch( cvMat.channels() ) { @@ -1377,13 +1109,13 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat ) d->m_bHasRGBPel = false; d->m_bHasHistogram = false; - UChar* pCvPel = cvMat.data; - if( d->m_iPixelFormat != GRAY ) + unsigned char* pCvPel = cvMat.data; + if( d->m_iPixelFormat != CLP_GRAY ) { - Pel* pInputPelR = d->m_pppcInputPel[COLOR_R][0]; - Pel* pInputPelG = d->m_pppcInputPel[COLOR_G][0]; - Pel* pInputPelB = d->m_pppcInputPel[COLOR_B][0]; - for( UInt i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) + ClpPel* pInputPelR = d->m_pppcInputPel[CLP_COLOR_R][0]; + ClpPel* pInputPelG = d->m_pppcInputPel[CLP_COLOR_G][0]; + ClpPel* pInputPelB = d->m_pppcInputPel[CLP_COLOR_B][0]; + for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) { *pInputPelB++ = *pCvPel++; *pInputPelG++ = *pCvPel++; @@ -1393,8 +1125,8 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat ) } else { - Pel* pPel = d->m_pppcInputPel[LUMA][0]; - for( UInt i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) + ClpPel* pPel = d->m_pppcInputPel[CLP_LUMA][0]; + for( unsigned int i = 0; i < d->m_uiWidth * d->m_uiHeight; i++ ) { *pPel++ = *pCvPel++; } @@ -1410,16 +1142,16 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat ) ************************************************************** */ -std::vector PlaYUVerFrame::supportedQualityMetricsList() +std::vector CalypFrame::supportedQualityMetricsList() { - return std::vector{ + return std::vector{ "PSNR", "MSE", "SSIM", }; } -Double PlaYUVerFrame::getQuality( Int Metric, PlaYUVerFrame* Org, Int component ) +double CalypFrame::getQuality( int Metric, CalypFrame* Org, int component ) { switch( Metric ) { @@ -1438,17 +1170,17 @@ Double PlaYUVerFrame::getQuality( Int Metric, PlaYUVerFrame* Org, Int component return 0; } -Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) +double CalypFrame::getMSE( CalypFrame* Org, int component ) { - Pel* pPelYUV = getPelBufferYUV()[component][0]; - Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; + ClpPel* pPelYUV = getPelBufferYUV()[component][0]; + ClpPel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; - Int aux_pel_1, aux_pel_2; - Int diff = 0; - Double ssd = 0; + int aux_pel_1, aux_pel_2; + int diff = 0; + double ssd = 0; - UInt numberOfPixels = 0; - if( component == LUMA ) + unsigned int numberOfPixels = 0; + if( component == CLP_LUMA ) { numberOfPixels = Org->getHeight() * Org->getWidth(); } @@ -1457,33 +1189,33 @@ Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) numberOfPixels = getChromaLength(); } - for( UInt i = 0; i < numberOfPixels; i++ ) + for( unsigned int i = 0; i < numberOfPixels; i++ ) { aux_pel_1 = *pPelYUV++; aux_pel_2 = *pOrgPelYUV++; diff = aux_pel_1 - aux_pel_2; - ssd += ( Double )( diff * diff ); + ssd += (double)( diff * diff ); } if( ssd == 0.0 ) { return 0.0; } - return ssd / Double( numberOfPixels ); + return ssd / double( numberOfPixels ); } -Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) +double CalypFrame::getPSNR( CalypFrame* Org, int component ) { - UInt uiMaxValue = ( 1 << Org->getBitsPel() ) - 1; - Double uiMaxValueSquare = uiMaxValue * uiMaxValue; - Double dPSNR = 100; - Double dMSE = getMSE( Org, component ); + unsigned int uiMaxValue = ( 1 << Org->getBitsPel() ) - 1; + double uiMaxValueSquare = uiMaxValue * uiMaxValue; + double dPSNR = 100; + double dMSE = getMSE( Org, component ); if( dMSE != 0 ) dPSNR = 10 * log10( uiMaxValueSquare / dMSE ); return dPSNR; } -float compute_ssim( Pel** refImg, Pel** encImg, Int width, Int height, Int win_width, Int win_height, - Int max_pel_value_comp, Int overlapSize ) +float compute_ssim( ClpPel** refImg, ClpPel** encImg, int width, int height, int win_width, int win_height, + int max_pel_value_comp, int overlapSize ) { static const float K1 = 0.01f, K2 = 0.03f; float max_pix_value_sqd; @@ -1549,10 +1281,10 @@ float compute_ssim( Pel** refImg, Pel** encImg, Int width, Int height, Int win_w return cur_distortion; } -Double PlaYUVerFrame::getSSIM( PlaYUVerFrame* Org, Int component ) +double CalypFrame::getSSIM( CalypFrame* Org, int component ) { - Double dSSIM = 1; - if( component == LUMA ) + double dSSIM = 1; + if( component == CLP_LUMA ) { dSSIM = compute_ssim( d->m_pppcInputPel[component], Org->getPelBufferYUV()[component], d->m_uiWidth, d->m_uiHeight, 8, 8, 255, 8 ); diff --git a/lib/CalypFrame.h b/lib/CalypFrame.h new file mode 100644 index 0000000..0a33367 --- /dev/null +++ b/lib/CalypFrame.h @@ -0,0 +1,371 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypFrame.h + * \ingroup CalypFrameGrp + * \brief Video Frame handling + */ + +#ifndef __CALYPFRAME_H__ +#define __CALYPFRAME_H__ + +#include "CalypDefs.h" + +namespace cv +{ +class Mat; +} + +#define CHROMASHIFT( SIZE, SHIFT ) (unsigned int)( -( ( -( (int)( SIZE ) ) ) >> ( SHIFT ) ) ) + +/** + * \class CalypPixel + * \ingroup CalypLibGrp CalypFrameGrp + * \brief Pixel handling class + */ +class CalypPixel +{ +public: + static int getMaxNumberOfComponents(); + + CalypPixel( const int& CalypColorSpace = CLP_COLOR_INVALID ); + CalypPixel( const int& CalypColorSpace, const ClpPel& c0 ); + CalypPixel( const int& CalypColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2 ); + CalypPixel( const int& CalypColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2, const ClpPel& c3 ); + CalypPixel( const CalypPixel& other ); + ~CalypPixel(); + + int colorSpace() const; + + ClpPel operator[]( const int& channel ) const; + ClpPel& operator[]( const int& channel ); + + CalypPixel operator=( const CalypPixel& ); + CalypPixel operator+( const CalypPixel& ); + CalypPixel operator+=( const CalypPixel& ); + CalypPixel operator-( const CalypPixel& ); + CalypPixel operator-=( const CalypPixel& ); + CalypPixel operator*( const double& ); + + /** + * Convert a Pixel to a new color space + * @param inputPixel input pixel (CalypPixel) + * @param eOutputSpace output color space + * @return converted pixel + */ + CalypPixel convertPixel( CalypColorSpace eOutputSpace ); + +private: + struct CalypPixelPrivate* d; +}; + +/** + * \class CalypFrame + * \ingroup CalypLibGrp CalypFrameGrp + * \brief Frame handling class + */ +class CalypFrame +{ +public: + /** + * Function that handles the supported color space + * of CalypFrame + * @return vector of strings with pixel formats names + */ + static std::vector supportedColorSpacesListNames(); + + /** + * Function that handles the supported pixel formats + * of CalypFrame + * @return vector of strings with pixel formats names + */ + static std::vector supportedPixelFormatListNames(); + static std::vector supportedPixelFormatListNames( int colorSpace ); + static int numberOfFormats(); + static int findPixelFormat( const ClpString& name ); + + /** + * Creates a new frame using the following configuration + * + * @param width width of the frame + * @param height height of the frame + * @param pel_format pixel format index (always use PixelFormats enum) + * + * @note this function might misbehave if the pixel format enum is not correct + */ + CalypFrame( unsigned int width, unsigned int height, int pelFormat, int bitsPixel = 8 ); + + /** + * Copy contructor + * + * @param other existing frame to copy from + */ + CalypFrame( const CalypFrame& other ); + CalypFrame( const CalypFrame* other ); + + /** + * Creates and new frame with the configuration of an existing one and copy + * its contents. This function only copies a specific region from the existing + * frame + * + * @param other existing frame to copy from + * @param posX position X to crop from + * @param posY position Y to crop from + * @param areaWidth crop width + * @param areaHeight crop height + */ + CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height ); + CalypFrame( const CalypFrame* other, unsigned int x, unsigned int y, unsigned int width, unsigned int height ); + + ~CalypFrame(); + + /** Format match opts + */ + enum FormatMatching + { + MATCH_COLOR_SPACE = 1, + MATCH_RESOLUTION = 2, + MATCH_PEL_FMT = 4, + MATCH_BITS = 8, + MATCH_COLOR_SPACE_IGNORE_GRAY = 16, + MATCH_ALL = 0xFFFF, + }; + + /** + * Check if two CalypFrames have the same fmt + * @param other frame to compare with + * @param match matching conditions (use enum FormatMatching) + * @return true if format matches + */ + bool haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const; + bool haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const; + + /** + * Get pixel format information + * @return pixel format index + */ + int getPelFormat() const; + + /** + * Get pixel format information + * @return pixel format name + */ + ClpString getPelFmtName(); + + /** + * Get color space information + * @return get color space index + */ + int getColorSpace() const; + + /** + * Get the number of channels + * @return number of channels + */ + unsigned int getNumberChannels() const; + + /** + * Get width of the frame + * @param channel/component + * @return number of pixels + */ + unsigned int getWidth( int channel = 0 ) const; + + /** + * Get height of the frame + * @param channel/component + * @return number of pixels + */ + unsigned int getHeight( int channel = 0 ) const; + + /** + * Get number of pixels of the frame + * @param channel/component + * @return number of pixels + */ + unsigned int getPixels( int channel = 0 ) const; + + /** + * Get chroma width ratio + * @return ratio multiple of 2 + */ + unsigned char getChromaWidthRatio() const; + + /** + * Get chroma height ratio + * @return ratio multiple of 2 + */ + unsigned char getChromaHeightRatio() const; + + /** + * Get number of pixels in each chroma channel + * @return number of pixels + */ + unsigned int getChromaLength() const; + + /** + * Get number of bits per pixel + * @return number of bits + */ + unsigned int getBitsPel() const; + + /** + * Get number of bytes per frame of an existing frame + * @return number of bytes per frame + */ + unsigned long getBytesPerFrame(); + + /** + * Get number of bytes per frame of a specific pixel format + * @return number of bytes per frame + */ + static unsigned long getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel ); + + /** + * Reset frame pixels to zero + */ + void reset(); + + ClpPel*** getPelBufferYUV() const; + ClpPel*** getPelBufferYUV(); + + unsigned char* getRGBBuffer() const; + + /** + * Get pixel value at coordinates + * @param ch frame channel + * @param xPos position in X axis + * @param yPos position in Y axis + * @return pixel value + */ + ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos ); + + /** + * Get pixel value at coordinates + * @param xPos position in X axis + * @param yPos position in Y axis + * @return pixel value + */ + CalypPixel operator()( unsigned int xPos, unsigned int yPos ); + + /** + * Get pixel value at coordinates + * @param xPos position in X axis + * @param yPos position in Y axis + * @return pixel value + */ + CalypPixel getPixel( unsigned int xPos, unsigned int yPos ); + + /** + * Get pixel value at coordinates + * in the desired color space + * @param xPos position in X axis + * @param yPos position in Y axis + * @param eColorSpace desired color space + * @return pixel value + */ + CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ); + + /** + * Set pixel value at coordinates to a given value + * @param xPos position in X axis + * @param yPos position in Y axis + */ + void setPixel( unsigned int xPos, unsigned int yPos, CalypPixel pixel ); + + void copyFrom( const CalypFrame& ); + void copyFrom( const CalypFrame* ); + void copyFrom( const CalypFrame&, unsigned int, unsigned int ); + void copyFrom( const CalypFrame*, unsigned int, unsigned int ); + + void frameFromBuffer( ClpByte*, int, unsigned long ); + void frameFromBuffer( ClpByte*, int ); + void frameToBuffer( ClpByte*, int ); + + void fillRGBBuffer(); + + /** + * Histogram + */ + enum HistogramChannels + { + HIST_CHAN_ONE = 0, + HIST_CHAN_TWO, + HIST_CHAN_THREE, + HIST_CHAN_FOUR, + HIST_LUMA = 10, + HIST_CHROMA_U, + HIST_CHROMA_V, + HIST_COLOR_R = 20, + HIST_COLOR_G, + HIST_COLOR_B, + HIST_COLOR_A, + HIST_ALL_CHANNELS = 254, + HISTOGRAM_MAX = 255, + }; + void calcHistogram(); + + unsigned int getMinimumPelValue( int channel ); + unsigned int getMaximumPelValue( int channel ); + + unsigned int getMaximum( int channel ); + unsigned int getNumPixelsRange( int channel, unsigned int start, unsigned int end ); + double getMean( int channel, unsigned int start, unsigned int end ); + int getMedian( int channel, unsigned int start, unsigned int end ); + double getStdDev( int channel, unsigned int start, unsigned int end ); + double getHistogramValue( int channel, unsigned int bin ); + int getNumHistogramSegment(); + + /** + * interface with OpenCV lib + */ + bool toMat( cv::Mat& cvMat, bool convertToGray = false ); + bool fromMat( cv::Mat& cvMat ); + + /** + * \ingroup CalypFrameGrp + * @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface + * @{ + * Quality metrics interface + * + */ + + enum QualityMetrics + { + NO_METRIC = -1, + PSNR_METRIC = 0, + MSE_METRIC, + SSIM_METRIC, + NUMBER_METRICS, + }; + + static std::vector supportedQualityMetricsList(); + double getQuality( int Metric, CalypFrame* Org, int component ); + double getMSE( CalypFrame* Org, int component ); + double getPSNR( CalypFrame* Org, int component ); + double getSSIM( CalypFrame* Org, int component ); + + /** @} */ + +private: + struct CalypFramePrivate* d; +}; + +#endif // __CALYPFRAME_H__ diff --git a/lib/PlaYUVerLib.h b/lib/CalypLib.h similarity index 65% rename from lib/PlaYUVerLib.h rename to lib/CalypLib.h index 8a0fba6..aff0414 100644 --- a/lib/PlaYUVerLib.h +++ b/lib/CalypLib.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,42 +18,42 @@ */ /** - * \file PlaYUVerLib.h - * \brief Inlcude all modules of PlaYUVer Lib + * \file CalypLib.h + * \brief Inlcude all modules of Calyp Lib */ -#ifndef __PLAYUVERLIB_H_ -#define __PLAYUVERLIB_H_ +#ifndef __CALYPLIB_H_ +#define __CALYPLIB_H_ /** - * @defgroup PlaYUVerLib PlaYUVer Lib + * @defgroup CalypLibGrp Calyp Lib * @{ * - * PlaYUVerLib is an independent module that provide the low level interface + * CalypLib is an independent module that provide the low level interface * for dealing with streams and frames. * - * Two main interfaces are defining PlaYUVerFrame and PlaYUVerStream. + * Two main interfaces are defining CalypFrame and CalypStream. * Moreover handler for external libs, as FFmpeg and OpenCv are provided - * which enables PlaYUVer to boost its functionality using external libs. + * which enables Calyp to boost its functionality using external libs. * * This guaratees that the top-level applications does not need to worry * about dealig with different stream formats as well as different pixel formats * - * @defgroup PlaYUVerLibFrame PlaYUVer Frame + * @defgroup CalypFrameGrp Calyp Frame * @{ - * Describe PlaYUVerFrame + * Describe Calyp Frame format * @} * - * @defgroup PlaYUVerLibStream PlaYUVer Stream + * @defgroup CalypStreamGrp Calyp Stream * @{ - * Describe PlaYUVerStream + * Describe Calyp Stream format * @} * * @} * */ -#include "PlaYUVerFrame.h" -#include "PlaYUVerStream.h" +#include "CalypFrame.h" +#include "CalypStream.h" -#endif // __PLAYUVERLIB_H_ +#endif // __CALYPLIB_H_ diff --git a/lib/CalypModuleIf.h b/lib/CalypModuleIf.h new file mode 100644 index 0000000..5338655 --- /dev/null +++ b/lib/CalypModuleIf.h @@ -0,0 +1,152 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypModuleIf.h + * \ingroup CalypLibGrp + * \brief Calyp modules interface + */ + +#ifndef __CALYPMODULESIF_H__ +#define __CALYPMODULESIF_H__ + +/** + * @defgroup Calyp_Modules Calyp Modules + * @{ + * CalypLib supports the creation of independent + * frame processing modules + * @} + */ + +#include "CalypFrame.h" +#include "CalypOptions.h" + +#define REGISTER_CLASS_MAKER( X ) \ + extern "C" CalypModuleIf* Maker() { return new X; } +#define REGISTER_CLASS_FACTORY( X ) \ +public: \ + static CalypModuleIf* Create() { return new X(); } \ + void Delete() { delete this; } +#define _BASIC_MODULE_API_2_CHECK_ \ + if( apcFrameList.size() != m_uiNumberOfFrames ) \ + return false; \ + for( unsigned int i = 0; i < apcFrameList.size(); i++ ) \ + if( !apcFrameList[i] ) \ + return false; + +/** Module_API_Version Enum + * \ingroup Calyp_Modules + * Version of the modules API required + * @see m_iModuleAPI + */ +enum Module_API_Version +{ + CLP_MODULE_API_1, + CLP_MODULE_API_2, +}; + +/** Module_Type Enum + * \ingroup Calyp_Modules + * Type of module + * @see m_iModuleType + */ +enum Module_Type +{ + CLP_FRAME_PROCESSING_MODULE, + CLP_FRAME_MEASUREMENT_MODULE, + CLP_MODULE_TYPE_MAX = 255, +}; + +/** Module_Features Enum + * \ingroup Calyp_Modules + * Features/Requirements of a module + * @see m_uiModuleRequirements + */ +enum Module_Features +{ + CLP_MODULE_REQUIRES_NOTHING = 0, + CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY = 1, + CLP_MODULE_REQUIRES_OPTIONS = 2, + CLP_MODULE_REQUIRES_NEW_WINDOW = 4, + CLP_MODULE_USES_KEYS = 8, + CLP_MODULES_VARIABLE_NUM_FRAMES = 16, + CLP_MODULE_REQURES_MAX = 1024, +}; + +enum Module_Key_Supported +{ + MODULE_KEY_LEFT, + MODULE_KEY_RIGHT, + MODULE_KEY_UP, + MODULE_KEY_DOWN, +}; + +/** + * \class CalypModuleIf + * \ingroup CalypLib Calyp_Modules + * \brief Abstract class for modules + */ +class CalypModuleIf +{ +public: + int m_iModuleAPI; + int m_iModuleType; + const char* m_pchModuleCategory; + const char* m_pchModuleName; + const char* m_pchModuleTooltip; + const char* m_pchModuleLongName; + + //! Number of frames + unsigned int m_uiNumberOfFrames; + //! Features/Requirements + unsigned int m_uiModuleRequirements; + + CalypOptions m_cModuleOptions; + + CalypModuleIf() + { + m_iModuleAPI = CLP_MODULE_API_1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; + m_pchModuleLongName = NULL; + } + virtual ~CalypModuleIf() {} + virtual void Delete() = 0; + virtual void destroy() = 0; + + const char* getModuleLongName() + { + return m_pchModuleLongName ? m_pchModuleLongName : m_pchModuleName; + } + + /** + * Module API version 1 + */ + virtual void create( CalypFrame* ) {} + virtual CalypFrame* process( CalypFrame* ) { return NULL; } + virtual double measure( CalypFrame* ) { return 0; } + /** + * Module API version 2 + */ + virtual bool create( std::vector apcFrameList ) { return false; } + virtual CalypFrame* process( std::vector ) { return NULL; } + virtual double measure( std::vector ) { return 0; } + virtual bool keyPressed( enum Module_Key_Supported ) { return false; } +}; + +#endif // __CALYPMODULESIF_H__ diff --git a/lib/PlaYUVerOptions.cpp b/lib/CalypOptions.cpp similarity index 71% rename from lib/PlaYUVerOptions.cpp rename to lib/CalypOptions.cpp index 22f1d3d..125cd51 100644 --- a/lib/PlaYUVerOptions.cpp +++ b/lib/CalypOptions.cpp @@ -32,14 +32,14 @@ */ /** - * \file PlaYUVerOptions.cpp + * \file CalypOptions.cpp * \brief Options handler */ -#include "PlaYUVerOptions.h" +#include "CalypOptions.h" #include "config.h" -#include "lib/PlaYUVerModuleIf.h" +#include "lib/CalypModuleIf.h" #include #include @@ -49,21 +49,21 @@ using namespace std; struct ParseFailure : public std::exception { - String arg; - String val; - ParseFailure( String arg0, String val0 ) throw() + ClpString arg; + ClpString val; + ParseFailure( ClpString arg0, ClpString val0 ) throw() : arg( arg0 ), val( val0 ) {} ~ParseFailure() throw() {} - const Char* what() const throw() { return "Option Parse Failure"; } + const char* what() const throw() { return "Option Parse Failure"; } }; /** Type specific option storage */ -class BoolOption : public OptionBase +class boolOption : public OptionBase { public: - BoolOption( const String& name, const String& desc ) + boolOption( const ClpString& name, const ClpString& desc ) : OptionBase( name, desc ) { is_binary = true; } - void parse( const String& arg ) { arg_count++; } + void parse( const ClpString& arg ) { arg_count++; } }; /** Type specific option storage */ @@ -71,20 +71,20 @@ template class StandardOption : public OptionBase { public: - StandardOption( const String& name, T& storage, const String& desc ) + StandardOption( const ClpString& name, T& storage, const ClpString& desc ) : OptionBase( name, desc ), opt_storage( storage ) { is_binary = false; } - void parse( const String& arg ); + void parse( const ClpString& arg ); T& opt_storage; std::vector opt_storage_array; }; /* Generic parsing */ template -inline void StandardOption::parse( const String& arg ) +inline void StandardOption::parse( const ClpString& arg ) { if( !is_binary ) { @@ -103,9 +103,9 @@ inline void StandardOption::parse( const String& arg ) } template <> -inline void StandardOption>::parse( const String& arg ) +inline void StandardOption>::parse( const ClpString& arg ) { - UInt aux_opt_storage; + unsigned int aux_opt_storage; std::istringstream arg_ss( arg, std::istringstream::in ); arg_ss.exceptions( std::ios::failbit ); try @@ -121,9 +121,9 @@ inline void StandardOption>::parse( const String& arg ) } template <> -inline void StandardOption>::parse( const String& arg ) +inline void StandardOption>::parse( const ClpString& arg ) { - Int aux_opt_storage; + int aux_opt_storage; std::istringstream arg_ss( arg, std::istringstream::in ); arg_ss.exceptions( std::ios::failbit ); try @@ -140,7 +140,7 @@ inline void StandardOption>::parse( const String& arg ) /* string parsing is specialized */ template <> -inline void StandardOption::parse( const String& arg ) +inline void StandardOption::parse( const ClpString& arg ) { opt_storage = arg; arg_count++; @@ -148,7 +148,7 @@ inline void StandardOption::parse( const String& arg ) /* string vector parsing is specialized */ template <> -inline void StandardOption>::parse( const String& arg ) +inline void StandardOption>::parse( const ClpString& arg ) { opt_storage.push_back( arg ); arg_count++; @@ -158,23 +158,23 @@ inline void StandardOption>::parse( const String& arg ) struct FunctionOption : public OptionBase { public: - typedef Void( Func )( PlaYUVerOptions&, const String& ); + typedef void( Func )( CalypOptions&, const ClpString& ); - FunctionOption( const String& name, PlaYUVerOptions& parent_, Func* func_, const String& desc ) + FunctionOption( const ClpString& name, CalypOptions& parent_, Func* func_, const ClpString& desc ) : OptionBase( name, desc ), parent( parent_ ), func( func_ ) { is_binary = false; } - void parse( const String& arg ) + void parse( const ClpString& arg ) { func( parent, arg ); arg_count++; } private: - PlaYUVerOptions& parent; - void ( *func )( PlaYUVerOptions&, const String& ); + CalypOptions& parent; + void ( *func )( CalypOptions&, const ClpString& ); }; /* Helper method to initiate adding options to Options */ @@ -185,9 +185,9 @@ private: * with default_val as the default value * with desc as an optional help description */ -PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, const String& desc ) +CalypOptions& CalypOptions::operator()( const ClpString& name, const ClpString& desc ) { - addOption( new BoolOption( name, desc ) ); + addOption( new boolOption( name, desc ) ); return *this; } @@ -197,60 +197,61 @@ PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, const String& * with desc as an optional help description */ template -PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, T& storage, const String& desc ) +CalypOptions& CalypOptions::operator()( const ClpString& name, T& storage, const ClpString& desc ) { addOption( new StandardOption( name, storage, desc ) ); return *this; } -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Bool& storage, const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, UInt& storage, const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int& storage, const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int64& storage, const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, String& storage, const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, - const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, - const String& desc ); -template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector& storage, - const String& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, bool& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, unsigned int& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, int& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, long& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, long long int& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, ClpString& storage, const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector& storage, + const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector& storage, + const ClpString& desc ); +template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector& storage, + const ClpString& desc ); -PlaYUVerOptions::Option::Option() +CalypOptions::Option::Option() : opt( 0 ) {} -PlaYUVerOptions::Option::~Option() +CalypOptions::Option::~Option() { if( opt ) delete opt; } -PlaYUVerOptions::PlaYUVerOptions( const String& name ) +CalypOptions::CalypOptions( const ClpString& name ) { m_cOptionGroupName = name; m_bAllowUnkonw = true; } -PlaYUVerOptions::~PlaYUVerOptions() +CalypOptions::~CalypOptions() { - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { delete *it; } } -OptionBase* PlaYUVerOptions::operator[]( const String& optName ) +OptionBase* CalypOptions::operator[]( const ClpString& optName ) { return getOption( optName ); } -OptionBase* PlaYUVerOptions::getOption( const String& optName ) +OptionBase* CalypOptions::getOption( const ClpString& optName ) { - PlaYUVerOptions::OptionMap::iterator opt_it; + CalypOptions::OptionMap::iterator opt_it; opt_it = opt_short_map.find( optName ); if( opt_it != opt_short_map.end() ) { OptionsList opt_list = ( *opt_it ).second; - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { return ( *it )->opt; } @@ -259,7 +260,7 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName ) if( opt_it != opt_long_map.end() ) { OptionsList opt_list = ( *opt_it ).second; - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { return ( *it )->opt; } @@ -267,13 +268,13 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName ) return NULL; } -Bool PlaYUVerOptions::hasOpt( const String& optName ) +bool CalypOptions::hasOpt( const ClpString& optName ) { OptionBase* opt = getOption( optName ); return opt ? opt->count() > 0 ? true : false : false; } -Void PlaYUVerOptions::addDefaultOptions() +void CalypOptions::addDefaultOptions() { addOptions() /**/ ( "help,h", "produce help message" ) /**/ @@ -284,12 +285,12 @@ Void PlaYUVerOptions::addDefaultOptions() ( "module_list_full", "detailed list supported modules" ); } -PlaYUVerOptions& PlaYUVerOptions::addOptions() +CalypOptions& CalypOptions::addOptions() { return *this; } -void PlaYUVerOptions::addOption( OptionBase* opt ) +void CalypOptions::addOption( OptionBase* opt ) { Option* names = new Option(); names->opt = opt; @@ -321,20 +322,20 @@ void PlaYUVerOptions::addOption( OptionBase* opt ) opt_list.push_back( names ); } -static void setOptions( PlaYUVerOptions::OptionsList& opt_list, const string& value ) +static void setOptions( CalypOptions::OptionsList& opt_list, const string& value ) { /* multiple options may be registered for the same name: * allow each to parse value */ - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { ( *it )->opt->parse( value ); } } -Bool PlaYUVerOptions::storePair( Bool allow_long, Bool allow_short, const string& name, const string& value ) +bool CalypOptions::storePair( bool allow_long, bool allow_short, const string& name, const string& value ) { bool found = false; - PlaYUVerOptions::OptionMap::iterator opt_it; + CalypOptions::OptionMap::iterator opt_it; if( allow_long ) { opt_it = opt_long_map.find( name ); @@ -368,7 +369,7 @@ Bool PlaYUVerOptions::storePair( Bool allow_long, Bool allow_short, const string return true; } -Bool PlaYUVerOptions::storePair( const string& name, const string& value ) +bool CalypOptions::storePair( const string& name, const string& value ) { return storePair( true, true, name, value ); } @@ -376,7 +377,7 @@ Bool PlaYUVerOptions::storePair( const string& name, const string& value ) /** * returns number of extra arguments consumed */ -UInt PlaYUVerOptions::parseLONG( UInt argc, Char* argv[] ) +unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] ) { /* gnu style long options can take the forms: * --option=arg @@ -387,7 +388,7 @@ UInt PlaYUVerOptions::parseLONG( UInt argc, Char* argv[] ) size_t arg_opt_sep = arg.find_first_of( '=' ); string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); - UInt extra_argc_consumed = 0; + unsigned int extra_argc_consumed = 0; if( arg_opt_sep == string::npos ) { /* no argument found => argument in argv[1] (maybe) */ @@ -417,7 +418,7 @@ UInt PlaYUVerOptions::parseLONG( UInt argc, Char* argv[] ) /** * returns number of extra arguments consumed */ -UInt PlaYUVerOptions::parseLONG( string arg ) +unsigned int CalypOptions::parseLONG( string arg ) { /* gnu style long options can take the forms: * --option=arg @@ -427,7 +428,7 @@ UInt PlaYUVerOptions::parseLONG( string arg ) size_t arg_opt_sep = arg.find_first_of( '=' ); string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); - UInt extra_argc_consumed = 0; + unsigned int extra_argc_consumed = 0; if( arg_opt_sep == string::npos ) { /* no argument found => argument in argv[1] (maybe) */ @@ -446,7 +447,7 @@ UInt PlaYUVerOptions::parseLONG( string arg ) return extra_argc_consumed; } -UInt PlaYUVerOptions::parseSHORT( UInt argc, Char* argv[] ) +unsigned int CalypOptions::parseSHORT( unsigned int argc, char* argv[] ) { /* short options can take the forms: * --option arg @@ -469,7 +470,7 @@ UInt PlaYUVerOptions::parseSHORT( UInt argc, Char* argv[] ) return 1; } -Bool PlaYUVerOptions::parse( UInt argc, Char* argv[] ) +bool CalypOptions::parse( unsigned int argc, char* argv[] ) { try { @@ -492,12 +493,12 @@ Bool PlaYUVerOptions::parse( UInt argc, Char* argv[] ) return true; } -list PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] ) +list CalypOptions::scanArgv( unsigned int argc, char* argv[] ) { /* a list for anything that didn't get handled as an option */ - list non_option_arguments; + list non_option_arguments; - for( UInt i = 1; i < argc; i++ ) + for( unsigned int i = 1; i < argc; i++ ) { if( argv[i][0] != '-' ) { @@ -538,9 +539,9 @@ list PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] ) return non_option_arguments; } -Void PlaYUVerOptions::parse( std::vector args_array ) +void CalypOptions::parse( std::vector args_array ) { - for( UInt i = 0; i < args_array.size(); i++ ) + for( unsigned int i = 0; i < args_array.size(); i++ ) { i += parseLONG( args_array[i] ); } @@ -553,13 +554,13 @@ static const char spaces[41] = " "; * using the formatting: "-x, --long", * if a short/long option isn't specified, it is not printed */ -static void doHelpOpt( ostream& out, const PlaYUVerOptions::Option& entry, UInt pad_short = 0 ) +static void doHelpOpt( ostream& out, const CalypOptions::Option& entry, unsigned int pad_short = 0 ) { pad_short = min( pad_short, 8u ); if( !entry.opt_short.empty() ) { - UInt pad = max( (int)pad_short - (int)entry.opt_short.front().size(), 0 ); + unsigned int pad = max( (int)pad_short - (int)entry.opt_short.front().size(), 0 ); out << "-" << entry.opt_short.front(); if( !entry.opt_long.empty() ) { @@ -580,27 +581,27 @@ static void doHelpOpt( ostream& out, const PlaYUVerOptions::Option& entry, UInt } /* format the help text */ -Void PlaYUVerOptions::doHelp( ostream& out, UInt columns ) +void CalypOptions::doHelp( ostream& out, unsigned int columns ) { - const UInt pad_short = 3; + const unsigned int pad_short = 3; /* first pass: work out the longest option name */ - UInt max_width = 0; - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) + unsigned int max_width = 0; + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { ostringstream line( ios_base::out ); doHelpOpt( line, **it, pad_short ); - max_width = max( max_width, (UInt)line.tellp() ); + max_width = max( max_width, (unsigned int)line.tellp() ); } - UInt opt_width = min( max_width + 2, 28u + pad_short ) + 2; - UInt desc_width = columns - opt_width; + unsigned int opt_width = min( max_width + 2, 28u + pad_short ) + 2; + unsigned int desc_width = columns - opt_width; /* second pass: write out formatted option and help text. * - align start of help text to start at opt_width * - if the option text is longer than opt_width, place the help * text at opt_width on the next line. */ - for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) + for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { ostringstream line( ios_base::out ); line << " "; @@ -677,30 +678,30 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns ) } } -Bool PlaYUVerOptions::checkListingOpts() +bool CalypOptions::checkListingOpts() { - Bool bRet = false; + bool bRet = false; if( hasOpt( "version" ) ) { - std::cout << "PlaYUVer version " << PLAYUVER_VERSION_STRING << "\n"; + std::cout << "Calyp version " << CALYP_VERSION_STRING << "\n"; bRet |= true; } if( hasOpt( "pel_fmts" ) ) { - printf( "PlaYUVer supported pixel formats: \n" ); - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + printf( "Calyp supported pixel formats: \n" ); + for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ ) { - printf( " %s\n", PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() ); + printf( " %s\n", CalypFrame::supportedPixelFormatListNames()[i].c_str() ); } bRet |= true; } if( hasOpt( "quality_metrics" ) ) { - printf( "PlaYUVer supported quality metrics: \n" ); - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + printf( "Calyp supported quality metrics: \n" ); + for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ ) { - printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); + printf( " %s\n", CalypFrame::supportedQualityMetricsList()[i].c_str() ); } bRet |= true; } diff --git a/lib/PlaYUVerOptions.h b/lib/CalypOptions.h similarity index 60% rename from lib/PlaYUVerOptions.h rename to lib/CalypOptions.h index bd7bf1b..1e20eaf 100644 --- a/lib/PlaYUVerOptions.h +++ b/lib/CalypOptions.h @@ -32,68 +32,77 @@ */ /** - * \file PlaYUVerOptions.h + * \file CalypOptions.h + * \ingroup CalypLibGrp * \brief Options handler */ -#ifndef __PROGRAMOPTIONS_H__ -#define __PROGRAMOPTIONS_H__ +#ifndef __CALYPOPTIONS_H__ +#define __CALYPOPTIONS_H__ -#include "PlaYUVerDefs.h" +#include "CalypDefs.h" #include #include -/** OptionBase: Virtual base class for storing information relating to a +/** + * \class OptionBase + * \ingroup CalypLibGrp + * \brief Virtual base class for storing information relating to a * specific option This base class describes common elements. * Type specific information should be stored in a derived class. */ class OptionBase { public: - OptionBase( const String& name, const String& desc ) + OptionBase( const ClpString& name, const ClpString& desc ) : arg_count( 0 ), opt_string( name ), opt_desc( desc ) {} virtual ~OptionBase() {} /* parse argument arg, to obtain a value for the option */ - virtual void parse( const String& arg ) = 0; - Int count() { return arg_count; } - Bool isBinary() { return is_binary; } + virtual void parse( const ClpString& arg ) = 0; + int count() { return arg_count; } + bool isBinary() { return is_binary; } int arg_count; - String opt_string; - String opt_desc; - Bool is_binary; + ClpString opt_string; + ClpString opt_desc; + bool is_binary; }; -class PlaYUVerOptions +/** + * \class CalypOptions + * \ingroup CalypLibGrp + * \brief Main class to store options + */ +class CalypOptions { public: struct Option { Option(); ~Option(); - std::list opt_long; - std::list opt_short; + std::list opt_long; + std::list opt_short; OptionBase* opt; }; typedef std::list OptionsList; - PlaYUVerOptions( const String& name = "" ); - ~PlaYUVerOptions(); + CalypOptions( const ClpString& name = "" ); + ~CalypOptions(); - Bool parse( UInt argc, Char* argv[] ); - Void parse( std::vector args_array ); + bool parse( unsigned int argc, char* argv[] ); + void parse( std::vector args_array ); - std::list& getUnhandledArgs() { return m_aUnhandledArgs; } - Void doHelp( std::ostream& out, unsigned columns = 80 ); + std::list& getUnhandledArgs() { return m_aUnhandledArgs; } + void doHelp( std::ostream& out, unsigned columns = 80 ); - OptionBase* operator[]( const String& optName ); - OptionBase* getOption( const String& optName ); + OptionBase* operator[]( const ClpString& optName ); + OptionBase* getOption( const ClpString& optName ); - Bool hasOpt( const String& optName ); + bool hasOpt( const ClpString& optName ); OptionsList getOptionList() { return opt_list; } - Void addDefaultOptions(); - PlaYUVerOptions& addOptions(); + void addDefaultOptions(); + CalypOptions& addOptions(); void addOption( OptionBase* opt ); /** @@ -102,7 +111,7 @@ public: * with default_val as the default value * with desc as an optional help description */ - PlaYUVerOptions& operator()( const String& name, const String& desc ); + CalypOptions& operator()( const ClpString& name, const ClpString& desc ); /** * Add option described by name to the parent Options list, @@ -111,27 +120,27 @@ public: * with desc as an optional help description */ template - PlaYUVerOptions& operator()( const String& name, T& storage, const String& desc ); + CalypOptions& operator()( const ClpString& name, T& storage, const ClpString& desc ); - Bool checkListingOpts(); + bool checkListingOpts(); private: - typedef std::map OptionMap; + typedef std::map OptionMap; OptionMap opt_long_map; OptionMap opt_short_map; OptionsList opt_list; - String m_cOptionGroupName; - Bool m_bAllowUnkonw; - std::list m_aUnhandledArgs; + ClpString m_cOptionGroupName; + bool m_bAllowUnkonw; + std::list m_aUnhandledArgs; - Bool storePair( Bool allow_long, Bool allow_short, const String& name, const String& value ); - Bool storePair( const String& name, const String& value ); - UInt parseLONG( UInt argc, Char* argv[] ); - UInt parseLONG( String arg ); - UInt parseSHORT( UInt argc, Char* argv[] ); - std::list scanArgv( UInt argc, Char* argv[] ); + bool storePair( bool allow_long, bool allow_short, const ClpString& name, const ClpString& value ); + bool storePair( const ClpString& name, const ClpString& value ); + unsigned int parseLONG( unsigned int argc, char* argv[] ); + unsigned int parseLONG( ClpString arg ); + unsigned int parseSHORT( unsigned int argc, char* argv[] ); + std::list scanArgv( unsigned int argc, char* argv[] ); }; -#endif // __PROGRAMOPTIONS_H__ +#endif // __CALYPOPTIONS_H__ diff --git a/lib/CalypPixel.cpp b/lib/CalypPixel.cpp new file mode 100644 index 0000000..c669409 --- /dev/null +++ b/lib/CalypPixel.cpp @@ -0,0 +1,226 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypFrame.cpp + * \brief Video Frame handling + */ + +#include "CalypFrame.h" + +#include "PixelFormats.h" +#include "config.h" + +#define MAX_NUMBER_COMPONENTS 4 + +struct CalypPixelPrivate +{ + CalypPixelPrivate( const int& ColorSpace ) + { + iColorSpace = ColorSpace == CLP_COLOR_GRAY ? + CLP_COLOR_YUV : + ColorSpace; + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + PelComp[i] = 0; + } + } + + int iColorSpace; + ClpPel PelComp[MAX_NUMBER_COMPONENTS]; +}; + +static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB ) +{ + iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ); + iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ); + iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ); + iR = iR < 0 ? 0 : iR > 255 ? 255 : iR; + iG = iG < 0 ? 0 : iG > 255 ? 255 : iG; + iB = iB < 0 ? 0 : iB > 255 ? 255 : iB; +} + +static inline void rgbToYuv( const int& iR, const int& iG, const int& iB, int& iY, int& iU, int& iV ) +{ + iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; + iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; + iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; +} + +int CalypPixel::getMaxNumberOfComponents() +{ + return MAX_NUMBER_COMPONENTS; +} + +CalypPixel::CalypPixel( const int& ColorSpace ) + : d( new CalypPixelPrivate( ColorSpace ) ) +{ +} + +CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0 ) + : d( new CalypPixelPrivate( ColorSpace ) ) +{ + d->PelComp[0] = c0; +} + +CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2 ) + : d( new CalypPixelPrivate( ColorSpace ) ) +{ + d->PelComp[0] = c0; + d->PelComp[1] = c1; + d->PelComp[2] = c2; +} + +CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2, const ClpPel& c3 ) + : d( new CalypPixelPrivate( ColorSpace ) ) +{ + d->PelComp[0] = c0; + d->PelComp[1] = c1; + d->PelComp[2] = c2; + d->PelComp[3] = c3; +} + +CalypPixel::CalypPixel( const CalypPixel& other ) + : d( new CalypPixelPrivate( other.colorSpace() ) ) +{ + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + d->PelComp[i] = other[i]; + } +} + +CalypPixel::~CalypPixel() +{ + delete d; +} + +int CalypPixel::colorSpace() const +{ + return d->iColorSpace; +} + +ClpPel CalypPixel::operator[]( const int& channel ) const +{ + return d->PelComp[channel]; +} +ClpPel& CalypPixel::operator[]( const int& channel ) +{ + return d->PelComp[channel]; +} + +CalypPixel CalypPixel::operator=( const CalypPixel& other ) +{ + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + d->PelComp[i] = other[i]; + } + return *this; +} + +CalypPixel CalypPixel::operator+( const CalypPixel& in ) +{ + CalypPixel result; + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + result[i] = d->PelComp[i] + in[i]; + } + return result; +} + +CalypPixel CalypPixel::operator+=( const CalypPixel& in ) +{ + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + d->PelComp[i] += in[i]; + } + return *this; +} + +CalypPixel CalypPixel::operator-( const CalypPixel& in ) +{ + CalypPixel result; + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + result[i] = d->PelComp[i] - in[i]; + } + return result; +} + +CalypPixel CalypPixel::operator-=( const CalypPixel& in ) +{ + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + d->PelComp[i] -= in[i]; + } + return *this; +} + +CalypPixel CalypPixel::operator*( const double& op ) +{ + CalypPixel result; + for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ ) + { + result[i] = d->PelComp[i] * op; + } + return result; +} + +CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) +{ + if( d->iColorSpace == eOutputSpace ) + return *this; + + int outA = 0; + int outB = 0; + int outC = 0; + int outD = 0; + if( d->iColorSpace == CLP_COLOR_YUV ) + { + switch( eOutputSpace ) + { + case CLP_COLOR_GRAY: + outA = d->PelComp[0]; + break; + case CLP_COLOR_RGBA: + outD = 255; + case CLP_COLOR_RGB: + yuvToRgb( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC ); + break; + default: + break; + } + } + if( d->iColorSpace == CLP_COLOR_RGB ) + { + switch( eOutputSpace ) + { + case CLP_COLOR_GRAY: + rgbToYuv( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC ); + case CLP_COLOR_YUV: + rgbToYuv( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC ); + break; + case CLP_COLOR_RGBA: + outD = 255; + break; + default: + break; + } + } + return CalypPixel( eOutputSpace, outA, outB, outC, outD ); +} diff --git a/lib/PlaYUVerStream.cpp b/lib/CalypStream.cpp similarity index 50% rename from lib/PlaYUVerStream.cpp rename to lib/CalypStream.cpp index e84deee..8f685fb 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/CalypStream.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,16 +18,16 @@ */ /** - * \file PlaYUVerStream.cpp + * \file CalypStream.cpp * \brief Input stream handling */ // Self -#include "PlaYUVerStream.h" +#include "CalypStream.h" +#include "CalypFrame.h" +#include "CalypStreamHandlerIf.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerStreamHandlerIf.h" #include "StreamHandlerPortableMap.h" #include "StreamHandlerRaw.h" #include "config.h" @@ -40,77 +40,77 @@ #include -std::vector PlaYUVerStream::supportedReadFormats() +std::vector CalypStream::supportedReadFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Read ); - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Read ); + INI_REGIST_CALYP_SUPPORTED_FMT; + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerRaw, Read ); + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerPortableMap, Read ); //#ifdef USE_OPENCV -// APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Read ); +// APPEND_CALYP_SUPPORTED_FMT( StreamHandlerOpenCV, Read ); //#endif #ifdef USE_FFMPEG - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Read ); + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerLibav, Read ); #endif - END_REGIST_PLAYUVER_SUPPORTED_FMT; + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector PlaYUVerStream::supportedWriteFormats() +std::vector CalypStream::supportedWriteFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Write ); - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Write ); + INI_REGIST_CALYP_SUPPORTED_FMT; + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerRaw, Write ); + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerPortableMap, Write ); #ifdef USE_FFMPEG - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Write ); + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerLibav, Write ); #endif #ifdef USE_OPENCV - APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Write ); + APPEND_CALYP_SUPPORTED_FMT( StreamHandlerOpenCV, Write ); #endif - END_REGIST_PLAYUVER_SUPPORTED_FMT; + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector PlaYUVerStream::stdResolutionSizes() +std::vector CalypStream::stdResolutionSizes() { -#define REGIST_PLAYUVER_STANDARD_RESOLUTION( name, width, height ) \ - stdResElement.shortName = name; \ - stdResElement.uiWidth = width; \ - stdResElement.uiHeight = height; \ +#define REGIST_CALYP_STANDARD_RESOLUTION( name, width, height ) \ + stdResElement.shortName = name; \ + stdResElement.uiWidth = width; \ + stdResElement.uiHeight = height; \ stdResList.push_back( stdResElement ); - std::vector stdResList; - PlaYUVerStdResolution stdResElement; - REGIST_PLAYUVER_STANDARD_RESOLUTION( "CIF", 352, 288 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "VGA", 640, 480 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "WVGA", 832, 480 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "XVGA", 1024, 768 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "HD", 1280, 720 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA-", 1280, 900 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA", 1280, 1024 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "WSXGA", 1440, 900 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "FullHD", 1920, 1080 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 ); - REGIST_PLAYUVER_STANDARD_RESOLUTION( "8K", 8192, 4608 ); + std::vector stdResList; + CalypStandardResolution stdResElement; + REGIST_CALYP_STANDARD_RESOLUTION( "CIF", 352, 288 ); + REGIST_CALYP_STANDARD_RESOLUTION( "VGA", 640, 480 ); + REGIST_CALYP_STANDARD_RESOLUTION( "WVGA", 832, 480 ); + REGIST_CALYP_STANDARD_RESOLUTION( "XVGA", 1024, 768 ); + REGIST_CALYP_STANDARD_RESOLUTION( "HD", 1280, 720 ); + REGIST_CALYP_STANDARD_RESOLUTION( "SXGA-", 1280, 900 ); + REGIST_CALYP_STANDARD_RESOLUTION( "SXGA", 1280, 1024 ); + REGIST_CALYP_STANDARD_RESOLUTION( "WSXGA", 1440, 900 ); + REGIST_CALYP_STANDARD_RESOLUTION( "FullHD", 1920, 1080 ); + REGIST_CALYP_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 ); + REGIST_CALYP_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 ); + REGIST_CALYP_STANDARD_RESOLUTION( "8K", 8192, 4608 ); return stdResList; } -class PlaYUVerStreamBufferPrivate +class CalypStreamBufferPrivate { private: - std::vector m_apcFrameBuffer; - UInt m_uiIndex; + std::vector m_apcFrameBuffer; + unsigned int m_uiIndex; public: - PlaYUVerStreamBufferPrivate( UInt size, UInt width, UInt height, Int pelFormat, Int bitsPixel ) + CalypStreamBufferPrivate( unsigned int size, unsigned int width, unsigned int height, int pelFormat, int bitsPixel ) { - for( UInt i = 0; i < size; i++ ) + for( unsigned int i = 0; i < size; i++ ) { - PlaYUVerFrame* pFrame = new PlaYUVerFrame( width, height, pelFormat, bitsPixel ); + CalypFrame* pFrame = new CalypFrame( width, height, pelFormat, bitsPixel ); m_apcFrameBuffer.push_back( pFrame ); } m_uiIndex = 0; } - ~PlaYUVerStreamBufferPrivate() + ~CalypStreamBufferPrivate() { while( m_apcFrameBuffer.size() > 0 ) { @@ -118,42 +118,42 @@ public: m_apcFrameBuffer.pop_back(); } } - Void increase( UInt newSize ) + void increase( unsigned int newSize ) { - for( UInt i = m_apcFrameBuffer.size(); i < newSize; i++ ) + for( unsigned int i = m_apcFrameBuffer.size(); i < newSize; i++ ) { - PlaYUVerFrame* pFrame = new PlaYUVerFrame( m_apcFrameBuffer.at( 0 ) ); + CalypFrame* pFrame = new CalypFrame( m_apcFrameBuffer.at( 0 ) ); m_apcFrameBuffer.push_back( pFrame ); } } - UInt size() { return m_apcFrameBuffer.size(); } - Void setIndex( UInt i ) { m_uiIndex = i; } - PlaYUVerFrame* frame( Int i ) { return m_apcFrameBuffer.at( i ); } + unsigned int size() { return m_apcFrameBuffer.size(); } + void setIndex( unsigned int i ) { m_uiIndex = i; } + CalypFrame* frame( int i ) { return m_apcFrameBuffer.at( i ); } - PlaYUVerFrame* current() { return m_apcFrameBuffer.at( m_uiIndex ); } - PlaYUVerFrame* next() { return m_apcFrameBuffer.at( nextIndex() ); } - Void setNextFrame() { m_uiIndex = nextIndex(); } + CalypFrame* current() { return m_apcFrameBuffer.at( m_uiIndex ); } + CalypFrame* next() { return m_apcFrameBuffer.at( nextIndex() ); } + void setNextFrame() { m_uiIndex = nextIndex(); } private: - inline Int nextIndex() { return m_uiIndex + 1 >= m_apcFrameBuffer.size() ? 0 : m_uiIndex + 1; } - inline Int prevIndex() { return m_uiIndex - 1 < 0 ? m_apcFrameBuffer.size() - 1 : m_uiIndex - 1; } + inline int nextIndex() { return m_uiIndex + 1 >= m_apcFrameBuffer.size() ? 0 : m_uiIndex + 1; } + inline int prevIndex() { return m_uiIndex - 1 < 0 ? m_apcFrameBuffer.size() - 1 : m_uiIndex - 1; } }; -struct PlaYUVerStreamPrivate +struct CalypStreamPrivate { - Bool isInit; - Bool isInput; + bool isInit; + bool isInput; - PlaYUVerStreamHandlerIf* handler; + CalypStreamHandlerIf* handler; CreateStreamHandlerFn pfctCreateHandler; - PlaYUVerStreamBufferPrivate* frameBuffer; + CalypStreamBufferPrivate* frameBuffer; - String cFilename; - Int64 iCurrFrameNum; - Bool bLoadAll; + ClpString cFilename; + long long int iCurrFrameNum; + bool bLoadAll; - PlaYUVerStreamPrivate() + CalypStreamPrivate() { isInit = false; pfctCreateHandler = NULL; @@ -165,13 +165,13 @@ struct PlaYUVerStreamPrivate } }; -std::vector PlaYUVerSupportedFormat::getExts() +std::vector CalypStreamFormat::getExts() { - std::vector arrayExt; - String::size_type prev_pos = 0, pos = 0; - while( ( pos = formatExt.find( ',', pos ) ) != String::npos ) + std::vector arrayExt; + ClpString::size_type prev_pos = 0, pos = 0; + while( ( pos = formatExt.find( ',', pos ) ) != ClpString::npos ) { - String substring( formatExt.substr( prev_pos, pos - prev_pos ) ); + ClpString substring( formatExt.substr( prev_pos, pos - prev_pos ) ); arrayExt.push_back( substring ); prev_pos = ++pos; } @@ -179,63 +179,68 @@ std::vector PlaYUVerSupportedFormat::getExts() return arrayExt; } -CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, bool bRead ) +CreateStreamHandlerFn CalypStream::findStreamHandler( ClpString strFilename, bool bRead ) { - String currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 ); - currExt = lowercase( currExt ); + ClpString currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 ); + currExt = clpLowercase( currExt ); - std::vector supportedFmts; + std::vector supportedFmts; if( bRead ) { - supportedFmts = PlaYUVerStream::supportedReadFormats(); + supportedFmts = CalypStream::supportedReadFormats(); } else { - supportedFmts = PlaYUVerStream::supportedWriteFormats(); + supportedFmts = CalypStream::supportedWriteFormats(); } - for( UInt i = 0; i < supportedFmts.size(); i++ ) + for( unsigned int i = 0; i < supportedFmts.size(); i++ ) { - std::vector arrayExt = supportedFmts[i].getExts(); - for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) + std::vector arrayExt = supportedFmts[i].getExts(); + for( std::vector::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) { if( currExt != "" && currExt == *e ) { return supportedFmts[i].formatFct; } - else if( strFilename.find( *e ) != String::npos ) + else if( strFilename.find( *e ) != ClpString::npos ) { return supportedFmts[i].formatFct; } } } + +#ifdef USE_FFMPEG return &StreamHandlerLibav::Create; +#else + return &StreamHandlerRaw::Create; +#endif } -PlaYUVerStream::PlaYUVerStream() - : d( new PlaYUVerStreamPrivate ) +CalypStream::CalypStream() + : d( new CalypStreamPrivate ) { } -PlaYUVerStream::~PlaYUVerStream() +CalypStream::~CalypStream() { close(); } -String PlaYUVerStream::getFormatName() +ClpString CalypStream::getFormatName() { return !d->handler ? "" : d->handler->getFormatName(); } -String PlaYUVerStream::getCodecName() +ClpString CalypStream::getCodecName() { return !d->handler ? "" : d->handler->getCodecName(); } -Bool PlaYUVerStream::open( String filename, String resolution, String input_format_name, UInt bitsPel, Int endianness, - UInt frame_rate, Bool bInput ) +bool CalypStream::open( ClpString filename, ClpString resolution, ClpString input_format_name, unsigned int bitsPel, int endianness, + unsigned int frame_rate, bool bInput ) { - UInt width = 0; - UInt height = 0; - Int input_format = -1; + unsigned int width = 0; + unsigned int height = 0; + int input_format = -1; if( resolution.size() > 0 ) { @@ -245,9 +250,9 @@ Bool PlaYUVerStream::open( String filename, String resolution, String input_form return false; } } - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ ) { - if( lowercase( PlaYUVerFrame::supportedPixelFormatListNames()[i] ) == lowercase( input_format_name ) ) + if( clpLowercase( CalypFrame::supportedPixelFormatListNames()[i] ) == clpLowercase( input_format_name ) ) { input_format = i; break; @@ -256,8 +261,8 @@ Bool PlaYUVerStream::open( String filename, String resolution, String input_form return open( filename, width, height, input_format, bitsPel, endianness, frame_rate, bInput ); } -Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, - UInt frame_rate, Bool bInput ) +bool CalypStream::open( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, + unsigned int frame_rate, bool bInput ) { if( d->isInit ) { @@ -266,17 +271,17 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f d->isInit = false; d->isInput = bInput; - d->pfctCreateHandler = PlaYUVerStream::findStreamHandler( filename, d->isInput ); + d->pfctCreateHandler = CalypStream::findStreamHandler( filename, d->isInput ); if( !d->pfctCreateHandler ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Invalid handler" ); + throw CalypFailure( "CalypStream", "Invalid handler" ); } d->handler = d->pfctCreateHandler(); if( !d->handler ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot create handler" ); + throw CalypFailure( "CalypStream", "Cannot create handler" ); } d->cFilename = filename; @@ -298,20 +303,20 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 ) { close(); - //throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration: width, height or pixel format" ); + //throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" ); return d->isInit; } // Keep past, current and future frames try { - d->frameBuffer = new PlaYUVerStreamBufferPrivate( d->isInput ? 3 : 1, d->handler->m_uiWidth, d->handler->m_uiHeight, - d->handler->m_iPixelFormat, d->handler->m_uiBitsPerPixel ); + d->frameBuffer = new CalypStreamBufferPrivate( d->isInput ? 3 : 1, d->handler->m_uiWidth, d->handler->m_uiHeight, + d->handler->m_iPixelFormat, d->handler->m_uiBitsPerPixel ); } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { close(); - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated frame buffer" ); + throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" ); return d->isInit; } @@ -323,14 +328,14 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f if( d->isInput && d->handler->m_uiTotalNumberFrames == 0 ) { close(); - throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration: less than one frame" ); + throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" ); return d->isInit; } if( !d->handler->configureBuffer( d->frameBuffer->current() ) ) { close(); - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated buffers" ); + throw CalypFailure( "CalypStream", "Cannot allocated buffers" ); return d->isInit; } @@ -343,13 +348,13 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f return d->isInit; } -Bool PlaYUVerStream::reload() +bool CalypStream::reload() { d->handler->closeHandler(); if( !d->handler->openHandler( d->cFilename, d->isInput ) ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot open stream " + d->cFilename + " with the " + - String( d->handler->m_pchHandlerName ) + " handler" ); + throw CalypFailure( "CalypStream", "Cannot open stream " + d->cFilename + " with the " + + ClpString( d->handler->m_pchHandlerName ) + " handler" ); } d->handler->m_uiNBytesPerFrame = d->frameBuffer->current()->getBytesPerFrame(); d->handler->calculateFrameNumber(); @@ -360,17 +365,17 @@ Bool PlaYUVerStream::reload() { return false; } - if( UInt( d->iCurrFrameNum ) >= d->handler->m_uiTotalNumberFrames ) + if( (unsigned int)( d->iCurrFrameNum ) >= d->handler->m_uiTotalNumberFrames ) { d->iCurrFrameNum = 0; } - Int currFrameNum = d->iCurrFrameNum; + int currFrameNum = d->iCurrFrameNum; d->iCurrFrameNum = -1; seekInput( currFrameNum ); return true; } -Void PlaYUVerStream::close() +void CalypStream::close() { if( !d->isInit ) return; @@ -384,44 +389,44 @@ Void PlaYUVerStream::close() d->isInit = false; } -String PlaYUVerStream::getFileName() +ClpString CalypStream::getFileName() { return d->cFilename; } -Bool PlaYUVerStream::isNative() +bool CalypStream::isNative() { return d->handler->m_bNative; } -UInt PlaYUVerStream::getFrameNum() +unsigned int CalypStream::getFrameNum() { return d->handler->m_uiTotalNumberFrames; } -UInt PlaYUVerStream::getWidth() const +unsigned int CalypStream::getWidth() const { return d->handler->m_uiWidth; } -UInt PlaYUVerStream::getHeight() const +unsigned int CalypStream::getHeight() const { return d->handler->m_uiHeight; } -Int PlaYUVerStream::getEndianess() const +int CalypStream::getEndianess() const { return d->handler->m_iEndianness; } -Double PlaYUVerStream::getFrameRate() +double CalypStream::getFrameRate() { return d->handler->m_dFrameRate; } -Int PlaYUVerStream::getCurrFrameNum() +int CalypStream::getCurrFrameNum() { return d->iCurrFrameNum; } -Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness, - UInt& rFrameRate ) +void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness, + unsigned int& rFrameRate ) { if( d->isInit ) { @@ -436,14 +441,14 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, { rWidth = 0; rHeight = 0; - rInputFormat = PlaYUVerFrame::YUV420p; + rInputFormat = CLP_YUV420P; rBitsPerPel = 8; rEndianness = 0; rFrameRate = 30; } } -Void PlaYUVerStream::loadAll() +void CalypStream::loadAll() { if( d->bLoadAll || !d->isInput ) return; @@ -452,14 +457,14 @@ Void PlaYUVerStream::loadAll() { d->frameBuffer->increase( d->handler->m_uiTotalNumberFrames ); } - catch( PlaYUVerFailure& e ) + catch( CalypFailure& e ) { close(); - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot allocated frame buffer for the whole stream" ); + throw CalypFailure( "CalypStream", "Cannot allocated frame buffer for the whole stream" ); } seekInput( 0 ); - for( UInt i = 2; i < d->frameBuffer->size(); i++ ) + for( unsigned int i = 2; i < d->frameBuffer->size(); i++ ) { readFrame( d->frameBuffer->frame( i ) ); } @@ -467,9 +472,9 @@ Void PlaYUVerStream::loadAll() d->iCurrFrameNum = 0; } -Void PlaYUVerStream::getDuration( Int* duration_array ) +void CalypStream::getDuration( int* duration_array ) { - // Int hours, mins, secs = 0; + // int hours, mins, secs = 0; // #ifdef USE_FFMPEG // if( m_iStreamHandler == FFMPEG ) // { @@ -490,7 +495,7 @@ Void PlaYUVerStream::getDuration( Int* duration_array ) // *duration_array++ = secs; } -Bool PlaYUVerStream::readFrame( PlaYUVerFrame* frame ) +bool CalypStream::readFrame( CalypFrame* frame ) { if( !d->isInit || !d->isInput || d->handler->m_uiCurrFrameFileIdx >= d->handler->m_uiTotalNumberFrames ) return false; @@ -500,36 +505,36 @@ Bool PlaYUVerStream::readFrame( PlaYUVerFrame* frame ) if( !d->handler->read( frame ) ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot read frame from stream" ); + throw CalypFailure( "CalypStream", "Cannot read frame from stream" ); return false; } return true; } -Void PlaYUVerStream::writeFrame() +void CalypStream::writeFrame() { writeFrame( d->frameBuffer->current() ); } -Void PlaYUVerStream::writeFrame( PlaYUVerFrame* pcFrame ) +void CalypStream::writeFrame( CalypFrame* pcFrame ) { if( !d->handler->write( pcFrame ) ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot write frame into the stream" ); + throw CalypFailure( "CalypStream", "Cannot write frame into the stream" ); } return; } -Bool PlaYUVerStream::saveFrame( const String& filename ) +bool CalypStream::saveFrame( const ClpString& filename ) { return saveFrame( filename, d->frameBuffer->current() ); } -Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame ) +bool CalypStream::saveFrame( const ClpString& filename, CalypFrame* saveFrame ) { - PlaYUVerStream auxSaveStream; + CalypStream auxSaveStream; if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), - saveFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false ) ) + saveFrame->getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ) ) { return false; } @@ -538,11 +543,11 @@ Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame* saveFrame return true; } -Bool PlaYUVerStream::setNextFrame() +bool CalypStream::setNextFrame() { - Bool bEndOfSeq = false; + bool bEndOfSeq = false; - if( d->iCurrFrameNum + 1 < Int64( d->handler->m_uiTotalNumberFrames ) ) + if( d->iCurrFrameNum + 1 < (long)( d->handler->m_uiTotalNumberFrames ) ) { d->frameBuffer->setNextFrame(); d->iCurrFrameNum++; @@ -554,38 +559,38 @@ Bool PlaYUVerStream::setNextFrame() return bEndOfSeq; } -Void PlaYUVerStream::readNextFrame() +void CalypStream::readNextFrame() { readFrame( d->frameBuffer->next() ); } -Void PlaYUVerStream::readNextFrameFillRGBBuffer() +void CalypStream::readNextFrameFillRGBBuffer() { readNextFrame(); d->frameBuffer->next()->fillRGBBuffer(); return; } -PlaYUVerFrame* PlaYUVerStream::getCurrFrame( PlaYUVerFrame* pyuv_image ) +CalypFrame* CalypStream::getCurrFrame( CalypFrame* pyuv_image ) { if( pyuv_image == NULL ) - pyuv_image = new PlaYUVerFrame( d->frameBuffer->current() ); + pyuv_image = new CalypFrame( d->frameBuffer->current() ); else pyuv_image->copyFrom( d->frameBuffer->current() ); return pyuv_image; } -PlaYUVerFrame* PlaYUVerStream::getCurrFrame() +CalypFrame* CalypStream::getCurrFrame() { return d->frameBuffer->current(); } -Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward ) +bool CalypStream::seekInputRelative( bool bIsFoward ) { if( !d->isInit || !d->isInput ) return false; - Bool bRet = false; + bool bRet = false; if( bIsFoward ) { bRet = !setNextFrame(); @@ -593,15 +598,15 @@ Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward ) } else { - UInt64 newFrameNum = d->iCurrFrameNum - 1; + unsigned long long int newFrameNum = d->iCurrFrameNum - 1; bRet = seekInput( newFrameNum ); } return bRet; } -Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) +bool CalypStream::seekInput( unsigned long new_frame_num ) { - if( !d->isInit || new_frame_num >= d->handler->m_uiTotalNumberFrames || Int64( new_frame_num ) == d->iCurrFrameNum ) + if( !d->isInit || new_frame_num >= d->handler->m_uiTotalNumberFrames || long( new_frame_num ) == d->iCurrFrameNum ) return false; d->iCurrFrameNum = new_frame_num; @@ -614,7 +619,7 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) if( !d->handler->seek( d->iCurrFrameNum ) ) { - throw PlaYUVerFailure( "PlaYUVerStream", "Cannot seek file into desired position" ); + throw CalypFailure( "CalypStream", "Cannot seek file into desired position" ); } d->frameBuffer->setIndex( 0 ); diff --git a/lib/CalypStream.h b/lib/CalypStream.h new file mode 100644 index 0000000..97ed7a9 --- /dev/null +++ b/lib/CalypStream.h @@ -0,0 +1,119 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypStream.h + * \ingroup CalypStreamGrp + * \brief Input stream handling + */ + +#ifndef __CALYPSTREAM_H__ +#define __CALYPSTREAM_H__ + +#include "CalypDefs.h" + +class CalypFrame; +class CalypStreamHandlerIf; + +typedef CalypStreamHandlerIf* ( *CreateStreamHandlerFn )( void ); + +typedef struct +{ + ClpString formatName; + ClpString formatExt; + std::vector getExts(); + ClpString formatPattern; + CreateStreamHandlerFn formatFct; +} CalypStreamFormat; + +typedef struct +{ + ClpString shortName; + unsigned int uiWidth; + unsigned int uiHeight; +} CalypStandardResolution; + +/** + * \class CalypStream + * \ingroup CalypLibGrp CalypStreamGrp + * \brief Stream handling class + */ +class CalypStream +{ +public: + static std::vector supportedReadFormats(); + static std::vector supportedWriteFormats(); + + static CreateStreamHandlerFn findStreamHandler( ClpString strFilename, bool bRead ); + + static std::vector stdResolutionSizes(); + + CalypStream(); + ~CalypStream(); + + ClpString getFormatName(); + ClpString getCodecName(); + + bool open( ClpString filename, ClpString resolution, ClpString input_format, unsigned int bitsPel, int endianness, unsigned int frame_rate, + bool bInput ); + bool open( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, unsigned int frame_rate, + bool bInput ); + bool reload(); + void close(); + + bool isNative(); + ClpString getFileName(); + unsigned int getFrameNum(); + unsigned int getWidth() const; + unsigned int getHeight() const; + int getEndianess() const; + int getCurrFrameNum(); + double getFrameRate(); + void getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness, + unsigned int& rFrameRate ); + + void loadAll(); + + void writeFrame(); + void writeFrame( CalypFrame* pcFrame ); + + bool saveFrame( const ClpString& filename ); + static bool saveFrame( const ClpString& filename, CalypFrame* saveFrame ); + + CalypFrame* getCurrFrame( CalypFrame* ); + + // continuous read control + bool setNextFrame(); + void readNextFrame(); + void readNextFrameFillRGBBuffer(); + CalypFrame* getCurrFrame(); + + bool seekInputRelative( bool bIsFoward ); + bool seekInput( unsigned long new_frame_num ); + + void getDuration( int* duration_array ); + +private: + bool readFrame( CalypFrame* frame ); + +private: + struct CalypStreamPrivate* d; +}; + +#endif // __CALYPSTREAM_H__ diff --git a/lib/CalypStreamHandlerIf.h b/lib/CalypStreamHandlerIf.h new file mode 100644 index 0000000..1a07dcc --- /dev/null +++ b/lib/CalypStreamHandlerIf.h @@ -0,0 +1,120 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypStreamHandlerIf.h + * \brief Abstract class for stream handling + */ + +#ifndef __CALYPSTREAMHANDLERIF_H__ +#define __CALYPSTREAMHANDLERIF_H__ + +#include "CalypStream.h" + +#define INI_REGIST_CALYP_SUPPORTED_FMT \ + std::vector formatsList; \ + CalypStreamFormat formatElem; + +#define END_REGIST_CALYP_SUPPORTED_FMT return formatsList; + +#define REGIST_CALYP_SUPPORTED_FMT( handler, name, ext ) \ + formatElem.formatName = name; \ + formatElem.formatExt = clpLowercase( ext ); \ + formatElem.formatFct = handler; \ + formatsList.push_back( formatElem ); + +#define REGIST_CALYP_SUPPORTED_ABSTRACT_FMT( handler, name, pattern ) \ + formatElem.formatPattern = pattern; \ + REGIST_CALYP_SUPPORTED_FMT( handler, name, "" ) + +#define APPEND_CALYP_SUPPORTED_FMT( class_name, fct ) \ + { \ + std::vector new_fmts = class_name::supported##fct##Formats(); \ + formatsList.insert( formatsList.end(), new_fmts.begin(), new_fmts.end() ); \ + } + +#define REGISTER_CALYP_STREAM_HANDLER( X ) \ +public: \ + static CalypStreamHandlerIf* Create() { return new X(); } \ + void Delete() { delete this; } \ + static std::vector supportedReadFormats(); \ + static std::vector supportedWriteFormats(); \ + // static int checkforSupportedFile( String, bool ); + +/** + * \class CalypStreamHandlerIf + * \ingroup CalypStreamGrp + * \brief Abstract class for stream handling + */ +class CalypStreamHandlerIf +{ + friend class CalypStream; + +public: + CalypStreamHandlerIf() + : m_bIsInput( true ) + , m_bNative( true ) + , m_uiCurrFrameFileIdx( 0 ) + , m_uiWidth( 0 ) + , m_uiHeight( 0 ) + , m_iPixelFormat( -1 ) + , m_uiBitsPerPixel( 8 ) + , m_iEndianness( -1 ) + , m_dFrameRate( 30 ) + , m_uiTotalNumberFrames( 0 ) + , m_pStreamBuffer( NULL ) + , m_uiNBytesPerFrame( 0 ) + { + } + virtual ~CalypStreamHandlerIf() {} + virtual void Delete() = 0; + + virtual bool openHandler( ClpString strFilename, bool bInput ) = 0; + virtual void closeHandler() = 0; + virtual bool configureBuffer( CalypFrame* pcFrame ) = 0; + virtual bool seek( unsigned long long int iFrameNum ) = 0; + virtual bool read( CalypFrame* pcFrame ) = 0; + virtual bool write( CalypFrame* pcFrame ) = 0; + + virtual void calculateFrameNumber(){}; + + ClpString getFormatName() { return m_strFormatName; } + ClpString getCodecName() { return m_strCodecName; } + +protected: + const char* m_pchHandlerName; + + ClpString m_strFormatName; + ClpString m_strCodecName; + bool m_bIsInput; + bool m_bNative; + unsigned long m_uiCurrFrameFileIdx; + ClpString m_cFilename; + unsigned int m_uiWidth; + unsigned int m_uiHeight; + int m_iPixelFormat; + unsigned int m_uiBitsPerPixel; + int m_iEndianness; + double m_dFrameRate; + unsigned long m_uiTotalNumberFrames; + ClpByte* m_pStreamBuffer; + unsigned long m_uiNBytesPerFrame; +}; + +#endif // __CALYPSTREAMHANDLERIF_H__ diff --git a/lib/LibMemory.h b/lib/LibMemory.h index 54aaf59..9e69b8f 100644 --- a/lib/LibMemory.h +++ b/lib/LibMemory.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,7 +19,7 @@ /** * \file LibMemory.cpp - * \ingroup PlaYUVerLib + * \ingroup CalypLib * \brief Memory allocation functions */ @@ -30,23 +30,6 @@ #include #include -typedef void Void; -typedef char Char; -typedef int Int; -typedef size_t SizeT; - -#ifdef _MSC_VER -typedef __int64 Int64; -#if _MSC_VER <= 1200 // MS VC6 -typedef __int64 UInt64; // MS VC6 does not support unsigned __int64 to double conversion -#else -typedef unsigned __int64 UInt64; -#endif -#else -typedef long long Int64; -typedef unsigned long long UInt64; -#endif - #define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free #if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) #define xMalloc( len ) _aligned_malloc( len, 32 ) @@ -57,9 +40,9 @@ typedef unsigned long long UInt64; #endif #define xMemSet( type, len, ptr ) memset( ptr, 0, ( len ) * sizeof( type ) ) -static inline Void* xMallocMem( SizeT nitems ) +static inline void* xMallocMem( size_t nitems ) { - Void* d; + void* d; if( ( d = xMalloc( nitems ) ) == NULL ) { printf( "malloc failed.\n" ); @@ -68,16 +51,16 @@ static inline Void* xMallocMem( SizeT nitems ) return d; } -static inline Void* xCallocMem( SizeT nitems, SizeT size ) +static inline void* xCallocMem( size_t nitems, size_t size ) { size_t padded_size = nitems * size; - Void* d = xMallocMem( padded_size ); + void* d = xMallocMem( padded_size ); memset( d, 0, (int)padded_size ); return d; } template -Int getMem1D( T** array1D, Int dim0 ) +int getMem1D( T** array1D, int dim0 ) { if( ( *array1D = (T*)xCallocMem( dim0, sizeof( T ) ) ) == NULL ) return 0; @@ -86,9 +69,9 @@ Int getMem1D( T** array1D, Int dim0 ) } template -Int getMem2D( T*** array2D, Int dim0, Int dim1 ) +int getMem2D( T*** array2D, int dim0, int dim1 ) { - Int i; + int i; if( ( *array2D = (T**)xMallocMem( dim0 * sizeof( T* ) ) ) == NULL ) printf( "get_mem2Dint: array2D" ); @@ -102,9 +85,9 @@ Int getMem2D( T*** array2D, Int dim0, Int dim1 ) } template -Int getMem3D( T**** array3D, Int dim0, Int dim1, Int dim2 ) +int getMem3D( T**** array3D, int dim0, int dim1, int dim2 ) { - Int i, mem_size = dim0 * sizeof( T** ); + int i, mem_size = dim0 * sizeof( T** ); if( ( ( *array3D ) = (T***)xMallocMem( dim0 * sizeof( T** ) ) ) == NULL ) printf( "get_mem3Dint: array3D" ); @@ -118,7 +101,7 @@ Int getMem3D( T**** array3D, Int dim0, Int dim1, Int dim2 ) } template -Void freeMem1D( T*& array1D ) +void freeMem1D( T*& array1D ) { if( array1D ) { @@ -128,7 +111,7 @@ Void freeMem1D( T*& array1D ) } template -Void freeMem2D( T**& array2D ) +void freeMem2D( T**& array2D ) { if( *array2D ) { @@ -147,7 +130,7 @@ Void freeMem2D( T**& array2D ) } template -Void freeMem3D( T***& array3D ) +void freeMem3D( T***& array3D ) { if( array3D ) { diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PixelFormats.cpp similarity index 89% rename from lib/PlaYUVerFramePixelFormats.cpp rename to lib/PixelFormats.cpp index f9c42d3..6ee0600 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PixelFormats.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,14 +18,14 @@ */ /** - * \file PlaYUVerFramePixelFormats.cpp + * \file PixelFormats.cpp * \brief Handling the pixel formats definition */ -#include "PlaYUVerFramePixelFormats.h" +#include "PixelFormats.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" #include "config.h" #ifdef USE_FFMPEG #include "StreamHandlerLibav.h" @@ -39,7 +39,7 @@ /* ************************************************************** * Handle different pel formats - * Interface to generalise into one struct the pixel formats + * interface to generalise into one struct the pixel formats ************************************************************** */ @@ -50,7 +50,7 @@ #endif #if 0 -Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) +void fillARGB32bufferYUV420p( Pel*** in, UChar* out, unsigned int width, unsigned int height, unsigned int depth ) { #ifdef USE_SSE if( ( width % 16 ) == 0 ) @@ -73,7 +73,7 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UI __m128i *srcy128r0, *srcy128r1; __m128i *dstrgb128r0, *dstrgb128r1; __m64 *srcu64, *srcv64; - UInt x, y; + unsigned int x, y; ysub = _mm_set1_epi32( 0x00100010 ); uvsub = _mm_set1_epi32( 0x00800080 ); @@ -198,12 +198,12 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UI } #endif -const std::map g_PlaYUVerPixFmtDescriptorsMap = { +const std::map g_CalypPixFmtDescriptorsMap = { { - PlaYUVerFrame::YUV420p, + CLP_YUV420P, { "YUV420p", - PlaYUVerPixel::COLOR_YUV, + CLP_COLOR_YUV, 3, 3, 1, @@ -217,10 +217,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::YUV422p, + CLP_YUV422P, { "YUV422p", - PlaYUVerPixel::COLOR_YUV, + CLP_COLOR_YUV, 3, 3, 1, @@ -234,10 +234,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::YUV444p, + CLP_YUV444P, { "YUV444p", - PlaYUVerPixel::COLOR_YUV, + CLP_COLOR_YUV, 3, 3, 0, @@ -251,10 +251,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::YUYV422, + CLP_YUYV422, { "YUYV422", - PlaYUVerPixel::COLOR_YUV, + CLP_COLOR_YUV, 3, 1, 1, @@ -268,10 +268,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::GRAY, + CLP_GRAY, { "GRAY", - PlaYUVerPixel::COLOR_GRAY, + CLP_COLOR_GRAY, 1, 1, 0, @@ -281,10 +281,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::RGBp, + CLP_RGB24P, { "RGBp", - PlaYUVerPixel::COLOR_RGB, + CLP_COLOR_RGB, 3, 3, 0, @@ -298,10 +298,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::RGB24, + CLP_RGB24, { "RGB", - PlaYUVerPixel::COLOR_RGB, + CLP_COLOR_RGB, 3, 1, 0, @@ -315,10 +315,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::BGR24, + CLP_BGR24, { "BGR", - PlaYUVerPixel::COLOR_RGB, + CLP_COLOR_RGB, 3, 1, 0, @@ -332,10 +332,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::BGR24, + CLP_BGR24, { "BGR", - PlaYUVerPixel::COLOR_RGB, + CLP_COLOR_RGB, 3, 1, 0, @@ -349,10 +349,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::RGBA, + CLP_RGBA32, { "RGBA", - PlaYUVerPixel::COLOR_RGBA, + CLP_COLOR_RGBA, 4, 1, 0, @@ -367,10 +367,10 @@ const std::map g_PlaYUVerPixFmtDescriptorsMap = { }, }, { - PlaYUVerFrame::BGRA, + CLP_BGRA32, { "BGRA", - PlaYUVerPixel::COLOR_RGBA, + CLP_COLOR_RGBA, 4, 1, 0, diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PixelFormats.h similarity index 76% rename from lib/PlaYUVerFramePixelFormats.h rename to lib/PixelFormats.h index 82553b7..23bda40 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PixelFormats.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,15 +18,14 @@ */ /** - * \file PlaYUVerFramePixelFormats.h + * \file PixelFormats.h * \brief Handling the pixel formats definition */ -#ifndef __PLAYUVERFRAMEPIXELFORMATS_H__ -#define __PLAYUVERFRAMEPIXELFORMATS_H__ +#ifndef __PIXELFORMATS_H__ +#define __PIXELFORMATS_H__ -#include "PlaYUVerDefs.h" -#include "PlaYUVerFrame.h" +#include "CalypFrame.h" #include @@ -34,26 +33,26 @@ #define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE ) -typedef struct PlaYUVerComponentDescriptor +typedef struct CalypComponentDescriptor { /** * Which of the 4 planes contains the component. */ - UInt16 plane; + unsigned short plane; /** * Number of elements between 2 horizontally consecutive pixels minus 1. * Elements are bits for bitstream formats, bytes otherwise. */ - UInt16 step_minus1; + unsigned short step_minus1; /** * Number of elements before the component of the first pixel plus 1. * Elements are bits for bitstream formats, bytes otherwise. */ - UInt16 offset_plus1; + unsigned short offset_plus1; -} PlaYUVerComponentDescriptor; +} CalypComponentDescriptor; /** * Descriptor that unambiguously describes how the bits of a pixel are @@ -64,15 +63,15 @@ typedef struct PlaYUVerComponentDescriptor * and all the YUV variants) AVPixFmtDescriptor just stores how values * are stored not what these values represent. */ -typedef struct PlaYUVerPixFmtDescriptor +typedef struct CalypPixelFormatDescriptor { const char* name; - Int colorSpace; + int colorSpace; - UInt8 numberChannels; ///< The number of components each pixel has, (1-4) + unsigned char numberChannels; ///< The number of components each pixel has, (1-4) - UInt8 numberPlanes; ///< The number of planes that should be read from the file + unsigned char numberPlanes; ///< The number of planes that should be read from the file /** * Amount to shift the luma width right to find the chroma width. @@ -81,7 +80,7 @@ typedef struct PlaYUVerPixFmtDescriptor * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ - UInt8 log2ChromaWidth; ///< chroma_width = -((-luma_width )>>log2ChromaWidth) + unsigned char log2ChromaWidth; ///< chroma_width = -((-luma_width )>>log2ChromaWidth) /** * Amount to shift the luma height right to find the chroma height. @@ -90,9 +89,9 @@ typedef struct PlaYUVerPixFmtDescriptor * The note above is needed to ensure rounding up. * This value only refers to the chroma components. */ - UInt8 log2ChromaHeight; + unsigned char log2ChromaHeight; - Int ffmpegPelFormat; + int ffmpegPelFormat; /** * Parameters that describe how pixels are packed. @@ -102,12 +101,12 @@ typedef struct PlaYUVerPixFmtDescriptor * if the RGB flag is set then 0 is red, 1 is green and 2 is blue; * otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V. */ - PlaYUVerComponentDescriptor comp[4]; + CalypComponentDescriptor comp[4]; -} PlaYUVerPixFmtDescriptor; +} CalypPixelFormatDescriptor; #define MAX_NUMBER_PLANES 3 -extern const std::map g_PlaYUVerPixFmtDescriptorsMap; +extern const std::map g_CalypPixFmtDescriptorsMap; -#endif // __PLAYUVERFRAMEPIXELFORMATS_H__ +#endif // __PIXELFORMATS_H__ diff --git a/lib/PlaYUVerConfig.cmake.in b/lib/PlaYUVerConfig.cmake.in deleted file mode 100644 index 2e6417a..0000000 --- a/lib/PlaYUVerConfig.cmake.in +++ /dev/null @@ -1,56 +0,0 @@ -# =================================================================================================================== -# The PlaYUVer Libs CMake configuration file -# -# ** File generated automatically, do not modify ** -# -# Usage from an external project: -# In your CMakeLists.txt, add these lines: -# -# find_package(PlaYUVer REQUIRED) -# include_directories(${PLAYUVER_INCLUDE_DIRS}) -# target_link_libraries(MY_TARGET_NAME ${PLAYUVER_LINKER_LIBS}) -# -# If the module is found then PLAYUVER__FOUND is set to TRUE. -# -# This file will define the following variables: -# - PLAYUVER_LINKER_LIBS : The list of all imported targets for OpenCV modules. -# - PLAYUVER_CXX_FLAGS -# - PLAYUVER_INCLUDE_DIRS : The PlaYUVer include directories. -# - PLAYUVER_VERSION : The version of this PlaYUVer build: "@PLAYUVER_VERSION@" -# - PLAYUVER_VERSION_MAJOR : Major version part of PLAYUVER_VERSION: "@PLAYUVER_VERSION_MAJOR@" -# - PLAYUVER_VERSION_MINOR : Minor version part of PLAYUVER_VERSION: "@PLAYUVER_VERSION_MINOR@" -# - PLAYUVER_VERSION_PATCH : Patch version part of PLAYUVER_VERSION: "@PLAYUVER_VERSION_PATCH@" -# -# =================================================================================================================== - - -# ====================================================== -# Variables: -# ====================================================== -SET(PLAYUVER_VERSION @PLAYUVER_VERSION@) -SET(PLAYUVER_VERSION_MAJOR @PLAYUVER_VERSION_MAJOR@) -SET(PLAYUVER_VERSION_MINOR @PLAYUVER_VERSION_MINOR@) -SET(PLAYUVER_VERSION_PATCH @PLAYUVER_VERSION_PATCH@) - -SET( PLAYUVER_LINKER_LIBS "" ) -SET( PLAYUVER_CXX_FLAGS "" ) -SET( PLAYUVER_INCLUDE_DIRS "" ) - -LIST(APPEND PLAYUVER_LINKER_LIBS "PlaYUVerLib" ) -LIST(APPEND PLAYUVER_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include ) - -# ====================================================== -# PlaYUVer dependencies: -# ====================================================== - -IF( @USE_OPENCV@ ) - LIST(APPEND PLAYUVER_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ) - LIST(APPEND PLAYUVER_LINKER_LIBS @OpenCV_LIBRARIES@ ) -ENDIF() - - -IF( @USE_FFMPEG@ ) - LIST(APPEND PLAYUVER_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS} ) - LIST(APPEND PLAYUVER_LINKER_LIBS @OpenCV_LIBRARIES@ ) -ENDIF() - diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h deleted file mode 100644 index 213469d..0000000 --- a/lib/PlaYUVerDefs.h +++ /dev/null @@ -1,126 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerDefs.h - * \ingroup PlaYUVerLib - * \brief Define basic types, new types and enumerations - */ - -#ifndef __PLAYUVERDEFS_H__ -#define __PLAYUVERDEFS_H__ - -#include -#include -#include - -typedef void Void; -typedef bool Bool; - -typedef char Char; -typedef unsigned char UChar; -typedef short Short; -typedef unsigned short UShort; -typedef int Int; -typedef unsigned int UInt; -typedef double Double; -typedef float Float; - -typedef unsigned char UInt8; -typedef unsigned int UInt16; - -typedef UShort Pel; ///< 16-bit pixel type -typedef UChar Byte; - -typedef std::string String; - -#ifdef _MSC_VER -typedef __int64 Int64; -#if _MSC_VER <= 1200 // MS VC6 -typedef __int64 UInt64; // MS VC6 does not support unsigned __int64 to double conversion -#else -typedef unsigned __int64 UInt64; -#endif -#else -typedef long long Int64; -typedef unsigned long long UInt64; -#endif - -enum LOG_LEVEL -{ - LOG_INFO = 1, - LOG_WARNINGS = 2, - LOG_RESULT = 3, - LOG_ERROR = 4, -}; - -enum YUVcomponent -{ - LUMA = 0, - CHROMA_U, - CHROMA_V, -}; - -enum RGBcomponent -{ - COLOR_R = 0, - COLOR_G, - COLOR_B, - COLOR_A, -}; - -enum Endianness -{ - PLAYUVER_BIG_ENDIAN = 0, - PLAYUVER_LITTLE_ENDIAN = 1, -}; - -inline String lowercase( const String& in ) -{ - String out; - transform( in.begin(), in.end(), std::back_inserter( out ), tolower ); - return out; -} - -inline String uppercase( const String& in ) -{ - String out; - transform( in.begin(), in.end(), std::back_inserter( out ), toupper ); - return out; -} - -struct PlaYUVerFailure : public std::exception -{ - String m_class_name; - String m_error_msg; - PlaYUVerFailure( String error_msg ) throw() - : m_error_msg( error_msg ) {} - PlaYUVerFailure( String class_name, String error_msg ) throw() - : m_class_name( class_name ), m_error_msg( error_msg ) - { - } - ~PlaYUVerFailure() throw() {} - const Char* what() const throw() - { - String* msg = new String( "[" + m_class_name + "] " + m_error_msg ); - return msg->c_str(); - } -}; - -#endif // __PLAYUVERDEFS_H__ diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h deleted file mode 100644 index 9c1dfa4..0000000 --- a/lib/PlaYUVerFrame.h +++ /dev/null @@ -1,423 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerFrame.h - * \ingroup PlaYUVerLibFrame - * \brief Video Frame handling - */ - -#ifndef __PLAYUVERFRAME_H__ -#define __PLAYUVERFRAME_H__ - -#include "PlaYUVerDefs.h" - -namespace cv -{ -class Mat; -} - -struct PlaYUVerPixFmtDescriptor; -struct PlaYUVerFramePrivate; - -#define CHROMASHIFT( SIZE, SHIFT ) UInt( -( ( -( Int( SIZE ) ) ) >> ( SHIFT ) ) ) - -/** - * \class PlaYUVerPixel - * \ingroup PlaYUVerLibFrame - * \brief Pixel handling class - */ -class PlaYUVerPixel -{ -public: - /** ColorSpace list - * List of supported color spaces - */ - enum ColorSpace - { - COLOR_INVALID = -1, //!< Invalid - COLOR_YUV = 0, //!< YUV - COLOR_RGB = 1, //!< RGB - COLOR_GRAY = 2, //!< Grayscale - COLOR_RGBA = 3, //!< RGB + Alpha - COLOR_MAX = 255, //!< Accouunt for future formats - }; - - static Int getMaxNumberOfComponents(); - - PlaYUVerPixel( const Int& ColorSpace = COLOR_INVALID ); - PlaYUVerPixel( const Int& ColorSpace, const Pel& c0 ); - PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2 ); - PlaYUVerPixel( const Int& ColorSpace, const Pel& c0, const Pel& c1, const Pel& c2, const Pel& c3 ); - PlaYUVerPixel( const PlaYUVerPixel& other ); - ~PlaYUVerPixel(); - - Int colorSpace() const; - - Pel Y() const; - Pel Cb() const; - Pel Cr() const; - Pel R() const; - Pel G() const; - Pel B() const; - Pel A() const; - - Pel& Y(); - Pel& Cb(); - Pel& Cr(); - Pel& R(); - Pel& G(); - Pel& B(); - Pel& A(); - - Pel operator[]( const Int& channel ) const; - Pel& operator[]( const Int& channel ); - - PlaYUVerPixel operator=( const PlaYUVerPixel& ); - PlaYUVerPixel operator+( const PlaYUVerPixel& ); - PlaYUVerPixel operator+=( const PlaYUVerPixel& ); - PlaYUVerPixel operator-( const PlaYUVerPixel& ); - PlaYUVerPixel operator-=( const PlaYUVerPixel& ); - PlaYUVerPixel operator*( const Double& ); - - /** - * Convert a Pixel to a new color space - * @param inputPixel input pixel (PlaYUVerPixel) - * @param eOutputSpace output color space - * @return converted pixel - */ - PlaYUVerPixel ConvertPixel( ColorSpace eOutputSpace ); - -private: - struct PlaYUVerPixelPrivate* d; -}; - -/** - * \class PlaYUVerFrame - * \ingroup PlaYUVerLibFrame - * \brief Frame handling class - */ -class PlaYUVerFrame -{ -public: - /** ColorSpace Enum - * List of supported pixel formats - */ - enum PixelFormats - { - NO_FMT = -1, - YUV420p = 0, - YUV422p, - YUV444p, - YUYV422, - GRAY, - RGBp, - RGB24, - BGR24, - RGBA, - BGRA, - PEL_FMT_MAX = 255, - }; - - /** - * Function that handles the supported color space - * of PlaYUVerFrame - * @return vector of strings with pixel formats names - */ - static std::vector supportedColorSpacesListNames(); - - /** - * Function that handles the supported pixel formats - * of PlaYUVerFrame - * @return vector of strings with pixel formats names - */ - static std::vector supportedPixelFormatListNames(); - static std::vector supportedPixelFormatListNames( Int colorSpace ); - static Int numberOfFormats(); - static Int findPixelFormat( const String& name ); - - /** - * Creates a new frame using the following configuration - * - * @param width width of the frame - * @param height height of the frame - * @param pel_format pixel format index (always use PixelFormats enum) - * - * @note this function might misbehave if the pixel format enum is not correct - */ - PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel = 8 ); - - /** - * Copy contructor - * - * @param other existing frame to copy from - */ - PlaYUVerFrame( const PlaYUVerFrame& other ); - PlaYUVerFrame( const PlaYUVerFrame* other ); - - /** - * Creates and new frame with the configuration of an existing one and copy - * its contents. This function only copies a specific region from the existing - * frame - * - * @param other existing frame to copy from - * @param posX position X to crop from - * @param posY position Y to crop from - * @param areaWidth crop width - * @param areaHeight crop height - */ - PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt width, UInt height ); - PlaYUVerFrame( const PlaYUVerFrame* other, UInt x, UInt y, UInt width, UInt height ); - - ~PlaYUVerFrame(); - - /** Format match opts - */ - enum FormatMatching - { - MATCH_COLOR_SPACE = 1, - MATCH_RESOLUTION = 2, - MATCH_PEL_FMT = 4, - MATCH_BITS = 8, - MATCH_COLOR_SPACE_IGNORE_GRAY = 16, - MATCH_ALL = 0xFFFF, - }; - - /** - * Check if two PlaYUVerFrames have the same fmt - * @param other frame to compare with - * @param match matching conditions (use enum FormatMatching) - * @return true if format matches - */ - Bool haveSameFmt( const PlaYUVerFrame& other, UInt match = MATCH_ALL ) const; - Bool haveSameFmt( const PlaYUVerFrame* other, UInt match = MATCH_ALL ) const; - - /** - * Get pixel format information - * @return pixel format index - */ - Int getPelFormat() const; - - /** - * Get pixel format information - * @return pixel format name - */ - String getPelFmtName(); - - /** - * Get color space information - * @return get color space index - */ - Int getColorSpace() const; - - /** - * Get the number of channels - * @return number of channels - */ - UInt getNumberChannels() const; - - /** - * Get width of the frame - * @param channel/component - * @return number of pixels - */ - UInt getWidth( Int channel = 0 ) const; - - /** - * Get height of the frame - * @param channel/component - * @return number of pixels - */ - UInt getHeight( Int channel = 0 ) const; - - /** - * Get number of pixels of the frame - * @param channel/component - * @return number of pixels - */ - UInt getPixels( Int channel = 0 ) const; - - /** - * Get chroma width ratio - * @return ratio multiple of 2 - */ - UInt8 getChromaWidthRatio() const; - - /** - * Get chroma height ratio - * @return ratio multiple of 2 - */ - UInt8 getChromaHeightRatio() const; - - /** - * Get number of pixels in each chroma channel - * @return number of pixels - */ - UInt getChromaLength() const; - - /** - * Get number of bits per pixel - * @return number of bits - */ - UInt getBitsPel() const; - - /** - * Get number of bytes per frame of an existing frame - * @return number of bytes per frame - */ - UInt64 getBytesPerFrame(); - - /** - * Get number of bytes per frame of a specific pixel format - * @return number of bytes per frame - */ - static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel ); - - /** - * Reset frame pixels to zero - */ - Void clear(); - - Pel*** getPelBufferYUV() const; - Pel*** getPelBufferYUV(); - - UChar* getRGBBuffer() const; - - /** - * Get pixel value at coordinates - * @param ch frame channel - * @param xPos position in X axis - * @param yPos position in Y axis - * @return pixel value - */ - Pel operator()( UInt ch, UInt xPos, UInt yPos ); - - /** - * Get pixel value at coordinates - * @param xPos position in X axis - * @param yPos position in Y axis - * @return pixel value - */ - PlaYUVerPixel operator()( UInt xPos, UInt yPos ); - - /** - * Get pixel value at coordinates - * @param xPos position in X axis - * @param yPos position in Y axis - * @return pixel value - */ - PlaYUVerPixel getPixel( UInt xPos, UInt yPos ); - - /** - * Get pixel value at coordinates - * in the desired color space - * @param xPos position in X axis - * @param yPos position in Y axis - * @param eColorSpace desired color space - * @return pixel value - */ - PlaYUVerPixel getPixel( UInt xPos, UInt yPos, PlaYUVerPixel::ColorSpace eColorSpace ); - - /** - * Set pixel value at coordinates to a given value - * @param xPos position in X axis - * @param yPos position in Y axis - */ - Void setPixel( UInt xPos, UInt yPos, PlaYUVerPixel pixel ); - - Void copyFrom( const PlaYUVerFrame& ); - Void copyFrom( const PlaYUVerFrame* ); - Void copyFrom( const PlaYUVerFrame&, UInt, UInt ); - Void copyFrom( const PlaYUVerFrame*, UInt, UInt ); - - Void frameFromBuffer( Byte*, Int, UInt64 ); - Void frameFromBuffer( Byte*, Int ); - Void frameToBuffer( Byte*, Int ); - - Void fillRGBBuffer(); - - /** - * Histogram - */ - - enum HistogramChannels - { - HIST_CHAN_ONE = 0, - HIST_CHAN_TWO, - HIST_CHAN_THREE, - HIST_CHAN_FOUR, - HIST_LUMA = 10, - HIST_CHROMA_U, - HIST_CHROMA_V, - HIST_COLOR_R = 20, - HIST_COLOR_G, - HIST_COLOR_B, - HIST_COLOR_A, - HIST_ALL_CHANNELS = 254, - HISTOGRAM_MAX = 255, - }; - Void calcHistogram(); - - UInt getMinimumPelValue( Int channel ); - UInt getMaximumPelValue( Int channel ); - - UInt getMaximum( Int channel ); - UInt getNumPixelsRange( Int channel, UInt start, UInt end ); - Double getMean( Int channel, UInt start, UInt end ); - Int getMedian( Int channel, UInt start, UInt end ); - Double getStdDev( Int channel, UInt start, UInt end ); - Double getHistogramValue( Int channel, UInt bin ); - Int getNumHistogramSegment(); - - /** - * Interface with OpenCV lib - */ - Bool toMat( cv::Mat& cvMat, Bool convertToGray = false ); - Bool fromMat( cv::Mat& cvMat ); - - /** - * \ingroup PlaYUVerLibFrame - * @defgroup PlaYUVerLibFrameQualityMetrics Quality Metrics Interface - * @{ - * Quality metrics interface - * - */ - - enum QualityMetrics - { - NO_METRIC = -1, - PSNR_METRIC = 0, - MSE_METRIC, - SSIM_METRIC, - NUMBER_METRICS, - }; - - static std::vector supportedQualityMetricsList(); - Double getQuality( Int Metric, PlaYUVerFrame* Org, Int component ); - Double getMSE( PlaYUVerFrame* Org, Int component ); - Double getPSNR( PlaYUVerFrame* Org, Int component ); - Double getSSIM( PlaYUVerFrame* Org, Int component ); - - /** @} */ - -private: - PlaYUVerFramePrivate* d; -}; - -#endif // __PLAYUVERFRAME_H__ diff --git a/lib/PlaYUVerModuleIf.h b/lib/PlaYUVerModuleIf.h deleted file mode 100644 index a919049..0000000 --- a/lib/PlaYUVerModuleIf.h +++ /dev/null @@ -1,167 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerModuleIf.h - * \ingroup PlaYUVer_Modules - * \brief PlaYUVer modules interface - */ - -#ifndef __PLAYUVERMODULESIF_H__ -#define __PLAYUVERMODULESIF_H__ - -/** - * @defgroup PlaYUVer_Modules PlaYUVer Modules - * @{ - * PlaYUVerLib supports the creation of independent - * frame processing modules - * @} - */ - -#include "PlaYUVerDefs.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerOptions.h" - -#define REGISTER_CLASS_MAKER( X ) \ - extern "C" PlaYUVerModuleIf* Maker() { return new X; } -#define REGISTER_CLASS_FACTORY( X ) \ -public: \ - static PlaYUVerModuleIf* Create() { return new X(); } \ - void Delete() { delete this; } -#define _BASIC_MODULE_API_2_CHECK_ \ - if( apcFrameList.size() != m_uiNumberOfFrames ) \ - return false; \ - for( UInt i = 0; i < apcFrameList.size(); i++ ) \ - if( !apcFrameList[i] ) \ - return false; - -/** Module_API_Version Enum - * \ingroup PlaYUVer_Modules - * Version of the modules API required - * @see m_iModuleAPI - */ -enum Module_API_Version -{ - MODULE_API_1, - MODULE_API_2, -}; - -/** Module_Type Enum - * \ingroup PlaYUVer_Modules - * Type of module - * @see m_iModuleType - */ -enum Module_Type -{ - FRAME_PROCESSING_MODULE, - FRAME_MEASUREMENT_MODULE, -}; - -/** Module_NumberOfFrames Enum - * \ingroup PlaYUVer_Modules - * Number of frames requires by a module - * @see m_uiNumberOfFrames - */ -enum Module_NumberOfFrames -{ - MODULE_REQUIRES_ONE_FRAME = 1, - MODULE_REQUIRES_TWO_FRAMES, - MODULE_REQUIRES_THREE_FRAMES, - MODULE_REQUIRES_FOUR_FRAMES, - MODULE_REQUIRES_FIVE_FRAMES, - MODULE_REQUIRES_SIX_FRAMES, - MODULE_REQUIRES_SEVERAL_FRAMES = 255, - MODULE_REQUIRES_MAX_NUM_FRAMES, -}; - -/** Module_Features Enum - * \ingroup PlaYUVer_Modules - * Features/Requirements of a module - * @see m_uiModuleRequirements - */ -enum Module_Features -{ - MODULE_REQUIRES_NOTHING = 0, - MODULE_REQUIRES_SKIP_WHILE_PLAY = 1, - MODULE_REQUIRES_OPTIONS = 2, - MODULE_REQUIRES_NEW_WINDOW = 4, - MODULE_USES_KEYS = 8, -}; - -enum Module_Key_Supported -{ - MODULE_KEY_LEFT, - MODULE_KEY_RIGHT, - MODULE_KEY_UP, - MODULE_KEY_DOWN, -}; - -/** - * \class PlaYUVerModuleIf - * \ingroup PlaYUVerLib PlaYUVer_Modules - * \brief Abstract class for modules - */ -class PlaYUVerModuleIf -{ -public: - Int m_iModuleAPI; - Int m_iModuleType; - const Char* m_pchModuleCategory; - const Char* m_pchModuleName; - const Char* m_pchModuleTooltip; - const Char* m_pchModuleLongName; - - //! Number of frames - enum Module_NumberOfFrames m_uiNumberOfFrames; - //! Features/Requirements - UInt m_uiModuleRequirements; - - PlaYUVerOptions m_cModuleOptions; - - PlaYUVerModuleIf() - { - m_iModuleAPI = MODULE_API_1; - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; - m_pchModuleLongName = NULL; - } - virtual ~PlaYUVerModuleIf() {} - virtual void Delete() = 0; - virtual Void destroy() = 0; - - const Char* getModuleLongName() - { - return m_pchModuleLongName ? m_pchModuleLongName : m_pchModuleName; - } - - /** - * Module API version 1 - */ - virtual Void create( PlaYUVerFrame* ) {} - virtual PlaYUVerFrame* process( PlaYUVerFrame* ) { return NULL; } - virtual Double measure( PlaYUVerFrame* ) { return 0; } - /** - * Module API version 2 - */ - virtual Bool create( std::vector apcFrameList ) { return false; } - virtual PlaYUVerFrame* process( std::vector ) { return NULL; } - virtual Double measure( std::vector ) { return 0; } - virtual Bool keyPressed( enum Module_Key_Supported ) { return false; } -}; - -#endif // __PLAYUVERMODULESIF_H__ diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h deleted file mode 100644 index 05e125f..0000000 --- a/lib/PlaYUVerStream.h +++ /dev/null @@ -1,127 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerStream.h - * \brief Input stream handling - */ - -#ifndef __PLAYUVERSTREAM_H__ -#define __PLAYUVERSTREAM_H__ - -#include "PlaYUVerDefs.h" - -class PlaYUVerFrame; -class PlaYUVerStreamHandlerIf; - -typedef PlaYUVerStreamHandlerIf* ( *CreateStreamHandlerFn )( void ); - -typedef struct -{ - String formatName; - String formatExt; - std::vector getExts(); - String formatPattern; - CreateStreamHandlerFn formatFct; -} PlaYUVerSupportedFormat; - -typedef struct -{ - String shortName; - UInt uiWidth; - UInt uiHeight; -} PlaYUVerStdResolution; - -/** - * \class PlaYUVerStream - * \ingroup PlaYUVerLib PlaYUVerLib_Stream - * \brief Stream handling class - */ -class PlaYUVerStream -{ -public: - static std::vector supportedReadFormats(); - static std::vector supportedWriteFormats(); - - static CreateStreamHandlerFn findStreamHandler( String strFilename, bool bRead ); - - static std::vector stdResolutionSizes(); - - PlaYUVerStream(); - ~PlaYUVerStream(); - - enum PlaYUVerStreamErrors - { - NO_STREAM_ERROR = 0, - READING, - WRITING, - LAST_FRAME, - END_OF_SEQ, - }; - - String getFormatName(); - String getCodecName(); - - Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate, - Bool bInput ); - Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, - Bool bInput ); - Bool reload(); - Void close(); - - Bool isNative(); - String getFileName(); - UInt getFrameNum(); - UInt getWidth() const; - UInt getHeight() const; - Int getEndianess() const; - Int getCurrFrameNum(); - Double getFrameRate(); - Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness, - UInt& rFrameRate ); - - Void loadAll(); - - Void writeFrame(); - Void writeFrame( PlaYUVerFrame* pcFrame ); - - Bool saveFrame( const String& filename ); - static Bool saveFrame( const String& filename, PlaYUVerFrame* saveFrame ); - - PlaYUVerFrame* getCurrFrame( PlaYUVerFrame* ); - - // continuous read control - Bool setNextFrame(); - Void readNextFrame(); - Void readNextFrameFillRGBBuffer(); - PlaYUVerFrame* getCurrFrame(); - - Bool seekInputRelative( Bool bIsFoward ); - Bool seekInput( UInt64 new_frame_num ); - - Void getDuration( Int* duration_array ); - -private: - Bool readFrame( PlaYUVerFrame* frame ); - -private: - struct PlaYUVerStreamPrivate* d; -}; - -#endif // __PLAYUVERSTREAM_H__ diff --git a/lib/PlaYUVerStreamHandlerIf.h b/lib/PlaYUVerStreamHandlerIf.h deleted file mode 100644 index 6bc8798..0000000 --- a/lib/PlaYUVerStreamHandlerIf.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerStreamHandlerIf.h - * \brief Abstract class for stream handling - */ - -#ifndef __PLAYUVERSTREAMHANDLERIF_H__ -#define __PLAYUVERSTREAMHANDLERIF_H__ - -#include "PlaYUVerDefs.h" -#include "PlaYUVerStream.h" - -class PlaYUVerFrame; - -#define INI_REGIST_PLAYUVER_SUPPORTED_FMT \ - std::vector formatsList; \ - PlaYUVerSupportedFormat formatElem; - -#define END_REGIST_PLAYUVER_SUPPORTED_FMT return formatsList; - -#define REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, ext ) \ - formatElem.formatName = name; \ - formatElem.formatExt = lowercase( ext ); \ - formatElem.formatFct = handler; \ - formatsList.push_back( formatElem ); - -#define REGIST_PLAYUVER_SUPPORTED_ABSTRACT_FMT( handler, name, pattern ) \ - formatElem.formatPattern = pattern; \ - REGIST_PLAYUVER_SUPPORTED_FMT( handler, name, "" ) - -#define APPEND_PLAYUVER_SUPPORTED_FMT( class_name, fct ) \ - { \ - std::vector new_fmts = class_name::supported##fct##Formats(); \ - formatsList.insert( formatsList.end(), new_fmts.begin(), new_fmts.end() ); \ - } - -#define REGISTER_STREAM_HANDLER( X ) \ -public: \ - static PlaYUVerStreamHandlerIf* Create() { return new X(); } \ - void Delete() { delete this; } \ - static std::vector supportedReadFormats(); \ - static std::vector supportedWriteFormats(); \ - // static Int checkforSupportedFile( String, Bool ); - -/** - * \class PlaYUVerStreamHandlerIf - * \ingroup PlaYUVerLib_Stream - * \brief Abstract class for stream handling - */ -class PlaYUVerStreamHandlerIf -{ - friend class PlaYUVerStream; - -public: - PlaYUVerStreamHandlerIf() - : m_bIsInput( true ) - , m_bNative( true ) - , m_uiCurrFrameFileIdx( 0 ) - , m_uiWidth( 0 ) - , m_uiHeight( 0 ) - , m_iPixelFormat( -1 ) - , m_uiBitsPerPixel( 8 ) - , m_iEndianness( -1 ) - , m_dFrameRate( 30 ) - , m_uiTotalNumberFrames( 0 ) - , m_pStreamBuffer( NULL ) - , m_uiNBytesPerFrame( 0 ) - { - } - virtual ~PlaYUVerStreamHandlerIf() {} - virtual void Delete() = 0; - - virtual Bool openHandler( String strFilename, Bool bInput ) = 0; - virtual Void closeHandler() = 0; - virtual Bool configureBuffer( PlaYUVerFrame* pcFrame ) = 0; - virtual Bool seek( UInt64 iFrameNum ) = 0; - virtual Bool read( PlaYUVerFrame* pcFrame ) = 0; - virtual Bool write( PlaYUVerFrame* pcFrame ) = 0; - - virtual Void calculateFrameNumber(){}; - - String getFormatName() { return m_strFormatName; } - String getCodecName() { return m_strCodecName; } - -protected: - const Char* m_pchHandlerName; - - String m_strFormatName; - String m_strCodecName; - Bool m_bIsInput; - Bool m_bNative; - UInt64 m_uiCurrFrameFileIdx; - String m_cFilename; - UInt m_uiWidth; - UInt m_uiHeight; - Int m_iPixelFormat; - UInt m_uiBitsPerPixel; - Int m_iEndianness; - Double m_dFrameRate; - UInt64 m_uiTotalNumberFrames; - Byte* m_pStreamBuffer; - UInt64 m_uiNBytesPerFrame; -}; - -#endif // __PLAYUVERSTREAMHANDLERIF_H__ diff --git a/lib/StreamHandlerLibav.cpp b/lib/StreamHandlerLibav.cpp index 2f94a35..a64d24b 100644 --- a/lib/StreamHandlerLibav.cpp +++ b/lib/StreamHandlerLibav.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,14 +19,14 @@ /** * \file StreamHandlerLibav.cpp - * \brief Interface with libav libs + * \brief interface with libav libs */ #include "StreamHandlerLibav.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerFramePixelFormats.h" +#include "PixelFormats.h" #include #include @@ -36,27 +36,27 @@ #define FF_USER_CODEC_PARAM #endif -std::vector StreamHandlerLibav::supportedReadFormats() +std::vector StreamHandlerLibav::supportedReadFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Portable Network Graphics", "png" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group", "jpg,jpeg" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows Bitmap", "bmp" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Tagged Image File Format", "tiff" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Graphics Interchange Format", "gif" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Audio video interleaved", "avi" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows media video", "wmv" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "MPEG-4", "mp4" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Matroska Multimedia Container", "mkv" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "H.264 streams", "264,h264" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "HEVC streams", "265,hevc" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Portable Network Graphics", "png" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group", "jpg,jpeg" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows Bitmap", "bmp" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Tagged Image File Format", "tiff" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Graphics interchange Format", "gif" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Audio video interleaved", "avi" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows media video", "wmv" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "MPEG-4", "mp4" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Matroska Multimedia Container", "mkv" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "H.264 streams", "264,h264" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerLibav::Create, "HEVC streams", "265,hevc" ); + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector StreamHandlerLibav::supportedWriteFormats() +std::vector StreamHandlerLibav::supportedWriteFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + END_REGIST_CALYP_SUPPORTED_FMT; } StreamHandlerLibav::StreamHandlerLibav() @@ -64,7 +64,7 @@ StreamHandlerLibav::StreamHandlerLibav() m_pchHandlerName = "FFmpeg"; } -Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) +bool StreamHandlerLibav::openHandler( ClpString strFilename, bool bInput ) { const char* filename = strFilename.c_str(); @@ -82,8 +82,8 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) // sprintf( aux_string, "%dx%d", m_uiWidth, m_uiHeight ); // av_dict_set( &format_opts, "video_size", aux_string, 0 ); // } - // Int ffmpeg_pel_format = - // g_PlaYUVerPixFmtDescriptorsList[m_iPixelFormat].ffmpegPelFormat; if( + // int ffmpeg_pel_format = + // g_CalypPixFmtDescriptorsList[m_iPixelFormat].ffmpegPelFormat; if( // ffmpeg_pel_format >= 0 ) // { // av_dict_set( &format_opts, "pix_fmt", av_get_pix_fmt_name( @@ -120,9 +120,9 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) /* find decoder for the stream */ #ifdef FF_USER_CODEC_PARAM - Int codecId = m_cStream->codecpar->codec_id; + int codecId = m_cStream->codecpar->codec_id; #else - Int codecId = m_cStream->codec->codec_id; + int codecId = m_cStream->codec->codec_id; #endif AVCodec* dec = avcodec_find_decoder( AVCodecID( codecId ) ); if( !dec ) @@ -165,7 +165,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) m_uiHeight = m_cStream->codec->height; #endif - m_strFormatName = uppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) ); + m_strFormatName = clpUppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) ); const char* name = avcodec_get_name( m_cCodedCtx->codec_id ); m_strCodecName = name; @@ -175,7 +175,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) /** * Auxiliar conversation to re-use similar pixfmt */ - Int auxPixFmt = m_ffPixFmt; + int auxPixFmt = m_ffPixFmt; switch( m_ffPixFmt ) { case AV_PIX_FMT_YUVJ420P: @@ -198,23 +198,23 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) auxPixFmt = AV_PIX_FMT_GRAY8; } - m_iPixelFormat = PlaYUVerFrame::NO_FMT; - for( Int i = 0; i < PlaYUVerFrame::numberOfFormats(); i++ ) + m_iPixelFormat = CLP_INVALID_FMT; + for( int i = 0; i < CalypFrame::numberOfFormats(); i++ ) { - if( g_PlaYUVerPixFmtDescriptorsMap.at( i ).ffmpegPelFormat == auxPixFmt ) + if( g_CalypPixFmtDescriptorsMap.at( i ).ffmpegPelFormat == auxPixFmt ) { m_iPixelFormat = i; break; } } - if( m_iPixelFormat == PlaYUVerFrame::NO_FMT ) + if( m_iPixelFormat == CLP_INVALID_FMT ) { m_bNative = false; - //throw PlaYUVerFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" ); + //throw CalypFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" ); //return false; } - Double fr = 30; + double fr = 30; if( m_cStream->avg_frame_rate.den && m_cStream->avg_frame_rate.num ) fr = av_q2d( m_cStream->avg_frame_rate ); #if FF_API_R_FRAME_RATE @@ -250,31 +250,31 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) if( !m_bNative ) { - Int newPelFmt = -1; + int newPelFmt = -1; const AVPixFmtDescriptor* ffPelDesc = av_pix_fmt_desc_get( AVPixelFormat( m_ffPixFmt ) ); if( ffPelDesc->flags & AV_PIX_FMT_FLAG_PAL ) { - newPelFmt = PlaYUVerFrame::RGB24; + newPelFmt = CLP_RGB24; } else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_ALPHA ) { - newPelFmt = PlaYUVerFrame::RGBA; + newPelFmt = CLP_RGBA32; } else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_RGB ) { - newPelFmt = PlaYUVerFrame::RGB24; + newPelFmt = CLP_RGB24; } else if( ffPelDesc->nb_components == 1 ) { - newPelFmt = PlaYUVerFrame::GRAY; + newPelFmt = CLP_GRAY; } else { - newPelFmt = PlaYUVerFrame::YUV444p; + newPelFmt = CLP_YUV444P; } m_iPixelFormat = newPelFmt; - AVPixelFormat newAvFmt = AVPixelFormat( g_PlaYUVerPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat ); + AVPixelFormat newAvFmt = AVPixelFormat( g_CalypPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat ); /* create scaling context */ m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ), @@ -310,7 +310,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput ) return true; } -Void StreamHandlerLibav::closeHandler() +void StreamHandlerLibav::closeHandler() { if( m_bHasStream ) { @@ -328,21 +328,21 @@ Void StreamHandlerLibav::closeHandler() freeMem1D( m_pStreamBuffer ); } -Bool StreamHandlerLibav::configureBuffer( PlaYUVerFrame* pcFrame ) +bool StreamHandlerLibav::configureBuffer( CalypFrame* pcFrame ) { - return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); + return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); } -Void StreamHandlerLibav::calculateFrameNumber() +void StreamHandlerLibav::calculateFrameNumber() { - UInt64 num_frames; + unsigned long long int num_frames; if( m_cStream->nb_frames ) { num_frames = m_cStream->nb_frames; } else if( m_cFmtCtx->duration != AV_NOPTS_VALUE ) { - Int64 duration = m_cFmtCtx->duration + 5000; + long long int duration = m_cFmtCtx->duration + 5000; m_uiSecs = duration / AV_TIME_BASE; num_frames = m_uiSecs * m_dFrameRate; m_uiMicroSec = duration % AV_TIME_BASE; @@ -355,12 +355,12 @@ Void StreamHandlerLibav::calculateFrameNumber() m_uiTotalNumberFrames = num_frames; } -Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame ) +bool StreamHandlerLibav::read( CalypFrame* pcFrame ) { - Int bGotFrame = 0; - Bool bErrors = false; - Bool bReadPkt = false; - Int iRet = 0; + int bGotFrame = 0; + bool bErrors = false; + bool bReadPkt = false; + int iRet = 0; while( !bGotFrame && !bErrors ) { @@ -427,12 +427,12 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame ) return false; } -Bool StreamHandlerLibav::write( PlaYUVerFrame* pcFrame ) +bool StreamHandlerLibav::write( CalypFrame* pcFrame ) { return false; } -Bool StreamHandlerLibav::seek( UInt64 iFrameNum ) +bool StreamHandlerLibav::seek( unsigned long long int iFrameNum ) { if( m_uiTotalNumberFrames == 1 ) return true; @@ -440,12 +440,12 @@ Bool StreamHandlerLibav::seek( UInt64 iFrameNum ) if( m_uiCurrFrameFileIdx == iFrameNum ) return true; - Int flags = AVSEEK_FLAG_ANY | AVSEEK_FLAG_FRAME; + int flags = AVSEEK_FLAG_ANY | AVSEEK_FLAG_FRAME; if( iFrameNum < m_uiCurrFrameFileIdx ) { flags |= AVSEEK_FLAG_BACKWARD; } - Int iRet = av_seek_frame( m_cFmtCtx, m_iStreamIdx, iFrameNum, flags ); + int iRet = av_seek_frame( m_cFmtCtx, m_iStreamIdx, iFrameNum, flags ); if( iRet < 0 ) { return false; diff --git a/lib/StreamHandlerLibav.h b/lib/StreamHandlerLibav.h index 215d6bf..8f1c798 100644 --- a/lib/StreamHandlerLibav.h +++ b/lib/StreamHandlerLibav.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,7 +19,8 @@ /** * \file StreamHandlerLibav.h - * \brief Interface with libav libs + * \ingroup CalypStreamGrp + * \brief interface with libav libs */ #ifndef __STREAMHANDLERLIBAV_H__ @@ -45,9 +46,8 @@ extern "C" { #include } -#include "PlaYUVerDefs.h" -#include "PlaYUVerStream.h" -#include "PlaYUVerStreamHandlerIf.h" +#include "CalypStream.h" +#include "CalypStreamHandlerIf.h" struct AVFormatContext; struct AVCodecContext; @@ -55,43 +55,43 @@ struct AVStream; struct AVStream; struct AVPacket; -class StreamHandlerLibav : public PlaYUVerStreamHandlerIf +class StreamHandlerLibav : public CalypStreamHandlerIf { - REGISTER_STREAM_HANDLER( StreamHandlerLibav ) + REGISTER_CALYP_STREAM_HANDLER( StreamHandlerLibav ) public: StreamHandlerLibav(); ~StreamHandlerLibav() {} - Bool openHandler( String strFilename, Bool bInput ); - Void closeHandler(); - Bool configureBuffer( PlaYUVerFrame* pcFrame ); - Void calculateFrameNumber(); - Bool seek( UInt64 iFrameNum ); - Bool read( PlaYUVerFrame* pcFrame ); - Bool write( PlaYUVerFrame* pcFrame ); + bool openHandler( ClpString strFilename, bool bInput ); + void closeHandler(); + bool configureBuffer( CalypFrame* pcFrame ); + void calculateFrameNumber(); + bool seek( unsigned long long int iFrameNum ); + bool read( CalypFrame* pcFrame ); + bool write( CalypFrame* pcFrame ); - UInt getStreamDuration() { return m_uiSecs; } - UChar* m_pchFrameBuffer; - UInt64 m_uiFrameBufferSize; + unsigned int getStreamDuration() { return m_uiSecs; } + unsigned char* m_pchFrameBuffer; + unsigned long long int m_uiFrameBufferSize; private: AVFormatContext* m_cFmtCtx; AVStream* m_cStream; - Int m_iStreamIdx; + int m_iStreamIdx; struct SwsContext* m_ScalerCtx; AVCodecContext* m_cCodedCtx; - Int m_ffPixFmt; + int m_ffPixFmt; AVFrame* m_cFrame; AVPacket m_cOrgPacket; AVPacket m_cPacket; - Bool m_bHasStream; + bool m_bHasStream; - UInt64 m_uiSecs; - UInt64 m_uiMicroSec; + unsigned long long int m_uiSecs; + unsigned long long int m_uiMicroSec; AVFrame* m_cConvertedFrame; }; diff --git a/lib/StreamHandlerOpenCV.cpp b/lib/StreamHandlerOpenCV.cpp index cd154e9..2ddf412 100644 --- a/lib/StreamHandlerOpenCV.cpp +++ b/lib/StreamHandlerOpenCV.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,14 +19,13 @@ /** * \file StreamHandlerOpenCV.cpp - * \brief Interface with opencv lib + * \brief interface with opencv lib */ #include "StreamHandlerOpenCV.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerFramePixelFormats.h" #include #include @@ -34,23 +33,23 @@ using cv::Mat; using cv::VideoCapture; -std::vector StreamHandlerOpenCV::supportedReadFormats() +std::vector StreamHandlerOpenCV::supportedReadFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; #if( CV_MAJOR_VERSION >= 3 ) - REGIST_PLAYUVER_SUPPORTED_ABSTRACT_FMT( &StreamHandlerOpenCV::Create, "Device", "/dev/video*" ); + REGIST_CALYP_SUPPORTED_ABSTRACT_FMT( &StreamHandlerOpenCV::Create, "Device", "/dev/video*" ); #endif - END_REGIST_PLAYUVER_SUPPORTED_FMT; + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector StreamHandlerOpenCV::supportedWriteFormats() +std::vector StreamHandlerOpenCV::supportedWriteFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable PixMap ", "ppm" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable Network Graphics", "png" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Joint Photographic Experts Group", "jpg" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Windows Bitmap", "bmp" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable PixMap ", "ppm" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Portable Network Graphics", "png" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Joint Photographic Experts Group", "jpg" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Windows Bitmap", "bmp" ); + END_REGIST_CALYP_SUPPORTED_FMT; } StreamHandlerOpenCV::StreamHandlerOpenCV() @@ -59,7 +58,7 @@ StreamHandlerOpenCV::StreamHandlerOpenCV() pcVideoCapture = NULL; } -Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput ) +bool StreamHandlerOpenCV::openHandler( ClpString strFilename, bool bInput ) { m_cFilename = strFilename; if( bInput ) @@ -68,12 +67,12 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput ) /* * Special filename to handle webcam input */ - if( m_cFilename.find( "/dev/video" ) != String::npos ) + if( m_cFilename.find( "/dev/video" ) != ClpString::npos ) { - Int iDeviceId = 0; - if( m_cFilename.find( "/dev/video0" ) != String::npos ) + int iDeviceId = 0; + if( m_cFilename.find( "/dev/video0" ) != ClpString::npos ) iDeviceId = 0; - else if( m_cFilename.find( "/dev/video1" ) != String::npos ) + else if( m_cFilename.find( "/dev/video1" ) != ClpString::npos ) iDeviceId = 1; m_strFormatName = "DEV"; @@ -86,14 +85,14 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput ) else #endif { - m_strCodecName = m_strFormatName = uppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) ); + m_strCodecName = m_strFormatName = clpUppercase( strFilename.substr( strFilename.find_last_of( "." ) + 1 ) ); Mat cvMat = cv::imread( m_cFilename ); m_uiWidth = cvMat.cols; m_uiHeight = cvMat.rows; m_dFrameRate = 1; } m_uiBitsPerPixel = 8; - m_iPixelFormat = PlaYUVerFrame::findPixelFormat( "BGR" ); + m_iPixelFormat = CalypFrame::findPixelFormat( "BGR" ); m_uiTotalNumberFrames = 1; if( pcVideoCapture ) @@ -105,7 +104,7 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput ) return true; } -Void StreamHandlerOpenCV::closeHandler() +void StreamHandlerOpenCV::closeHandler() { if( pcVideoCapture ) { @@ -115,20 +114,20 @@ Void StreamHandlerOpenCV::closeHandler() } } -Bool StreamHandlerOpenCV::configureBuffer( PlaYUVerFrame* pcFrame ) +bool StreamHandlerOpenCV::configureBuffer( CalypFrame* pcFrame ) { return true; } -Bool StreamHandlerOpenCV::seek( UInt64 iFrameNum ) +bool StreamHandlerOpenCV::seek( unsigned long long int iFrameNum ) { // m_uiCurrFrameFileIdx = return true; } -Bool StreamHandlerOpenCV::read( PlaYUVerFrame* pcFrame ) +bool StreamHandlerOpenCV::read( CalypFrame* pcFrame ) { - Bool bRet = false; + bool bRet = false; if( pcVideoCapture ) { Mat cvMat; @@ -146,9 +145,9 @@ Bool StreamHandlerOpenCV::read( PlaYUVerFrame* pcFrame ) return bRet; } -Bool StreamHandlerOpenCV::write( PlaYUVerFrame* pcFrame ) +bool StreamHandlerOpenCV::write( CalypFrame* pcFrame ) { - Bool bRet = false; + bool bRet = false; Mat cvFrame; bRet = pcFrame->toMat( cvFrame ); if( bRet ) diff --git a/lib/StreamHandlerOpenCV.h b/lib/StreamHandlerOpenCV.h index f35a61e..84f5b77 100644 --- a/lib/StreamHandlerOpenCV.h +++ b/lib/StreamHandlerOpenCV.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,35 +19,33 @@ /** * \file StreamHandlerOpenCV.h - * \brief Interface with opencv lib + * \ingroup CalypStreamGrp + * \brief interface with opencv lib */ #ifndef __STREAMHANDLEROPENCV_H__ #define __STREAMHANDLEROPENCV_H__ -#include "PlaYUVerDefs.h" -#include "PlaYUVerStreamHandlerIf.h" +#include "CalypStreamHandlerIf.h" namespace cv { class VideoCapture; } -class PlaYUVerFrame; - -class StreamHandlerOpenCV : public PlaYUVerStreamHandlerIf +class StreamHandlerOpenCV : public CalypStreamHandlerIf { - REGISTER_STREAM_HANDLER( StreamHandlerOpenCV ) + REGISTER_CALYP_STREAM_HANDLER( StreamHandlerOpenCV ) public: StreamHandlerOpenCV(); ~StreamHandlerOpenCV() {} - Bool openHandler( String strFilename, Bool bInput ); - Void closeHandler(); - Bool configureBuffer( PlaYUVerFrame* pcFrame ); - Bool seek( UInt64 iFrameNum ); - Bool read( PlaYUVerFrame* pcFrame ); - Bool write( PlaYUVerFrame* pcFrame ); + bool openHandler( ClpString strFilename, bool bInput ); + void closeHandler(); + bool configureBuffer( CalypFrame* pcFrame ); + bool seek( unsigned long long int iFrameNum ); + bool read( CalypFrame* pcFrame ); + bool write( CalypFrame* pcFrame ); private: cv::VideoCapture* pcVideoCapture; diff --git a/lib/StreamHandlerPortableMap.cpp b/lib/StreamHandlerPortableMap.cpp index ce1cb06..a6ce073 100644 --- a/lib/StreamHandlerPortableMap.cpp +++ b/lib/StreamHandlerPortableMap.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -24,30 +24,29 @@ #include "StreamHandlerPortableMap.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerFramePixelFormats.h" #include #include -std::vector StreamHandlerPortableMap::supportedReadFormats() +std::vector StreamHandlerPortableMap::supportedReadFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - //REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable PixMap ", "ppm" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + //REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable BitMap ", "pbm" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable PixMap ", "ppm" ); + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector StreamHandlerPortableMap::supportedWriteFormats() +std::vector StreamHandlerPortableMap::supportedWriteFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerPortableMap::Create, "Portable GrayMap ", "pgm" ); + END_REGIST_CALYP_SUPPORTED_FMT; } -Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput ) +bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput ) { m_bIsInput = bInput; m_pFile = NULL; @@ -72,7 +71,7 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput ) { m_uiBitsPerPixel = 1; m_iMaxValue = 1; - m_iPixelFormat = PlaYUVerFrame::GRAY; + m_iPixelFormat = CLP_GRAY; } else { @@ -80,7 +79,7 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput ) ; sscanf( line, "%d", &m_iMaxValue ); m_uiBitsPerPixel = log( m_iMaxValue + 1 ) / log( 2 ); - m_iPixelFormat = m_iMagicNumber == 2 || m_iMagicNumber == 5 ? PlaYUVerFrame::GRAY : PlaYUVerFrame::RGB24; + m_iPixelFormat = m_iMagicNumber == 2 || m_iMagicNumber == 5 ? CLP_GRAY : CLP_RGB24; } } else @@ -90,11 +89,11 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput ) { m_iMagicNumber = 4; } - else if( m_iPixelFormat == PlaYUVerFrame::GRAY ) + else if( m_iPixelFormat == CLP_GRAY ) { m_iMagicNumber = 5; } - else if( m_iPixelFormat == PlaYUVerFrame::RGB24 ) + else if( m_iPixelFormat == CLP_RGB24 ) { m_iMagicNumber = 6; } @@ -110,7 +109,7 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput ) return true; } -Void StreamHandlerPortableMap::closeHandler() +void StreamHandlerPortableMap::closeHandler() { if( m_pFile ) fclose( m_pFile ); @@ -119,28 +118,28 @@ Void StreamHandlerPortableMap::closeHandler() freeMem1D( m_pStreamBuffer ); } -Bool StreamHandlerPortableMap::configureBuffer( PlaYUVerFrame* pcFrame ) +bool StreamHandlerPortableMap::configureBuffer( CalypFrame* pcFrame ) { - return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); + return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); } -Bool StreamHandlerPortableMap::seek( UInt64 iFrameNum ) +bool StreamHandlerPortableMap::seek( unsigned long long int iFrameNum ) { // m_uiCurrFrameFileIdx = return true; } -Bool StreamHandlerPortableMap::read( PlaYUVerFrame* pcFrame ) +bool StreamHandlerPortableMap::read( CalypFrame* pcFrame ) { - UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile ); + unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile ); if( processed_bytes != m_uiNBytesPerFrame ) return false; - pcFrame->frameFromBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN ); + pcFrame->frameFromBuffer( m_pStreamBuffer, CLP_BIG_ENDIAN ); m_uiCurrFrameFileIdx++; return true; } -Bool StreamHandlerPortableMap::write( PlaYUVerFrame* pcFrame ) +bool StreamHandlerPortableMap::write( CalypFrame* pcFrame ) { fseek( m_pFile, 0, SEEK_SET ); fprintf( m_pFile, "P%d\n%d %d\n", m_iMagicNumber, m_uiWidth, m_uiHeight ); @@ -148,8 +147,8 @@ Bool StreamHandlerPortableMap::write( PlaYUVerFrame* pcFrame ) { fprintf( m_pFile, "%d\n", m_iMaxValue ); } - pcFrame->frameToBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN ); - UInt64 processed_bytes = fwrite( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile ); + pcFrame->frameToBuffer( m_pStreamBuffer, CLP_BIG_ENDIAN ); + unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile ); if( processed_bytes != m_uiNBytesPerFrame ) return false; return true; diff --git a/lib/StreamHandlerPortableMap.h b/lib/StreamHandlerPortableMap.h index bde01de..48d4c82 100644 --- a/lib/StreamHandlerPortableMap.h +++ b/lib/StreamHandlerPortableMap.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,35 +19,33 @@ /** * \file StreamHandlerPortableMap.h + * \ingroup CalypStreamGrp * \brief Handling portable pixmap formats */ #ifndef __STREAMHANDLERPORTABLEMAP_H__ #define __STREAMHANDLERPORTABLEMAP_H__ -#include "PlaYUVerDefs.h" -#include "PlaYUVerStreamHandlerIf.h" +#include "CalypStreamHandlerIf.h" -class PlaYUVerFrame; - -class StreamHandlerPortableMap : public PlaYUVerStreamHandlerIf +class StreamHandlerPortableMap : public CalypStreamHandlerIf { - REGISTER_STREAM_HANDLER( StreamHandlerPortableMap ) + REGISTER_CALYP_STREAM_HANDLER( StreamHandlerPortableMap ) public: StreamHandlerPortableMap() { m_pchHandlerName = "PortableMaps"; } ~StreamHandlerPortableMap() {} - Bool openHandler( String strFilename, Bool bInput ); - Void closeHandler(); - Bool configureBuffer( PlaYUVerFrame* pcFrame ); - Bool seek( UInt64 iFrameNum ); - Bool read( PlaYUVerFrame* pcFrame ); - Bool write( PlaYUVerFrame* pcFrame ); + bool openHandler( ClpString strFilename, bool bInput ); + void closeHandler(); + bool configureBuffer( CalypFrame* pcFrame ); + bool seek( unsigned long long int iFrameNum ); + bool read( CalypFrame* pcFrame ); + bool write( CalypFrame* pcFrame ); private: FILE* m_pFile; /**< The input file pointer >*/ - Int m_iMagicNumber; - Int m_iMaxValue; + int m_iMagicNumber; + int m_iMaxValue; }; #endif // __STREAMHANDLERPORTABLEMAP_H__ diff --git a/lib/StreamHandlerRaw.cpp b/lib/StreamHandlerRaw.cpp index 4413cb9..c4167dc 100644 --- a/lib/StreamHandlerRaw.cpp +++ b/lib/StreamHandlerRaw.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,34 +19,33 @@ /** * \file StreamHandlerRaw.cpp - * \brief Interface for raw (yuv) streams + * \brief interface for raw (yuv) streams */ #include "StreamHandlerRaw.h" +#include "CalypFrame.h" #include "LibMemory.h" -#include "PlaYUVerFrame.h" -#include "PlaYUVerFramePixelFormats.h" #include -std::vector StreamHandlerRaw::supportedReadFormats() +std::vector StreamHandlerRaw::supportedReadFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw YUV Video", "yuv" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Gray Video", "gray" ); - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw RGB Video", "rgb" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw YUV Video", "yuv" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Gray Video", "gray" ); + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw RGB Video", "rgb" ); + END_REGIST_CALYP_SUPPORTED_FMT; } -std::vector StreamHandlerRaw::supportedWriteFormats() +std::vector StreamHandlerRaw::supportedWriteFormats() { - INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Video", "yuv" ); - END_REGIST_PLAYUVER_SUPPORTED_FMT; + INI_REGIST_CALYP_SUPPORTED_FMT; + REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Video", "yuv" ); + END_REGIST_CALYP_SUPPORTED_FMT; } -Bool StreamHandlerRaw::openHandler( String strFilename, Bool bInput ) +bool StreamHandlerRaw::openHandler( ClpString strFilename, bool bInput ) { m_bIsInput = bInput; m_pFile = NULL; @@ -61,7 +60,7 @@ Bool StreamHandlerRaw::openHandler( String strFilename, Bool bInput ) return true; } -Void StreamHandlerRaw::closeHandler() +void StreamHandlerRaw::closeHandler() { if( m_pFile ) fclose( m_pFile ); @@ -69,23 +68,23 @@ Void StreamHandlerRaw::closeHandler() freeMem1D( m_pStreamBuffer ); } -Bool StreamHandlerRaw::configureBuffer( PlaYUVerFrame* pcFrame ) +bool StreamHandlerRaw::configureBuffer( CalypFrame* pcFrame ) { - return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); + return getMem1D( &m_pStreamBuffer, pcFrame->getBytesPerFrame() ); } -Void StreamHandlerRaw::calculateFrameNumber() +void StreamHandlerRaw::calculateFrameNumber() { if( m_pFile && m_uiNBytesPerFrame > 0 ) { fseek( m_pFile, 0, SEEK_END ); - UInt64 fileSize = ftell( m_pFile ); + unsigned long long int fileSize = ftell( m_pFile ); fseek( m_pFile, 0, SEEK_SET ); m_uiTotalNumberFrames = fileSize / m_uiNBytesPerFrame; } } -Bool StreamHandlerRaw::seek( UInt64 iFrameNum ) +bool StreamHandlerRaw::seek( unsigned long long int iFrameNum ) { if( m_bIsInput && m_pFile ) { @@ -96,11 +95,11 @@ Bool StreamHandlerRaw::seek( UInt64 iFrameNum ) return false; } -Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame ) +bool StreamHandlerRaw::read( CalypFrame* pcFrame ) { if( !m_pFile || !m_pStreamBuffer || m_uiNBytesPerFrame == 0 ) return false; - UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile ); + unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile ); if( processed_bytes != m_uiNBytesPerFrame ) return false; m_uiCurrFrameFileIdx++; @@ -108,10 +107,10 @@ Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame ) return true; } -Bool StreamHandlerRaw::write( PlaYUVerFrame* pcFrame ) +bool StreamHandlerRaw::write( CalypFrame* pcFrame ) { pcFrame->frameToBuffer( m_pStreamBuffer, m_iEndianness ); - UInt64 processed_bytes = fwrite( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile ); + unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile ); if( processed_bytes != m_uiNBytesPerFrame ) return false; return true; diff --git a/lib/StreamHandlerRaw.h b/lib/StreamHandlerRaw.h index 9890e66..d7f1b3e 100644 --- a/lib/StreamHandlerRaw.h +++ b/lib/StreamHandlerRaw.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -19,22 +19,22 @@ /** * \file StreamHandlerRaw.h + * \ingroup CalypStreamGrp * \brief Abstract class for stream handling */ #ifndef __STREAMHANDLERRAW_H__ #define __STREAMHANDLERRAW_H__ -#include "PlaYUVerDefs.h" -#include "PlaYUVerStreamHandlerIf.h" +#include "CalypStreamHandlerIf.h" /** * \class StreamHandlerRaw * \brief Class to handle raw video format */ -class StreamHandlerRaw : public PlaYUVerStreamHandlerIf +class StreamHandlerRaw : public CalypStreamHandlerIf { - REGISTER_STREAM_HANDLER( StreamHandlerRaw ) + REGISTER_CALYP_STREAM_HANDLER( StreamHandlerRaw ) private: FILE* m_pFile; /**< The input file pointer >*/ @@ -42,13 +42,13 @@ private: public: StreamHandlerRaw() { m_pchHandlerName = "RawVideo"; } ~StreamHandlerRaw() {} - Bool openHandler( String strFilename, Bool bInput ); - Void closeHandler(); - Bool configureBuffer( PlaYUVerFrame* pcFrame ); - Void calculateFrameNumber(); - Bool seek( UInt64 iFrameNum ); - Bool read( PlaYUVerFrame* pcFrame ); - Bool write( PlaYUVerFrame* pcFrame ); + bool openHandler( ClpString strFilename, bool bInput ); + void closeHandler(); + bool configureBuffer( CalypFrame* pcFrame ); + void calculateFrameNumber(); + bool seek( unsigned long long int iFrameNum ); + bool read( CalypFrame* pcFrame ); + bool write( CalypFrame* pcFrame ); }; #endif // __STREAMHANDLERRAW_H__ diff --git a/modules/AbsoluteFrameDifference.cpp b/modules/AbsoluteFrameDifference.cpp index f350ddc..9c750e7 100644 --- a/modules/AbsoluteFrameDifference.cpp +++ b/modules/AbsoluteFrameDifference.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,51 +27,49 @@ AbsoluteFrameDifference::AbsoluteFrameDifference() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; // Use API version 2 (recommended). + m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended). // See this example for details on the functions prototype - m_iModuleType = FRAME_PROCESSING_MODULE; // Apply module to the frames or to + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to // the whole sequence. m_pchModuleCategory = "Measurements"; // Category (sub-menu) m_pchModuleName = "AbsoluteFrameDifference"; // Name (no spaces) m_pchModuleLongName = "Absolute Difference"; // Long Name m_pchModuleTooltip = "Measure the absolute difference " // Description "between two images (Y plane), e. g., abs( Y1 - Y2 )"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; // Number of Frames required - // (ONE_FRAME, TWO_FRAMES, - // THREE_FRAMES) - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; // Module requirements - // (check - // PlaYUVerModulesIf.h). + m_uiNumberOfFrames = 2; // Number of frames required + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; // Module requirements + // (check + // CalypModulesIf.h). // Several requirements should be "or" between each others. m_pcFrameDifference = NULL; } -Bool AbsoluteFrameDifference::create( std::vector apcFrameList ) +bool AbsoluteFrameDifference::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) return false; m_pcFrameDifference = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); return true; } -PlaYUVerFrame* AbsoluteFrameDifference::process( std::vector apcFrameList ) +CalypFrame* AbsoluteFrameDifference::process( std::vector apcFrameList ) { - PlaYUVerFrame* Input1 = apcFrameList[0]; - PlaYUVerFrame* Input2 = apcFrameList[1]; - Pel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; - Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; - Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; - Int aux_pel_1, aux_pel_2; + CalypFrame* Input1 = apcFrameList[0]; + CalypFrame* Input2 = apcFrameList[1]; + ClpPel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; + ClpPel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; + ClpPel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; + int aux_pel_1, aux_pel_2; - for( UInt y = 0; y < m_pcFrameDifference->getHeight(); y++ ) - for( UInt x = 0; x < m_pcFrameDifference->getWidth(); x++ ) + for( unsigned int y = 0; y < m_pcFrameDifference->getHeight(); y++ ) + for( unsigned int x = 0; x < m_pcFrameDifference->getWidth(); x++ ) { aux_pel_1 = *pInput1PelYUV++; aux_pel_2 = *pInput2PelYUV++; @@ -80,7 +78,7 @@ PlaYUVerFrame* AbsoluteFrameDifference::process( std::vector apc return m_pcFrameDifference; } -Void AbsoluteFrameDifference::destroy() +void AbsoluteFrameDifference::destroy() { if( m_pcFrameDifference ) delete m_pcFrameDifference; diff --git a/modules/AbsoluteFrameDifference.h b/modules/AbsoluteFrameDifference.h index 6052721..7524f9c 100644 --- a/modules/AbsoluteFrameDifference.h +++ b/modules/AbsoluteFrameDifference.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,22 +25,22 @@ #ifndef __ABSOLUTEFRAMEDIFFERENCE_H__ #define __ABSOLUTEFRAMEDIFFERENCE_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class AbsoluteFrameDifference : public PlaYUVerModuleIf +class AbsoluteFrameDifference : public CalypModuleIf { REGISTER_CLASS_FACTORY( AbsoluteFrameDifference ) private: - PlaYUVerFrame* m_pcFrameDifference; + CalypFrame* m_pcFrameDifference; public: AbsoluteFrameDifference(); virtual ~AbsoluteFrameDifference() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __FRAMEDIFFERENCE_H__ diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 3477466..5f682b5 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,13 +1,13 @@ ### -### CMakeLists for playuver modules component +### CMakeLists for calyp modules component ### -OPTION( MODULE_THREADED_MODULES "Use threads for modules" OFF ) +OPTION( CALYP_THREADED_MODULES "Use threads for modules" OFF ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -set(plaYUver_Mod_SRCS - PlaYUVerModuleFactory.cpp +set(Calyp_Mod_SRCS + CalypModulesFactory.cpp ) # @@ -36,9 +36,9 @@ ADD_MODULE_USE_OPENCV( OpticalFlowDualTVL1 "OpticalFlow" VERSION 3.1.0 MODULES ADD_MODULE_USE_OPENCV( OpticalFlowSparseToDense "OpticalFlow" VERSION 3.1.0 MODULES optflow ) ADD_MODULE_USE_OPENCV( OpticalFlowFarneback "OpticalFlow" VERSION 3.1.0 MODULES video optflow ) ADD_MODULE_USE_OPENCV( OpticalDeepFlow "OpticalFlow" VERSION 3.1.0 MODULES video optflow ) -ADD_MODULE_USE_OPENCV( SaliencyDetectionSpectral "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) -ADD_MODULE_USE_OPENCV( SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) -ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) +ADD_MODULE_USE_OPENCV( SaliencyDetectionSpectral "SaliencyDetection" VERSION 3.3.0 MODULES saliency ) +ADD_MODULE_USE_OPENCV( SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3.3.0 MODULES saliency ) +ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.3.0 MODULES saliency ) # @@ -46,8 +46,8 @@ ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSI # CREATE_MODULE_MACROS() INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} ) -ADD_LIBRARY( PlaYUVerModules ${plaYUver_Mod_SRCS} ) -TARGET_LINK_LIBRARIES( PlaYUVerModules PlaYUVerLib ${OpenCV_LIBRARIES} ) +ADD_LIBRARY( CalypModules ${Calyp_Mod_SRCS} ) +TARGET_LINK_LIBRARIES( CalypModules ${PROJECT_LIBRARY} ${OpenCV_LIBRARIES} ) IF( USE_DYNLOAD ) - TARGET_LINK_LIBRARIES( PlaYUVerModules -ldl ) + TARGET_LINK_LIBRARIES( CalypModules -ldl ) ENDIF() diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/CalypModulesFactory.cpp similarity index 68% rename from modules/PlaYUVerModuleFactory.cpp rename to modules/CalypModulesFactory.cpp index c19525e..78e45b7 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/CalypModulesFactory.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,35 +18,36 @@ */ /** - * \file PlaYUVerModuleFactory.cpp - * \brief PlaYUVer modules factory + * \file CalypModuleFactory.cpp + * \brief Calyp modules factory */ -#include "PlaYUVerModuleFactory.h" +#include "CalypModulesFactory.h" #include "config.h" #include #include #ifdef USE_DYNLOAD #include +#include #endif // Generated by cmake #include "ModulesListHeader.h" -PlaYUVerModuleFactory::PlaYUVerModuleFactory(){REGISTER_ALL_MODULES} +CalypModulesFactory::CalypModulesFactory(){REGISTER_ALL_MODULES} -PlaYUVerModuleFactory::~PlaYUVerModuleFactory() +CalypModulesFactory::~CalypModulesFactory() { m_FactoryMap.clear(); } -Void PlaYUVerModuleFactory::Register( const char* moduleName, CreateModuleFn pfnCreate ) +void CalypModulesFactory::Register( const char* moduleName, CreateModuleFn pfnCreate ) { m_FactoryMap[moduleName] = pfnCreate; } -Bool PlaYUVerModuleFactory::RegisterDl( const char* dlName ) +bool CalypModulesFactory::RegisterDl( const char* dlName ) { #ifdef USE_DYNLOAD void* pHndl = dlopen( dlName, RTLD_NOW ); @@ -67,11 +68,11 @@ Bool PlaYUVerModuleFactory::RegisterDl( const char* dlName ) #endif } -PlaYUVerModuleIf* PlaYUVerModuleFactory::CreateModule( const char* moduleName ) +CalypModuleIf* CalypModulesFactory::CreateModule( const char* moduleName ) { - PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); - PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); - for( ; it != PlaYUVerModuleFactoryMap.end(); ++it ) + CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); + CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin(); + for( ; it != moduleFactoryMap.end(); ++it ) { if( !strcmp( it->first, moduleName ) ) { diff --git a/modules/PlaYUVerModuleFactory.h b/modules/CalypModulesFactory.h similarity index 51% rename from modules/PlaYUVerModuleFactory.h rename to modules/CalypModulesFactory.h index 9236f73..465d328 100644 --- a/modules/PlaYUVerModuleFactory.h +++ b/modules/CalypModulesFactory.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,45 +18,45 @@ */ /** - * \file PlaYUVerModuleFactory.h - * \brief PlaYUVer modules factory + * \file CalypModuleFactory.h + * \brief Calyp modules factory */ -#ifndef __PLAYUVERMODULESFACTORY_H__ -#define __PLAYUVERMODULESFACTORY_H__ +#ifndef __CALYPMODULESFACTORY_H__ +#define __CALYPMODULESFACTORY_H__ #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" #define REGISTER_MODULE( X ) Register( "X", &( X::Create ) ); -typedef PlaYUVerModuleIf* ( *CreateModuleFn )( void ); -typedef std::map PlaYUVerModuleFactoryMap; +typedef CalypModuleIf* ( *CreateModuleFn )( void ); +typedef std::map CalypModulesFactoryMap; -// Factory for creating instances of PlaYUVerModuleIf -class PlaYUVerModuleFactory +// Factory for creating instances of CalypModuleIf +class CalypModulesFactory { private: - PlaYUVerModuleFactory(); - PlaYUVerModuleFactory& operator=( const PlaYUVerModuleFactory& ) { return *this; } - PlaYUVerModuleFactoryMap m_FactoryMap; + CalypModulesFactory(); + CalypModulesFactory& operator=( const CalypModulesFactory& ) { return *this; } + CalypModulesFactoryMap m_FactoryMap; public: - ~PlaYUVerModuleFactory(); + ~CalypModulesFactory(); - static PlaYUVerModuleFactory* Get() + static CalypModulesFactory* Get() { - static PlaYUVerModuleFactory instance; + static CalypModulesFactory instance; return &instance; } - Void Register( const char* moduleName, CreateModuleFn pfnCreate ); - Bool RegisterDl( const char* dlName ); + void Register( const char* moduleName, CreateModuleFn pfnCreate ); + bool RegisterDl( const char* dlName ); - PlaYUVerModuleIf* CreateModule( const char* moduleName ); - PlaYUVerModuleFactoryMap& getMap() { return m_FactoryMap; } + CalypModuleIf* CreateModule( const char* moduleName ); + CalypModulesFactoryMap& getMap() { return m_FactoryMap; } }; -#endif // __PLAYUVERMODULESFACTORY_H__ +#endif // __CALYPMODULESFACTORY_H__ diff --git a/modules/DisparityStereoBM.cpp b/modules/DisparityStereoBM.cpp index 61c8f1b..f052797 100644 --- a/modules/DisparityStereoBM.cpp +++ b/modules/DisparityStereoBM.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -28,15 +28,15 @@ DisparityStereoBM::DisparityStereoBM() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Stereo"; m_pchModuleName = "Disparity-BM"; m_pchModuleLongName = "Block macth based disparity"; m_pchModuleTooltip = "Measure the disparity between two images using the " "Stereo BM method (OpenCV)"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 2; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "block_size", m_uiBlockSize, "Block Size (positive odd number) [9]" ); @@ -45,11 +45,11 @@ DisparityStereoBM::DisparityStereoBM() m_uiBlockSize = 9; } -Bool DisparityStereoBM::create( std::vector apcFrameList ) +bool DisparityStereoBM::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ m_pcDisparityFrame = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); if( ( m_uiBlockSize % 2 ) == 0 ) { m_uiBlockSize++; @@ -80,10 +80,10 @@ Bool DisparityStereoBM::create( std::vector apcFrameList ) #endif return true; } -PlaYUVerFrame* DisparityStereoBM::process( std::vector apcFrameList ) +CalypFrame* DisparityStereoBM::process( std::vector apcFrameList ) { - PlaYUVerFrame* InputLeft = apcFrameList[0]; - PlaYUVerFrame* InputRight = apcFrameList[1]; + CalypFrame* InputLeft = apcFrameList[0]; + CalypFrame* InputRight = apcFrameList[1]; cv::Mat leftImage, rightImage; if( !InputLeft->toMat( leftImage, true ) || !InputRight->toMat( rightImage, true ) ) @@ -104,7 +104,7 @@ PlaYUVerFrame* DisparityStereoBM::process( std::vector apcFrameL return m_pcDisparityFrame; } -Void DisparityStereoBM::destroy() +void DisparityStereoBM::destroy() { if( m_pcDisparityFrame ) delete m_pcDisparityFrame; diff --git a/modules/DisparityStereoBM.h b/modules/DisparityStereoBM.h index a4bfee5..6a78664 100644 --- a/modules/DisparityStereoBM.h +++ b/modules/DisparityStereoBM.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,17 +29,17 @@ // OpenCV #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class DisparityStereoBM : public PlaYUVerModuleIf +class DisparityStereoBM : public CalypModuleIf { REGISTER_CLASS_FACTORY( DisparityStereoBM ) private: - PlaYUVerFrame* m_pcDisparityFrame; - Int m_uiNumberOfDisparities; - UInt m_uiBlockSize; + CalypFrame* m_pcDisparityFrame; + int m_uiNumberOfDisparities; + unsigned int m_uiBlockSize; #if( CV_MAJOR_VERSION == 2 ) cv::StereoBM m_cStereoBM; #else @@ -49,9 +49,9 @@ private: public: DisparityStereoBM(); virtual ~DisparityStereoBM() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __DISPARITYSTEREOBM_H__ diff --git a/modules/DisparityStereoSGBM.cpp b/modules/DisparityStereoSGBM.cpp index 8afa443..4b0a565 100644 --- a/modules/DisparityStereoSGBM.cpp +++ b/modules/DisparityStereoSGBM.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -28,15 +28,15 @@ DisparityStereoSGBM::DisparityStereoSGBM() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Stereo"; m_pchModuleName = "Disparity-SGBM"; m_pchModuleName = "SGBM based disparity"; m_pchModuleTooltip = "Measure the disparity between two images using the " "Stereo SGBM method (OpenCV)"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 2; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "block_size", m_uiBlockSize, "Block Size (positive odd number) [3]" )( "HHAlgorithm", m_bUseHH, @@ -47,17 +47,17 @@ DisparityStereoSGBM::DisparityStereoSGBM() m_uiNumberOfDisparities = 0; } -Bool DisparityStereoSGBM::create( std::vector apcFrameList ) +bool DisparityStereoSGBM::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ m_pcDisparityFrame = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); if( ( m_uiBlockSize % 2 ) == 0 ) { m_uiBlockSize++; } m_uiNumberOfDisparities = ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16; - Int cn = apcFrameList[0]->getNumberChannels(); + int cn = apcFrameList[0]->getNumberChannels(); #if( CV_MAJOR_VERSION == 3 ) m_cStereoMatch = cv::StereoSGBM::create( 0, 16, m_uiBlockSize ); m_cStereoMatch->setPreFilterCap( 63 ); @@ -89,10 +89,10 @@ Bool DisparityStereoSGBM::create( std::vector apcFrameList ) return true; } -PlaYUVerFrame* DisparityStereoSGBM::process( std::vector apcFrameList ) +CalypFrame* DisparityStereoSGBM::process( std::vector apcFrameList ) { - PlaYUVerFrame* InputLeft = apcFrameList[0]; - PlaYUVerFrame* InputRight = apcFrameList[1]; + CalypFrame* InputLeft = apcFrameList[0]; + CalypFrame* InputRight = apcFrameList[1]; cv::Mat leftImage, rightImage; if( !InputLeft->toMat( leftImage, true ) || !InputRight->toMat( rightImage, true ) ) { @@ -109,7 +109,7 @@ PlaYUVerFrame* DisparityStereoSGBM::process( std::vector apcFram return m_pcDisparityFrame; } -Void DisparityStereoSGBM::destroy() +void DisparityStereoSGBM::destroy() { if( m_pcDisparityFrame ) delete m_pcDisparityFrame; diff --git a/modules/DisparityStereoSGBM.h b/modules/DisparityStereoSGBM.h index e98c0c1..b7b0579 100644 --- a/modules/DisparityStereoSGBM.h +++ b/modules/DisparityStereoSGBM.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -48,18 +48,18 @@ // OpenCV #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class DisparityStereoSGBM : public PlaYUVerModuleIf +class DisparityStereoSGBM : public CalypModuleIf { REGISTER_CLASS_FACTORY( DisparityStereoSGBM ) private: - PlaYUVerFrame* m_pcDisparityFrame; - Bool m_bUseHH; - Int m_uiNumberOfDisparities; - UInt m_uiBlockSize; + CalypFrame* m_pcDisparityFrame; + bool m_bUseHH; + int m_uiNumberOfDisparities; + unsigned int m_uiBlockSize; #if( CV_MAJOR_VERSION == 3 ) cv::Ptr m_cStereoMatch; #else @@ -69,9 +69,9 @@ private: public: DisparityStereoSGBM(); virtual ~DisparityStereoSGBM() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __DISPARITYSTEREOSGBM_H__ diff --git a/modules/DisparityStereoVar.cpp b/modules/DisparityStereoVar.cpp index b8364cc..d27eb46 100644 --- a/modules/DisparityStereoVar.cpp +++ b/modules/DisparityStereoVar.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -53,18 +53,18 @@ DisparityStereoVar::DisparityStereoVar() m_cStereoVar.USE_MEDIAN_FILTERING; } -Bool DisparityStereoVar::create( std::vector apcFrameList ) +bool DisparityStereoVar::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ m_pcDisparityFrame = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CalypFrame::GRAY ); m_cStereoVar.minDisp = -( ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16 ); return true; } -PlaYUVerFrame* DisparityStereoVar::process( std::vector apcFrameList ) +CalypFrame* DisparityStereoVar::process( std::vector apcFrameList ) { - PlaYUVerFrame* InputLeft = apcFrameList[0]; - PlaYUVerFrame* InputRight = apcFrameList[1]; + CalypFrame* InputLeft = apcFrameList[0]; + CalypFrame* InputRight = apcFrameList[1]; cv::Mat* leftImage = InputLeft->getCvMat(); cv::Mat* rightImage = InputRight->getCvMat(); @@ -77,7 +77,7 @@ PlaYUVerFrame* DisparityStereoVar::process( std::vector apcFrame return m_pcDisparityFrame; } -Void DisparityStereoVar::destroy() +void DisparityStereoVar::destroy() { if( m_pcDisparityFrame ) delete m_pcDisparityFrame; diff --git a/modules/DisparityStereoVar.h b/modules/DisparityStereoVar.h index c3e1bbf..4d68bac 100644 --- a/modules/DisparityStereoVar.h +++ b/modules/DisparityStereoVar.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,23 +29,23 @@ // OpenCV #include -// PlaYUVerLib -#include "PlaYUVerModuleIf.h" +// CalypLib +#include "CalypModuleIf.h" -class DisparityStereoVar : public PlaYUVerModuleIf +class DisparityStereoVar : public CalypModuleIf { REGISTER_CLASS_FACTORY( DisparityStereoVar ) private: - PlaYUVerFrame* m_pcDisparityFrame; + CalypFrame* m_pcDisparityFrame; cv::StereoVar m_cStereoVar; public: DisparityStereoVar(); virtual ~DisparityStereoVar() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __DISPARITYSTEREOVAR_H__ diff --git a/modules/EightBitsSampling.cpp b/modules/EightBitsSampling.cpp index 9d34c4a..e0a0712 100644 --- a/modules/EightBitsSampling.cpp +++ b/modules/EightBitsSampling.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,45 +27,45 @@ EightBitsSampling::EightBitsSampling() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Conversions"; m_pchModuleName = "EightBitsSampling"; m_pchModuleLongName = "8 bit sub-sampling"; m_pchModuleTooltip = "Sub-sampling frame to 8bpp"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; m_pcSubSampledFrame = NULL; } -Bool EightBitsSampling::create( std::vector apcFrameList ) +bool EightBitsSampling::create( std::vector apcFrameList ) { if( apcFrameList[0]->getBitsPel() > 8 ) { m_pcSubSampledFrame = NULL; - m_pcSubSampledFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), - apcFrameList[0]->getPelFormat(), 8 ); + m_pcSubSampledFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), + apcFrameList[0]->getPelFormat(), 8 ); return true; } return false; } -PlaYUVerFrame* EightBitsSampling::process( std::vector apcFrameList ) +CalypFrame* EightBitsSampling::process( std::vector apcFrameList ) { - PlaYUVerFrame* pcFrame = apcFrameList[0]; - UInt uiShiftBits = pcFrame->getBitsPel() - 8; - Pel* pPelInput = pcFrame->getPelBufferYUV()[0][0]; - Pel* pPelSubSampled = m_pcSubSampledFrame->getPelBufferYUV()[0][0]; - Pel pelValue; + CalypFrame* pcFrame = apcFrameList[0]; + unsigned int uiShiftBits = pcFrame->getBitsPel() - 8; + ClpPel* pPelInput = pcFrame->getPelBufferYUV()[0][0]; + ClpPel* pPelSubSampled = m_pcSubSampledFrame->getPelBufferYUV()[0][0]; + ClpPel pelValue; - for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) + for( unsigned int i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) { pelValue = *pPelInput++; pelValue = pelValue >> uiShiftBits; *pPelSubSampled++ = pelValue; } - for( UInt i = 0; i < pcFrame->getChromaLength() * 2; i++ ) + for( unsigned int i = 0; i < pcFrame->getChromaLength() * 2; i++ ) { pelValue = *pPelInput++; pelValue = pelValue >> uiShiftBits; @@ -74,7 +74,7 @@ PlaYUVerFrame* EightBitsSampling::process( std::vector apcFrameL return m_pcSubSampledFrame; } -Void EightBitsSampling::destroy() +void EightBitsSampling::destroy() { if( m_pcSubSampledFrame ) delete m_pcSubSampledFrame; diff --git a/modules/EightBitsSampling.h b/modules/EightBitsSampling.h index df6c80c..809f321 100644 --- a/modules/EightBitsSampling.h +++ b/modules/EightBitsSampling.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,22 +25,22 @@ #ifndef __EIGHTBITSSAMPLING_H__ #define __EIGHTBITSSAMPLING_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class EightBitsSampling : public PlaYUVerModuleIf +class EightBitsSampling : public CalypModuleIf { REGISTER_CLASS_FACTORY( EightBitsSampling ) private: - PlaYUVerFrame* m_pcSubSampledFrame; + CalypFrame* m_pcSubSampledFrame; public: EightBitsSampling(); virtual ~EightBitsSampling() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __EIGHTBITSSAMPLING_H__ diff --git a/modules/FilterComponent.cpp b/modules/FilterComponent.cpp index 90c5d3b..895c496 100644 --- a/modules/FilterComponent.cpp +++ b/modules/FilterComponent.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,32 +29,32 @@ FilterComponentModule::FilterComponentModule() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; m_pchModuleCategory = "Filtering"; m_pcFilteredFrame = NULL; } -Bool FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel ) +bool FilterComponentModule::createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel ) { m_pcFilteredFrame = NULL; - m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY, bitsPixel ); + m_pcFilteredFrame = new CalypFrame( uiWidth, uiHeight, CLP_GRAY, bitsPixel ); return true; } -PlaYUVerFrame* FilterComponentModule::filterComponent( PlaYUVerFrame* InputFrame, Int Component ) +CalypFrame* FilterComponentModule::filterComponent( CalypFrame* InputFrame, int Component ) { - Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV(); - Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV(); - memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[Component][0], - m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof( Pel ) ); + ClpPel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV(); + ClpPel*** pppInputPelYUV = InputFrame->getPelBufferYUV(); + memcpy( pppOutputPelYUV[CLP_LUMA][0], pppInputPelYUV[Component][0], + m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof( ClpPel ) ); return m_pcFilteredFrame; } -Void FilterComponentModule::destroy() +void FilterComponentModule::destroy() { if( m_pcFilteredFrame ) delete m_pcFilteredFrame; @@ -69,14 +69,14 @@ FilterComponentLuma::FilterComponentLuma() m_pchModuleTooltip = "Filter Y matrix of YUV frame"; // Description } -Bool FilterComponentLuma::create( std::vector apcFrameList ) +bool FilterComponentLuma::create( std::vector apcFrameList ) { return createFilter( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getBitsPel() ); } -PlaYUVerFrame* FilterComponentLuma::process( std::vector apcFrameList ) +CalypFrame* FilterComponentLuma::process( std::vector apcFrameList ) { - return filterComponent( apcFrameList[0], LUMA ); + return filterComponent( apcFrameList[0], CLP_LUMA ); } FilterComponentChromaU::FilterComponentChromaU() @@ -86,19 +86,19 @@ FilterComponentChromaU::FilterComponentChromaU() m_pchModuleTooltip = "Filter U matrix of YUV frame"; } -Bool FilterComponentChromaU::create( std::vector apcFrameList ) +bool FilterComponentChromaU::create( std::vector apcFrameList ) { if( apcFrameList[0]->getNumberChannels() > 1 ) { - return createFilter( apcFrameList[0]->getWidth( CHROMA_U ), apcFrameList[0]->getHeight( CHROMA_U ), + return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_U ), apcFrameList[0]->getHeight( CLP_CHROMA_U ), apcFrameList[0]->getBitsPel() ); } return false; } -PlaYUVerFrame* FilterComponentChromaU::process( std::vector apcFrameList ) +CalypFrame* FilterComponentChromaU::process( std::vector apcFrameList ) { - return filterComponent( apcFrameList[0], CHROMA_U ); + return filterComponent( apcFrameList[0], CLP_CHROMA_U ); } FilterComponentChromaV::FilterComponentChromaV() @@ -109,17 +109,17 @@ FilterComponentChromaV::FilterComponentChromaV() m_pchModuleTooltip = "Filter V matrix of YUV frame"; } -Bool FilterComponentChromaV::create( std::vector apcFrameList ) +bool FilterComponentChromaV::create( std::vector apcFrameList ) { if( apcFrameList[0]->getNumberChannels() > 1 ) { - return createFilter( apcFrameList[0]->getWidth( CHROMA_V ), apcFrameList[0]->getHeight( CHROMA_V ), + return createFilter( apcFrameList[0]->getWidth( CLP_CHROMA_V ), apcFrameList[0]->getHeight( CLP_CHROMA_V ), apcFrameList[0]->getBitsPel() ); } return false; } -PlaYUVerFrame* FilterComponentChromaV::process( std::vector apcFrameList ) +CalypFrame* FilterComponentChromaV::process( std::vector apcFrameList ) { - return filterComponent( apcFrameList[0], CHROMA_V ); + return filterComponent( apcFrameList[0], CLP_CHROMA_V ); } diff --git a/modules/FilterComponent.h b/modules/FilterComponent.h index 6626e93..1a03418 100644 --- a/modules/FilterComponent.h +++ b/modules/FilterComponent.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,23 +25,23 @@ #ifndef __FILTERCOMPONENT_H__ #define __FILTERCOMPONENT_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FilterComponentModule : public PlaYUVerModuleIf +class FilterComponentModule : public CalypModuleIf { private: - PlaYUVerFrame* m_pcFilteredFrame; + CalypFrame* m_pcFilteredFrame; public: FilterComponentModule(); virtual ~FilterComponentModule() {} - Bool create( std::vector apcFrameList ) = 0; - PlaYUVerFrame* process( std::vector apcFrameList ) = 0; - Void destroy(); + bool create( std::vector apcFrameList ) = 0; + CalypFrame* process( std::vector apcFrameList ) = 0; + void destroy(); - Bool createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel ); - PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component ); + bool createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel ); + CalypFrame* filterComponent( CalypFrame* InputFrame, int Component ); }; class FilterComponentLuma : public FilterComponentModule @@ -50,8 +50,8 @@ class FilterComponentLuma : public FilterComponentModule public: FilterComponentLuma(); virtual ~FilterComponentLuma() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; class FilterComponentChromaU : public FilterComponentModule @@ -60,8 +60,8 @@ class FilterComponentChromaU : public FilterComponentModule public: FilterComponentChromaU(); virtual ~FilterComponentChromaU() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; class FilterComponentChromaV : public FilterComponentModule @@ -70,8 +70,8 @@ class FilterComponentChromaV : public FilterComponentModule public: FilterComponentChromaV(); virtual ~FilterComponentChromaV() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; #endif // __FILTERFRAME_H__ diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp index 1f7fe6c..f832f0c 100644 --- a/modules/FrameBinarization.cpp +++ b/modules/FrameBinarization.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,13 +27,13 @@ FrameBinarization::FrameBinarization() { /* Module Definition */ - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleLongName = "Binarization"; m_pchModuleName = "FrameBinarization"; m_pchModuleTooltip = "Binarize frame"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" ); @@ -42,25 +42,25 @@ FrameBinarization::FrameBinarization() m_uiThreshold = 128; } -Void FrameBinarization::create( PlaYUVerFrame* frame ) +void FrameBinarization::create( CalypFrame* frame ) { m_pcBinFrame = NULL; - m_pcBinFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), PlaYUVerFrame::GRAY, 8 ); + m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), CLP_GRAY, 8 ); } -PlaYUVerFrame* FrameBinarization::process( PlaYUVerFrame* frame ) +CalypFrame* FrameBinarization::process( CalypFrame* frame ) { - Pel* pPelInput = frame->getPelBufferYUV()[0][0]; - Pel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0]; - for( UInt y = 0; y < frame->getHeight(); y++ ) - for( UInt x = 0; x < frame->getWidth(); x++ ) + ClpPel* pPelInput = frame->getPelBufferYUV()[0][0]; + ClpPel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0]; + for( unsigned int y = 0; y < frame->getHeight(); y++ ) + for( unsigned int x = 0; x < frame->getWidth(); x++ ) { *pPelBin++ = *pPelInput++ >= m_uiThreshold ? 255 : 0; } return m_pcBinFrame; } -Void FrameBinarization::destroy() +void FrameBinarization::destroy() { if( m_pcBinFrame ) delete m_pcBinFrame; diff --git a/modules/FrameBinarization.h b/modules/FrameBinarization.h index 8b9502b..cd3d95f 100644 --- a/modules/FrameBinarization.h +++ b/modules/FrameBinarization.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,23 +25,23 @@ #ifndef __FRAMEBINARIZATION_H__ #define __FRAMEBINARIZATION_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameBinarization : public PlaYUVerModuleIf +class FrameBinarization : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameBinarization ) private: - PlaYUVerFrame* m_pcBinFrame; - UInt m_uiThreshold; + CalypFrame* m_pcBinFrame; + unsigned int m_uiThreshold; public: FrameBinarization(); virtual ~FrameBinarization() {} - Void create( PlaYUVerFrame* ); - PlaYUVerFrame* process( PlaYUVerFrame* ); - Void destroy(); + void create( CalypFrame* ); + CalypFrame* process( CalypFrame* ); + void destroy(); }; #endif // __FRAMEBINARIZATION_H__ diff --git a/modules/FrameCrop.cpp b/modules/FrameCrop.cpp index a2161d1..bb26ea5 100644 --- a/modules/FrameCrop.cpp +++ b/modules/FrameCrop.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,13 +27,13 @@ FrameCrop::FrameCrop() { /* Module Definition */ - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleLongName = "Crop"; m_pchModuleName = "FrameCrop"; m_pchModuleTooltip = "Crop a region of a frame"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "xPosition", m_uiXPosition, "X cordinate of the left-top corner of the crop region [0]" ) /**/ @@ -48,7 +48,7 @@ FrameCrop::FrameCrop() m_iYSize = -1; } -Void FrameCrop::create( PlaYUVerFrame* frame ) +void FrameCrop::create( CalypFrame* frame ) { m_pcCropedFrame = NULL; if( m_uiXPosition >= frame->getWidth() ) @@ -59,16 +59,16 @@ Void FrameCrop::create( PlaYUVerFrame* frame ) m_iXSize = frame->getWidth() - m_uiXPosition; if( m_iYSize == -1 || ( m_uiYPosition + m_iYSize ) >= frame->getHeight() ) m_iYSize = frame->getHeight() - m_uiYPosition; - m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat(), frame->getBitsPel() ); + m_pcCropedFrame = new CalypFrame( m_iXSize, m_iYSize, frame->getPelFormat(), frame->getBitsPel() ); } -PlaYUVerFrame* FrameCrop::process( PlaYUVerFrame* frame ) +CalypFrame* FrameCrop::process( CalypFrame* frame ) { m_pcCropedFrame->copyFrom( frame, m_uiXPosition, m_uiYPosition ); return m_pcCropedFrame; } -Void FrameCrop::destroy() +void FrameCrop::destroy() { if( m_pcCropedFrame ) delete m_pcCropedFrame; diff --git a/modules/FrameCrop.h b/modules/FrameCrop.h index 089f172..66f495a 100644 --- a/modules/FrameCrop.h +++ b/modules/FrameCrop.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,26 +25,26 @@ #ifndef __FRAMECROP_H__ #define __FRAMECROP_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameCrop : public PlaYUVerModuleIf +class FrameCrop : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameCrop ) private: - PlaYUVerFrame* m_pcCropedFrame; - UInt m_uiXPosition; - UInt m_uiYPosition; - Int m_iXSize; - Int m_iYSize; + CalypFrame* m_pcCropedFrame; + unsigned int m_uiXPosition; + unsigned int m_uiYPosition; + int m_iXSize; + int m_iYSize; public: FrameCrop(); virtual ~FrameCrop() {} - Void create( PlaYUVerFrame* ); - PlaYUVerFrame* process( PlaYUVerFrame* ); - Void destroy(); + void create( CalypFrame* ); + CalypFrame* process( CalypFrame* ); + void destroy(); }; #endif // __FRAMECROP_H__ diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index 5f8a446..f3b4fe9 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,15 +27,15 @@ FrameDifference::FrameDifference() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Measurements"; m_pchModuleName = "FrameDifference"; m_pchModuleName = "Difference"; m_pchModuleTooltip = "Measure the difference between two images (Y plane), " "Y1 - Y2, with max absolute diff of 128"; - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 2; m_cModuleOptions.addOptions() /**/ ( "Bits per pixel", m_uiBitsPixel, "Bits per pixel (use zero to avoid scaling) [0]" ); @@ -45,15 +45,15 @@ FrameDifference::FrameDifference() m_pcFrameDifference = NULL; } -Bool FrameDifference::create( std::vector apcFrameList ) +bool FrameDifference::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - UInt uiMaxBitsPixel = 0; - for( UInt i = 0; i < apcFrameList.size(); i++ ) + unsigned int uiMaxBitsPixel = 0; + for( unsigned int i = 0; i < apcFrameList.size(); i++ ) { if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], - PlaYUVerFrame::MATCH_COLOR_SPACE | PlaYUVerFrame::MATCH_RESOLUTION ) ) + CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_RESOLUTION ) ) return false; if( apcFrameList[i]->getBitsPel() > uiMaxBitsPixel ) { @@ -69,21 +69,21 @@ Bool FrameDifference::create( std::vector apcFrameList ) m_iDiffBitShift = ( uiMaxBitsPixel + 1 ) - m_uiBitsPixel; m_iMaxDiffValue = ( 1 << ( m_uiBitsPixel - 1 ) ); - m_pcFrameDifference = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), - PlaYUVerFrame::GRAY, m_uiBitsPixel ); + m_pcFrameDifference = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), + CLP_GRAY, m_uiBitsPixel ); return true; } -PlaYUVerFrame* FrameDifference::process( std::vector apcFrameList ) +CalypFrame* FrameDifference::process( std::vector apcFrameList ) { - Pel* pInput1PelYUV = apcFrameList[0]->getPelBufferYUV()[0][0]; - Pel* pInput2PelYUV = apcFrameList[1]->getPelBufferYUV()[0][0]; - Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; - Int aux_pel_1, aux_pel_2; - Int diff = 0; + ClpPel* pInput1PelYUV = apcFrameList[0]->getPelBufferYUV()[0][0]; + ClpPel* pInput2PelYUV = apcFrameList[1]->getPelBufferYUV()[0][0]; + ClpPel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; + int aux_pel_1, aux_pel_2; + int diff = 0; - for( UInt y = 0; y < m_pcFrameDifference->getHeight(); y++ ) - for( UInt x = 0; x < m_pcFrameDifference->getWidth(); x++ ) + for( unsigned int y = 0; y < m_pcFrameDifference->getHeight(); y++ ) + for( unsigned int x = 0; x < m_pcFrameDifference->getWidth(); x++ ) { aux_pel_1 = *pInput1PelYUV++; aux_pel_2 = *pInput2PelYUV++; @@ -98,7 +98,7 @@ PlaYUVerFrame* FrameDifference::process( std::vector apcFrameLis return m_pcFrameDifference; } -Void FrameDifference::destroy() +void FrameDifference::destroy() { if( m_pcFrameDifference ) delete m_pcFrameDifference; diff --git a/modules/FrameDifference.h b/modules/FrameDifference.h index 28008bc..3211b35 100644 --- a/modules/FrameDifference.h +++ b/modules/FrameDifference.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,25 +25,25 @@ #ifndef __FRAMEDIFFERENCE_H__ #define __FRAMEDIFFERENCE_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameDifference : public PlaYUVerModuleIf +class FrameDifference : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameDifference ) private: - UInt m_uiBitsPixel; - Int m_iDiffBitShift; - Int m_iMaxDiffValue; - PlaYUVerFrame* m_pcFrameDifference; + unsigned int m_uiBitsPixel; + int m_iDiffBitShift; + int m_iMaxDiffValue; + CalypFrame* m_pcFrameDifference; public: FrameDifference(); virtual ~FrameDifference() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __FRAMEDIFFERENCE_H__ diff --git a/modules/FrameMask.cpp b/modules/FrameMask.cpp index 5d5e3b2..0df432a 100644 --- a/modules/FrameMask.cpp +++ b/modules/FrameMask.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,14 +27,14 @@ FrameMask::FrameMask() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleLongName = "Apply mask"; m_pchModuleName = "FrameMask"; m_pchModuleTooltip = "Applies a mask to the selected image (first image)"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS | MODULE_USES_KEYS; + m_uiNumberOfFrames = 2; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS | CLP_MODULE_USES_KEYS; m_cModuleOptions.addOptions() /**/ ( "MaskWeigth", m_iWeight, "Influence of the mask [60%]" ); @@ -44,15 +44,15 @@ FrameMask::FrameMask() m_pcFrameProcessed = NULL; } -Bool FrameMask::create( std::vector apcFrameList ) +bool FrameMask::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) { - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE_IGNORE_GRAY | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE_IGNORE_GRAY | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) { return false; } @@ -61,41 +61,41 @@ Bool FrameMask::create( std::vector apcFrameList ) m_iWeight = m_iWeight > 100 || m_iWeight < 0 ? 5 : m_iWeight; m_iWeight = m_iWeight > 10 ? m_iWeight / 10 : m_iWeight; - Int iPelFmt = 0; - Int iColorSpace = apcFrameList[0]->getColorSpace(); - if( iColorSpace == PlaYUVerPixel::COLOR_GRAY ) + int iPelFmt = 0; + int iColorSpace = apcFrameList[0]->getColorSpace(); + if( iColorSpace == CLP_COLOR_GRAY ) { iColorSpace = apcFrameList[1]->getPelFormat(); } switch( iColorSpace ) { - case PlaYUVerPixel::COLOR_GRAY: - iPelFmt = PlaYUVerFrame::GRAY; + case CLP_COLOR_GRAY: + iPelFmt = CLP_GRAY; break; - case PlaYUVerPixel::COLOR_YUV: - iPelFmt = PlaYUVerFrame::YUV444p; + case CLP_COLOR_YUV: + iPelFmt = CLP_YUV444P; break; - case PlaYUVerPixel::COLOR_RGB: - iPelFmt = PlaYUVerFrame::RGB24; + case CLP_COLOR_RGB: + iPelFmt = CLP_RGB24; break; } - m_pcFrameProcessed = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), iPelFmt, - apcFrameList[0]->getBitsPel() ); + m_pcFrameProcessed = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), iPelFmt, + apcFrameList[0]->getBitsPel() ); return true; } -PlaYUVerFrame* FrameMask::process( std::vector apcFrameList ) +CalypFrame* FrameMask::process( std::vector apcFrameList ) { - PlaYUVerFrame* InputFrame = apcFrameList[0]; - PlaYUVerFrame* MaskFrame = apcFrameList[1]; - PlaYUVerPixel pixelImg; - PlaYUVerPixel pixelMask; - PlaYUVerPixel pixelOut; + CalypFrame* InputFrame = apcFrameList[0]; + CalypFrame* MaskFrame = apcFrameList[1]; + CalypPixel pixelImg; + CalypPixel pixelMask; + CalypPixel pixelOut; - for( UInt y = 0; y < m_pcFrameProcessed->getHeight(); y++ ) + for( unsigned int y = 0; y < m_pcFrameProcessed->getHeight(); y++ ) { - for( UInt x = 0; x < m_pcFrameProcessed->getWidth(); x++ ) + for( unsigned int x = 0; x < m_pcFrameProcessed->getWidth(); x++ ) { pixelImg = InputFrame->getPixel( x, y ); pixelMask = MaskFrame->getPixel( x, y ); @@ -107,7 +107,7 @@ PlaYUVerFrame* FrameMask::process( std::vector apcFrameList ) return m_pcFrameProcessed; } -Bool FrameMask::keyPressed( enum Module_Key_Supported value ) +bool FrameMask::keyPressed( enum Module_Key_Supported value ) { if( value == MODULE_KEY_UP && m_iWeight < 10 ) { @@ -122,7 +122,7 @@ Bool FrameMask::keyPressed( enum Module_Key_Supported value ) return false; } -Void FrameMask::destroy() +void FrameMask::destroy() { if( m_pcFrameProcessed ) { diff --git a/modules/FrameMask.h b/modules/FrameMask.h index 4471c30..3b61f3b 100644 --- a/modules/FrameMask.h +++ b/modules/FrameMask.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,24 +25,24 @@ #ifndef __FRAMEMASK_H__ #define __FRAMEMASK_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameMask : public PlaYUVerModuleIf +class FrameMask : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameMask ) private: - Int m_iWeight; - PlaYUVerFrame* m_pcFrameProcessed; + int m_iWeight; + CalypFrame* m_pcFrameProcessed; public: FrameMask(); virtual ~FrameMask() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Bool keyPressed( enum Module_Key_Supported value ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + bool keyPressed( enum Module_Key_Supported value ); + void destroy(); }; #endif // __FRAMEMASK_H__ diff --git a/modules/FrameRotate.cpp b/modules/FrameRotate.cpp index b9be8f4..893baaa 100644 --- a/modules/FrameRotate.cpp +++ b/modules/FrameRotate.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,14 +27,14 @@ FrameRotate::FrameRotate() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleLongName = "Rotation"; m_pchModuleName = "FrameRotate"; m_pchModuleTooltip = "Rotates frame"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "Angle", m_iAngle, "Angle to rotate (0, 90, 180, 270)" ); @@ -44,12 +44,12 @@ FrameRotate::FrameRotate() m_pcFrameProcessed = NULL; } -Bool FrameRotate::create( std::vector apcFrameList ) +bool FrameRotate::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - UInt iWidth; - UInt iHeight; + unsigned int iWidth; + unsigned int iHeight; switch( m_iAngle ) { @@ -67,23 +67,23 @@ Bool FrameRotate::create( std::vector apcFrameList ) return false; } - m_pcFrameProcessed = new PlaYUVerFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(), - apcFrameList[0]->getBitsPel() ); + m_pcFrameProcessed = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(), + apcFrameList[0]->getBitsPel() ); return true; } -PlaYUVerFrame* FrameRotate::process( std::vector apcFrameList ) +CalypFrame* FrameRotate::process( std::vector apcFrameList ) { - PlaYUVerFrame* InputFrame = apcFrameList[0]; - UInt inWidht = InputFrame->getWidth(); - UInt inHeight = InputFrame->getHeight(); - PlaYUVerPixel pixel; - UInt inX; - UInt inY; + CalypFrame* InputFrame = apcFrameList[0]; + unsigned int inWidht = InputFrame->getWidth(); + unsigned int inHeight = InputFrame->getHeight(); + CalypPixel pixel; + unsigned int inX; + unsigned int inY; - for( UInt y = 0; y < m_pcFrameProcessed->getHeight(); y++ ) + for( unsigned int y = 0; y < m_pcFrameProcessed->getHeight(); y++ ) { - for( UInt x = 0; x < m_pcFrameProcessed->getWidth(); x++ ) + for( unsigned int x = 0; x < m_pcFrameProcessed->getWidth(); x++ ) { inX = x; inY = y; @@ -109,7 +109,7 @@ PlaYUVerFrame* FrameRotate::process( std::vector apcFrameList ) return m_pcFrameProcessed; } -Void FrameRotate::destroy() +void FrameRotate::destroy() { if( m_pcFrameProcessed ) { diff --git a/modules/FrameRotate.h b/modules/FrameRotate.h index c40d7f4..1f4cc14 100644 --- a/modules/FrameRotate.h +++ b/modules/FrameRotate.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,23 +25,23 @@ #ifndef __FRAMEROTATE_H__ #define __FRAMEROTATE_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameRotate : public PlaYUVerModuleIf +class FrameRotate : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameRotate ) private: - Int m_iAngle; - PlaYUVerFrame* m_pcFrameProcessed; + int m_iAngle; + CalypFrame* m_pcFrameProcessed; public: FrameRotate(); virtual ~FrameRotate() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __FRAMEROTATE_H__ diff --git a/modules/FrameShift.cpp b/modules/FrameShift.cpp index aea5559..aa710ab 100644 --- a/modules/FrameShift.cpp +++ b/modules/FrameShift.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,14 +27,14 @@ FrameShift::FrameShift() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Utilities"; m_pchModuleLongName = "Pixel Shift"; m_pchModuleName = "FrameShift"; m_pchModuleTooltip = "Shift frame horizontal and vertical"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS | MODULE_USES_KEYS; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS | CLP_MODULE_USES_KEYS; m_cModuleOptions.addOptions() /**/ ( "ShiftHorizontal", m_iShiftHor, "Amount of pixels to shift in horizontal direction" ) /**/ @@ -45,42 +45,42 @@ FrameShift::FrameShift() m_iShiftVer = 0; } -Bool FrameShift::create( std::vector apcFrameList ) +bool FrameShift::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - m_pcProcessedFrame = new PlaYUVerFrame( apcFrameList[0] ); + m_pcProcessedFrame = new CalypFrame( apcFrameList[0] ); return true; } -PlaYUVerFrame* FrameShift::process( std::vector apcFrameList ) +CalypFrame* FrameShift::process( std::vector apcFrameList ) { - Pel* pPelInput; - Pel* pPelOut; + ClpPel* pPelInput; + ClpPel* pPelOut; - m_pcProcessedFrame->clear(); + m_pcProcessedFrame->reset(); - for( UInt ch = 0; ch < m_pcProcessedFrame->getNumberChannels(); ch++ ) + for( unsigned int ch = 0; ch < m_pcProcessedFrame->getNumberChannels(); ch++ ) { - UInt uiWidth = m_pcProcessedFrame->getWidth( ch ); - UInt uiHeight = m_pcProcessedFrame->getHeight( ch ); + unsigned int uiWidth = m_pcProcessedFrame->getWidth( ch ); + unsigned int uiHeight = m_pcProcessedFrame->getHeight( ch ); - Int iShiftHor = m_iShiftHor >> ( ch > 0 ? m_pcProcessedFrame->getChromaWidthRatio() : 0 ); - Int iShiftVer = m_iShiftVer >> ( ch > 0 ? m_pcProcessedFrame->getChromaHeightRatio() : 0 ); + int iShiftHor = m_iShiftHor >> ( ch > 0 ? m_pcProcessedFrame->getChromaWidthRatio() : 0 ); + int iShiftVer = m_iShiftVer >> ( ch > 0 ? m_pcProcessedFrame->getChromaHeightRatio() : 0 ); - UInt xStartIn = iShiftHor >= 0 ? 0 : -iShiftHor; - UInt yStartIn = iShiftVer >= 0 ? 0 : -iShiftVer; + unsigned int xStartIn = iShiftHor >= 0 ? 0 : -iShiftHor; + unsigned int yStartIn = iShiftVer >= 0 ? 0 : -iShiftVer; - UInt xStartOut = std::max( iShiftHor, 0 ); - UInt xEndOut = std::min( uiWidth, uiWidth + iShiftHor ); + unsigned int xStartOut = std::max( iShiftHor, 0 ); + unsigned int xEndOut = std::min( uiWidth, uiWidth + iShiftHor ); - UInt yStartOut = std::max( iShiftVer, 0 ); - UInt yEndOut = std::min( uiHeight, uiHeight + iShiftVer ); + unsigned int yStartOut = std::max( iShiftVer, 0 ); + unsigned int yEndOut = std::min( uiHeight, uiHeight + iShiftVer ); - for( UInt y = yStartOut, yIn = yStartIn; y < yEndOut; y++, yIn++ ) + for( unsigned int y = yStartOut, yIn = yStartIn; y < yEndOut; y++, yIn++ ) { pPelInput = &( apcFrameList[0]->getPelBufferYUV()[ch][yIn][xStartIn] ); pPelOut = &( m_pcProcessedFrame->getPelBufferYUV()[ch][y][xStartOut] ); - for( UInt x = xStartOut; x < xEndOut; x++ ) + for( unsigned int x = xStartOut; x < xEndOut; x++ ) { *pPelOut = *pPelInput; pPelInput++; @@ -91,7 +91,7 @@ PlaYUVerFrame* FrameShift::process( std::vector apcFrameList ) return m_pcProcessedFrame; } -Bool FrameShift::keyPressed( enum Module_Key_Supported value ) +bool FrameShift::keyPressed( enum Module_Key_Supported value ) { if( value == MODULE_KEY_LEFT ) { @@ -117,7 +117,7 @@ Bool FrameShift::keyPressed( enum Module_Key_Supported value ) return false; } -Void FrameShift::destroy() +void FrameShift::destroy() { if( m_pcProcessedFrame ) delete m_pcProcessedFrame; diff --git a/modules/FrameShift.h b/modules/FrameShift.h index 7cb8eb6..8e1e264 100644 --- a/modules/FrameShift.h +++ b/modules/FrameShift.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,25 +25,25 @@ #ifndef __FRAMESHIFT_H__ #define __FRAMESHIFT_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class FrameShift : public PlaYUVerModuleIf +class FrameShift : public CalypModuleIf { REGISTER_CLASS_FACTORY( FrameShift ) private: - PlaYUVerFrame* m_pcProcessedFrame; - Int m_iShiftHor; - Int m_iShiftVer; + CalypFrame* m_pcProcessedFrame; + int m_iShiftHor; + int m_iShiftVer; public: FrameShift(); virtual ~FrameShift() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Bool keyPressed( enum Module_Key_Supported value ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + bool keyPressed( enum Module_Key_Supported value ); + void destroy(); }; #endif // __FrameShift_H__ diff --git a/modules/InterFrameVariance.cpp b/modules/InterFrameVariance.cpp index 32ad36a..93b2876 100644 --- a/modules/InterFrameVariance.cpp +++ b/modules/InterFrameVariance.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,77 +29,73 @@ InterFrameVariance::InterFrameVariance() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; // Use API version 2 (recommended). + m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended). // See this example for details on the functions prototype - m_iModuleType = FRAME_PROCESSING_MODULE; // Apply module to the frames or to - // the whole sequence. - m_pchModuleCategory = "Measurements"; // Category (sub-menu) - m_pchModuleName = "InterFrameVariance"; // Name + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to + // the whole sequence. + m_pchModuleCategory = "Measurements"; // Category (sub-menu) + m_pchModuleName = "InterFrameVariance"; // Name m_pchModuleLongName = "Variance across frames"; m_pchModuleTooltip = "Measure the variance across several frames"; - m_uiNumberOfFrames = MODULE_REQUIRES_SEVERAL_FRAMES; // Number of Frames required (This module - // allows a variable number of inputs) - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; // Module requirements - // (check - // PlaYUVerModulesIf.h). + m_uiNumberOfFrames = 2; // Number of Frames required (This module + // allows a variable number of inputs) + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULES_VARIABLE_NUM_FRAMES; // Several requirements should be "or" between each others. m_pcFrameVariance = NULL; } -Bool InterFrameVariance::create( std::vector apcFrameList ) +bool InterFrameVariance::create( std::vector apcFrameList ) { - m_uiNumberOfFrames = Module_NumberOfFrames( apcFrameList.size() ); - _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) return false; m_pcFrameVariance = - new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY, 8 ); + new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, 8 ); getMem2D( &m_pVariance, apcFrameList[0]->getHeight(), apcFrameList[0]->getWidth() ); return true; } -PlaYUVerFrame* InterFrameVariance::process( std::vector apcFrameList ) +CalypFrame* InterFrameVariance::process( std::vector apcFrameList ) { - Int numFrames = apcFrameList.size(); + int numFrames = apcFrameList.size(); - Pel** pInput = new Pel*[numFrames]; - Pel* pOutputPelYUV = m_pcFrameVariance->getPelBufferYUV()[0][0]; + ClpPel** pInput = new ClpPel*[numFrames]; + ClpPel* pOutputPelYUV = m_pcFrameVariance->getPelBufferYUV()[0][0]; - for( Int i = 0; i < numFrames; i++ ) + for( int i = 0; i < numFrames; i++ ) { pInput[i] = apcFrameList[i]->getPelBufferYUV()[0][0]; } - Double maxVariance = 0; - for( UInt y = 0; y < m_pcFrameVariance->getHeight(); y++ ) - for( UInt x = 0; x < m_pcFrameVariance->getWidth(); x++ ) + double maxVariance = 0; + for( unsigned int y = 0; y < m_pcFrameVariance->getHeight(); y++ ) + for( unsigned int x = 0; x < m_pcFrameVariance->getWidth(); x++ ) { - Int sum = 0; - Int v = 0; + int sum = 0; + int v = 0; m_pVariance[y][x] = 0; - for( Int i = 0; i < numFrames; i++ ) + for( int i = 0; i < numFrames; i++ ) { v = *pInput[i]++; sum += v; m_pVariance[y][x] += v * v; } // Final result of the variance for one block - m_pVariance[y][x] -= Double( sum * sum ) / Double( numFrames ); - m_pVariance[y][x] /= Double( numFrames ); + m_pVariance[y][x] -= double( sum * sum ) / double( numFrames ); + m_pVariance[y][x] /= double( numFrames ); if( m_pVariance[y][x] > maxVariance ) maxVariance = m_pVariance[y][x]; } - for( UInt y = 0; y < m_pcFrameVariance->getHeight(); y++ ) - for( UInt x = 0; x < m_pcFrameVariance->getWidth(); x++ ) + for( unsigned int y = 0; y < m_pcFrameVariance->getHeight(); y++ ) + for( unsigned int x = 0; x < m_pcFrameVariance->getWidth(); x++ ) { *pOutputPelYUV++ = m_pVariance[y][x] * 255 / maxVariance; } @@ -107,7 +103,7 @@ PlaYUVerFrame* InterFrameVariance::process( std::vector apcFrame return m_pcFrameVariance; } -Void InterFrameVariance::destroy() +void InterFrameVariance::destroy() { if( m_pVariance ) freeMem2D( m_pVariance ); diff --git a/modules/InterFrameVariance.h b/modules/InterFrameVariance.h index 19da25f..d2f8ec5 100644 --- a/modules/InterFrameVariance.h +++ b/modules/InterFrameVariance.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,30 +18,30 @@ */ /** - * \file InterFrameVariance.h + * \file interFrameVariance.h * \brief Absolute Frame Difference module */ #ifndef __INTERFRAMEVARIANCE_H__ #define __INTERFRAMEVARIANCE_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class InterFrameVariance : public PlaYUVerModuleIf +class InterFrameVariance : public CalypModuleIf { REGISTER_CLASS_FACTORY( InterFrameVariance ) private: - PlaYUVerFrame* m_pcFrameVariance; - Double** m_pVariance; + CalypFrame* m_pcFrameVariance; + double** m_pVariance; public: InterFrameVariance(); virtual ~InterFrameVariance() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __INTERFRAMEVARIANCE_H__ diff --git a/modules/LumaAverage.cpp b/modules/LumaAverage.cpp index bc19b3d..fb56353 100644 --- a/modules/LumaAverage.cpp +++ b/modules/LumaAverage.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,35 +27,35 @@ LumaAverage::LumaAverage() { /* Module Definition */ - m_iModuleType = FRAME_MEASUREMENT_MODULE; // Apply module to the frames or to + m_iModuleType = CLP_FRAME_MEASUREMENT_MODULE; // Apply module to the frames or to // the whole sequence. // Currently only support for frame m_pchModuleCategory = "Measurements"; // Category (sub-menu) m_pchModuleName = "LumaAverage"; // Name m_pchModuleLongName = "Average"; // Long name m_pchModuleTooltip = "Measure the average of luma component"; // Description - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; // Number of Frames required + m_uiNumberOfFrames = 1; // Number of Frames required // (ONE_FRAME, TWO_FRAMES, // THREE_FRAMES) - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; // Module requirements + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; // Module requirements // (check - // PlaYUVerModulesIf.h). + // CalypModulesIf.h). // Several requirements should be "or" between each others. } -Void LumaAverage::create( PlaYUVerFrame* frame ) {} +void LumaAverage::create( CalypFrame* frame ) {} -Double LumaAverage::measure( PlaYUVerFrame* frame ) +double LumaAverage::measure( CalypFrame* frame ) { - Double average = 0; - Pel* pPel = frame->getPelBufferYUV()[0][0]; - for( UInt y = 0; y < frame->getHeight(); y++ ) - for( UInt x = 0; x < frame->getWidth(); x++ ) + double average = 0; + ClpPel* pPel = frame->getPelBufferYUV()[0][0]; + for( unsigned int y = 0; y < frame->getHeight(); y++ ) + for( unsigned int x = 0; x < frame->getWidth(); x++ ) { average += *pPel; pPel++; } - return average / Double( frame->getHeight() * frame->getWidth() ); + return average / double( frame->getHeight() * frame->getWidth() ); } -Void LumaAverage::destroy() {} +void LumaAverage::destroy() {} diff --git a/modules/LumaAverage.h b/modules/LumaAverage.h index 96e82cf..54f3e35 100644 --- a/modules/LumaAverage.h +++ b/modules/LumaAverage.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,10 +25,10 @@ #ifndef __LUMAAVERAGE_H__ #define __LUMAAVERAGE_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class LumaAverage : public PlaYUVerModuleIf +class LumaAverage : public CalypModuleIf { REGISTER_CLASS_FACTORY( LumaAverage ) @@ -36,9 +36,9 @@ private: public: LumaAverage(); virtual ~LumaAverage() {} - Void create( PlaYUVerFrame* ); - Double measure( PlaYUVerFrame* ); - Void destroy(); + void create( CalypFrame* ); + double measure( CalypFrame* ); + void destroy(); }; #endif // __LUMAAVERAGE_H__ diff --git a/modules/MeasureOpticalFlowDualTVL1.cpp b/modules/MeasureOpticalFlowDualTVL1.cpp index 2d7e2c8..7a0f1ac 100644 --- a/modules/MeasureOpticalFlowDualTVL1.cpp +++ b/modules/MeasureOpticalFlowDualTVL1.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -34,14 +34,14 @@ using cv::Scalar; MeasureOpticalFlowDualTVL1::MeasureOpticalFlowDualTVL1() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Measurements"; m_pchModuleName = "MeasureOpticalFlowDualTVL1"; m_pchModuleLongName = "Optical flow based on DualTVL1"; m_pchModuleTooltip = "Measure optical flow"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 2; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "Show reconstruction", m_bShowReconstruction, "Show reconstructed frame instead of MVs [false]" ); @@ -50,19 +50,19 @@ MeasureOpticalFlowDualTVL1::MeasureOpticalFlowDualTVL1() m_pcOutputFrame = NULL; } -Bool MeasureOpticalFlowDualTVL1::create( std::vector apcFrameList ) +bool MeasureOpticalFlowDualTVL1::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) return false; m_iStep = 16; m_cTvl1 = cv::createOptFlow_DualTVL1(); - m_pcOutputFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); return true; } @@ -72,7 +72,7 @@ static inline bool isFlowCorrect( Point2f u ) return !cvIsNaN( u.x ) && !cvIsNaN( u.y ) && fabs( u.x ) < 1e9 && fabs( u.y ) < 1e9; } -Void MeasureOpticalFlowDualTVL1::drawFlow() +void MeasureOpticalFlowDualTVL1::drawFlow() { Mat cvMatAfter; m_pcFrameAfter->toMat( cvMatAfter, true ); @@ -82,7 +82,7 @@ Void MeasureOpticalFlowDualTVL1::drawFlow() for( int x = m_iStep / 2; x < m_cvFlow.cols; x += m_iStep ) { Point2f u( 0, 0 ); - Double count = 0; + double count = 0; for( int i = ( -m_iStep / 2 ); i < ( m_iStep / 2 ); i++ ) { for( int j = ( -m_iStep / 2 ); j < ( m_iStep / 2 ); j++ ) @@ -105,16 +105,16 @@ Void MeasureOpticalFlowDualTVL1::drawFlow() m_pcOutputFrame->fromMat( cvMatAfter ); } -Void MeasureOpticalFlowDualTVL1::compensateFlow() +void MeasureOpticalFlowDualTVL1::compensateFlow() { - for( UInt c = 0; c < m_pcOutputFrame->getNumberChannels(); c++ ) + for( unsigned int c = 0; c < m_pcOutputFrame->getNumberChannels(); c++ ) { - Pel** pPelPrev = m_pcFramePrev->getPelBufferYUV()[c]; - Pel* pPelOut = m_pcOutputFrame->getPelBufferYUV()[c][0]; + ClpPel** pPelPrev = m_pcFramePrev->getPelBufferYUV()[c]; + ClpPel* pPelOut = m_pcOutputFrame->getPelBufferYUV()[c][0]; - for( UInt y = 0; y < m_pcOutputFrame->getHeight( c ); y++ ) + for( unsigned int y = 0; y < m_pcOutputFrame->getHeight( c ); y++ ) { - for( UInt x = 0; x < m_pcOutputFrame->getWidth( c ); x++ ) + for( unsigned int x = 0; x < m_pcOutputFrame->getWidth( c ); x++ ) { Point2f u = m_cvFlow( y, x ); Point p( x + u.x, y + u.y ); @@ -125,7 +125,7 @@ Void MeasureOpticalFlowDualTVL1::compensateFlow() } } -PlaYUVerFrame* MeasureOpticalFlowDualTVL1::process( std::vector apcFrameList ) +CalypFrame* MeasureOpticalFlowDualTVL1::process( std::vector apcFrameList ) { m_pcFrameAfter = apcFrameList[0]; m_pcFramePrev = apcFrameList[1]; @@ -145,7 +145,7 @@ PlaYUVerFrame* MeasureOpticalFlowDualTVL1::process( std::vector return m_pcOutputFrame; } -Void MeasureOpticalFlowDualTVL1::destroy() +void MeasureOpticalFlowDualTVL1::destroy() { if( m_pcOutputFrame ) delete m_pcOutputFrame; diff --git a/modules/MeasureOpticalFlowDualTVL1.h b/modules/MeasureOpticalFlowDualTVL1.h index fc27d74..9a64eac 100644 --- a/modules/MeasureOpticalFlowDualTVL1.h +++ b/modules/MeasureOpticalFlowDualTVL1.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -28,31 +28,31 @@ #include #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class MeasureOpticalFlowDualTVL1 : public PlaYUVerModuleIf +class MeasureOpticalFlowDualTVL1 : public CalypModuleIf { REGISTER_CLASS_FACTORY( MeasureOpticalFlowDualTVL1 ) private: - Bool m_bShowReconstruction; - Int m_iStep; + bool m_bShowReconstruction; + int m_iStep; cv::Ptr m_cTvl1; cv::Mat_ m_cvFlow; - PlaYUVerFrame* m_pcFramePrev; - PlaYUVerFrame* m_pcFrameAfter; - PlaYUVerFrame* m_pcOutputFrame; + CalypFrame* m_pcFramePrev; + CalypFrame* m_pcFrameAfter; + CalypFrame* m_pcOutputFrame; - Void drawFlow(); - Void compensateFlow(); + void drawFlow(); + void compensateFlow(); public: MeasureOpticalFlowDualTVL1(); virtual ~MeasureOpticalFlowDualTVL1() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; #endif // __MeasureOpticalFlowDualTVL1_H__ diff --git a/modules/OpticalFlow.cpp b/modules/OpticalFlow.cpp index 84927f6..8fd44dd 100644 --- a/modules/OpticalFlow.cpp +++ b/modules/OpticalFlow.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -37,11 +37,11 @@ using cv::Scalar; OpticalFlowModule::OpticalFlowModule() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "OpticalFlow"; - m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 2; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "Show reconstruction", m_bShowReconstruction, "Show reconstructed frame instead of MVs [false]" ); @@ -50,18 +50,18 @@ OpticalFlowModule::OpticalFlowModule() m_pcOutputFrame = NULL; } -Bool OpticalFlowModule::commonCreate( std::vector apcFrameList ) +bool OpticalFlowModule::commonCreate( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 1; i < apcFrameList.size(); i++ ) - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_COLOR_SPACE | - PlaYUVerFrame::MATCH_RESOLUTION | - PlaYUVerFrame::MATCH_BITS ) ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE | + CalypFrame::MATCH_RESOLUTION | + CalypFrame::MATCH_BITS ) ) return false; m_iStep = 16; - m_pcOutputFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); return true; } @@ -71,7 +71,7 @@ static inline bool isFlowCorrect( Point2f u ) return !cvIsNaN( u.x ) && !cvIsNaN( u.y ) && fabs( u.x ) < 1e9 && fabs( u.y ) < 1e9; } -Void OpticalFlowModule::drawFlow() +void OpticalFlowModule::drawFlow() { Mat cvMatAfter; m_pcFrameAfter->toMat( cvMatAfter, true ); @@ -81,7 +81,7 @@ Void OpticalFlowModule::drawFlow() for( int x = m_iStep / 2; x < m_cvFlow.cols; x += m_iStep ) { Point2f u( 0, 0 ); - Double count = 0; + double count = 0; for( int i = ( -m_iStep / 2 ); i < ( m_iStep / 2 ); i++ ) { for( int j = ( -m_iStep / 2 ); j < ( m_iStep / 2 ); j++ ) @@ -104,16 +104,16 @@ Void OpticalFlowModule::drawFlow() m_pcOutputFrame->fromMat( cvMatAfter ); } -Void OpticalFlowModule::compensateFlow() +void OpticalFlowModule::compensateFlow() { - for( UInt c = 0; c < m_pcOutputFrame->getNumberChannels(); c++ ) + for( unsigned int c = 0; c < m_pcOutputFrame->getNumberChannels(); c++ ) { - Pel** pPelPrev = m_pcFramePrev->getPelBufferYUV()[c]; - Pel* pPelOut = m_pcOutputFrame->getPelBufferYUV()[c][0]; + ClpPel** pPelPrev = m_pcFramePrev->getPelBufferYUV()[c]; + ClpPel* pPelOut = m_pcOutputFrame->getPelBufferYUV()[c][0]; - for( UInt y = 0; y < m_pcOutputFrame->getHeight( c ); y++ ) + for( unsigned int y = 0; y < m_pcOutputFrame->getHeight( c ); y++ ) { - for( UInt x = 0; x < m_pcOutputFrame->getWidth( c ); x++ ) + for( unsigned int x = 0; x < m_pcOutputFrame->getWidth( c ); x++ ) { Point2f u = m_cvFlow( y, x ); Point p( x + u.x, y + u.y ); @@ -124,7 +124,7 @@ Void OpticalFlowModule::compensateFlow() } } -PlaYUVerFrame* OpticalFlowModule::process( std::vector apcFrameList ) +CalypFrame* OpticalFlowModule::process( std::vector apcFrameList ) { m_pcFrameAfter = apcFrameList[0]; m_pcFramePrev = apcFrameList[1]; @@ -144,7 +144,7 @@ PlaYUVerFrame* OpticalFlowModule::process( std::vector apcFrameL return m_pcOutputFrame; } -Void OpticalFlowModule::destroy() +void OpticalFlowModule::destroy() { if( m_pcOutputFrame ) delete m_pcOutputFrame; @@ -161,9 +161,9 @@ OpticalFlowDualTVL1::OpticalFlowDualTVL1() m_pchModuleTooltip = "Measure optical flow using DualTVL1 method"; } -Bool OpticalFlowDualTVL1::create( std::vector apcFrameList ) +bool OpticalFlowDualTVL1::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_cOpticalFlow = cv::createOptFlow_DualTVL1(); @@ -178,9 +178,9 @@ OpticalFlowSparseToDense::OpticalFlowSparseToDense() m_pchModuleTooltip = "Measure optical flow using SparseToDense method"; } -Bool OpticalFlowSparseToDense::create( std::vector apcFrameList ) +bool OpticalFlowSparseToDense::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_cOpticalFlow = cv::optflow::createOptFlow_SparseToDense(); @@ -195,9 +195,9 @@ OpticalFlowFarneback::OpticalFlowFarneback() m_pchModuleTooltip = "Measure optical flow using Farneback method"; } -Bool OpticalFlowFarneback::create( std::vector apcFrameList ) +bool OpticalFlowFarneback::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_cOpticalFlow = cv::optflow::createOptFlow_Farneback(); @@ -212,9 +212,9 @@ OpticalDeepFlow::OpticalDeepFlow() m_pchModuleTooltip = "Measure optical flow using Farneback method"; } -Bool OpticalDeepFlow::create( std::vector apcFrameList ) +bool OpticalDeepFlow::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_cOpticalFlow = cv::optflow::createOptFlow_DeepFlow(); diff --git a/modules/OpticalFlow.h b/modules/OpticalFlow.h index e88ac07..e42d1a2 100644 --- a/modules/OpticalFlow.h +++ b/modules/OpticalFlow.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,28 +29,28 @@ #include #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class OpticalFlowModule : public PlaYUVerModuleIf +class OpticalFlowModule : public CalypModuleIf { protected: - Bool m_bShowReconstruction; - Int m_iStep; + bool m_bShowReconstruction; + int m_iStep; cv::Ptr m_cOpticalFlow; cv::Mat_ m_cvFlow; - PlaYUVerFrame* m_pcFramePrev; - PlaYUVerFrame* m_pcFrameAfter; - PlaYUVerFrame* m_pcOutputFrame; - Void drawFlow(); - Void compensateFlow(); - Bool commonCreate( std::vector apcFrameList ); + CalypFrame* m_pcFramePrev; + CalypFrame* m_pcFrameAfter; + CalypFrame* m_pcOutputFrame; + void drawFlow(); + void compensateFlow(); + bool commonCreate( std::vector apcFrameList ); public: OpticalFlowModule(); virtual ~OpticalFlowModule() {} - PlaYUVerFrame* process( std::vector apcFrameList ); - Void destroy(); + CalypFrame* process( std::vector apcFrameList ); + void destroy(); }; class OpticalFlowDualTVL1 : public OpticalFlowModule @@ -59,7 +59,7 @@ class OpticalFlowDualTVL1 : public OpticalFlowModule public: OpticalFlowDualTVL1(); virtual ~OpticalFlowDualTVL1() {} - Bool create( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); }; class OpticalFlowSparseToDense : public OpticalFlowModule @@ -68,7 +68,7 @@ class OpticalFlowSparseToDense : public OpticalFlowModule public: OpticalFlowSparseToDense(); virtual ~OpticalFlowSparseToDense() {} - Bool create( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); }; class OpticalFlowFarneback : public OpticalFlowModule @@ -77,7 +77,7 @@ class OpticalFlowFarneback : public OpticalFlowModule public: OpticalFlowFarneback(); virtual ~OpticalFlowFarneback() {} - Bool create( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); }; class OpticalDeepFlow : public OpticalFlowModule @@ -86,7 +86,7 @@ class OpticalDeepFlow : public OpticalFlowModule public: OpticalDeepFlow(); virtual ~OpticalDeepFlow() {} - Bool create( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); }; #endif // __OPTICALFLOW_H__ diff --git a/modules/SaliencyDetection.cpp b/modules/SaliencyDetection.cpp index ed1b3f7..96eaed1 100644 --- a/modules/SaliencyDetection.cpp +++ b/modules/SaliencyDetection.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -35,25 +35,25 @@ using namespace cv::saliency; SaliencyDetectionModule::SaliencyDetectionModule() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Saliency"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; m_pcSaliencyFrame = NULL; } -Bool SaliencyDetectionModule::commonCreate( std::vector apcFrameList ) +bool SaliencyDetectionModule::commonCreate( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - m_pcSaliencyFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + m_pcSaliencyFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY ); return true; } -Bool SaliencyDetectionModule::commonProcess( std::vector apcFrameList ) +bool SaliencyDetectionModule::commonProcess( std::vector apcFrameList ) { Mat cvFrame; if( !apcFrameList[0]->toMat( cvFrame, true ) ) @@ -64,7 +64,7 @@ Bool SaliencyDetectionModule::commonProcess( std::vector apcFram return m_ptrSaliencyAlgorithm->computeSaliency( cvFrame, m_matSaliency ); } -Void SaliencyDetectionModule::destroy() +void SaliencyDetectionModule::destroy() { if( m_pcSaliencyFrame ) delete m_pcSaliencyFrame; @@ -77,7 +77,7 @@ SaliencyDetectionSpectral::SaliencyDetectionSpectral() m_pchModuleLongName = "Spectral residual"; m_pchModuleTooltip = "Measure saliency using spectral residual method"; - m_uiModuleRequirements = m_uiModuleRequirements | MODULE_REQUIRES_OPTIONS; + m_uiModuleRequirements = m_uiModuleRequirements | CLP_MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions() /**/ ( "Binary map", m_bBinaryMap, "Measure a binary saliency map [false]" ); @@ -85,9 +85,9 @@ SaliencyDetectionSpectral::SaliencyDetectionSpectral() m_bBinaryMap = false; } -Bool SaliencyDetectionSpectral::create( std::vector apcFrameList ) +bool SaliencyDetectionSpectral::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; @@ -96,7 +96,7 @@ Bool SaliencyDetectionSpectral::create( std::vector apcFrameList return true; } -PlaYUVerFrame* SaliencyDetectionSpectral::process( std::vector apcFrameList ) +CalypFrame* SaliencyDetectionSpectral::process( std::vector apcFrameList ) { if( commonProcess( apcFrameList ) ) { @@ -125,16 +125,16 @@ SaliencyDetectionFineGrained::SaliencyDetectionFineGrained() m_pchModuleTooltip = "Measure saliency using fine grained method"; } -Bool SaliencyDetectionFineGrained::create( std::vector apcFrameList ) +bool SaliencyDetectionFineGrained::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_ptrSaliencyAlgorithm = cv::saliency::StaticSaliencyFineGrained::create(); return true; } -PlaYUVerFrame* SaliencyDetectionFineGrained::process( std::vector apcFrameList ) +CalypFrame* SaliencyDetectionFineGrained::process( std::vector apcFrameList ) { if( commonProcess( apcFrameList ) ) m_pcSaliencyFrame->fromMat( m_matSaliency ); @@ -149,9 +149,9 @@ SaliencyDetectionBinWangApr2014::SaliencyDetectionBinWangApr2014() m_pchModuleTooltip = "Measure saliency using a fast self-tuning background subtraction algorithm"; } -Bool SaliencyDetectionBinWangApr2014::create( std::vector apcFrameList ) +bool SaliencyDetectionBinWangApr2014::create( std::vector apcFrameList ) { - Bool bRet = commonCreate( apcFrameList ); + bool bRet = commonCreate( apcFrameList ); if( !bRet ) return bRet; m_ptrSaliencyAlgorithm = MotionSaliencyBinWangApr2014::create(); @@ -160,7 +160,7 @@ Bool SaliencyDetectionBinWangApr2014::create( std::vector apcFra return true; } -PlaYUVerFrame* SaliencyDetectionBinWangApr2014::process( std::vector apcFrameList ) +CalypFrame* SaliencyDetectionBinWangApr2014::process( std::vector apcFrameList ) { if( commonProcess( apcFrameList ) ) { diff --git a/modules/SaliencyDetection.h b/modules/SaliencyDetection.h index ad42fbb..c15a9a1 100644 --- a/modules/SaliencyDetection.h +++ b/modules/SaliencyDetection.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,36 +29,36 @@ #include #include -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" /** - * \ingroup PlaYUVer_Modules - * @defgroup PlaYUVer_Modules_Saliency Saliency + * \ingroup Calyp_Modules + * @defgroup Calyp_Modules_Saliency Saliency * @{ * Frame processing modules for saliency detection * @} */ -class SaliencyDetectionModule : public PlaYUVerModuleIf +class SaliencyDetectionModule : public CalypModuleIf { protected: - PlaYUVerFrame* m_pcSaliencyFrame; + CalypFrame* m_pcSaliencyFrame; cv::Ptr m_ptrSaliencyAlgorithm; cv::Mat m_matSaliency; - Bool commonCreate( std::vector apcFrameList ); - Bool commonProcess( std::vector apcFrameList ); + bool commonCreate( std::vector apcFrameList ); + bool commonProcess( std::vector apcFrameList ); public: SaliencyDetectionModule(); virtual ~SaliencyDetectionModule() {} - Void destroy(); + void destroy(); }; /** - * \ingroup PlaYUVer_Modules_Saliency + * \ingroup Calyp_Modules_Saliency * \class SaliencyDetectionSpectral * \brief Starting from the principle of natural image statistics, * this method simulate the behavior of pre-attentive visual search. @@ -73,17 +73,17 @@ class SaliencyDetectionSpectral : public SaliencyDetectionModule { REGISTER_CLASS_FACTORY( SaliencyDetectionSpectral ) private: - Bool m_bBinaryMap; + bool m_bBinaryMap; public: SaliencyDetectionSpectral(); virtual ~SaliencyDetectionSpectral() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; /** - * \ingroup PlaYUVer_Modules_Saliency + * \ingroup Calyp_Modules_Saliency * \class SaliencyDetectionFineGrained * \brief This method calculates saliency based on center-surround * differences. High resolution saliency maps are generated in real @@ -98,12 +98,12 @@ class SaliencyDetectionFineGrained : public SaliencyDetectionModule public: SaliencyDetectionFineGrained(); virtual ~SaliencyDetectionFineGrained() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; /** - * \ingroup PlaYUVer_Modules_Saliency + * \ingroup Calyp_Modules_Saliency * \class SaliencyDetectionBinWangApr2014 * \brief Fast Self-tuning Background Subtraction Algorithm based on the work * Wang and P. Dudek “A Fast Self-tuning Background Subtraction Algorithm”, @@ -115,8 +115,8 @@ class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule public: SaliencyDetectionBinWangApr2014(); virtual ~SaliencyDetectionBinWangApr2014() {} - Bool create( std::vector apcFrameList ); - PlaYUVerFrame* process( std::vector apcFrameList ); + bool create( std::vector apcFrameList ); + CalypFrame* process( std::vector apcFrameList ); }; #endif // __SALIENCYDETECTION_H__ diff --git a/modules/SetChromaHalfScale.cpp b/modules/SetChromaHalfScale.cpp index 1f84321..a05bc91 100644 --- a/modules/SetChromaHalfScale.cpp +++ b/modules/SetChromaHalfScale.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -27,42 +27,42 @@ SetChromaHalfScale::SetChromaHalfScale() { /* Module Definition */ - m_iModuleType = FRAME_PROCESSING_MODULE; + m_iModuleType = CLP_FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Conversions"; m_pchModuleName = "SetChromaHalfScale"; m_pchModuleLongName = "Half scale chroma"; m_pchModuleTooltip = "Copy frame only keeping luma component"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + m_uiNumberOfFrames = 1; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; m_pcProcessedFrame = NULL; } -Void SetChromaHalfScale::create( PlaYUVerFrame* frame ) +void SetChromaHalfScale::create( CalypFrame* frame ) { m_pcProcessedFrame = NULL; m_pcProcessedFrame = - new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), frame->getPelFormat(), frame->getBitsPel() ); + new CalypFrame( frame->getWidth(), frame->getHeight(), frame->getPelFormat(), frame->getBitsPel() ); } -PlaYUVerFrame* SetChromaHalfScale::process( PlaYUVerFrame* frame ) +CalypFrame* SetChromaHalfScale::process( CalypFrame* frame ) { - Pel* pPelInput = frame->getPelBufferYUV()[LUMA][0]; - Pel* pPelOut = m_pcProcessedFrame->getPelBufferYUV()[0][0]; - Pel halfScaleValue = 1 << ( frame->getBitsPel() - 1 ); - for( UInt i = 0; i < frame->getHeight() * frame->getWidth(); i++ ) + ClpPel* pPelInput = frame->getPelBufferYUV()[CLP_LUMA][0]; + ClpPel* pPelOut = m_pcProcessedFrame->getPelBufferYUV()[0][0]; + ClpPel halfScaleValue = 1 << ( frame->getBitsPel() - 1 ); + for( unsigned int i = 0; i < frame->getHeight() * frame->getWidth(); i++ ) { *pPelOut++ = *pPelInput++; } - pPelInput = frame->getPelBufferYUV()[CHROMA_U][0]; - for( UInt i = 0; i < m_pcProcessedFrame->getChromaLength() * 2; i++ ) + pPelInput = frame->getPelBufferYUV()[CLP_CHROMA_U][0]; + for( unsigned int i = 0; i < m_pcProcessedFrame->getChromaLength() * 2; i++ ) { *pPelOut++ = halfScaleValue; } return m_pcProcessedFrame; } -Void SetChromaHalfScale::destroy() +void SetChromaHalfScale::destroy() { if( m_pcProcessedFrame ) delete m_pcProcessedFrame; diff --git a/modules/SetChromaHalfScale.h b/modules/SetChromaHalfScale.h index 45040c9..1049f82 100644 --- a/modules/SetChromaHalfScale.h +++ b/modules/SetChromaHalfScale.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,22 +25,22 @@ #ifndef _SETCHROMAHALFSCALE_H_ #define _SETCHROMAHALFSCALE_H_ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class SetChromaHalfScale : public PlaYUVerModuleIf +class SetChromaHalfScale : public CalypModuleIf { REGISTER_CLASS_FACTORY( SetChromaHalfScale ) private: - PlaYUVerFrame* m_pcProcessedFrame; + CalypFrame* m_pcProcessedFrame; public: SetChromaHalfScale(); virtual ~SetChromaHalfScale() {} - Void create( PlaYUVerFrame* ); - PlaYUVerFrame* process( PlaYUVerFrame* ); - Void destroy(); + void create( CalypFrame* ); + CalypFrame* process( CalypFrame* ); + void destroy(); }; #endif // _SETCHROMAHALFSCALE_H_ diff --git a/modules/WeightedPSNR.cpp b/modules/WeightedPSNR.cpp index c3c7032..0fcc990 100644 --- a/modules/WeightedPSNR.cpp +++ b/modules/WeightedPSNR.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -29,14 +29,14 @@ WeightedPSNR::WeightedPSNR() { /* Module Definition */ - m_iModuleAPI = MODULE_API_2; - m_iModuleType = FRAME_MEASUREMENT_MODULE; + m_iModuleAPI = CLP_MODULE_API_2; + m_iModuleType = CLP_FRAME_MEASUREMENT_MODULE; m_pchModuleCategory = "Quality"; m_pchModuleName = "WeightedPSNR"; m_pchModuleLongName = "Weighted PSNR"; m_pchModuleTooltip = "Measure the weighted PSNR between two images"; - m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; - m_uiNumberOfFrames = MODULE_REQUIRES_THREE_FRAMES; + m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS; + m_uiNumberOfFrames = 3; m_cModuleOptions.addOptions() /**/ ( "Component", m_uiComponent, "Select the component to compute quality [0]" ); @@ -44,40 +44,40 @@ WeightedPSNR::WeightedPSNR() m_uiComponent = 0; } -Bool WeightedPSNR::create( std::vector apcFrameList ) +bool WeightedPSNR::create( std::vector apcFrameList ) { _BASIC_MODULE_API_2_CHECK_ - for( UInt i = 0; i < apcFrameList.size(); i++ ) + for( unsigned int i = 0; i < apcFrameList.size(); i++ ) { - if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_RESOLUTION ) ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_RESOLUTION ) ) return false; } if( apcFrameList[0]->getNumberChannels() != 1 ) { return false; } - for( UInt i = 1; i < apcFrameList.size(); i++ ) + for( unsigned int i = 1; i < apcFrameList.size(); i++ ) { - if( !apcFrameList[i]->haveSameFmt( apcFrameList[1], PlaYUVerFrame::MATCH_COLOR_SPACE | PlaYUVerFrame::MATCH_BITS ) ) + if( !apcFrameList[i]->haveSameFmt( apcFrameList[1], CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_BITS ) ) return false; } return true; } -Double measureWMSE( Int component, PlaYUVerFrame* Org, PlaYUVerFrame* Rec, PlaYUVerFrame* Mask ) +double measureWMSE( int component, CalypFrame* Org, CalypFrame* Rec, CalypFrame* Mask ) { - Pel* pMaskPelYUV = Mask->getPelBufferYUV()[0][0]; - Pel* pRecPelYUV = Rec->getPelBufferYUV()[component][0]; - Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; + ClpPel* pMaskPelYUV = Mask->getPelBufferYUV()[0][0]; + ClpPel* pRecPelYUV = Rec->getPelBufferYUV()[component][0]; + ClpPel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; - Double aux_pel_1, aux_pel_2, aux_pel_mask; - Int diff = 0; - Double ssd = 0; - UInt count = 0; + double aux_pel_1, aux_pel_2, aux_pel_mask; + int diff = 0; + double ssd = 0; + unsigned int count = 0; - UInt numberOfPixels = 0; - if( component == LUMA ) + unsigned int numberOfPixels = 0; + if( component == CLP_LUMA ) { numberOfPixels = Org->getHeight() * Org->getWidth(); } @@ -86,7 +86,7 @@ Double measureWMSE( Int component, PlaYUVerFrame* Org, PlaYUVerFrame* Rec, PlaYU numberOfPixels = Rec->getChromaLength(); } - for( UInt i = 0; i < numberOfPixels; i++ ) + for( unsigned int i = 0; i < numberOfPixels; i++ ) { aux_pel_mask = *pMaskPelYUV++; aux_pel_1 = *pRecPelYUV++; @@ -99,17 +99,17 @@ Double measureWMSE( Int component, PlaYUVerFrame* Org, PlaYUVerFrame* Rec, PlaYU { return 0.0; } - return ssd / Double( count ); + return ssd / double( count ); } -Double WeightedPSNR::measure( std::vector apcFrameList ) +double WeightedPSNR::measure( std::vector apcFrameList ) { - Double dPSNR = 100; - Double dMaxValue = ( 1 << apcFrameList[1]->getBitsPel() ) - 1; - Double dMSE = measureWMSE( m_uiComponent, apcFrameList[1], apcFrameList[2], apcFrameList[0] ); + double dPSNR = 100; + double dMaxValue = ( 1 << apcFrameList[1]->getBitsPel() ) - 1; + double dMSE = measureWMSE( m_uiComponent, apcFrameList[1], apcFrameList[2], apcFrameList[0] ); if( dMSE != 0 ) dPSNR = 10 * log10( ( dMaxValue * dMaxValue ) / dMSE ); return dPSNR; } -Void WeightedPSNR::destroy() {} +void WeightedPSNR::destroy() {} diff --git a/modules/WeightedPSNR.h b/modules/WeightedPSNR.h index e806f3d..63f34dd 100644 --- a/modules/WeightedPSNR.h +++ b/modules/WeightedPSNR.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -25,22 +25,22 @@ #ifndef __WEIGHTEDPSNR_H__ #define __WEIGHTEDPSNR_H__ -// PlaYUVerLib -#include "lib/PlaYUVerModuleIf.h" +// CalypLib +#include "lib/CalypModuleIf.h" -class WeightedPSNR : public PlaYUVerModuleIf +class WeightedPSNR : public CalypModuleIf { REGISTER_CLASS_FACTORY( WeightedPSNR ) private: - UInt m_uiComponent; + unsigned int m_uiComponent; public: WeightedPSNR(); virtual ~WeightedPSNR() {} - Bool create( std::vector apcFrameList ); - Double measure( std::vector apcFrameList ); - Void destroy(); + bool create( std::vector apcFrameList ); + double measure( std::vector apcFrameList ); + void destroy(); }; #endif // __WEIGHTEDPSNR_H__ diff --git a/playuver-codestyle.xml b/playuver-codestyle.xml deleted file mode 100644 index ed59ca6..0000000 --- a/playuver-codestyle.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6dc7b7d..9580596 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,5 @@ ### -### CMakeLists for playuver app component +### CMakeLists for calyp tools component ### # This is hard way - please fix @@ -8,15 +8,15 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ ) -set(plaYUver_Tools_SRCS +set(Calyp_Tools_SRCS main.cpp - PlaYUVerTools.cpp - PlaYUVerToolsCmdParser.cpp + CalypTools.cpp + CalypToolsCmdParser.cpp ) -ADD_EXECUTABLE( ${PROJECT_NAME}Tools ${plaYUver_Tools_SRCS} ) +ADD_EXECUTABLE( ${PROJECT_NAME}Tools ${Calyp_Tools_SRCS} ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME}Tools PlaYUVerLib PlaYUVerModules ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME}Tools ${PROJECT_LIBRARY} CalypModules ) INSTALL(TARGETS ${PROJECT_NAME}Tools DESTINATION bin ) diff --git a/tools/PlaYUVerTools.cpp b/tools/CalypTools.cpp similarity index 52% rename from tools/PlaYUVerTools.cpp rename to tools/CalypTools.cpp index 47f2477..e0f423e 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/CalypTools.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,22 +18,22 @@ */ /** - * \file PlaYUVerTools.cpp - * \brief Main definition of the PlaYUVerTools APp + * \file CalypTools.cpp + * \brief Main definition of the CalypTools APp */ -#include "PlaYUVerTools.h" +#include "CalypTools.h" #include "config.h" #include #include -#include "lib/PlaYUVerFrame.h" -#include "lib/PlaYUVerModuleIf.h" -#include "lib/PlaYUVerStream.h" -#include "modules/PlaYUVerModuleFactory.h" +#include "lib/CalypFrame.h" +#include "lib/CalypModuleIf.h" +#include "lib/CalypStream.h" +#include "modules/CalypModulesFactory.h" -PlaYUVerTools::PlaYUVerTools() +CalypTools::CalypTools() { m_bVerbose = true; m_uiOperation = INVALID_OPERATION; @@ -44,13 +44,13 @@ PlaYUVerTools::PlaYUVerTools() m_pcCurrModuleIf = NULL; } -PlaYUVerTools::~PlaYUVerTools() +CalypTools::~CalypTools() { - for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) + for( unsigned int i = 0; i < m_apcInputStreams.size(); i++ ) { m_apcInputStreams[i]->close(); } - for( UInt i = 0; i < m_apcOutputStreams.size(); i++ ) + for( unsigned int i = 0; i < m_apcOutputStreams.size(); i++ ) { m_apcOutputStreams[i]->close(); } @@ -58,22 +58,22 @@ PlaYUVerTools::~PlaYUVerTools() #define GET_PARAM( X, i ) X[X.size() > i ? i : X.size() - 1] -Int PlaYUVerTools::openInputs() +int CalypTools::openInputs() { /** * Create input streams */ if( Opts().hasOpt( "input" ) ) { - std::vector inputFileNames = m_apcInputs; + std::vector inputFileNames = m_apcInputs; - String resolutionString( "" ); - String fmtString( "yuv420p" ); - UInt uiBitPerPixel = 8; - UInt uiEndianness = 0; + ClpString resolutionString( "" ); + ClpString fmtString( "yuv420p" ); + unsigned int uiBitPerPixel = 8; + unsigned int uiEndianness = 0; - PlaYUVerStream* pcStream; - for( UInt i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ ) + CalypStream* pcStream; + for( unsigned int i = 0; i < inputFileNames.size() && i < MAX_NUMBER_INPUTS; i++ ) { if( Opts().hasOpt( "size" ) ) { @@ -98,19 +98,19 @@ Int PlaYUVerTools::openInputs() uiEndianness = 1; } } - pcStream = new PlaYUVerStream; + pcStream = new CalypStream; try { if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitPerPixel, uiEndianness, 1, true ) ) { - log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); + log( CLP_LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2; } m_apcInputStreams.push_back( pcStream ); } catch( const char* msg ) { - log( LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), + log( CLP_LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); return 2; } @@ -124,7 +124,7 @@ Int PlaYUVerTools::openInputs() } m_uiNumberOfComponents = UINT_MAX; - for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) + for( unsigned int i = 0; i < m_apcInputStreams.size(); i++ ) { m_uiNumberOfFrames = std::min( m_uiNumberOfFrames, m_apcInputStreams[i]->getFrameNum() ); m_uiNumberOfComponents = @@ -134,9 +134,9 @@ Int PlaYUVerTools::openInputs() return 0; } -Int PlaYUVerTools::Open( Int argc, Char* argv[] ) +int CalypTools::Open( int argc, char* argv[] ) { - Int iRet = 0; + int iRet = 0; if( ( iRet = parseToolsArgs( argc, argv ) ) > 0 ) { @@ -152,12 +152,12 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) { if( m_apcInputStreams.size() == 0 ) { - log( LOG_ERROR, "Invalid number of input streams! " ); + log( CLP_LOG_ERROR, "Invalid number of input streams! " ); return 2; } - Int64 currFrames = 0; - Int64 numberOfFrames = LONG_MAX; - for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) + long long int currFrames = 0; + long long int numberOfFrames = LONG_MAX; + for( unsigned int i = 0; i < m_apcInputStreams.size(); i++ ) { currFrames = m_apcInputStreams[i]->getFrameNum(); if( currFrames < numberOfFrames ) @@ -166,33 +166,33 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) m_iFrameNum = m_iFrames; if( !( m_iFrameNum >= 0 && m_iFrameNum < numberOfFrames ) ) { - log( LOG_ERROR, "Invalid frame number! Use --frame option " ); + log( CLP_LOG_ERROR, "Invalid frame number! Use --frame option " ); return 2; } if( Opts().hasOpt( "output" ) ) m_pcOutputFileNames.push_back( m_strOutput ); if( m_pcOutputFileNames.size() != m_apcInputStreams.size() ) { - log( LOG_ERROR, "Invalid number of outputs! Each input must have an " - "output filename. " ); + log( CLP_LOG_ERROR, "Invalid number of outputs! Each input must have an " + "output filename. " ); return 2; } m_uiOperation = SAVE_OPERATION; - m_fpProcess = &PlaYUVerTools::SaveOperation; - log( LOG_INFO, "PlaYUVer Save Frame\n" ); + m_fpProcess = &CalypTools::SaveOperation; + log( CLP_LOG_INFO, "Calyp Save Frame\n" ); } if( Opts().hasOpt( "rate-reduction" ) ) { if( m_apcInputStreams.size() == 0 ) { - log( LOG_ERROR, "Invalid number of input streams! " ); + log( CLP_LOG_ERROR, "Invalid number of input streams! " ); return 2; } - Int64 currFrames = 0; - Int64 numberOfFrames = LONG_MAX; - for( UInt i = 0; i < m_apcInputStreams.size(); i++ ) + long long int currFrames = 0; + long long int numberOfFrames = LONG_MAX; + for( unsigned int i = 0; i < m_apcInputStreams.size(); i++ ) { currFrames = m_apcInputStreams[i]->getFrameNum(); if( currFrames < numberOfFrames ) @@ -200,24 +200,24 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) } if( m_iRateReductionFactor <= 0 ) { - log( LOG_ERROR, "Invalid frame rate reduction value!" ); + log( CLP_LOG_ERROR, "Invalid frame rate reduction value!" ); return 2; } if( Opts().hasOpt( "output" ) ) m_pcOutputFileNames.push_back( m_strOutput ); - PlaYUVerFrame* pcInputFrame = m_apcInputStreams[0]->getCurrFrame(); - PlaYUVerStream* pcOutputStream = new PlaYUVerStream; + CalypFrame* pcInputFrame = m_apcInputStreams[0]->getCurrFrame(); + CalypStream* pcOutputStream = new CalypStream; try { pcOutputStream->open( m_pcOutputFileNames[0], pcInputFrame->getWidth(), pcInputFrame->getHeight(), - pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, + pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ); } catch( const char* msg ) { - log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", m_pcOutputFileNames[0].c_str(), + log( CLP_LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", m_pcOutputFileNames[0].c_str(), msg ); delete pcOutputStream; pcOutputStream = NULL; @@ -227,14 +227,14 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) if( m_apcOutputStreams.size() != m_apcInputStreams.size() ) { - log( LOG_ERROR, "Invalid number of outputs! Each input must have an " - "output filename. " ); + log( CLP_LOG_ERROR, "Invalid number of outputs! Each input must have an " + "output filename. " ); return 2; } m_uiOperation = RATE_REDUCTION_OPERATION; - m_fpProcess = &PlaYUVerTools::RateReductionOperation; - log( LOG_INFO, "PlaYUVer Frame Rate Reduction\n" ); + m_fpProcess = &CalypTools::RateReductionOperation; + log( CLP_LOG_INFO, "Calyp Frame Rate Reduction\n" ); } /** @@ -242,27 +242,27 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) */ if( Opts().hasOpt( "quality" ) ) { - String qualityMetric = m_strQualityMetric; + ClpString qualityMetric = m_strQualityMetric; if( m_apcInputStreams.size() < 2 ) { - log( LOG_ERROR, "Invalid number of inputs! " ); + log( CLP_LOG_ERROR, "Invalid number of inputs! " ); return 2; } - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ ) { - if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) ) + if( clpLowercase( CalypFrame::supportedQualityMetricsList()[i] ) == clpLowercase( qualityMetric ) ) { m_uiQualityMetric = i; } } if( m_uiQualityMetric == -1 ) { - log( LOG_ERROR, "Invalid quality metric! " ); + log( CLP_LOG_ERROR, "Invalid quality metric! " ); return 2; } m_uiOperation = QUALITY_OPERATION; - m_fpProcess = &PlaYUVerTools::QualityOperation; - log( LOG_INFO, "PlaYUVer Quality\n" ); + m_fpProcess = &CalypTools::QualityOperation; + log( CLP_LOG_INFO, "Calyp Quality\n" ); } /** @@ -270,11 +270,11 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) */ if( Opts().hasOpt( "module" ) ) { - String moduleName = m_strModule; + ClpString moduleName = m_strModule; - PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); - PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); - for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) + CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); + CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin(); + for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ ) { if( strcmp( it->first, moduleName.c_str() ) == 0 ) { @@ -284,51 +284,51 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) } if( !m_pcCurrModuleIf ) { - log( LOG_ERROR, "Invalid module! " ); + log( CLP_LOG_ERROR, "Invalid module! " ); return 2; } if( m_apcInputStreams.size() != m_pcCurrModuleIf->m_uiNumberOfFrames ) { - log( LOG_ERROR, "Invalid number of inputs! " ); + log( CLP_LOG_ERROR, "Invalid number of inputs! " ); return 2; } m_pcCurrModuleIf->m_cModuleOptions.parse( argc, argv ); // Create Module - Bool moduleCreated = false; - std::vector apcFrameList; - for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) + bool moduleCreated = false; + std::vector apcFrameList; + for( unsigned int i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) { apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() ); } - if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + if( m_pcCurrModuleIf->m_iModuleAPI == CLP_MODULE_API_2 ) { moduleCreated = m_pcCurrModuleIf->create( apcFrameList ); } - else if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_1 ) + else if( m_pcCurrModuleIf->m_iModuleAPI == CLP_MODULE_API_1 ) { m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); moduleCreated = true; } if( !moduleCreated ) { - log( LOG_ERROR, "Module is not supported with the selected inputs! " ); + log( CLP_LOG_ERROR, "Module is not supported with the selected inputs! " ); return 2; } - if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) + if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { // Check outputs - std::vector outputFileNames; + std::vector outputFileNames; if( Opts().hasOpt( "output" ) ) outputFileNames.push_back( m_strOutput ); if( outputFileNames.size() == 1 ) { - PlaYUVerFrame* pcModFrame; - if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + CalypFrame* pcModFrame; + if( m_pcCurrModuleIf->m_iModuleAPI == CLP_MODULE_API_2 ) { pcModFrame = m_pcCurrModuleIf->process( apcFrameList ); } @@ -336,15 +336,15 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) { pcModFrame = applyFrameModule(); } - PlaYUVerStream* pcModStream = new PlaYUVerStream; + CalypStream* pcModStream = new CalypStream; try { pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), - pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false ); + pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ); } catch( const char* msg ) { - log( LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", outputFileNames[0].c_str(), + log( CLP_LOG_ERROR, "Cannot open input stream %s with the following error %s!\n", outputFileNames[0].c_str(), msg ); delete pcModStream; pcModStream = NULL; @@ -354,39 +354,39 @@ Int PlaYUVerTools::Open( Int argc, Char* argv[] ) } else { - log( LOG_ERROR, "One output is required! " ); + log( CLP_LOG_ERROR, "One output is required! " ); return 2; } } m_uiOperation = MODULE_OPERATION; - m_fpProcess = &PlaYUVerTools::ModuleOperation; - log( LOG_INFO, "PlaYUVer Module\n" ); + m_fpProcess = &CalypTools::ModuleOperation; + log( CLP_LOG_INFO, "Calyp Module\n" ); } if( m_uiOperation == INVALID_OPERATION ) { - log( LOG_ERROR, "No operation was selected! " ); + log( CLP_LOG_ERROR, "No operation was selected! " ); return 2; } return iRet; } -Int PlaYUVerTools::Process() +int CalypTools::Process() { return ( this->*m_fpProcess )(); } -Int PlaYUVerTools::Close() +int CalypTools::Close() { // Finish return 0; } -Int PlaYUVerTools::SaveOperation() +int CalypTools::SaveOperation() { - Bool bRet = true; - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + bool bRet = true; + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) { bRet = m_apcInputStreams[s]->seekInput( m_iFrameNum ); if( bRet == false ) @@ -398,16 +398,16 @@ Int PlaYUVerTools::SaveOperation() return 0; } -Int PlaYUVerTools::RateReductionOperation() +int CalypTools::RateReductionOperation() { - Bool abEOF; - log( LOG_INFO, "\n Reducing frame rate by a factor of %d ... ", m_iRateReductionFactor ); - for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) + bool abEOF; + log( CLP_LOG_INFO, "\n Reducing frame rate by a factor of %d ... ", m_iRateReductionFactor ); + for( unsigned int frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - log( LOG_INFO, "\n Reading frame %d ... ", frame ); + log( CLP_LOG_INFO, "\n Reading frame %d ... ", frame ); if( ( frame % m_iRateReductionFactor ) == 0 ) { - log( LOG_INFO, "Writing", frame ); + log( CLP_LOG_INFO, "Writing", frame ); m_apcOutputStreams[0]->writeFrame( m_apcInputStreams[0]->getCurrFrame() ); } abEOF = m_apcInputStreams[0]->setNextFrame(); @@ -419,26 +419,26 @@ Int PlaYUVerTools::RateReductionOperation() return 0; } -Int PlaYUVerTools::QualityOperation() +int CalypTools::QualityOperation() { - const char* pchQualityMetricName = PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str(); - PlaYUVerFrame* apcCurrFrame[MAX_NUMBER_INPUTS]; - Bool abEOF[MAX_NUMBER_INPUTS]; - Double adAverageQuality[MAX_NUMBER_INPUTS - 1][PlaYUVerPixel::getMaxNumberOfComponents()]; - Double dQuality; + const char* pchQualityMetricName = CalypFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str(); + CalypFrame* apcCurrFrame[MAX_NUMBER_INPUTS]; + bool abEOF[MAX_NUMBER_INPUTS]; + double adAverageQuality[MAX_NUMBER_INPUTS - 1][CalypPixel::getMaxNumberOfComponents()]; + double dQuality; - String metric_fmt = " "; + ClpString metric_fmt = " "; switch( m_uiQualityMetric ) { - case PlaYUVerFrame::PSNR_METRIC: + case CalypFrame::PSNR_METRIC: //"PSNR_0_0" metric_fmt += " %6.3f "; break; - case PlaYUVerFrame::SSIM_METRIC: + case CalypFrame::SSIM_METRIC: //"SSIM_0_0" metric_fmt += " %6.4f "; break; - case PlaYUVerFrame::MSE_METRIC: + case CalypFrame::MSE_METRIC: //"MSE_0_0" metric_fmt += "%7.2f"; break; @@ -447,47 +447,47 @@ Int PlaYUVerTools::QualityOperation() } metric_fmt += " "; - log( LOG_INFO, " Measuring Quality using %s ... \n", pchQualityMetricName ); - log( LOG_INFO, "# Frame ", pchQualityMetricName ); + log( CLP_LOG_INFO, " Measuring Quality using %s ... \n", pchQualityMetricName ); + log( CLP_LOG_INFO, "# Frame ", pchQualityMetricName ); - for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) + for( unsigned int s = 1; s < m_apcInputStreams.size(); s++ ) { - for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) + for( unsigned int c = 0; c < m_uiNumberOfComponents; c++ ) { - log( LOG_INFO, "%s_%d_%d ", pchQualityMetricName, s, c ); + log( CLP_LOG_INFO, "%s_%d_%d ", pchQualityMetricName, s, c ); } - log( LOG_INFO, " " ); + log( CLP_LOG_INFO, " " ); } - log( LOG_INFO, "\n" ); + log( CLP_LOG_INFO, "\n" ); - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = false; - for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) + for( unsigned int c = 0; c < m_uiNumberOfComponents; c++ ) { adAverageQuality[s][c] = 0; } } - for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) + for( unsigned int frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - log( LOG_INFO, " %3d ", frame ); - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + log( CLP_LOG_INFO, " %3d ", frame ); + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame(); - for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) + for( unsigned int s = 1; s < m_apcInputStreams.size(); s++ ) { - log( LOG_RESULT, " " ); - for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) + log( CLP_LOG_RESULT, " " ); + for( unsigned int c = 0; c < m_uiNumberOfComponents; c++ ) { dQuality = apcCurrFrame[s]->getQuality( m_uiQualityMetric, apcCurrFrame[0], c ); - adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * Double( frame ) + dQuality ) / Double( frame + 1 ); - log( LOG_RESULT, metric_fmt.c_str(), dQuality ); + adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * double( frame ) + dQuality ) / double( frame + 1 ); + log( CLP_LOG_RESULT, metric_fmt.c_str(), dQuality ); } - log( LOG_RESULT, " " ); + log( CLP_LOG_RESULT, " " ); } - log( LOG_RESULT, "\n" ); - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + log( CLP_LOG_RESULT, "\n" ); + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = m_apcInputStreams[s]->setNextFrame(); if( !abEOF[s] ) @@ -496,55 +496,55 @@ Int PlaYUVerTools::QualityOperation() } } } - log( LOG_INFO, "\n Mean Values: \n " ); - for( UInt s = 0; s < m_apcInputStreams.size() - 1; s++ ) + log( CLP_LOG_INFO, "\n Mean Values: \n " ); + for( unsigned int s = 0; s < m_apcInputStreams.size() - 1; s++ ) { - for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) + for( unsigned int c = 0; c < m_uiNumberOfComponents; c++ ) { - log( LOG_INFO, metric_fmt.c_str(), adAverageQuality[s][c] ); + log( CLP_LOG_INFO, metric_fmt.c_str(), adAverageQuality[s][c] ); } - log( LOG_RESULT, " " ); + log( CLP_LOG_RESULT, " " ); } - log( LOG_INFO, "\n" ); + log( CLP_LOG_INFO, "\n" ); return 0; } -PlaYUVerFrame* PlaYUVerTools::applyFrameModule() +CalypFrame* CalypTools::applyFrameModule() { - PlaYUVerFrame* pcProcessedFrame = NULL; - if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) + CalypFrame* pcProcessedFrame = NULL; + if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame() ); } return pcProcessedFrame; } -Int PlaYUVerTools::ModuleOperation() +int CalypTools::ModuleOperation() { - std::vector apcFrameList; - log( LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, + std::vector apcFrameList; + log( CLP_LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); - PlaYUVerFrame* pcProcessedFrame = NULL; - Double dMeasurementResult = 0.0; - Double dAveragedMeasurementResult = 0; - Bool abEOF[MAX_NUMBER_INPUTS]; + CalypFrame* pcProcessedFrame = NULL; + double dMeasurementResult = 0.0; + double dAveragedMeasurementResult = 0; + bool abEOF[MAX_NUMBER_INPUTS]; - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = false; } - for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) + for( unsigned int frame = 0; frame < m_uiNumberOfFrames; frame++ ) { apcFrameList.clear(); - for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) + for( unsigned int i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) { apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() ); } - if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) + if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE ) { - if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + if( m_pcCurrModuleIf->m_iModuleAPI == CLP_MODULE_API_2 ) { pcProcessedFrame = m_pcCurrModuleIf->process( apcFrameList ); } @@ -554,9 +554,9 @@ Int PlaYUVerTools::ModuleOperation() } m_apcOutputStreams[0]->writeFrame( pcProcessedFrame ); } - else if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) + else if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE ) { - if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + if( m_pcCurrModuleIf->m_iModuleAPI == CLP_MODULE_API_2 ) { dMeasurementResult = m_pcCurrModuleIf->measure( apcFrameList ); } @@ -564,13 +564,13 @@ Int PlaYUVerTools::ModuleOperation() { dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); } - log( LOG_INFO, " %3d", frame ); - log( LOG_RESULT, " %8.3f \n", dMeasurementResult ); + log( CLP_LOG_INFO, " %3d", frame ); + log( CLP_LOG_RESULT, " %8.3f \n", dMeasurementResult ); dAveragedMeasurementResult = - ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 ); + ( dAveragedMeasurementResult * double( frame ) + dMeasurementResult ) / double( frame + 1 ); } - for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) + for( unsigned int s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = m_apcInputStreams[s]->setNextFrame(); if( !abEOF[s] ) @@ -580,9 +580,9 @@ Int PlaYUVerTools::ModuleOperation() } } - if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) + if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE ) { - log( LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); + log( CLP_LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); } return 0; diff --git a/tools/CalypTools.h b/tools/CalypTools.h new file mode 100644 index 0000000..ef75d0a --- /dev/null +++ b/tools/CalypTools.h @@ -0,0 +1,104 @@ +/* This file is a part of Calyp project + * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) + * Luis Lucas (luisfrlucas@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file CalypTools.h + * \brief Main definition of the CalypTools app + * + * @defgroup CalypTools Calyp Tools + * @{ + * + * CalypTools is a command line interface + * for the modules and quality metrics + * included in Calyp + * + * @} + */ + +#ifndef __CALYPTOOLS_H__ +#define __CALYPTOOLS_H__ + +/** + * @defgroup CalypTools Calyp Tools + * @{ + * CalypTools is a command line interface + * for the modules and quality metrics + * included in Calyp + * @} + * + */ + +#include "lib/CalypFrame.h" + +#include "CalypToolsCmdParser.h" + +class CalypFrame; +class CalypStream; +class CalypModuleIf; + +#define MAX_NUMBER_INPUTS 10 + +class CalypTools : public CalypToolsCmdParser +{ +public: + CalypTools(); + ~CalypTools(); + + int Open( int argc, char* argv[] ); + int Process(); + int Close(); + +private: + bool m_bVerbose; + + unsigned int m_uiOperation; + enum TOOLS_OPERATIONS_LIST + { + INVALID_OPERATION, + SAVE_OPERATION, + RATE_REDUCTION_OPERATION, + QUALITY_OPERATION, + MODULE_OPERATION, + }; + + unsigned int m_uiNumberOfFrames; + unsigned int m_uiNumberOfComponents; + std::vector m_apcInputStreams; + std::vector m_apcOutputStreams; + + int openInputs(); + + typedef int ( CalypTools::*FpProcess )(); + FpProcess m_fpProcess; + + long long int m_iFrameNum; + std::vector m_pcOutputFileNames; + int SaveOperation(); + + int RateReductionOperation(); + + int m_uiQualityMetric; + int QualityOperation(); + + CalypModuleIf* m_pcCurrModuleIf; + CalypFrame* applyFrameModule(); + int ModuleOperation(); +}; + +#endif // __CALYPTOOLS_H__ diff --git a/tools/PlaYUVerToolsCmdParser.cpp b/tools/CalypToolsCmdParser.cpp similarity index 67% rename from tools/PlaYUVerToolsCmdParser.cpp rename to tools/CalypToolsCmdParser.cpp index 60e874a..cef64b5 100644 --- a/tools/PlaYUVerToolsCmdParser.cpp +++ b/tools/CalypToolsCmdParser.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,22 +18,22 @@ */ /** - * \file PlaYUVerToolsCmdParser.cpp + * \file CalypToolsCmdParser.cpp * \brief Handle for command line */ -#include "PlaYUVerToolsCmdParser.h" +#include "CalypToolsCmdParser.h" -#include "lib/PlaYUVerFrame.h" -#include "lib/PlaYUVerModuleIf.h" -#include "lib/PlaYUVerStream.h" -#include "modules/PlaYUVerModuleFactory.h" +#include "lib/CalypFrame.h" +#include "lib/CalypModuleIf.h" +#include "lib/CalypStream.h" +#include "modules/CalypModulesFactory.h" #include #include #include -PlaYUVerToolsCmdParser::PlaYUVerToolsCmdParser() +CalypToolsCmdParser::CalypToolsCmdParser() { m_uiLogLevel = 0; m_bQuiet = false; @@ -42,9 +42,9 @@ PlaYUVerToolsCmdParser::PlaYUVerToolsCmdParser() m_cOptions.addDefaultOptions(); } -PlaYUVerToolsCmdParser::~PlaYUVerToolsCmdParser() {} +CalypToolsCmdParser::~CalypToolsCmdParser() {} -Void PlaYUVerToolsCmdParser::log( UInt level, const char* fmt, ... ) +void CalypToolsCmdParser::log( unsigned int level, const char* fmt, ... ) { if( level >= m_uiLogLevel ) { @@ -55,9 +55,9 @@ Void PlaYUVerToolsCmdParser::log( UInt level, const char* fmt, ... ) } } -Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char* argv[] ) +int CalypToolsCmdParser::parseToolsArgs( int argc, char* argv[] ) { - Int iRet = 0; + int iRet = 0; m_cOptions.addOptions() /**/ ( "quiet,q", m_bQuiet, "disable verbose" )( "input,i", m_apcInputs, "input file" ) /**/ @@ -79,7 +79,7 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char* argv[] ) if( m_bQuiet ) { - m_uiLogLevel = LOG_RESULT; + m_uiLogLevel = CLP_LOG_RESULT; } if( m_cOptions.hasOpt( "module_list" ) || m_cOptions.hasOpt( "module_list_full" ) ) @@ -104,14 +104,14 @@ Int PlaYUVerToolsCmdParser::parseToolsArgs( Int argc, Char* argv[] ) return iRet; } -Void PlaYUVerToolsCmdParser::listModuleHelp() +void CalypToolsCmdParser::listModuleHelp() { - String moduleName = m_strModule; - PlaYUVerModuleIf* pcCurrModuleIf = NULL; + ClpString moduleName = m_strModule; + CalypModuleIf* pcCurrModuleIf = NULL; - PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); - PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); - for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) + CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); + CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin(); + for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ ) { if( strcmp( it->first, moduleName.c_str() ) == 0 ) { @@ -121,56 +121,54 @@ Void PlaYUVerToolsCmdParser::listModuleHelp() } if( pcCurrModuleIf ) { - printf( "Usage: playuverTools --module=%s options:\n", it->first ); + printf( "Usage: calypTools --module=%s options:\n", it->first ); pcCurrModuleIf->m_cModuleOptions.doHelp( std::cout ); } } -Void PlaYUVerToolsCmdParser::listModules() +void CalypToolsCmdParser::listModules() { - Bool bDetailed = false; + bool bDetailed = false; if( m_cOptions.hasOpt( "module_list_full" ) ) bDetailed = true; - PlaYUVerModuleIf* pcCurrModuleIf; - PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); - PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); + CalypModuleIf* pcCurrModuleIf; + CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap(); + CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin(); - printf( "PlaYUVer available modules: \n" ); - printf( " [Internal Name] " ); + printf( "Calyp available modules: \n" ); + printf( " [Internal Name] " ); if( bDetailed ) { - printf( " [Full Name] " ); + printf( " [Full Name] " ); printf( " [Type] " ); printf( " [Description]" ); } printf( " \n" ); - Char ModuleNameString[40]; - - for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) + for( unsigned int i = 0; it != moduleFactoryMap.end(); ++it, i++ ) { printf( " " ); - printf( "%-30s", it->first ); + printf( "%-33s", it->first ); if( bDetailed ) { - ModuleNameString[0] = '\0'; + ClpString ModuleNameString; pcCurrModuleIf = it->second(); if( pcCurrModuleIf->m_pchModuleCategory ) { - strcat( ModuleNameString, pcCurrModuleIf->m_pchModuleCategory ); - strcat( ModuleNameString, "/" ); + ModuleNameString += pcCurrModuleIf->m_pchModuleCategory; + ModuleNameString += "/"; } - strcat( ModuleNameString, pcCurrModuleIf->m_pchModuleName ); - printf( " %-40s", ModuleNameString ); + ModuleNameString += pcCurrModuleIf->m_pchModuleName; + printf( " %-43s", ModuleNameString.c_str() ); switch( pcCurrModuleIf->m_iModuleType ) { - case FRAME_PROCESSING_MODULE: + case CLP_FRAME_PROCESSING_MODULE: printf( " Processing " ); break; - case FRAME_MEASUREMENT_MODULE: + case CLP_FRAME_MEASUREMENT_MODULE: printf( " Measurement " ); break; } diff --git a/tools/PlaYUVerToolsCmdParser.h b/tools/CalypToolsCmdParser.h similarity index 57% rename from tools/PlaYUVerToolsCmdParser.h rename to tools/CalypToolsCmdParser.h index f0b4f17..3207c91 100644 --- a/tools/PlaYUVerToolsCmdParser.h +++ b/tools/CalypToolsCmdParser.h @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * @@ -18,24 +18,23 @@ */ /** - * \file PlaYUVerToolsCmdParser.h + * \file CalypToolsCmdParser.h * \brief Handle for command line */ -#ifndef __PLAYUVERTOOLSCMDPARSER_H__ -#define __PLAYUVERTOOLSCMDPARSER_H__ +#ifndef __CALYPTOOLSCMDPARSER_H__ +#define __CALYPTOOLSCMDPARSER_H__ #include "config.h" -#include "lib/PlaYUVerDefs.h" -#include "lib/PlaYUVerOptions.h" +#include "lib/CalypOptions.h" -class PlaYUVerToolsCmdParser +class CalypToolsCmdParser { public: - PlaYUVerToolsCmdParser(); - ~PlaYUVerToolsCmdParser(); + CalypToolsCmdParser(); + ~CalypToolsCmdParser(); - Void setLogLevel( enum LOG_LEVEL level ) { m_uiLogLevel = level; } + void setLogLevel( enum CLP_LOG_LEVEL level ) { m_uiLogLevel = level; } /** * Send the specified message to the log if the level is higher than or equal * to the current LogLevel. By default, all logging messages are sent to @@ -48,41 +47,41 @@ public: * * @note this function might not be safe in C++ (try to upgrade it) */ - Void log( UInt level, const char* fmt, ... ); + void log( unsigned int level, const char* fmt, ... ); - Int parseToolsArgs( Int argc, Char* argv[] ); + int parseToolsArgs( int argc, char* argv[] ); - PlaYUVerOptions& Opts() { return m_cOptions; } + CalypOptions& Opts() { return m_cOptions; } protected: - PlaYUVerOptions m_cOptions; - UInt m_uiLogLevel; + CalypOptions m_cOptions; + unsigned int m_uiLogLevel; /** - * Command line opts for PlaYUVerTools + * Command line opts for CalypTools */ - Bool m_bShowHelp; - Bool m_bShowVersion; - Bool m_bQuiet; + bool m_bShowHelp; + bool m_bShowVersion; + bool m_bQuiet; - std::vector m_apcInputs; - std::vector m_strResolution; - std::vector m_strPelFmt; - std::vector m_uiBitsPerPixel; - std::vector m_strEndianness; - String m_strOutput; - Int64 m_iFrames; + std::vector m_apcInputs; + std::vector m_strResolution; + std::vector m_strPelFmt; + std::vector m_uiBitsPerPixel; + std::vector m_strEndianness; + ClpString m_strOutput; + long m_iFrames; - Int m_iRateReductionFactor; - String m_strQualityMetric; - String m_strModule; + int m_iRateReductionFactor; + ClpString m_strQualityMetric; + ClpString m_strModule; - Bool m_bListPelFmts; - Bool m_bListQuality; - Bool m_bListModules; + bool m_bListPelFmts; + bool m_bListQuality; + bool m_bListModules; - Void listModules(); - Void listModuleHelp(); + void listModules(); + void listModuleHelp(); }; -#endif // __PLAYUVERTOOLSCMDPARSER_H__ +#endif // __CALYPTOOLSCMDPARSER_H__ diff --git a/tools/PlaYUVerTools.h b/tools/PlaYUVerTools.h deleted file mode 100644 index 70d9d3d..0000000 --- a/tools/PlaYUVerTools.h +++ /dev/null @@ -1,105 +0,0 @@ -/* This file is a part of PlaYUVer project - * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) - * Luis Lucas (luisfrlucas@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file PlaYUVerTools.h - * \brief Main definition of the PlaYUVerTools app - * - * @defgroup PlaYUVerTools PlaYUVer Tools - * @{ - * - * PlaYUVerTools is a command line interface - * for the modules and quality metrics - * included in PlaYUVer - * - * @} - */ - -#ifndef __PLAYUVERTOOLS_H__ -#define __PLAYUVERTOOLS_H__ - -/** - * @defgroup PlaYUVerTools PlaYUVer Tools - * @{ - * PlaYUVerTools is a command line interface - * for the modules and quality metrics - * included in PlaYUVer - * @} - * - */ - -#include "lib/PlaYUVerDefs.h" -#include "lib/PlaYUVerFrame.h" - -#include "PlaYUVerToolsCmdParser.h" - -class PlaYUVerFrame; -class PlaYUVerStream; -class PlaYUVerModuleIf; - -#define MAX_NUMBER_INPUTS 10 - -class PlaYUVerTools : public PlaYUVerToolsCmdParser -{ -public: - PlaYUVerTools(); - ~PlaYUVerTools(); - - Int Open( Int argc, Char* argv[] ); - Int Process(); - Int Close(); - -private: - Bool m_bVerbose; - - UInt m_uiOperation; - enum TOOLS_OPERATIONS_LIST - { - INVALID_OPERATION, - SAVE_OPERATION, - RATE_REDUCTION_OPERATION, - QUALITY_OPERATION, - MODULE_OPERATION, - }; - - UInt m_uiNumberOfFrames; - UInt m_uiNumberOfComponents; - std::vector m_apcInputStreams; - std::vector m_apcOutputStreams; - - Int openInputs(); - - typedef Int ( PlaYUVerTools::*FpProcess )(); - FpProcess m_fpProcess; - - Int64 m_iFrameNum; - std::vector m_pcOutputFileNames; - Int SaveOperation(); - - Int RateReductionOperation(); - - Int m_uiQualityMetric; - Int QualityOperation(); - - PlaYUVerModuleIf* m_pcCurrModuleIf; - PlaYUVerFrame* applyFrameModule(); - Int ModuleOperation(); -}; - -#endif // __PLAYUVERTOOLS_H__ diff --git a/tools/main.cpp b/tools/main.cpp index f0e835c..c1292e5 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -1,4 +1,4 @@ -/* This file is a part of PlaYUVer project +/* This file is a part of Calyp project * Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com) * * Luis Lucas (luisfrlucas@gmail.com) @@ -23,14 +23,14 @@ * \brief main file */ -#include "PlaYUVerTools.h" +#include "CalypTools.h" -int main( int argc, Char* argv[] ) +int main( int argc, char* argv[] ) { - Int iRet = 0; - PlaYUVerTools PlaYUVerToolsApp; + int iRet = 0; + CalypTools CalypToolsApp; - iRet = PlaYUVerToolsApp.Open( argc, argv ); + iRet = CalypToolsApp.Open( argc, argv ); if( iRet == 1 ) { return 0; @@ -41,13 +41,13 @@ int main( int argc, Char* argv[] ) return 1; } - if( PlaYUVerToolsApp.Process() > 1 ) + if( CalypToolsApp.Process() > 1 ) { printf( "Exiting with error \n" ); return 1; } - if( PlaYUVerToolsApp.Close() > 1 ) + if( CalypToolsApp.Close() > 1 ) { printf( "Exiting with error \n" ); return 1;