16 #include <QDataStream>
17 #include <QFontMetrics>
25 memset(
m_roi, 0,
sizeof(
float) * 4);
30 memcpy(
m_roi,
roi,
sizeof(
float) * 4);
34 assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
35 if (dataVersion < 21) {
43 QDataStream outStream(&out);
44 for (
int i = 0; i < 4; ++i) outStream <<
m_roi[i];
50 return std::max(
static_cast<short>(21),
62 if (dataVersion < 21)
return false;
65 QDataStream inStream(&in);
66 for (
int i = 0; i < 4; ++i) inStream >>
m_roi[i];
117 for (
unsigned i = 0; i < 12; ++i) {
139 float relativeZoom = 1.0f;
140 float dx = 0, dy = 0;
146 relativeZoom = winTotalZoom / totalZoom;
153 dx =
static_cast<float>(dC.
x + P.
x);
154 dy =
static_cast<float>(dC.
y + P.
y);
171 QPoint(dx +
m_roi[0] * relativeZoom, dy +
m_roi[1] * relativeZoom);
173 QPoint(dx +
m_roi[2] * relativeZoom, dy +
m_roi[1] * relativeZoom);
175 QPoint(dx +
m_roi[2] * relativeZoom, dy +
m_roi[3] * relativeZoom);
177 QPoint(dx +
m_roi[0] * relativeZoom, dy +
m_roi[3] * relativeZoom);
182 if (!title.isEmpty()) {
185 titleFont.setBold(
true);
186 QFontMetrics titleFontMetrics(titleFont);
187 int titleHeight = titleFontMetrics.height();
189 int xStart =
static_cast<int>(dx + std::min<float>(
m_roi[0],
m_roi[2]) *
191 int yStart =
static_cast<int>(dy + std::min<float>(
m_roi[1],
m_roi[3]) *
void setRoi(const float *roi)
Sets ROI (relative to screen)
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
cc2DViewportLabel(QString name=QString())
Default constructor.
void update2DLabelView(CC_DRAW_CONTEXT &context, bool updateScreen=true)
const float * roi() const
Returns ROI (relative to screen)
short minimumFileVersion_MeOnly() const override
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
ecvViewportParameters m_params
Viewport parameters.
short minimumFileVersion_MeOnly() const override
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
virtual bool isVisible() const
Returns whether entity is visible or not.
virtual void setVisible(bool state)
Sets entity visibility.
bool m_selected
Specifies whether the object is selected or not.
T * data()
Returns a pointer to internal data.
void apply(float vec[3]) const
Applies transformation to a 3D vector (in place) - float version.
QString getViewId() const
virtual QString getName() const
Returns object name.
virtual bool isEnabled() const
Returns whether the object is enabled or not.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
Standard parameters for GL displays/viewports.
bool perspectiveView
Perspective view state.
float fov_deg
Camera F.O.V. (field of view) in degrees.
float pixelSize
Current pixel size (in 'current unit'/pixel)
float cameraAspectRatio
Camera aspect ratio.
const CCVector3d & getCameraCenter() const
Returns the camera center.
const CCVector3d & getPivotPoint() const
Returns the pivot point (for object-centered view mode)
ccGLMatrixd viewMat
Visualization matrix (rotation only)
#define MACRO_Draw2D(context)
#define MACRO_Foreground(context)
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
constexpr Rgbub defaultColor(MAX, MAX, MAX)
constexpr Rgb red(MAX, 0, 0)
Rgbf FromRgb(const Rgb &color)