Merge pull request #3116 from shun-iwasawa/g/actual_pixel_in_cleanup_preview
Enable Actual Pixel View in Cleanup Preview Mode
This commit is contained in:
commit
e366a9d6c1
1 changed files with 43 additions and 30 deletions
|
@ -2016,7 +2016,7 @@ double SceneViewer::projectToZ(const TPointD &delta) {
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
double modelview[16], projection[16];
|
double modelview[16], projection[16];
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
projection[i] = (double)m_projectionMatrix.constData()[i];
|
projection[i] = (double)m_projectionMatrix.constData()[i];
|
||||||
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
|
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
|
||||||
|
|
||||||
|
@ -2178,8 +2178,9 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
|
||||||
if (reset || ((m_zoomScale3D < 500 || !forward) &&
|
if (reset || ((m_zoomScale3D < 500 || !forward) &&
|
||||||
(m_zoomScale3D > 0.01 || forward))) {
|
(m_zoomScale3D > 0.01 || forward))) {
|
||||||
double oldZoomScale = m_zoomScale3D;
|
double oldZoomScale = m_zoomScale3D;
|
||||||
m_zoomScale3D = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
|
m_zoomScale3D =
|
||||||
m_zoomScale3D, forward);
|
reset ? 1
|
||||||
|
: ImageUtils::getQuantizedZoomFactor(m_zoomScale3D, forward);
|
||||||
|
|
||||||
m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D;
|
m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D;
|
||||||
}
|
}
|
||||||
|
@ -2200,17 +2201,18 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
TAffine &viewAff = m_viewAff[i];
|
TAffine &viewAff = m_viewAff[i];
|
||||||
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
|
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
|
||||||
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
|
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
|
||||||
double scale2 = std::abs(viewAff.det());
|
double scale2 = std::abs(viewAff.det());
|
||||||
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
|
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
|
||||||
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
|
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
|
||||||
if (reset || ((scale2 < 100000 || !forward) &&
|
if (reset || ((scale2 < 100000 || !forward) &&
|
||||||
(scale2 > 0.001 * 0.05 || forward))) {
|
(scale2 > 0.001 * 0.05 || forward))) {
|
||||||
double oldZoomScale = sqrt(scale2) * dpiFactor;
|
double oldZoomScale = sqrt(scale2) * dpiFactor;
|
||||||
double zoomScale = reset ? 1 : ImageUtils::getQuantizedZoomFactor(
|
double zoomScale =
|
||||||
oldZoomScale, forward);
|
reset ? 1
|
||||||
|
: ImageUtils::getQuantizedZoomFactor(oldZoomScale, forward);
|
||||||
|
|
||||||
// threshold value -0.001 is intended to absorb the error of calculation
|
// threshold value -0.001 is intended to absorb the error of calculation
|
||||||
if ((oldZoomScale - zoomScaleFittingWithScreen) *
|
if ((oldZoomScale - zoomScaleFittingWithScreen) *
|
||||||
|
@ -2268,17 +2270,27 @@ double SceneViewer::getDpiFactor() {
|
||||||
// If the option "ActualPixelViewOnSceneEditingMode" is ON,
|
// If the option "ActualPixelViewOnSceneEditingMode" is ON,
|
||||||
// use current level's DPI set in the level settings.
|
// use current level's DPI set in the level settings.
|
||||||
else if (Preferences::instance()
|
else if (Preferences::instance()
|
||||||
->isActualPixelViewOnSceneEditingModeEnabled() &&
|
->isActualPixelViewOnSceneEditingModeEnabled()) {
|
||||||
!CleanupPreviewCheck::instance()->isEnabled() &&
|
if (CleanupPreviewCheck::instance()->isEnabled() ||
|
||||||
!CameraTestCheck::instance()->isEnabled()) {
|
CameraTestCheck::instance()->isEnabled()) {
|
||||||
TXshSimpleLevel *sl;
|
double cleanupCameraDpi = TApp::instance()
|
||||||
sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
|
->getCurrentScene()
|
||||||
if (!sl) return Stage::inch / cameraDpi;
|
->getScene()
|
||||||
if (sl->getType() == PLI_XSHLEVEL) return Stage::inch / cameraDpi;
|
->getProperties()
|
||||||
if (sl->getDpi() == TPointD()) return Stage::inch / cameraDpi;
|
->getCleanupParameters()
|
||||||
// use default value for the argument of getDpi() (=TFrameId::NO_FRAME)
|
->m_camera.getDpi()
|
||||||
// so that the dpi of the first frame in the level will be returned.
|
.x;
|
||||||
return Stage::inch / sl->getDpi().x;
|
return Stage::inch / cleanupCameraDpi;
|
||||||
|
} else {
|
||||||
|
TXshSimpleLevel *sl;
|
||||||
|
sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
|
||||||
|
if (!sl) return Stage::inch / cameraDpi;
|
||||||
|
if (sl->getType() == PLI_XSHLEVEL) return Stage::inch / cameraDpi;
|
||||||
|
if (sl->getDpi() == TPointD()) return Stage::inch / cameraDpi;
|
||||||
|
// use default value for the argument of getDpi() (=TFrameId::NO_FRAME)
|
||||||
|
// so that the dpi of the first frame in the level will be returned.
|
||||||
|
return Stage::inch / sl->getDpi().x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// When the scene editing mode without any option, use the camera dpi
|
// When the scene editing mode without any option, use the camera dpi
|
||||||
else {
|
else {
|
||||||
|
@ -2501,9 +2513,9 @@ void SceneViewer::fitToCamera() {
|
||||||
TPointD P11 = cameraAff * cameraRect.getP11();
|
TPointD P11 = cameraAff * cameraRect.getP11();
|
||||||
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
|
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
|
||||||
std::min({P00.y, P01.y, P10.y, P11.y}));
|
std::min({P00.y, P01.y, P10.y, P11.y}));
|
||||||
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
|
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
|
||||||
std::max({P00.y, P01.y, P10.y, P11.y}));
|
std::max({P00.y, P01.y, P10.y, P11.y}));
|
||||||
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
|
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
// Pan
|
// Pan
|
||||||
if (!is3DView()) {
|
if (!is3DView()) {
|
||||||
|
@ -2556,8 +2568,8 @@ void SceneViewer::resetZoom() {
|
||||||
TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23);
|
TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23);
|
||||||
TAffine aff =
|
TAffine aff =
|
||||||
getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]);
|
getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]);
|
||||||
aff.a13 = realCenter.x;
|
aff.a13 = realCenter.x;
|
||||||
aff.a23 = realCenter.y;
|
aff.a23 = realCenter.y;
|
||||||
if (m_isFlippedX) aff = aff * TScale(-1, 1);
|
if (m_isFlippedX) aff = aff * TScale(-1, 1);
|
||||||
if (m_isFlippedY) aff = aff * TScale(1, -1);
|
if (m_isFlippedY) aff = aff * TScale(1, -1);
|
||||||
setViewMatrix(aff, m_viewMode);
|
setViewMatrix(aff, m_viewMode);
|
||||||
|
@ -2614,16 +2626,17 @@ void SceneViewer::setActualPixelSize() {
|
||||||
} else
|
} else
|
||||||
dpi = sl->getDpi(fid);
|
dpi = sl->getDpi(fid);
|
||||||
|
|
||||||
const double inch = Stage::inch;
|
const double inch = Stage::inch;
|
||||||
TAffine tempAff = getNormalZoomScale();
|
TAffine tempAff = getNormalZoomScale();
|
||||||
if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
|
if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
|
||||||
if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
|
if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
|
||||||
TPointD tempScale = dpi;
|
TPointD tempScale = dpi;
|
||||||
if (m_isFlippedX) tempScale.x = -tempScale.x;
|
if (m_isFlippedX) tempScale.x = -tempScale.x;
|
||||||
if (m_isFlippedY) tempScale.y = -tempScale.y;
|
if (m_isFlippedY) tempScale.y = -tempScale.y;
|
||||||
for (int i = 0; i < m_viewAff.size(); ++i)
|
for (int i = 0; i < m_viewAff.size(); ++i)
|
||||||
setViewMatrix(dpi == TPointD(0, 0) ? tempAff : TScale(tempScale.x / inch,
|
setViewMatrix(dpi == TPointD(0, 0)
|
||||||
tempScale.y / inch),
|
? tempAff
|
||||||
|
: TScale(tempScale.x / inch, tempScale.y / inch),
|
||||||
i);
|
i);
|
||||||
|
|
||||||
m_pos = QPoint(0, 0);
|
m_pos = QPoint(0, 0);
|
||||||
|
@ -2906,7 +2919,7 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
|
||||||
|
|
||||||
TStageObject *pegbar =
|
TStageObject *pegbar =
|
||||||
objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0;
|
objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0;
|
||||||
const TStroke *stroke = 0;
|
const TStroke *stroke = 0;
|
||||||
if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke();
|
if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke();
|
||||||
if (!stroke) return;
|
if (!stroke) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue