ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  getHTMLImageMap() dosnt work.
Posted by taejin Kim on Feb-09-2023 15:45
HI~~

Line and Mark shows good, but getHTMLImageMap() dosnt work.
Please Let me know what is problem.
Thanks.

my source is down below.
============================
for (k = m_GridMesh->kTop; k < m_GridMesh->vkSRRIndex[m_GridMesh->SRRollTot].rollContactE; k++)
{
vecLabel.push_back(k - 2); // ktop이 2부터 시작하므로 -2를 해야 함.

fa = m_GridMesh->xc[iIndex][jIndex][k];
fb = m_GridMesh->yc[iIndex][jIndex][k];
fc = m_GridMesh->zc[iIndex][jIndex][k];

fd = m_GridMesh->xc[iIndex][jIndex][k + 1];
fe = m_GridMesh->yc[iIndex][jIndex][k + 1];
ff = m_GridMesh->zc[iIndex][jIndex][k + 1];

fVal1 = pow(fa - fd, 2);
fVal2 = pow(fb - fe, 2);
fVal3 = pow(fc - ff, 2);

fVal4 = sqrt(fVal1 + fVal2 + fVal3);

vecLength.push_back(fVal4);
}

CRect rectView;
GetClientRect(&rectView);

//XYChart* c = new XYChart(rectView.right, 200, 0xeeeeff, 0x000000, 1);
XYChart* c = new XYChart(rectView.right-20, 200, 0xeeeeff, 0x000000, 1);
c->setPlotArea(50, 10, rectView.right-80, 140, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
LineLayer* layer;
layer = c->addLineLayer(vectorToArray(vecLength));
layer->setLineWidth(1);

int meshMold = pGlobalUtil->Mesh.Mold.meshFromMoldTopToMoldFlux
+ pGlobalUtil->Mesh.Mold.meshPoolDepthOfMoldFlux
+ pGlobalUtil->Mesh.Mold.meshClusteringForMeniscus
+ pGlobalUtil->Mesh.Mold.meshDtoE
+ pGlobalUtil->Mesh.Mold.meshClusteringForSENExit
+ pGlobalUtil->Mesh.Mold.meshFtoG
+ pGlobalUtil->Mesh.Mold.meshGtoH
+ pGlobalUtil->Mesh.Mold.meshClusteringForMoldExit;

int meshSPR = m_GridMesh->vkSPRIndex[m_GridMesh->SPRollTot].rollContactC;
int meshGRR = m_GridMesh->vkGRIndex[m_GridMesh->GRollTot].rollContactC;
int meshSRR = m_GridMesh->vkSRRIndex[m_GridMesh->SRRollTot].rollContactC;

c->xAxis()->addZone(0, meshMold, 0xFAED7D);
Mark* xMarkMold = c->xAxis()->addMark(meshMold, 0x000000, "Mold"); //mold : 글씨가 표시되면 그래프가 잘 안보여서 주석 처리 함. 아래도 동일
xMarkMold->setLineWidth(1);
xMarkMold->setAlignment(Chart::TopLeft);
//xMarkMold->setFontAngle(90);

c->xAxis()->addZone(meshMold, meshSPR, 0xA0A0FF); // 160 160 255
Mark* xMarkMoldFlux = c->xAxis()->addMark(meshSPR, 0x000000, "Spray Roll"); //Spray Roll
xMarkMoldFlux->setLineWidth(1);
xMarkMoldFlux->setAlignment(Chart::TopLeft);
//xMarkMoldFlux->setFontAngle(90);

c->xAxis()->addZone(meshSPR, meshGRR, 0xFAED7D); // 250 237 125
Mark* xMarkMoldCluster = c->xAxis()->addMark(meshGRR, 0x000000, "Guide Roll");//Guid Roll
xMarkMoldCluster->setLineWidth(1);
xMarkMoldCluster->setAlignment(Chart::TopLeft);
//xMarkMoldCluster->setFontAngle(90);

c->xAxis()->addZone(meshGRR, meshSRR, 0xA0A0FF);
Mark* xMarkMoldSteel = c->xAxis()->addMark(meshSRR-2, 0x000000, "Soft Reduction Roll");// Soft Reduction Roll /// -2를 해줘야 글씨가 표시됨. -1로도 글씨 표시 안됨
xMarkMoldSteel->setLineWidth(1);
xMarkMoldSteel->setAlignment(Chart::TopLeft);
//xMarkMoldSteel->setFontAngle(90);


c->yAxis()->setTitle("Length(mm)");
c->xAxis()->setLabels(vectorToArray(vecLabel));//c->xAxis()->setLabels(StringArray(labels, labels_size));
c->xAxis()->setLabelStep(40);//c->xAxis()->setLabelStep(3);
c->xAxis()->setTitle("Mesh Count");//c->xAxis()->setTitle("Temperature (℃)");
// Output the chart
if (!c->makeChart("StrandH.png"))
{
dlgMessage = new CMessageBox_MGT();
dlgMessage->Title = _T("Warning");
dlgMessage->Information = _T("Fail to make chart image : StrandH.png");
dlgMessage->DoModal();
}
else
{
m_ChartViewer.setChart(c);
m_ChartViewer.setImageMap(c->getHTMLImageMap("clickable", "", "title='Mesh Count {xLabel}: Length(mm) {value} '"));
//m_ChartViewer.MoveWindow(CRect(230, rectView.bottom + iHorScrollThick, rectView.right + 800, rectView.bottom + fPlotHeight), TRUE);
}
delete c;
============================

  Re: getHTMLImageMap() dosnt work.
Posted by Peter Kwan on Feb-09-2023 17:29
Attachments:
Hi taejin Kim,

I have just tried your code with some made up data. It produces the attached chart. The chart has tooltips for the line, which shows that the image map is working normally. Is it what you get?

Note that for your code, the mark lines should have no tooltips. Do you want the mark lines to have tooltips too?

The code I used is as follows. I inserted it into the MFC helloworld sample code that comes with ChartDirector to test it. The charting code is essentially the same as your code, but I use a loop to made up some data for testing.



DoubleArray vectorToArray(std::vector<double>& v)
{
return (v.size() == 0) ? DoubleArray() : DoubleArray(&(v[0]), (int)v.size());
}


BOOL CHelloworldDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// *** code automatically generated by VC++ MFC AppWizard ***
// Set the icon for this dialog.  The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

//
// Draw Chart and set to CChartViewer
//

std::vector<double> vecLabel;
std::vector<double> vecLength;

for (int i = 0; i < 400; ++i)
{
vecLabel.push_back(i);
vecLength.push_back(10 * (i % 40));
}

CRect rectView;
GetClientRect(&rectView);

//XYChart* c = new XYChart(rectView.right, 200, 0xeeeeff, 0x000000, 1);
XYChart* c = new XYChart(rectView.right - 20, 200, 0xeeeeff, 0x000000, 1);
c->setPlotArea(50, 10, rectView.right - 80, 140, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
LineLayer* layer;
layer = c->addLineLayer(vectorToArray(vecLength));
layer->setLineWidth(1);

int meshMold = 50;
int meshSPR = 200;
int meshGRR = 300;
int meshSRR = 400;

c->xAxis()->addZone(0, meshMold, 0xFAED7D);
Mark* xMarkMold = c->xAxis()->addMark(meshMold, 0x000000, "Mold"); //mold : 글씨가 표시되면 그래프가 잘 안보여서 주석 처리 함. 아래도 동일
xMarkMold->setLineWidth(1);
xMarkMold->setAlignment(Chart::TopLeft);
//xMarkMold->setFontAngle(90);

c->xAxis()->addZone(meshMold, meshSPR, 0xA0A0FF); // 160 160 255
Mark* xMarkMoldFlux = c->xAxis()->addMark(meshSPR, 0x000000, "Spray Roll"); //Spray Roll
xMarkMoldFlux->setLineWidth(1);
xMarkMoldFlux->setAlignment(Chart::TopLeft);
//xMarkMoldFlux->setFontAngle(90);

c->xAxis()->addZone(meshSPR, meshGRR, 0xFAED7D); // 250 237 125
Mark* xMarkMoldCluster = c->xAxis()->addMark(meshGRR, 0x000000, "Guide Roll");//Guid Roll
xMarkMoldCluster->setLineWidth(1);
xMarkMoldCluster->setAlignment(Chart::TopLeft);
//xMarkMoldCluster->setFontAngle(90);

c->xAxis()->addZone(meshGRR, meshSRR, 0xA0A0FF);
Mark* xMarkMoldSteel = c->xAxis()->addMark(meshSRR - 2, 0x000000, "Soft Reduction Roll");// Soft Reduction Roll /// -2를 해줘야 글씨가 표시됨. -1로도 글씨 표시 안됨
xMarkMoldSteel->setLineWidth(1);
xMarkMoldSteel->setAlignment(Chart::TopLeft);
//xMarkMoldSteel->setFontAngle(90);

c->yAxis()->setTitle("Length(mm)");
c->xAxis()->setLabels(vectorToArray(vecLabel));//c->xAxis()->setLabels(StringArray(labels, labels_size));
c->xAxis()->setLabelStep(40);//c->xAxis()->setLabelStep(3);
c->xAxis()->setTitle("Mesh Count");//c->xAxis()->setTitle("Temperature (℃)");

// Output the chart
c->makeChart("StrandH.png");
m_ChartViewer.setChart(c);
m_ChartViewer.setImageMap(c->getHTMLImageMap("clickable", "", "title='Mesh Count {xLabel}: Length(mm) {value} '"));

// In this sample project, we do not need to chart object any more, so we
// delete it now.
    delete c;
return TRUE;
}


Best Regards
Peter Kwan
helloworld_20230209172351.png

  picture box property assertion
Posted by taejin Kim on Feb-10-2023 09:51
Hi ~~

I changed picture box property and tooltip displayed.
However when close window and reopen window,  if mouse cursor above the chartdirector
"Assertion Failed!".

it happened picture box property set to Enabled, if I changed to disabled, assertion not occured.

Please give me a advise....

Best Regards.

  Re: getHTMLImageMap() dosnt work.
Posted by taejin Kim on Feb-10-2023 07:38
Thanks Peter Kwan.

I tried your code to my program. But still not work properly. Even mouse cursor not changed.
I think source code is right, did I miss anything ?
Something like picture control property?
Is there anything must care about behind source code ?

I'm novice chartdirector.

Best Regards

  Re: getHTMLImageMap() dosnt work.
Posted by taejin Kim on Feb-10-2023 08:01
I found error.
Picture box was set enabled is false.
Changed that property to true, then image map working good.
mouse cursor changed and tooltip shows.

There is one more problem.
mouse cursor is changed, looks like clickable but "Hot Spot Properties" dialog window is not popup.

Like picture control property, is there anything should I check ?

Best Regards

  Re: getHTMLImageMap() dosnt work.
Posted by Peter Kwan on Feb-11-2023 00:06
Hi taejin Kim,

Have you added a BN_CLICK handler for the chart, and does the handler pop-up the "Hot Spot Properties" window?

The "Hot Spot Properties" is not built-in. It is a dialog box we provided in the mfcdemo sample code in the file HotSpotDlg.cpp and the associated dialog resource IDD_HOTSPOTPARAM.

The only thing the image map does is to generate a BN_CLICK event like clicking a pushbutton. Your code needs to handle that event if you want it to do something. In the mfcdemo sample code, the event is handled by the OnClickHotSpot event handler, and it pops up the CHotSpotDlg.

For your case, you may add an OnClickHotSpot handler in your message map:

ON_BN_CLICKED(IDC_CHART, OnClickHotSpot)

in which OnClickHotSpot is the event handler like:

//
// Handles mouse clicks on the chart image
// (copied from the mfcdemo sample code)
//
void CHelloworldDlg::OnClickHotSpot()
{
ImageMapHandler* handler = m_ChartViewer.getImageMapHandler();

if (0 != handler)
{
// Query the ImageMapHandler to see if the mouse is on a clickable hot spot. We
// consider the hot spot as clickable if its href ("path") parameter is not empty.
const char* path = handler->getValue("path");
if (path && *path)
{
// In this sample code, we just show all hot spot parameters.
CHotSpotDlg hs;
hs.SetData(handler);
hs.DoModal();
}
}
}

Best Regards
Peter Kwan

  Re: getHTMLImageMap() dosnt work.
Posted by taejin Kim on Feb-13-2023 14:14
Thanks Peter Kwan.

As let me know, about getHTMLImageMap() related problem was solved. Many thanks !!!

But still got one issue. assertion :(

When I tried first time, everything is perfect, however closed window (that include m_ChartView) and re opened that window and when mouse over the m_ChartView,
assertion failed.

.../src/vctools/VC7Libs/ship/atlmfc/include/afxcmn.inl
Line:429

Debugger says
_AFXCMN_INLINE void CToolTipCtrl::RelayEvent(_In_ LPMSG lpMsg)
{ ASSERT(::IsWindow(m_hWnd));  ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); }


Where should I look into?

Best Regards.

  Re: getHTMLImageMap() dosnt work.
Posted by Peter Kwan on Feb-13-2023 21:55
Hi taejin Kim,

I think it is due to re-using the same MFC window object after the window has been destroyed.

If the user press the "X" button to "close" the window, MFC will close (WM_CLOSE) and then destroy (WM_DESTROY) the underlying window. The error may occur if you continue to use the same MFC window object after the window has been destroyed.

The window is like a file in the OS. They are created and destroy by the OS. In the programming language, they are represented by a "handle". For example, in C, when you open a file with fopen, it returns a FILE handle. If the file is destroyed and the code continue to use the same file handle. that may cause error.

The followings are one possibility that can cause the problem.

// declare as member variable
CSimpleZoomScrollDlg myDialog;

void showMyDialog()
{
     myDialog->show();
}

In the above, after the dialog is opened and then closed, and if the code calls showMyDialog again, it may crash.


The following are code that should work:


void showMyDialog()
{
     // Declare as local variable. When the dialog is closed and the code exit
     // this method, the local variable will be destroyed. Next time this method
     // is called, a new local variable will be created.
     CSimpleZoomScrollDlg myDialog;

     myDialog->show();
}


void showMyDialog2()
{
     // This works because the a new instance will be created every time.
     CSimpleZoomScrollDlg *myDialog = new CSimpleZoomScrollDlg();
     myDialog->show();
     delete myDialog;
}


// declare as member variable
CSimpleZoomScrollDlg *myDialog = 0;

void showMyDialog3()
{
     // This works because the a new instance will be created every time.
     myDialog = new CSimpleZoomScrollDlg();
     myDialog->show();
     delete myDialog;
}


Best Regards
Peter Kwan

  Re: getHTMLImageMap() dosnt work.
Posted by taejin Kim on Feb-14-2023 08:03
Many thanks again Peter Kwan.

All the problems are solved.

Best Regards.