pqDoubleLineEdit.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqDoubleLineEdit.h
5 
6  Copyright (c) 2005-2018 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqDoubleLineEdit_h
33 #define pqDoubleLineEdit_h
34 
35 // Qt Includes.
36 #include <QScopedPointer> // for ivar
37 #include <QTextStream> // for formatDouble
38 
39 // ParaView Includes.
40 #include "pqLineEdit.h"
41 #include "pqWidgetsModule.h"
42 
61 {
62  Q_OBJECT
63  Q_ENUMS(RealNumberNotation)
64  Q_PROPERTY(RealNumberNotation notation READ notation WRITE setNotation)
65  Q_PROPERTY(int precision READ precision WRITE setPrecision)
66  Q_PROPERTY(bool useGlobalPrecisionAndNotation READ useGlobalPrecisionAndNotation WRITE
67  setUseGlobalPrecisionAndNotation)
68  using Superclass = pqLineEdit;
69 
70 public:
71  pqDoubleLineEdit(QWidget* parent = 0);
72  ~pqDoubleLineEdit() override;
73 
78  {
79  MixedNotation = 0,
81  FixedNotation
82  };
83 
88  RealNumberNotation notation() const;
89 
94  int precision() const;
95 
101  bool useGlobalPrecisionAndNotation() const;
102 
104 
109  static void setGlobalPrecisionAndNotation(int precision, RealNumberNotation notation);
110  static int globalPrecision();
111  static RealNumberNotation globalNotation();
113 
118  QString simplifiedText() const;
119 
121 
125  static QString formatDouble(
126  double value, QTextStream::RealNumberNotation notation, int precision);
127  static QString formatDouble(
128  double value, pqDoubleLineEdit::RealNumberNotation notation, int precision);
130 
132 
136  static QString formatDoubleUsingGlobalPrecisionAndNotation(double value);
138 
139 public Q_SLOTS:
144  void setNotation(RealNumberNotation _notation);
145 
150  void setPrecision(int precision);
151 
156  void setUseGlobalPrecisionAndNotation(bool value);
157 
158 protected:
159  void paintEvent(QPaintEvent* evt) override;
160  void resizeEvent(QResizeEvent* event) override;
161 
162 private:
163  Q_DISABLE_COPY(pqDoubleLineEdit)
164 
165  static int GlobalPrecision;
166  static RealNumberNotation GlobalNotation;
167 
168  class pqInternals;
169  QScopedPointer<pqInternals> Internals;
170 };
171 
172 #endif
RealNumberNotation
This enum specifies which notations to use for displaying the value.
#define PQWIDGETS_EXPORT
pqLineEdit subclass that supports a low precision view when inactive
pqLineEdit is a specialization of QLineEdit which provide a new property &#39;text2&#39;. ...
Definition: pqLineEdit.h:53