Skip to content

Commit

Permalink
Repair EMF and SVG output (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunterkoenigsmann committed Nov 14, 2023
1 parent 9903c2b commit d09d7fe
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Better display of diff(), if multiplication dots are enabled (#1825)
- Tried to resolve a few asserts (#1831)
- Resolved many warnings from different static analysis tools
- Repaired EMF and SVG output (#1838)

# 23.10.0

Expand Down
2 changes: 2 additions & 0 deletions src/cells/TextCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ void TextCell::Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) {
SetTextColor(dc);
dc->DrawText(m_displayedText, point.x + padding,
point.y - m_center + MC_TEXT_PADDING);
// std::cerr<<"Text=\""<<m_displayedText<<"\",pos=("<<point.x<<","<<point.y<<") Cntxt="<<dc<<"\n";

}
}

Expand Down
12 changes: 6 additions & 6 deletions src/graphical_io/BitmapOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ BitmapOut::BitmapOut(Configuration **configuration, double scale)
m_dc.SetPen(wxNullPen);
m_cmn.SetRecalculationContext(m_dc);

auto &config = m_cmn.GetConfiguration();
config.SetRecalcContext(m_dc);
config.SetCanvasSize(wxSize(BM_FULL_WIDTH, BM_FULL_WIDTH));
auto *config = m_cmn.GetConfiguration();
config->SetRecalcContext(m_dc);
config->SetCanvasSize(wxSize(BM_FULL_WIDTH, BM_FULL_WIDTH));
}

BitmapOut::BitmapOut(Configuration **configuration,
Expand Down Expand Up @@ -99,10 +99,10 @@ bool BitmapOut::Layout(long int maxSize) {
}

void BitmapOut::Draw() {
auto &config = m_cmn.GetConfiguration();
config.ClipToDrawRegion(false);
auto config = m_cmn.GetConfiguration();
config->ClipToDrawRegion(false);

auto bgColor = config.m_styles[TS_TEXT_BACKGROUND].GetColor();
auto bgColor = config->m_styles[TS_TEXT_BACKGROUND].GetColor();
m_dc.SetBackground(*(wxTheBrushList->FindOrCreateBrush(bgColor,
wxBRUSHSTYLE_SOLID)));
m_dc.Clear();
Expand Down
1 change: 1 addition & 0 deletions src/graphical_io/EMFout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bool Emfout::Layout() {
wxEnhMetaFileDC dc(m_cmn.GetFilename(), size.x, size.y);

config.SetRecalcContext(dc);
m_cmn.SetRecalculationContext(dc);
m_cmn.Draw(m_tree.get());
m_metaFile.reset(
dc.Close()); // Closing the DC triggers the output of the file.
Expand Down
1 change: 1 addition & 0 deletions src/graphical_io/OutCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ bool OutCommon::PrepareLayout(Cell *tree) {
return false;

tree->SetConfigurationList(&m_thisconfig);
m_thisconfig.ClipToDrawRegion(false);
tree->FontsChangedList();
tree->ResetSize();
if(m_recalculationDc)
Expand Down
2 changes: 1 addition & 1 deletion src/graphical_io/OutCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class OutCommon
const wxString &GetFilename() const { return m_filename; }
const wxString &GetTempFilename() const { return m_tempFilename; }
//! Get the configuration for the file/bitmap/... output
Configuration &GetConfiguration() { return m_thisconfig; }
Configuration *GetConfiguration() { return &m_thisconfig; }
//! Get the configuration for the screen output
Configuration &GetScreenConfig() { return *(*m_configuration); }
wxSize getPPI() const { return m_ppi; }
Expand Down
35 changes: 28 additions & 7 deletions src/graphical_io/SVGout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ Svgout::Svgout(Configuration **configuration, const wxString &filename,
#if wxCHECK_VERSION(3, 1, 0)
m_recalculationDc.SetBitmapHandler(new wxSVGBitmapEmbedHandler());
#endif
auto &config = m_cmn.GetConfiguration();
config.SetRecalcContext(m_recalculationDc);
config.SetCanvasSize(wxSize(700 * scale, 100000 * scale));
auto *config = m_cmn.GetConfiguration();
config->SetRecalcContext(m_recalculationDc);
config->SetCanvasSize(wxSize(700 * scale, 100000 * scale));
}

Svgout::Svgout(Configuration **configuration, std::unique_ptr<Cell> &&tree,
Expand All @@ -79,16 +79,37 @@ bool Svgout::Layout() {

// Let's switch to a DC of the right size for our object.
auto size = m_cmn.GetSize();
auto &config = m_cmn.GetConfiguration();
auto *config = m_cmn.GetConfiguration();
wxSVGFileDC dc(m_cmn.GetFilename(), size.x, size.y, 20 * m_cmn.GetScale());
m_cmn.SetRecalculationContext(dc);
#if wxCHECK_VERSION(3, 1, 0)
dc.SetBitmapHandler(new wxSVGBitmapEmbedHandler());
#endif

config.SetRecalcContext(dc);
m_cmn.Draw(m_tree.get());
config.UnsetContext();
config->SetRecalcContext(dc);
//std::cerr<<"DrawContext="<<&dc<<"\n";
//std::cerr<<"Visible region1: ("<<config->GetVisibleRegion().GetLeft()<<","<<
// config->GetVisibleRegion().GetTop()<<"):("<<config->GetVisibleRegion().GetRight() <<
// ","<<config->GetVisibleRegion().GetBottom()<<")\n";

//std::cerr<<"Visible region2: ("<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetLeft()<<","<<
// m_tree.get()->GetConfiguration()->GetVisibleRegion().GetTop()<<"):("<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetRight() <<
// ","<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetBottom()<<")\n";

//std::cerr<<"Visible region1: ("<<config->GetVisibleRegion().GetLeft()<<","<<
// config->GetVisibleRegion().GetTop()<<"):("<<config->GetVisibleRegion().GetRight() <<
// ","<<config->GetVisibleRegion().GetBottom()<<")\n";

//std::cerr<<"Visible region2: ("<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetLeft()<<","<<
// m_tree.get()->GetConfiguration()->GetVisibleRegion().GetTop()<<"):("<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetRight() <<
// ","<<m_tree.get()->GetConfiguration()->GetVisibleRegion().GetBottom()<<")\n";
//std::cerr<<"Update region2: ("<<m_tree.get()->GetConfiguration()->GetUpdateRegion().GetLeft()<<","<<
// m_tree.get()->GetConfiguration()->GetUpdateRegion().GetTop()<<"):("<<m_tree.get()->GetConfiguration()->GetUpdateRegion().GetRight() <<
// ","<<m_tree.get()->GetConfiguration()->GetUpdateRegion().GetBottom()<<")\n";
m_cmn.Draw(m_tree.get());
config->UnsetContext();
// std::cerr<<"cfg1="<<config<<", cfg2="<<m_tree.get()->GetConfiguration()<<"\n";
// std::cerr<<"LayoutEnd\n";
return true;
}

Expand Down

0 comments on commit d09d7fe

Please sign in to comment.