Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Getting more than one selected objects
Topic Summary: How to get multiple selected objects?
Created On: 4-Apr-2006 12:01
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 4-Apr-2006 12:01
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hello,

does anyone know how to retrieve multiple selected objects in a formal module?

The DXL reference manual only refers to function "current()" to get the one and only selected object. But how to deal with several selected objects?

Any help is appreciated.

Best regards,
Oliver

-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 4-Apr-2006 12:27
User is offline View Users Profile Print this message


Iftakher Uddin

Posts: 56
Joined: 16-Sep-2004

Hallo,

you can use the following code:

Module modTheModule = current
Object objStart = null
Object objEnd = null
int intStartObjAbsNum, intEndObjAbsNum

getSelection(modTheModule, objStart, objEnd)
intStartObjAbsNum = objStart."Absolute Number"
intEndObjAbsNum = objEnd."Absolute Number"


Now, you have first selected and last selected object. Then you can loop through this range and get all the selected objects.

Please note: Selection of Object heading and DOORS table is diffirent.

Many greetings,

Rony

=====================
Iftakher Uddin (Rony)
Iftakher.Uddin@HOOD-Group.com

Edited: 4-Apr-2006 at 12:30 by Iftakher Uddin
Report this to a Moderator Report this to a Moderator
 4-Apr-2006 16:40
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Rony,

many thanks for you reply. The code works but unfortunately not for all use cases.
Say we have an object #1 and three objects below #1.1, #1.2, #1.3:
#1
   #1.1
   #1.2
   #1.3

The I select the objects from #1 to #1.3.
Now the code return for start and end the same value.

Maybe the child objects of obj #1 are semantically included if their parent has been selected?

This way I cannot distinguish between this case and the case that the user intentionally not selected the child objects.
But how to deal with this behaviour?

Best,
Oliver




-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 4-Apr-2006 17:18
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Rony,

unfortunately your code does not work correct for another case:
if the numerical range [intStartObjAbsNum,intEndObjAbsNum] contains objects which are not selected.
Remeber that the objects can be reordered in a formal module.

Does anyone know an approch for getting the selected objects? Since the object numbers of the selected range may not be ordered the best way would be to store them in a Sklip list.

Many thanks in advance for your help.

Best regards,
Oliver



-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 4-Apr-2006 18:20
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

I use this and it works for me...

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 4-Apr-2006 18:40
User is offline View Users Profile Print this message


cliff Bly

Posts: 58
Joined: 11-Apr-2003

I like Shawn's approach -- very concise.

I prefer to put objects into a skiplist.

-------------------------
Cliff Bly


Edited: 4-Apr-2006 at 18:42 by cliff Bly
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 15:41
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Cliff,

thank you for your code which is working in most cases, but not in all cases.
Your code puts child objects more than once into the skip list if they are explicitly selected by the user.

So I took your code and modified it slightly:
I do not use an object counter as the key, but the absolute number of the object.
This way I can check if this object is already part of the skip list. 
Furthermore I support single selections, too and I support skipping headline objects (empty heading).

Any feedback is appreciated.

-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 16:53
User is offline View Users Profile Print this message


Iftakher Uddin

Posts: 56
Joined: 16-Sep-2004

Hallo Oliver,

here is another thought (pls, see the attached code)...


Greetings,
Rony

=====================
Iftakher Uddin (Rony)
Iftakher.Uddin@HOOD-Group.com


P.S: If the attached code is not properly visible then use the following (I cant see all in attach box!)


int getTotalSelectedObjects(Module modTheModule, Skip &skpList)
{
Object objTmp
int intIndex = 0

for objTmp in modTheModule do
{

if(isSelected(objTmp))
{
intIndex ++
//print objTmp."Absolute Number" " is selected \n"
put(skpList, intIndex, objTmp)
}
}

return intIndex
}


//Test Code
Module m = current
Object objMySelectedObject
Skip skpList = create
int intTotal = getTotalSelectedObjects(m, skpList)
int intIndex
//Verify the stored objects
for(intIndex = 1; intIndex <= intTotal; intIndex++)
{
if (find(skpList, intIndex, objMySelectedObject))
{
print objMySelectedObject."Absolute Number" " is selected \n"
}
}
delete(skpList)

Edited: 5-Apr-2006 at 17:04 by Iftakher Uddin
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 20:00
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi all,

unfortunalely I got wrong selections in some rare cases with my previous posted code.

I explored that the only reliable way to get all selected objects is to find the first selected object and then to iterate over all remaining objects til the end of the module is reached (Shawn's approach).
Each of the remaining objects must be checked if it is selected and if it is visible. That's all.
Here's the new code:
Any test feedback is appreciated!

-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 20:01
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Golly, I did it the odd way: for obj in entire mod do; if (isSelected(obj)) do something with it.

- Louie
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 20:07
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Louie,

that's indeed a very simple, reduced and effective way.


-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 5-Apr-2006 20:25
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Louie,

fyi: you code does not deal with objects which are currently hided by an active filter. Not visible objects which are in the range of  the visible selected objects will be selected by DOORS automatically :-( and have normally to be filtered out, since the user works on that what's visible.

Module mod = current
for obj in entire mod do
    if (isSelected(obj) && isVisible(obj))
    {
        int no = obj."Absolute Number"
        print no "\n"
    }

Thank you for the simple and effective approach. ("entire" was new to me).

-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 10-Apr-2006 17:53
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Using "entire" is routine for me. Its easier for me to get all objects and explicetely exclude the ones I don't want. Well "easier" means I understand it better 6 months from now. Also, most of my scripts cannot be dependant on whatever is the current view. Some common excludes I use are isDeleted(obj), isVisible(obj), cell(obj), row(obj), table(obj).

In this example, if you want only visible selected objects you can bypass "entire": for obj in mod do; if (isSelected(obj)).

- Louie
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.