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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 modify subrange

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
couturier Posted - 11/12/2018 : 04:58:04 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
couturier Posted - 11/15/2018 : 09:05:48 AM
thanks
Castiel Posted - 11/12/2018 : 11:44:08 AM
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
**********************************************************
couturier Posted - 11/12/2018 : 10:43:07 AM
Thanks Castiel,

the problem is that rows > 20 get deleted :-/
Castiel Posted - 11/12/2018 : 10:26:10 AM
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
**********************************************************

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000