2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// The View menu, stuff to snap to certain special vews of the model, and to
|
|
|
|
// display our current view of the model to the user.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-01-04 00:35:28 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
|
|
|
|
void TextWindow::ShowEditView(void) {
|
|
|
|
Printf(true, "%Ft3D VIEW PARAMETERS%E");
|
|
|
|
|
|
|
|
Printf(true, "%Bd %Ftoverall scale factor%E");
|
|
|
|
Printf(false, "%Ba %# px/%s %Fl%Ll%f[edit]%E",
|
|
|
|
SS.GW.scale * SS.MmPerUnit(),
|
|
|
|
SS.UnitName(),
|
|
|
|
&ScreenChangeViewScale);
|
|
|
|
Printf(false, "");
|
|
|
|
|
|
|
|
Printf(false, "%Bd %Ftorigin (maps to center of screen)%E");
|
|
|
|
Printf(false, "%Ba (%s, %s, %s) %Fl%Ll%f[edit]%E",
|
2015-11-06 08:40:12 +00:00
|
|
|
SS.MmToString(-SS.GW.offset.x).c_str(),
|
|
|
|
SS.MmToString(-SS.GW.offset.y).c_str(),
|
|
|
|
SS.MmToString(-SS.GW.offset.z).c_str(),
|
2010-01-04 00:35:28 +00:00
|
|
|
&ScreenChangeViewOrigin);
|
|
|
|
Printf(false, "");
|
|
|
|
|
|
|
|
Vector n = (SS.GW.projRight).Cross(SS.GW.projUp);
|
|
|
|
Printf(false, "%Bd %Ftprojection onto screen%E");
|
|
|
|
Printf(false, "%Ba %Ftright%E (%3, %3, %3) %Fl%Ll%f[edit]%E",
|
|
|
|
CO(SS.GW.projRight),
|
|
|
|
&ScreenChangeViewProjection);
|
2010-01-04 07:07:35 +00:00
|
|
|
Printf(false, "%Bd %Ftup%E (%3, %3, %3)", CO(SS.GW.projUp));
|
2010-01-04 00:35:28 +00:00
|
|
|
Printf(false, "%Ba %Ftout%E (%3, %3, %3)", CO(n));
|
|
|
|
Printf(false, "");
|
|
|
|
|
|
|
|
Printf(false, "The perspective may be changed in the");
|
|
|
|
Printf(false, "configuration screen.");
|
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void TextWindow::ScreenChangeViewScale(int link, uint32_t v) {
|
2010-01-04 00:35:28 +00:00
|
|
|
SS.TW.edit.meaning = EDIT_VIEW_SCALE;
|
2015-11-06 08:40:12 +00:00
|
|
|
SS.TW.ShowEditControl(12, 3, ssprintf("%.3f", SS.GW.scale * SS.MmPerUnit()));
|
2010-01-04 00:35:28 +00:00
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void TextWindow::ScreenChangeViewOrigin(int link, uint32_t v) {
|
2015-11-06 08:40:12 +00:00
|
|
|
std::string edit_value =
|
|
|
|
ssprintf("%s, %s, %s",
|
|
|
|
SS.MmToString(-SS.GW.offset.x).c_str(),
|
|
|
|
SS.MmToString(-SS.GW.offset.y).c_str(),
|
|
|
|
SS.MmToString(-SS.GW.offset.z).c_str());
|
2010-01-04 00:35:28 +00:00
|
|
|
|
|
|
|
SS.TW.edit.meaning = EDIT_VIEW_ORIGIN;
|
2015-11-06 08:40:12 +00:00
|
|
|
SS.TW.ShowEditControl(18, 3, edit_value);
|
2010-01-04 00:35:28 +00:00
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void TextWindow::ScreenChangeViewProjection(int link, uint32_t v) {
|
2015-11-06 08:40:12 +00:00
|
|
|
std::string edit_value =
|
|
|
|
ssprintf("%.3f, %.3f, %.3f", CO(SS.GW.projRight));
|
2010-01-04 00:35:28 +00:00
|
|
|
SS.TW.edit.meaning = EDIT_VIEW_PROJ_RIGHT;
|
2015-11-06 08:40:12 +00:00
|
|
|
SS.TW.ShowEditControl(24, 10, edit_value);
|
2010-01-04 00:35:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 19:51:20 +00:00
|
|
|
bool TextWindow::EditControlDoneForView(const char *s) {
|
2010-01-04 00:35:28 +00:00
|
|
|
switch(edit.meaning) {
|
|
|
|
case EDIT_VIEW_SCALE: {
|
|
|
|
Expr *e = Expr::From(s, true);
|
|
|
|
if(e) {
|
2010-01-11 00:44:11 +00:00
|
|
|
double v = e->Eval() / SS.MmPerUnit();
|
|
|
|
if(v > LENGTH_EPS) {
|
|
|
|
SS.GW.scale = v;
|
|
|
|
} else {
|
|
|
|
Error("Scale cannot be zero or negative.");
|
|
|
|
}
|
2010-01-04 00:35:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EDIT_VIEW_ORIGIN: {
|
|
|
|
Vector pt;
|
|
|
|
if(sscanf(s, "%lf, %lf, %lf", &pt.x, &pt.y, &pt.z) == 3) {
|
|
|
|
pt = pt.ScaledBy(SS.MmPerUnit());
|
|
|
|
SS.GW.offset = pt.ScaledBy(-1);
|
|
|
|
} else {
|
|
|
|
Error("Bad format: specify x, y, z");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EDIT_VIEW_PROJ_RIGHT:
|
|
|
|
case EDIT_VIEW_PROJ_UP: {
|
|
|
|
Vector pt;
|
|
|
|
if(sscanf(s, "%lf, %lf, %lf", &pt.x, &pt.y, &pt.z) != 3) {
|
|
|
|
Error("Bad format: specify x, y, z");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(edit.meaning == EDIT_VIEW_PROJ_RIGHT) {
|
|
|
|
SS.GW.projRight = pt;
|
|
|
|
SS.GW.NormalizeProjectionVectors();
|
|
|
|
edit.meaning = EDIT_VIEW_PROJ_UP;
|
|
|
|
char buf[1024];
|
|
|
|
sprintf(buf, "%.3f, %.3f, %.3f", CO(SS.GW.projUp));
|
2010-07-12 07:51:12 +00:00
|
|
|
HideEditControl();
|
|
|
|
ShowEditControl(26, 10, buf);
|
2010-01-04 00:35:28 +00:00
|
|
|
edit.showAgain = true;
|
|
|
|
} else {
|
|
|
|
SS.GW.projUp = pt;
|
|
|
|
SS.GW.NormalizeProjectionVectors();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|