Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 MoveData
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

carlao

54 Posts

Posted - 19 Apr 2005 :  05:48:29  Show Profile  Reply with Quote
I am using MoveData class to move points in graph. Using MOVE_X it is possible to move relate to x axis. I would like to know if there is a way to move the points that are near the selected point. That is, when I move a point, 2 or 3 points in the left and right are moved together. For example, when I move a point by 20 pixels, the first neighbor is moved by 17 pixels, the second by 13 pixels and the third by 6 pixels. Is there a method that I can use or I need to override or create a new one?
Thanks.

quinncurtis

1164 Posts

Posted - 19 Apr 2005 :  09:37:13  Show Profile  Reply with Quote
It sounds like you should override the MoveData class. The example MoveDatapoint.cs in the ChartTabDemo example program has an example of overriding this class and adding some custom logic, though it does nothing like you describe.

In the OnMouseUp event you would want to probably find the index of the selected point using the nearestPoint object property of the MoveDatapoint class.

public class CustomMouseMoveListener: MoveData
{ MoveDatapoint obj;
public CustomMouseMoveListener(MoveDatapoint component, CartesianCoordinates transform):
base( component, transform)
{
obj = component;
}
public override void OnMouseUp (MouseEventArgs mouseevent)
{ NearestPointData np = this.nearestPoint;
int nearestpointindex = np.GetNearestPointIndex();
base.OnMouseUp(mouseevent);
// Add whatever other logic you want
//obj.UpdateDraw(); // you may need to add this to force graph to
// update with any changes that you make
}
}

You would then have to calculate what other points you want to move, calculate the new xy positions for each, then change the underlying values of the data points in the dataset.
Go to Top of Page

carlao

54 Posts

Posted - 19 Apr 2005 :  10:22:39  Show Profile  Reply with Quote
Yes, I am already using the example that you mentioned as a guide. That's the reason why I posted my question: I could not find more info in there.
I will try to use your suggestion.

Thanks a lot.
Go to Top of Page

carlao

54 Posts

Posted - 21 Apr 2005 :  16:18:42  Show Profile  Reply with Quote
Bug in MoveData?
It seems to be a bug in MoveData class. I am using SimpleScatterPlot in my project and using selectedDataset.IsDataPointGood method to see if I have a valid data.
Wen I click out the points, this method returns false and my routine is not executed. That`s right. Then I click over a point and move it and now my routine is executed. Right again. The problem is when I click out any data and I see that selectedDataset.IsDataPointGood method returns true even I have not selected any point. I went to debug and saw that after the first time that I click over a point, selectedDataset retains the selected data and IsDataPointGood method will ever return true. Is there a way to clean selectedDataset when I am going out OnMouseUp event so if I click out any point I can use IsDataPointGood?
Thanks
Go to Top of Page

quinncurtis

1164 Posts

Posted - 21 Apr 2005 :  16:41:03  Show Profile  Reply with Quote
We don't understand what you mean by "Wen I click out the points", please explain in more detail what you are doing. Are you marking data points invalid somehow using the ChartDataset.SetValidData method or ChartDataset.SetData property.

Go to Top of Page

carlao

54 Posts

Posted - 21 Apr 2005 :  21:36:53  Show Profile  Reply with Quote
Click out of points mean that I click in an area where doesn`t have points, that is, an empty area. If I have already selected a point (clicked over it) and I click on empty area, the IsDataPointGood method returns true. That is, it ever returns true if I click over a point or not. This behavior ir not correct.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 21 Apr 2005 :  22:09:31  Show Profile  Reply with Quote
You do not understand the ChartDataset.IsDataPointGood method. Is is a test of whether or not a data point in a dataset is good, based on whether or not it was marked invalid using the ChartDataset.SetValidData method. Datapoints marked invalid do not get plotted.

The ChartDataset.IsDataPointGood method has nothing to do with the MoveData class. The MoveData class does not set whether or not a datapoint is valid or not. My best guess is that since every point in the dataset is good, any call to IsDataPointGood, no matter what index you use, will return true.

If you want to test whether or not a MoveData.OnMouseUp event resulted in a selected datapoint, test for whether or not this.selectedPlotObj is null, before the call to the
base.OnMouseUp event.


public override void OnMouseUp (MouseEventArgs mouseevent)
{ NearestPointData np = this.nearestPoint;
int nearestpointindex;
// Calculate new averages using changed value
if (this.selectedPlotObj != null)
{
nearestpointindex = np.GetNearestPointIndex();
obj.UpdateDraw();
}
base.OnMouseUp(mouseevent);
}
Go to Top of Page

carlao

54 Posts

