mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0024714: Camera integration - difference in behavior of V3d_View::SetSize
Restored behavior of SetSize method
This commit is contained in:
parent
34db9c0093
commit
3dfe95cdb9
@ -215,7 +215,10 @@ public:
|
||||
//! Sets camera scale. For orthographic projection the scale factor
|
||||
//! corresponds to parallel scale of view mapping (i.e. size
|
||||
//! of viewport). For perspective camera scale is converted to
|
||||
//! distance.
|
||||
//! distance. The scale specifies equal size of the view projection in
|
||||
//! both dimensions assuming that the aspect is 1.0. The projection height
|
||||
//! and width are specified with the scale and correspondingly multiplied
|
||||
//! by the aspect.
|
||||
//! @param theScale [in] the scale factor.
|
||||
Standard_EXPORT void SetScale (const Standard_Real theScale);
|
||||
|
||||
@ -288,7 +291,7 @@ public:
|
||||
return myZFar;
|
||||
}
|
||||
|
||||
//! Change display ratio.
|
||||
//! Changes width / height display ratio.
|
||||
//! @param theAspect [in] the display ratio.
|
||||
Standard_EXPORT void SetAspect (const Standard_Real theAspect);
|
||||
|
||||
|
@ -852,14 +852,12 @@ is
|
||||
raises BadValue from V3d;
|
||||
-- If one of the dimensions of the projection is NULL.
|
||||
|
||||
SetSize ( me : mutable ; Size : Length )
|
||||
SetSize ( me : mutable; theSize : Length )
|
||||
---Level: Public
|
||||
---Purpose: Defines the size of the view while preserving the
|
||||
-- center and height/width ratio of the window supporting
|
||||
-- the view.
|
||||
-- NOTE than the Depth of the View is NOT modified .
|
||||
raises BadValue from V3d ;
|
||||
-- If the size of the view is <= 0
|
||||
---Purpose: Defines the view projection size in its maximum dimension,
|
||||
-- keeping the inital height/width ratio unchanged.
|
||||
raises BadValue from V3d;
|
||||
-- If <theSize> is <= 0.0
|
||||
|
||||
SetZSize ( me : mutable ; Size : Length )
|
||||
---Level: Public
|
||||
|
@ -1345,12 +1345,11 @@ void V3d_View::SetCenter (const Standard_Integer theXp,
|
||||
//function : SetSize
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void V3d_View::SetSize(const Standard_Real Size)
|
||||
void V3d_View::SetSize (const Standard_Real theSize)
|
||||
{
|
||||
V3d_BadValue_Raise_if( Size <= 0.,
|
||||
"V3d_View::SetSize, Window Size is NULL");
|
||||
V3d_BadValue_Raise_if (theSize <= 0.0, "V3d_View::SetSize, Window Size is NULL");
|
||||
|
||||
myCamera->SetScale (Size);
|
||||
myCamera->SetScale (myCamera->Aspect() >= 1.0 ? theSize / myCamera->Aspect() : theSize);
|
||||
|
||||
AutoZFit();
|
||||
|
||||
|
@ -4435,6 +4435,13 @@ static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, con
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aParseKey.IsEmpty())
|
||||
{
|
||||
std::cout << theArgVec[0] << ": values should be passed with key.\n";
|
||||
std::cout << "Type help for more information.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aMapOfKeysByValues.ChangeFind (aParseKey).Append (anArg);
|
||||
}
|
||||
|
||||
@ -4450,6 +4457,7 @@ static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, con
|
||||
const TColStd_SequenceOfAsciiString& aValues = aMapIt.Value();
|
||||
|
||||
if (!(aKey.IsEqual ("SCALE") && (aValues.Length() == 1 || aValues.IsEmpty()))
|
||||
&& !(aKey.IsEqual ("SIZE") && (aValues.Length() == 1 || aValues.IsEmpty()))
|
||||
&& !(aKey.IsEqual ("EYE") && (aValues.Length() == 3 || aValues.IsEmpty()))
|
||||
&& !(aKey.IsEqual ("AT") && (aValues.Length() == 3 || aValues.IsEmpty()))
|
||||
&& !(aKey.IsEqual ("UP") && (aValues.Length() == 3 || aValues.IsEmpty()))
|
||||
@ -4480,6 +4488,20 @@ static int VViewParams (Draw_Interpretor& theDi, Standard_Integer theArgsNb, con
|
||||
anAISView->SetScale (aValues (1).RealValue());
|
||||
}
|
||||
}
|
||||
if (aMapOfKeysByValues.Find ("SIZE", aValues))
|
||||
{
|
||||
if (aValues.IsEmpty())
|
||||
{
|
||||
Standard_Real aSizeX = 0.0;
|
||||
Standard_Real aSizeY = 0.0;
|
||||
anAISView->Size (aSizeX, aSizeY);
|
||||
theDi << "Size X: " << aSizeX << " Y: " << aSizeY << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
anAISView->SetSize (aValues (1).RealValue());
|
||||
}
|
||||
}
|
||||
if (aMapOfKeysByValues.Find ("EYE", aValues))
|
||||
{
|
||||
if (aValues.IsEmpty())
|
||||
@ -6589,16 +6611,18 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
theCommands.Add ("vviewparams", "vviewparams usage:\n"
|
||||
"- vviewparams\n"
|
||||
"- vviewparams [-scale [s]] [-eye [x y z]] [-at [x y z]] [-up [x y z]]\n"
|
||||
" [-proj [x y z]] [-center x y]\n"
|
||||
" [-proj [x y z]] [-center x y] [-size sx]\n"
|
||||
"- Gets or sets current view parameters.\n"
|
||||
"- If called without arguments, all view parameters are printed.\n"
|
||||
"- The options are:\n"
|
||||
" -scale [s] : prints or sets viewport scale.\n"
|
||||
" -scale [s] : prints or sets viewport relative scale.\n"
|
||||
" -eye [x y z] : prints or sets eye location.\n"
|
||||
" -at [x y z] : prints or sets center of look.\n"
|
||||
" -up [x y z] : prints or sets direction of up vector.\n"
|
||||
" -proj [x y z] : prints or sets direction of look.\n"
|
||||
" -center x y : sets location of center of the screen in pixels.\n",
|
||||
" -center x y : sets location of center of the screen in pixels.\n"
|
||||
" -size [sx] : prints viewport projection width and height sizes\n"
|
||||
" : or changes the size of its maximum dimension.\n",
|
||||
__FILE__, VViewParams, group);
|
||||
theCommands.Add("vchangeselected",
|
||||
"vchangeselected shape"
|
||||
|
30
tests/bugs/vis/bug24714
Normal file
30
tests/bugs/vis/bug24714
Normal file
@ -0,0 +1,30 @@
|
||||
puts "============"
|
||||
puts "CR24714"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
##################################
|
||||
# Test V3d_View::SetSize method
|
||||
##################################
|
||||
|
||||
set aV "Driver1/Viewer1/View1"
|
||||
vinit name=$aV l=32 t=32 w=400 h=200
|
||||
vactivate $aV
|
||||
vclear
|
||||
|
||||
box b 10 10 10
|
||||
vdisplay b
|
||||
vright
|
||||
vfit
|
||||
|
||||
vviewparams -size 22
|
||||
|
||||
vmoveto 200 100
|
||||
|
||||
checkcolor 200 9 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
puts "Error : the view projection size is incorrect!"
|
||||
}
|
||||
|
||||
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user