Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HighResolution #449

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/apps/weblib/cinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ void vizzu_update(APIHandles::Chart chart, double timeInMSecs)
void vizzu_render(APIHandles::Chart chart,
APIHandles::Canvas canvas,
double width,
double height)
double height,
int highResolution)
{
return Interface::getInstance().render(chart,
canvas,
width,
height);
height,
static_cast<bool>(highResolution));
}

const char *style_getList() { return Interface::getStyleList(); }
Expand Down
3 changes: 2 additions & 1 deletion src/apps/weblib/cinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ extern void vizzu_update(APIHandles::Chart chart, double timeInMSecs);
extern void vizzu_render(APIHandles::Chart chart,
APIHandles::Canvas canvas,
double width,
double height);
double height,
int highResolution);
extern const char *vizzu_errorMessage(
APIHandles::Exception exceptionPtr,
const std::type_info *typeinfo);
Expand Down
5 changes: 3 additions & 2 deletions src/apps/weblib/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void Interface::update(ObjectRegistryHandle chart, double timeInMSecs)
void Interface::render(ObjectRegistryHandle chart,
ObjectRegistryHandle canvas,
double width,
double height)
double height,
bool highResolution)
{
auto &&widget = objects.get<UI::ChartWidget>(chart);
auto &&ptr = objects.get<Gfx::ICanvas>(canvas);
Expand All @@ -398,7 +399,7 @@ void Interface::render(ObjectRegistryHandle chart,

widget->onUpdateSize({width, height});

widget->onDraw(ptr);
widget->onDraw(ptr, highResolution);

ptr->frameEnd();
}
Expand Down
3 changes: 2 additions & 1 deletion src/apps/weblib/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class Interface
void render(ObjectRegistryHandle chart,
ObjectRegistryHandle canvas,
double width,
double height);
double height,
bool highResolution);

ObjectRegistryHandle storeAnim(ObjectRegistryHandle chart);
void restoreAnim(ObjectRegistryHandle chart,
Expand Down
4 changes: 2 additions & 2 deletions src/apps/weblib/ts-api/cvizzu.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export interface CVizzu {
_vizzu_wheel(chart: CChartPtr, canvas: CCanvasPtr, delta: number): void
_vizzu_setLogging(enable: boolean): void
_vizzu_update(chart: CChartPtr, time: number): void
_vizzu_render(chart: CChartPtr, canvas: CCanvasPtr, width: number, height: number): void

_vizzu_render(chart: CChartPtr, canvas: CCanvasPtr, width: number, height: number,
highResolution: boolean): void
_vizzu_errorMessage(exceptionPtr: CException, typeinfo: CTypeInfo): CString
_vizzu_version(): CString
_data_addDimension(
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/ts-api/module/cchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CChart extends CObject {

render(cCanvas: CCanvas, width: number, height: number): void {
this._cCanvas = cCanvas
this._call(this._wasm._vizzu_render)(cCanvas.getId(), width, height)
this._call(this._wasm._vizzu_render)(cCanvas.getId(), width, height, true)
}

animate(callback: (ok: boolean) => void): void {
Expand Down
Empty file added src/base/gui/widget.h
Empty file.
6 changes: 5 additions & 1 deletion src/chart/main/chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ Gen::Config Chart::getConfig()
return Gen::Config{getOptions(), table};
}

void Chart::draw(Gfx::ICanvas &canvas)
void Chart::draw(Gfx::ICanvas &canvas, bool highResolution)
{
static_cast<Draw::Painter *>(canvas.getPainter())
->setResMode(highResolution ? Draw::ResolutionMode::High
: Draw::ResolutionMode::Low);

renderedChart = Draw::RenderedChart{
actPlot ? Draw::CoordinateSystem{layout.plotArea,
actPlot->getOptions()->angle,
Expand Down
2 changes: 1 addition & 1 deletion src/chart/main/chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Chart

Chart();
Chart(Chart &&) noexcept = delete;
void draw(Gfx::ICanvas &canvas);
void draw(Gfx::ICanvas &canvas, bool highResolution);
void setBoundRect(const Geom::Rect &rect);

Data::DataTable &getTable() { return table; }
Expand Down
1 change: 0 additions & 1 deletion src/chart/rendering/drawplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void DrawPlot::drawPlotArea(Gfx::ICanvas &canvas,
auto rect = Geom::Rect::Ident();
painter.setPolygonToCircleFactor(0.0);
painter.setPolygonStraightFactor(0.0);
painter.setResMode(ResolutionMode::High);

if (clip) { painter.drawPolygon(rect.points(), true); }
else {
Expand Down
1 change: 0 additions & 1 deletion src/chart/rendering/markerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ void MarkerRenderer::draw(Gfx::ICanvas &canvas,
: static_cast<double>(abstractMarker.morphToCircle));
painter.setPolygonStraightFactor(
static_cast<double>(abstractMarker.linear));
painter.setResMode(ResolutionMode::High);

auto colors = getColor(abstractMarker, factor);

Expand Down
1 change: 1 addition & 0 deletions src/chart/rendering/painter/painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void Painter::drawPolygon(const std::array<Geom::Point, 4> &ps,
Draw::DrawPolygon::Options options(system);
options.circ = polygonOptions.toCircleFactor;
options.linear = polygonOptions.straightFactor;
options.resolutionMode = mode;
Draw::DrawPolygon(ps, options, getCanvas(), clip);
}

Expand Down
5 changes: 3 additions & 2 deletions src/chart/ui/chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ void ChartWidget::onWheel(double delta) const
onWheelEvent->invoke(WheelEvent(delta, nullptr));
}

void ChartWidget::onDraw(const std::shared_ptr<Gfx::ICanvas> &canvas)
void ChartWidget::onDraw(const std::shared_ptr<Gfx::ICanvas> &canvas,
bool highResolution)
{
chart.draw(*canvas);
chart.draw(*canvas, highResolution);
}

void ChartWidget::onUpdateSize(Geom::Size size)
Expand Down
3 changes: 2 additions & 1 deletion src/chart/ui/chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ChartWidget
void onPointerUp(const GUI::PointerEvent &event) const;
void onPointerLeave(const GUI::PointerEvent &event) const;
void onWheel(double delta) const;
void onDraw(const std::shared_ptr<Gfx::ICanvas> &);
void onDraw(const std::shared_ptr<Gfx::ICanvas> &,
bool highResolution);
void onUpdateSize(Geom::Size size);

[[nodiscard]] Chart &getChart() { return chart; }
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion test/qtest/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Window::paintEvent(QPaintEvent *)

chart.getChart().onUpdateSize(size);
canvas.frameBegin();
chart.getChart().onDraw({std::shared_ptr<void>{}, &canvas});
chart.getChart().onDraw({std::shared_ptr<void>{}, &canvas}, true);
canvas.frameEnd();
}

Expand Down
Loading