#include "ModuleBase.h"
#include <QObject>
+#include <QMap>
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
/// Update current viewer
virtual void update() = 0;
+ const double Scale(const Handle(V3d_View)& theView)
+ {
+ if (!myWindowScale.contains(theView))
+ myWindowScale.insert(theView, theView->Camera()->Scale());
+ return myWindowScale[theView];
+ }
+
+ void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
+
/// Method returns True if the viewer can process editing objects
/// by mouse drugging. If this is impossible thet it has to return False.
virtual bool canDragByMouse() const { return true; }
/// Signal emitted on transformation of view point in view window
/// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
void viewTransformed(int theTransformation);
+
+ protected:
+ QMap<Handle(V3d_View), double> myWindowScale;
};
#endif
//**********************************************
void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
{
+ if(myWindowScale.contains(myView->v3dView()))
+ myWindowScale.remove(myView->v3dView());
emit deleteView(myView);
}
connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
+ myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale());
+
emit viewCreated(myView);
}
return;
double aLen = aView->Convert(20);
+ double aPrevLen = SketcherPrs_Tools::getArrowSize();
SketcherPrs_Tools::setArrowSize(aLen);
+ const double aPrevScale = aViewer->Scale(aViewer->activeView());
+ const double aCurScale = aViewer->activeView()->Camera()->Scale();
+ aViewer->SetScale(aViewer->activeView(), aCurScale);
+ SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight());
bool isModified = false;
QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
foreach (AISObjectPtr aAIS, aPrsList) {
myAspect->MakeText3d(false);
myAspect->MakeTextShaded(false);
myAspect->MakeUnitsDisplayed(false);
- myAspect->TextAspect()->SetHeight(MyTextHeight);
+ myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight());
myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize());
- SetSelToleranceForText2d(MyTextHeight);
+ SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
SetDimensionAspect(myAspect);
}
return;
}
}
+ SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
AIS_LengthDimension::ComputeSelection(aSelection, aMode);
}
myAspect->MakeText3d(false);
myAspect->MakeTextShaded(false);
myAspect->MakeUnitsDisplayed(false);
- myAspect->TextAspect()->SetHeight(MyTextHeight);
+ myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight());
myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize());
SetDimensionAspect(myAspect);
- SetSelToleranceForText2d(MyTextHeight);
+ SetSelToleranceForText2d(SketcherPrs_Tools::getDefaultTextHeight());
}
}
aGroup->UserDraw(this, true);
+
+ // Disable frustum culling for this object by marking it as mutable
+ aGroup->Structure()->SetMutable(true);
//aGroup->AddPrimitiveArray(myPntArray);
}
MyArrowSize = theSize;
}
+static double MyTextHeight = 20;
+double getTextHeight()
+{
+ return MyTextHeight;
+}
+
+void setTextHeight(double theHeight)
+{
+ MyTextHeight = theHeight;
+}
+
+double getDefaultTextHeight()
+{
+ return 30;
+}
+
double getFlyoutDistance(const ModelAPI_Feature* theConstraint)
{
std::shared_ptr<GeomDataAPI_Point2D> aFlyoutPoint =
class GeomDataAPI_Point2D;
-#define MyTextHeight 20
+//#define MyTextHeight 20
namespace SketcherPrs_Tools {
SKETCHERPRS_EXPORT void setArrowSize(double theSize);
+ SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
+
+ SKETCHERPRS_EXPORT double getTextHeight();
+
+ SKETCHERPRS_EXPORT double getDefaultTextHeight();
+
SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd)
{
+ if (myWindowScale.contains(theWnd->v3dView()))
+ myWindowScale.remove (theWnd->v3dView());
emit deleteView(theWnd);
}
{
theWnd->viewPort()->installEventFilter(this);
+ myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale());
+
emit viewCreated(theWnd);
}
connect(theWnd, SIGNAL(vpTransformationFinished(AppElements_ViewWindow::OperationType)),
this, SLOT(onViewTransformed(AppElements_ViewWindow::OperationType)));
+ myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale());
+
emit viewCreated(theWnd);
}