#include <QMessageBox>
#include <QAction>
#include <QTextCodec>
+#include <QWindow>
+#include <QScreen>
#include <sstream>
#include <string>
return true;
}
+qreal currentPixelRatio()
+{
+ QWindowList aWnds = qApp->topLevelWindows();
+ if (aWnds.size() > 0)
+ return aWnds.first()->devicePixelRatio();
+ return qApp->primaryScreen()->devicePixelRatio();
+}
+
} // namespace ModuleBase_Tools
std::string MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute,
ModuleBase_IWorkshop* theWorkshop);
+/// Returns pixel ratio of a screen where main window is displayed
+qreal MODULEBASE_EXPORT currentPixelRatio();
}
#endif
if (!aFOperation)
return;
+ SketcherPrs_Tools::setPixelRatio(ModuleBase_Tools::currentPixelRatio());
+
myModule->onViewTransformed();
// Display all sketcher sub-Objects
Quantity_Color aExternalColor = aIsEdge ? Quantity_NOC_BLACK : Quantity_NOC_YELLOW;
Quantity_Color aInternalColor = aIsEdge ? Quantity_NOC_YELLOW : Quantity_NOC_BLACK;
+ int aRatio = SketcherPrs_Tools::pixelRatio();
+
// Create the presentation as a combination of standard point markers
bool aCustomColor = myIsCustomColor;
// The external yellow contour
Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d();
aPtA->SetType(Aspect_TOM_RING3);
- aPtA->SetScale(2.);
+ aPtA->SetScale(2. * aRatio);
aPtA->SetColor(!aCustomColor ? aExternalColor : myCustomColor);
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
// Make a black mid ring
aPtA = new Graphic3d_AspectMarker3d();
aPtA->SetType(aIsEdge ? Aspect_TOM_STAR : Aspect_TOM_RING1);
- aPtA->SetScale(1.);
+ aPtA->SetScale(1. * aRatio);
aPtA->SetColor(!aCustomColor ? aInternalColor : myCustomColor);
aGroup->SetPrimitivesAspect(aPtA);
aGroup->AddPrimitiveArray (aPntArray);
// Make an internal ring
aPtA = new Graphic3d_AspectMarker3d();
aPtA->SetType(Aspect_TOM_POINT);
- aPtA->SetScale(5.);
+ aPtA->SetScale(5. * aRatio);
aPtA->SetColor(!aCustomColor ? aInternalColor : myCustomColor);
aGroup->SetPrimitivesAspect(aPtA);
aGroup->AddPrimitiveArray (aPntArray);
aFile += iconName();
Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
if (aPixMap->Load(aFile.c_str())) {
+ int aRatio = SketcherPrs_Tools::pixelRatio();
+ if (aRatio > 1) {
+ Handle(Image_AlienPixMap) aSizedMap = new Image_AlienPixMap();
+ Standard_Size aWidth = aPixMap->Width() * aRatio;
+ Standard_Size aHeigh = aPixMap->Height() * aRatio;
+ aSizedMap->InitTrash(aPixMap->Format(), aWidth, aHeigh);
+ for (Standard_Size i = 0; i < aWidth; i++) {
+ for (Standard_Size j = 0; j < aHeigh; j++) {
+ aSizedMap->SetPixelColor(i, j, aPixMap->PixelColor(i / aRatio, j / aRatio));
+ }
+ }
+ aPixMap = aSizedMap;
+ }
myIconsMap[iconName()] = aPixMap;
return aPixMap;
}
return aLin2d.project(thePoint);
}
+static int MyPixelRatio = 1;
+
+void setPixelRatio(int theRatio)
+{
+ MyPixelRatio = theRatio;
+}
+
+int pixelRatio()
+{
+ return MyPixelRatio;
+}
static double MyArrowSize = 20;
+
double getArrowSize()
{
return MyArrowSize;
static double MyTextHeight = 16;
double getTextHeight()
{
- return MyTextHeight;
+ return MyTextHeight * MyPixelRatio;
}
void setTextHeight(double theHeight)
double getDefaultTextHeight()
{
- return 16;
+ return 16 * MyPixelRatio;
}
double getConfigTextHeight()
{
- return Config_PropManager::integer("Visualization", "dimension_value_size");
+ return Config_PropManager::integer("Visualization", "dimension_value_size") * MyPixelRatio;
}
double getFlyoutDistance(const ModelAPI_Feature* theConstraint)
/// \param theError a debug error information
SKETCHERPRS_EXPORT void sendEmptyPresentationError(ModelAPI_Feature* theFeature,
const std::string theError);
+
+ SKETCHERPRS_EXPORT void setPixelRatio(int theRatio);
+
+ SKETCHERPRS_EXPORT int pixelRatio();
};
#endif