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
 Matrix selections

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
Mike Buess Posted - 03/30/2003 : 6:55:35 PM
Is there a way to select and deselect a matrix range in Origin C or LabTalk? In particular, I want to deselect all matrix cells.

Mike Buess
Origin WebRing Member
8   L A T E S T    R E P L I E S    (Newest First)
bunkytop Posted - 05/04/2003 : 3:02:26 PM
Hi,

Thanks for the fast response! I incorporated your LabTalk
routines into my code. I also stumbled onto another way, in my usual incompetent manner:

worksheet -s 0 1 0 150
menu -e 57635

This selects rows 1 through 150 and then "cuts" the values while
leaving the empty cells in place.

Christopher
Mike Buess Posted - 05/04/2003 : 11:40:50 AM
Hi Christopher,

Both of the following methods assume contiguous selections.

Origin C...
void clearRange()
{
Worksheet wks = Project.ActiveLayer();
int r1,r2,c1,c2,rr,cc;
wks.GetSelection(c1,c2,r1,r2);
for(rr=r1;rr<=r2;rr++)
for(cc=c1;cc<=c2;cc++)
wks.SetCell(rr,cc,"--");
}



Labtalk...
loop (rr,wks.r1,wks.r2) {
loop (cc,wks.c1,wks.c2) {
%(%H,cc,rr)=0/0; // missing value or "--"
};
};


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 05/04/2003 11:41:52 AM
bunkytop Posted - 05/03/2003 : 09:47:23 AM
Hi,
Follow up question. One you have selected a region of a worksheet,
is there a way to cut all the data with LabTalk, leaving all the elements (or cells) with the - symbol? This is a poor man's way of not plotting those regions when converting to a 3D surface plot. I can do this GREAT by hand, just select the cells, then hit EDIT: CUT, but can't figure out how to do it in LabTalk. One can use the CELL= define command, but since I have a worksheet of size 1000*250 units, this is
way too slow.

Christopher
Mike Buess Posted - 04/16/2003 : 2:46:49 PM
Follow up...

It turns out that this single LabTalk command...

wks.colSel(1,0);

is enough to deselect an entire matrix. Trying to deselect individual columns beyond the first generates a command error. This behavior might have something to do with the fact that a matrix is considered a single dataset.

Oddly enough, wks.colSel(n,1) generates a command error if n>1 and selects the first column (rather than the entire matrix) if n=1. Go figure.

Mike Buess
Origin WebRing Member
Mike Buess Posted - 04/15/2003 : 7:28:49 PM
For those who are interested, I found a way to select or deselect a matrix column. Many wks object properties and methods also work with matrices, in particular...

wks.colSel(colnum,n); // If n = 1, select the colnum column. If n = 0, deselect the colnum column.

I use wks.colSel() in the following Origin C function, which deselects all columns in the named matrix...

void DeselectAll(string matName)
{
Matrix mm(matName);
uint nCols = mm.GetNumCols();
MatrixPage mp(matName);
for(int i=0; i<nCols; i++)
{
LT_set_var("ii",i+1);
mp.LT_execute("wks.colSel(ii,0);");
}
}


Mike Buess
Origin WebRing Member
Mike Buess Posted - 03/31/2003 : 8:53:22 PM
I found a workaround for my particular matrix problem. I was using the screen reader and PointProc macro on a matrix image and PointProc ran an Origin C function which changed a pixel value on double-click. If any selections had been made in data mode the matrix image looked garbled after PointProc ran. I solved that by disabling automatic dynamic range (Z) update (SetZRangeUpdate(FALSE)) in my OC function. However, I still think a code or script method for changing matrix selections would be useful.

Mike Buess
Origin WebRing Member
Mike Buess Posted - 03/31/2003 : 7:44:18 PM
Hi Ricardo,

Good suggestion, but activating one window does not affect selections in another. I want to deselect all cells in a matrix because some matrix operations behave unpredictably when a range of cells are selected, especially when the range spans more than one row. Here is a simple example...

1> Create a new matrix.
2> Enter (%H)=1; in the script window to set all cell values to 1.
3> Select two rows and enter (%H)=2; Two cells in the first row change to 2.
4> Select three rows and enter (%H)=3; Three cells in the first row change to 3.

After playing around with selections for a while a pattern emerges that suggests the following test:

5> Select the entire matrix and enter (%H)=10; Sure enough, this works... all cells change to 10.

So, changing all cell values with the simple expression (%H)=v; is reliable only if there are no selections spanning more than one row or if the entire matrix is selected. The affect of selections on what I'm actually doing is more subtle, but the workaround is the same - make sure that all or nothing is selected.

Mike Buess
Origin WebRing Member
srmcarneir Posted - 03/31/2003 : 4:17:21 PM
Hi Mike,

My suggestion may seem idiot and I really do not know why you
need to deselect all of YourMatrix cells, but I guess that if you created a dummy matrix it would set focus on it and thus deselect the whole YourMatrix... Regards.

Ricardo Carneiro

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