Posted - 23 Apr 2005 :  09:11:20  Show Profile  Reply with Quote
My opinion is that when I use selectedDataset variable it means that I want access to dataset that was selected. When I click with mouse over an area that is out of the plotted line, it means that selectedDataset would be filled with no valid data once that I have not selected any point. I think that its actual behavior is confuse.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 24 Apr 2005 :  09:48:13  Show Profile  Reply with Quote
The selectedDataset member variable is an internal variable, not a property that we expose for programmers to normally access. we use it to store the NEW selected datapoints dataset, IF found. Otherwise its value reamins unchanged from the previously selected dataset. Internally, we never access selectedDataset unless a data point has been found, you shouldn't either.
Go to Top of Page

carlao

54 Posts

Posted - 25 May 2005 :  02:58:43  Show Profile  Reply with Quote
I am using something similar your MoveDatapoint example. The difference is that I also have a horizontal scroll bar that I added to the chartview control. My question is about focus. I figured out that in the first place the focus is with the tab page. Then when I click tab stop, the focus move to the chart. Then when I click arrow down the focus move to the horizontal scroll bar. Now if I use arrow left/down the scroll move to left and if I use arrow right/up, the scroll move to right. Is there a way to move the focus back to the chart when I press the arrow key? Or, in other words, when the focus is with chart and I press down arrow the focus move to the scroll bar and if I press up arrow I would like to have the focus back to the chart.
Thanks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 25 May 2005 :  09:09:31  Show Profile  Reply with Quote
Sorry, we don't know how to do what you describe. It is not a function of our Charting software but is instead a programming issue of how to combine and use .Net components, tabs pages, scrollbars and UserControls (our ChartView is a UserControl derived window). I would assume that you can trap the key strokes used to move the scrollbar, and further trap for the up arrow key, and then force the keyboard focus somewhere else, but I don't see how to do that, since the Scroll event parameter, ScrollEventArgs, does not seem to differentiate whether the scroll event was causes by a mouse click or a key press.
Go to Top of Page

carlao

54 Posts

Posted - 14 Jun 2005 :  08:18:31  Show Profile  Reply with Quote
Suppose that I want to do a clone of MoveDatapoint class in your MoveDatapoint example. The target here is to do a clone of the entire chart, including titles, attibutes, colors, point positions and so on, to make an exact copy of the chart but this copy needs to be entirely independent of the source. That is, I need to do a deep copy and not a reference copy. Using serialization I figured out that many classes like ChartView does not have [Serializable] attibute. That way, I decided to do a custom copy: I created a new copy of my derived class and assigned the variable values from one instance to another. The problems relies with MoveData class. What I need to copy from MoveData in a way that I have the same ploted point position in the new copied class?
Thanks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 14 Jun 2005 :  08:50:36  Show Profile  Reply with Quote
After you create the copy of the chart, including a copy of the current data (the MoveData class changes the values in the underlying dataset in reponse to moved datapoints), create a new MoveData object passing in the new ChartView object, the Coordinate system for your new graph, and setting the other parameters the same as your original graph, then set it as the ChartView.SetCurrentMouseListener for that ChartView.

CustomMouseMoveListener mouselistener2 = new CustomMouseMoveListener(chartVu2, pTransform2);
mouselistener2.SetMarkerType( ChartObj.MARKER_CROSS);
mouselistener2.SetMarkerSize(12);
mouselistener2.SetMoveMode(ChartObj.MOVE_Y);
mouselistener2.SetEnable(true);
chartVu2.SetCurrentMouseListener(mouselistener2);

In any new posts please describe what your actual problem is.
Go to Top of Page

carlao

54 Posts

Posted - 14 Jun 2005 :  14:48:02  Show Profile  Reply with Quote
Well, I asked about this question because I am trying to serialize the ChartView class to get a new ChartView instance, but I received a message that ChartView does not have the Serializable attribute. I tried to use Reflection but I also receive receive the same message relate to some .Net classes like Drawing and so on.
Thanks.


Carlos
Go to Top of Page

quinncurtis

1164 Posts

Posted - 14 Jun 2005 :  15:31:17  Show Profile  Reply with Quote
The base class of the QCChart2D for .Net ChartView class is the System.Windows.Forms.UserControl class. Microsoft has made the UserControl class not serializable; therefore our derived class is also not serializable.
Go to Top of Page

carlao

54 Posts

Posted - 15 Jun 2005 :  06:22:24  Show Profile  Reply with Quote
I have a CreateChart method that builds an entire chart including the mouselistener class. Suppose that I have a chart A created by CreateChart. Then I move some points in A. Now I want to do a new copy of chart A that will be chart B. Chart B needs to have the same points position as chart A. Then, I call CreateChart, I do a copy of Datasets from A to B, I create a new mouselistener and set it using SetCurrentMouseListener method. I do a updateDraw. Even so, the created chart seems to be using the old Dataset that was created in the first place. Any ideas?
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07