Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:48:26

0001 //========================================================================
0002 //
0003 // PDFRectange.h
0004 //
0005 // Code originally from Page.cc
0006 //
0007 // Copyright 1996-2007 Glyph & Cog, LLC
0008 //
0009 //========================================================================
0010 
0011 //========================================================================
0012 //
0013 // Modified under the Poppler project - http://poppler.freedesktop.org
0014 //
0015 // All changes made under the Poppler project to this file are licensed
0016 // under GPL version 2 or later
0017 //
0018 // Copyright (C) 2020 Albert Astals Cid <aacid@kde.org>
0019 // Copyright (C) 2025 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
0020 // Copyright (C) 2026 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
0021 //
0022 // To see a description of the changes please see the Changelog file that
0023 // came with your tarball or type make ChangeLog if you are building from git
0024 //
0025 //========================================================================
0026 
0027 #ifndef PDFRECTANGLE_H
0028 #define PDFRECTANGLE_H
0029 
0030 //------------------------------------------------------------------------
0031 
0032 class PDFRectangle
0033 {
0034 public:
0035     double x1 = 0.0;
0036     double y1 = 0.0;
0037     double x2 = 0.0;
0038     double y2 = 0.0;
0039 
0040     constexpr PDFRectangle() = default;
0041     constexpr PDFRectangle(double x1A, double y1A, double x2A, double y2A)
0042     {
0043         x1 = x1A;
0044         y1 = y1A;
0045         x2 = x2A;
0046         y2 = y2A;
0047     }
0048     constexpr bool isValid() const { return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0; }
0049     constexpr bool isEmpty() const { return x1 == x2 && y1 == y2; }
0050     constexpr bool contains(double x, double y) const { return x1 <= x && x <= x2 && y1 <= y && y <= y2; }
0051     constexpr void clipTo(const PDFRectangle &rect);
0052 
0053     constexpr bool operator==(const PDFRectangle &rect) const { return x1 == rect.x1 && y1 == rect.y1 && x2 == rect.x2 && y2 == rect.y2; }
0054 };
0055 
0056 constexpr void PDFRectangle::clipTo(const PDFRectangle &rect)
0057 {
0058     if (x1 < rect.x1) {
0059         x1 = rect.x1;
0060     } else if (x1 > rect.x2) {
0061         x1 = rect.x2;
0062     }
0063     if (x2 < rect.x1) {
0064         x2 = rect.x1;
0065     } else if (x2 > rect.x2) {
0066         x2 = rect.x2;
0067     }
0068     if (y1 < rect.y1) {
0069         y1 = rect.y1;
0070     } else if (y1 > rect.y2) {
0071         y1 = rect.y2;
0072     }
0073     if (y2 < rect.y1) {
0074         y2 = rect.y1;
0075     } else if (y2 > rect.y2) {
0076         y2 = rect.y2;
0077     }
0078 }
0079 
0080 #endif