- Geen afrondfouten/oveflow bij Centroid berekening als zowel x en y rond INT_MAX
- vectordpi functie toegevoegd - SaveAs tweede parameter ascii toegevoegd - Meer commentaren in ascii versie tempdwf - Labels van contouren die niet herkend waren maar vanuit ASP label hebben gekregen wel tekenen svn path=/Slnkdwf/trunk/; revision=43706
This commit is contained in:
@@ -46,7 +46,7 @@ interface IDWFFile : IDispatch{
|
||||
interface IWhipFile : IDispatch{
|
||||
[id(1), helpstring("method Load")] HRESULT Load([in] BSTR WhipPath);
|
||||
[id(2), helpstring("method LoadStream")] HRESULT LoadStream([in] VARIANT EPlotStream);
|
||||
[id(3), helpstring("method SaveAs")] HRESULT SaveAs([in] BSTR WhipPath);
|
||||
[id(3), helpstring("method SaveAs")] HRESULT SaveAs([in] BSTR WhipPath, [in, defaultvalue(0)] VARIANT_BOOL ascii);
|
||||
[id(6), helpstring("method HighlightUnrecognized")] HRESULT HighlightUnrecognized();
|
||||
[id(8), helpstring("method SetLabelFont")] HRESULT SetLabelFont([in] BSTR FontName, [in] DOUBLE FontHeight, [in, defaultvalue(0)] DOUBLE FontHeightSymbols);
|
||||
[id(9), helpstring("method SetLabelPosition")] HRESULT SetLabelPosition([in, defaultvalue(1)] BYTE LabelPos);
|
||||
@@ -66,6 +66,7 @@ interface IWhipFile : IDispatch{
|
||||
[propget, id(24), helpstring("property minContSize")] HRESULT minContSize([out, retval] DOUBLE* pVal);
|
||||
[propput, id(24), helpstring("property minContSize")] HRESULT minContSize([in] DOUBLE newVal);
|
||||
[propget, id(25), helpstring("property AddContour")] HRESULT AddContour([out, retval] ISLNKContour** pVal);
|
||||
[propget, id(27), helpstring("property vectorDpi")] HRESULT vectorDpi([out, retval] LONG* pVal);
|
||||
};
|
||||
[
|
||||
object,
|
||||
@@ -152,6 +153,7 @@ interface IEPlotSection : IDispatch{
|
||||
[propget, id(11), helpstring("property SourceDescription")] HRESULT SourceDescription([out, retval] BSTR* pVal);
|
||||
[propget, id(12), helpstring("property PropertiesXML")] HRESULT PropertiesXML([out, retval] BSTR* pVal);
|
||||
[propget, id(13), helpstring("property PaperClipWidth")] HRESULT PaperClipWidth([out, retval] DOUBLE* pVal);
|
||||
[propget, id(15), helpstring("property PaperClipHeight")] HRESULT PaperClipHeight([out, retval] DOUBLE* pVal);
|
||||
[propget, id(14), helpstring("property EPlotSectionImpl"), hidden] HRESULT EPlotSectionImpl([out, retval] /*CEPlotSectionImpl*/BYTE ** pVal);
|
||||
[propput, id(14), helpstring("property EPlotSectionImpl"), hidden] HRESULT EPlotSectionImpl([in] /*CEPlotSectionImpl*/ BYTE * newVal);
|
||||
};
|
||||
|
||||
@@ -82,6 +82,7 @@ CWhipFile::CWhipFile()
|
||||
m_minContSize = 0.20e6; // Minimale opp om herkend te worden.
|
||||
m_forFind = TRUE; // backward compatible
|
||||
m_activeLayerName = "";
|
||||
m_vdpi = 0;
|
||||
|
||||
// Predefine fixed symbols
|
||||
// Merk op dat m_contunits hier nog gewoon de default identity matrix is
|
||||
@@ -160,6 +161,15 @@ STDMETHODIMP CWhipFile::LoadStream(VARIANT EPlotStream)
|
||||
return ProcessContouren();
|
||||
}
|
||||
|
||||
void comment(myWT_File &my_file, const char *str)
|
||||
{
|
||||
if (!my_file.m_ascii)
|
||||
return;
|
||||
WT_Comments cmt;
|
||||
cmt.set(str);
|
||||
cmt.serialize(my_file);
|
||||
}
|
||||
|
||||
HRESULT CWhipFile::ProcessContouren()
|
||||
{
|
||||
m_W2DFile.set_file_mode(WT_File::File_Read);
|
||||
@@ -180,6 +190,17 @@ HRESULT CWhipFile::ProcessContouren()
|
||||
myDoTRACE("\nFound %d polylines, %d contours and %d labels.", xxxx, m_SLNKContouren.GetCount(), m_SLNKLabels.GetCount());
|
||||
|
||||
m_W2DFile.close(); // closing Input file.
|
||||
|
||||
double ClipWidth, ClipHeight;
|
||||
m_iEPlotSection->get_PaperClipWidth(&ClipWidth);
|
||||
m_iEPlotSection->get_PaperClipHeight(&ClipHeight);
|
||||
if (ClipWidth > 0 && ClipHeight > 0)
|
||||
{
|
||||
double dwfDx = m_view.view().m_max.m_x - m_view.view().m_min.m_x;
|
||||
double dwfDy = m_view.view().m_max.m_y - m_view.view().m_min.m_y;
|
||||
m_vdpi = myRound(max(dwfDx / ClipWidth, dwfDy / ClipHeight));
|
||||
myDoTRACE("\nGuessing vector dpi: %d", m_vdpi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -234,6 +255,18 @@ void CWhipFile::read_for_contours()
|
||||
m_W2DFile.set_text_action(my_process_text);
|
||||
m_W2DFile.set_polyline_action(my_process_polyline);
|
||||
|
||||
// Shiften tijdens *inlezen* om overflow te voorkomen
|
||||
// Problemen: hoe achterhaal je op een nette manier zo vroeg hoeveel je moet shiften
|
||||
// (uit DWFGraphicResoure.transform() voelt niet goed)
|
||||
// Bovendien werkt de transform niet op de Viewport/Units zodat dwf2dwg conversie niet klopt
|
||||
// WT_Logical_Point lshift(m_W2DFile.lshift()[0] - 1, m_W2DFile.lshift()[1] - 1);
|
||||
// m_W2DFile.heuristics().set_transform(WT_Transform(lshift, 1.0, 1.0, 0));
|
||||
// y:\Library\Dwf770\develop\global\src\dwf\whiptk\heuristics.h
|
||||
// This is only used when writing to a file. This method is not applicable in a read mode.
|
||||
// anders zou ik het graag tijdens inlezen al doen om overflow problemen veel vroeger te voorkomen
|
||||
// Toch lijkt het al te werken?
|
||||
// m_W2DFile.heuristics().set_apply_transform(true);
|
||||
|
||||
// AutoCAD does not generate polygon's for closed polylines
|
||||
// It only does for filled SOLID hatching
|
||||
//m_W2DFile.set_polygon_action(my_process_polygon);
|
||||
@@ -595,17 +628,17 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do
|
||||
case WT_Object::Drawable:
|
||||
if (firstDrawable)
|
||||
{
|
||||
comment(my_file, "== Contouren start (solid=true)");
|
||||
GenerateContouren(my_plan_file, my_file, scale, true); // Alle 'solid' kleuren
|
||||
comment(my_file, "== Contouren end (solid=true)");
|
||||
firstDrawable = false;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (my_plan_file.current_object()->object_id() == WT_Object::Origin_ID
|
||||
&& !my_file.heuristics().allow_binary_data()
|
||||
)
|
||||
{ // I do not understand why but it will assert otherwise
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (CurrentLayerOn)
|
||||
my_plan_file.current_object()->serialize(my_file);
|
||||
break;
|
||||
@@ -697,12 +730,12 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do
|
||||
}
|
||||
|
||||
// Extra saveas wrapper om met __try een eventuele Win32 exception ook op te vangen
|
||||
STDMETHODIMP CWhipFile::SaveAs(BSTR WhipPath)
|
||||
STDMETHODIMP CWhipFile::SaveAs(BSTR WhipPath, VARIANT_BOOL ascii)
|
||||
{
|
||||
myTRACE("\nAbout to save into %ls", (LPCTSTR)WhipPath);
|
||||
|
||||
__try {
|
||||
return SaveAs2(WhipPath);
|
||||
return SaveAs2(WhipPath, ascii);
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
@@ -715,11 +748,12 @@ STDMETHODIMP CWhipFile::SaveAs(BSTR WhipPath)
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CWhipFile::SaveAs2(BSTR WhipPath)
|
||||
STDMETHODIMP CWhipFile::SaveAs2(BSTR WhipPath, VARIANT_BOOL ascii)
|
||||
{
|
||||
try {
|
||||
myWT_File my_file;
|
||||
my_file.set_filename(WhipPath);
|
||||
my_file.m_ascii = ascii;
|
||||
return Generate(my_file);
|
||||
}
|
||||
catch (WT_Result::Enum e)
|
||||
@@ -778,14 +812,10 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file)
|
||||
symbol->serialize(my_file, m_contunits, NULL,
|
||||
m_next_node_num,
|
||||
m_hintScale, m_forFind, scale);
|
||||
else
|
||||
else
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
WT_Comments cmt;
|
||||
CString s; s.Format("About to insert symbol %s", symbol->m_symbolName);
|
||||
cmt.set(s);
|
||||
cmt.serialize(my_file);
|
||||
#endif
|
||||
comment(my_file, s);
|
||||
symbol->serialize(my_file, m_contunits, m_SLNKSymbolDefinitions[symbol->m_symbolName],
|
||||
m_next_node_num,
|
||||
m_hintScale, m_forFind, scale);
|
||||
@@ -934,7 +964,7 @@ bool CWhipFile::GenerateLabels(WT_File &my_planfile, myWT_File &my_file, double
|
||||
CSLNKContourImpl *contour= m_SLNKContouren[i];
|
||||
|
||||
// Een polyline hebben we nu niet nodig
|
||||
if (contour->m_contLabel.length()!=0 && contour->m_ShowLabel != "")
|
||||
if (contour->m_ShowLabel != "")
|
||||
{ // We have got a proper label/contour
|
||||
// Alle teksten tekenen
|
||||
contour->SerializeLabel(my_file, scale, myDC);
|
||||
@@ -963,9 +993,9 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file)
|
||||
WT_Result result;
|
||||
|
||||
my_file.set_file_mode(WT_File::File_Write);
|
||||
#ifdef _DEBUG
|
||||
my_file.heuristics().set_allow_binary_data(WD_False);
|
||||
#endif
|
||||
|
||||
WT_Boolean binary = !my_file.m_ascii;
|
||||
my_file.heuristics().set_allow_binary_data(binary);
|
||||
// Zal niet zo snel meer gebeuren maar we willen het zeker niet
|
||||
my_file.heuristics().set_allow_drawable_merging(WD_False);
|
||||
// Let op: De viewer kan 60-file niet zo maar lezen, dat moet naar packed-DWF
|
||||
@@ -982,6 +1012,8 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file)
|
||||
// Symbolen worden mogelijk geplaatst net buiten onze coordinatenruimte (met name X)
|
||||
// Dat gaf clipping problemen.
|
||||
// Daarom verplaatsen we alles in onze coordinatenruimte naar links/onder (0,0)
|
||||
// Merk op dat dit alleen helpt later in de de 'viewer', liefst zou ik het
|
||||
// al tijdens het *inlezen* doen maar dat had haken en ogen (zie read_for_contours())
|
||||
WT_Logical_Point lshift(-(max(0,this->m_view.view().m_min.m_x)),
|
||||
-(max(0,this->m_view.view().m_min.m_y))); // Iets minder clipping van INT_MAX
|
||||
// Contouren hebben we ondertussen al wel/
|
||||
@@ -991,11 +1023,8 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file)
|
||||
myTRACE("\nAbout to open plan");
|
||||
if (m_W2DFile.open() == WT_Result::Success)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
WT_Comments cmt;
|
||||
cmt.set("About to insert planfile");
|
||||
cmt.serialize(my_file);
|
||||
#endif
|
||||
comment(my_file, "== Original file start");
|
||||
|
||||
// TODO: Dit moet uit de originele PlanDWF z'n Manifest/Paper komen
|
||||
|
||||
int keep=my_file.heuristics().target_version();
|
||||
@@ -1009,11 +1038,8 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file)
|
||||
my_file.heuristics().set_apply_transform(true);
|
||||
|
||||
SerializePlan(m_W2DFile, my_file, scale); // Heeft eventueel een GenerateContouren in zich!
|
||||
#ifdef _DEBUG
|
||||
cmt.set("Plan is serialized");
|
||||
cmt.serialize(my_file);
|
||||
#endif
|
||||
myTRACE("\nPlan is serialized");
|
||||
comment(my_file, "== Original file end");
|
||||
|
||||
m_W2DFile.close();
|
||||
}
|
||||
else
|
||||
@@ -1022,15 +1048,19 @@ STDMETHODIMP CWhipFile::Generate(myWT_File &my_file)
|
||||
return myAtlReportError (GetObjectCLSID(), "ERROR: Unable to open plan file");
|
||||
}
|
||||
|
||||
myTRACE("\nAbout to generate Contouren");
|
||||
comment(my_file, "== Contouren start (solid=false)");
|
||||
// Twee loops. Eerst alle contouren (en vlakvullingen), daarna pas
|
||||
// de teksten. Zodoende zijn de teksten altijd leesbaar
|
||||
GenerateContouren(m_W2DFile, my_file, scale, false); // Alle transparante kleuren
|
||||
comment(my_file, "== Contouren end (solid=false)");
|
||||
//merging geeft vreemd effect op de contouren die we om symbolen tekenen in _DEBUG mode
|
||||
// dan worden die contouren niet meer meegeschaald? TODO: Uitzoeken
|
||||
//my_file.heuristics().set_allow_drawable_merging(WD_True); // Voor symbolen kan het (na verschalen) wel schelen
|
||||
comment(my_file, "== Symbols start");
|
||||
GenerateSymbols(my_file); // Ook alle contouren van symbolen
|
||||
comment(my_file, "== Symbol labels start");
|
||||
GenerateSymbolLabels(my_file);
|
||||
comment(my_file, "== Contour labels start");
|
||||
GenerateLabels(m_W2DFile, my_file, scale);
|
||||
|
||||
myTRACE("\nAbout to close");
|
||||
@@ -1325,4 +1355,11 @@ STDMETHODIMP CWhipFile::get_AddContour(ISLNKContour** pVal)
|
||||
this->m_SLNKContouren.Add(myContour);
|
||||
|
||||
return get_ContourItem((ULONG)m_SLNKContouren.GetCount() - 1, pVal);
|
||||
};
|
||||
};
|
||||
|
||||
STDMETHODIMP CWhipFile::get_vectorDpi(LONG* pVal)
|
||||
{
|
||||
*pVal = m_vdpi;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
STDMETHOD(Load)(BSTR WhipPath);
|
||||
STDMETHOD(LoadStream)(VARIANT EPlotStream);
|
||||
STDMETHOD(SetLayers)(BSTR reContouren, BSTR reLabels);
|
||||
STDMETHOD(SaveAs)(BSTR WhipPath);
|
||||
STDMETHOD(SaveAs2)(BSTR WhipPath);
|
||||
STDMETHOD(SaveAs)(BSTR WhipPath, VARIANT_BOOL ascii);
|
||||
STDMETHOD(SaveAs2)(BSTR WhipPath, VARIANT_BOOL ascii);
|
||||
STDMETHOD(HighlightUnrecognized)();
|
||||
STDMETHOD(SetLabelFont)(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols);
|
||||
STDMETHOD(SetLabelPosition)(BYTE LabelPos);
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
|
||||
CComQIPtr<IEPlotSection> m_iEPlotSection; // Om scope levend te houden
|
||||
myWT_File m_W2DFile;
|
||||
long m_vdpi;
|
||||
WT_View m_view; // Initial view
|
||||
HRESULT ProcessContouren();
|
||||
HRESULT SerializePlan(WT_File & my_plan_file, myWT_File & my_file, double scale);
|
||||
@@ -100,6 +101,7 @@ public:
|
||||
STDMETHOD(return_ContourItem)(CSLNKContourImpl *pContour, ISLNKContour** pVal);
|
||||
STDMETHOD(get_minContSize)(DOUBLE* pVal);
|
||||
STDMETHOD(put_minContSize)(DOUBLE newVal);
|
||||
STDMETHOD(get_vectorDpi)(LONG* pVal);
|
||||
|
||||
// Voorheen WhipFileState
|
||||
public:
|
||||
|
||||
@@ -70,6 +70,12 @@ STDMETHODIMP CEPlotSection::get_PaperClipWidth(DOUBLE* pVal)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEPlotSection::get_PaperClipHeight(DOUBLE* pVal)
|
||||
{
|
||||
(*pVal) = m_pSectionImpl->get_PaperClipHeight();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEPlotSection::Open(BOOL bForWrite)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
STDMETHOD(get_PropertiesXML)(BSTR* pVal);
|
||||
#endif
|
||||
STDMETHOD(get_PaperClipWidth)(DOUBLE* pVal);
|
||||
STDMETHOD(get_PaperClipHeight)(DOUBLE* pVal);
|
||||
public:
|
||||
STDMETHOD(get_EPlotSectionImpl)(/* CEPlotSectionImpl ** */ BYTE ** pVal);
|
||||
public:
|
||||
|
||||
@@ -334,17 +334,21 @@ WT_Logical_Point CSLNKContourImpl::LabelPosition(LABELPOS pos /*= LABEL_DEFAULT*
|
||||
double ptx = 0;
|
||||
double pty = 0;
|
||||
int i, j;
|
||||
double dDWFarea = 0; // Die ook meteen uitrekenen
|
||||
for (i = 0; i < pg.count(); i++) {
|
||||
j = (i + 1) % pg.count();
|
||||
double Xi=pg.points()[i].m_x, // Alles naar double anders krijgen wel overflows
|
||||
double Xi=pg.points()[i].m_x, // Alles naar double anders krijgen wel overflows
|
||||
Yi=pg.points()[i].m_y,
|
||||
Xj=pg.points()[j].m_x,
|
||||
Yj=pg.points()[j].m_y;
|
||||
double dArea = Xi*Yj - Xj*Yi;
|
||||
//double dArea = Xi*Yj - Xj*Yi; // heeft bij X en Y beide rond INT_MAX zelfs met double afrondproblemen
|
||||
double dArea = (Xi-Xj)*Yj + Xj*(Yj-Yi);
|
||||
dDWFarea += dArea;
|
||||
ptx += (Xi+Xj) * dArea;
|
||||
pty += (Yi+Yj) * dArea;
|
||||
}
|
||||
double dDWFArea6 = 6*DWFArea(pg);
|
||||
dDWFarea /= 2;
|
||||
double dDWFArea6 = 6 * dDWFarea;
|
||||
return WT_Logical_Point((WT_Integer32)(ptx / dDWFArea6), (WT_Integer32)(pty / dDWFArea6));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
\************************************************************/
|
||||
|
||||
myWT_File::myWT_File(void): m_color(0x00ffffff),
|
||||
m_EPlotSection(NULL)
|
||||
m_EPlotSection(NULL),
|
||||
m_ascii(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
#ifndef DWFTK_READ_ONLY
|
||||
bool SaveAsAscii(const CString &destpath, EPlot_Progress_Action action = NULL);
|
||||
#endif
|
||||
bool m_ascii;
|
||||
|
||||
protected:
|
||||
unsigned int m_color;
|
||||
|
||||
Reference in New Issue
Block a user