The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 modify subrange
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 11/12/2018 :  04:58:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: win

I'd like to modify only the plotted subrange of a column.

Assuming I already have the DataPlot dp object:

DataPlotStrings stDescStrs;
int nPlotType = dp.GetPlotType(&stDescStrs);

strY = stDescStrs.szDepRange;
DataRange drY;
okxf_init_range_from_string(&drY, strY);
vector vY;
drY.GetData(&vY, 0);
vY += 1;
drY.SetData(vY);

If plotted part was from row 10 to 20 of col(B), for example:
- rows 1 to 9 are unchanged. Good
- rows 10 to 20 are modified. Good
- rows after 20 are deleted: :-(


I could also get the whole col as a vector, then a subvector to modify, then push back the subvector into whole vector and finally push back the whole vector into the column but it seems to me that makes a lot of unneeded copies.

Is there a simple way to do it ?
With LabTalk, it is as simple as
range rg = 1;
rg += 1;

Thanks

Edited by - couturier on 11/12/2018 06:32:18 AM

Castiel

343 Posts

Posted - 11/12/2018 :  10:26:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: win

I'd like to modify only the plotted subrange of a column.

Assuming I already have the DataPlot dp object:

DataPlotStrings stDescStrs;
int nPlotType = dp.GetPlotType(&stDescStrs);

strY = stDescStrs.szDepRange;
DataRange drY;
okxf_init_range_from_string(&drY, strY);
vector vY;
drY.GetData(&vY, 0);
vY += 1;
drY.SetData(vY);

If plotted part was from row 10 to 20 of col(B), for example:
- rows 1 to 9 are unchanged. Good
- rows 10 to 20 are modified. Good
- rows after 20 are deleted: :-(


I could also get the whole col as a vector, then a subvector to modify, then push back the subvector into whole vector and finally push back the whole vector into the column but it seems to me that makes a lot of unneeded copies.

Is there a simple way to do it ?
With LabTalk, it is as simple as
range rg = 1;
rg += 1;

Thanks



DataPlotStrings is unnecessary in this case. I'm afraid you still have to get the data from row 10 to 20 and set it back, similar to the following:

1) Get DataRange of the DataPlot.
DataRange dr;
dp.GetDataRange(dr);

2) Get the first data from row 10 to 20.
vector<double> fs;
dr.GetData(fs, 0);

3) Now set it back:
fs += 1.0;
dr.SetData(fs, 0);
//dr.SetColumnData(fs, 0);



                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
Go to Top of Page

couturier

France
291 Posts

Posted - 11/12/2018 :  10:43:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Castiel,

the problem is that rows > 20 get deleted :-/
Go to Top of Page

Castiel

343 Posts

Posted - 11/12/2018 :  11:44:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Thanks Castiel,

the problem is that rows > 20 get deleted :-/



Oops...bug it may be.

You may get the corresponding column and row range using DataRange::GetRange(), then

vectorbase& vb = col.GetDataObject();

This is reference to the column data so actually no data copied.

Next you can get the sub vector by vSub = vb.GetSubVector(...)

vSub += 1;

To set it bact, just use vb.SetSubVector(...)





                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
Go to Top of Page

couturier

France
291 Posts

Posted - 11/15/2018 :  09:05:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000