//! 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);
return myZFar;
}
- //! Change display ratio.
+ //! Changes width / height display ratio.
//! @param theAspect [in] the display ratio.
Standard_EXPORT void SetAspect (const Standard_Real theAspect);
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
//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();
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);
}
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()))
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())
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"
--- /dev/null
+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