Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Problem in example code (Tried SplitterFrame yet minor problem.)
Re: Problem in example code [message #45951 is a reply to message #45950] Sat, 30 January 2016 17:09 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Sat, 30 January 2016 16:37
Probably you are right that dynamic_cast is not working. EditFields have dedicated names. Here "if (dynamic_cast<EditField *> (q)) { " is not true.

The dynamic_cast actually works correctly in the test application I attached in my previous post. Are you calling this function on the correct Ctrl? GetFirstChild iterates over Ctrls added directly to the one you are calling the function on. You can try to add DUMP(typeid(*q).name()) before the dynamic_cast condition to see the types over which you actually iterate to make sure it is really those that you want to save. Note that it will log mangled names, but they should still be readable, e.g. "N3Upp10EditMinMaxIiNS_10ConvertIntEEE" stands for Upp::EditMinMax<ConvertInt> which is just typedefed EditInt.

If you still speak about the application using ParentCtrls to switch layouts, I guess you just iterate over the ParentCtrl. You'll have to either a) call it on the actual layout (i.e. something like "for (Ctrl* q = doPlt->GetFirstChild(); ...") or b) iterate recursively over the controls to save all the Ctrls even when they lower layers of the hierarchy tree).

Honza
Re: Problem in example code [message #45957 is a reply to message #45951] Sun, 31 January 2016 15:09 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

dolik.rce wrote on Sat, 30 January 2016 21:39
vegaonline wrote on Sat, 30 January 2016 16:37
Probably you are right that dynamic_cast is not working. EditFields have dedicated names. Here "if (dynamic_cast<EditField *> (q)) { " is not true.

The dynamic_cast actually works correctly in the test application I attached in my previous post. Are you calling this function on the correct Ctrl? GetFirstChild iterates over Ctrls added directly to the one you are calling the function on. You can try to add DUMP(typeid(*q).name()) before the dynamic_cast condition to see the types over which you actually iterate to make sure it is really those that you want to save. Note that it will log mangled names, but they should still be readable, e.g. "N3Upp10EditMinMaxIiNS_10ConvertIntEEE" stands for Upp::EditMinMax<ConvertInt> which is just typedefed EditInt.

If you still speak about the application using ParentCtrls to switch layouts, I guess you just iterate over the ParentCtrl. You'll have to either a) call it on the actual layout (i.e. something like "for (Ctrl* q = doPlt->GetFirstChild(); ...") or b) iterate recursively over the controls to save all the Ctrls even when they lower layers of the hierarchy tree).

Honza


Dear Honza,

Thanks for your hints. The example you sent worked well in its capacity. In my case the DUMP reported
* /home/vega/upp.out/MyApps/GCC.Debug.Debug_Full.Gui.Shared/Flasher 31.01.2016 19:48:23, user: vega

{}
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp6ButtonE
typeid(*q).name() = N3Upp6ButtonE
typeid(*q).name() = N3Upp6ButtonE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
typeid(*q).name() = N3Upp5LabelE
typeid(*q).name() = N3Upp9EditFieldE
json = {"projTitle":"testing","eventNum":"979817974","nPerGen":"12","zVal":"11","inactN":"1","actN":"1","wCutoff":"0.009","massNo":"221","KEMeV":"12","beamX":"0","beamY":"0","beamZ":"0","cosTheta":"1","sinPhi":"0","cosPhi":"1"}




So Your guess is perfect that I was iterating over ParentCtrl.

Your advice for properly using Ctrl was also OK as I used
for (Ctrl *q = doCard.GetFirstChild(); q; q=q->GetNext()) {..}


I GOT SAVED FILE. THANKS

***** Actually, I have a card Layout and I want to fill different forms like EditField, EditInt etc and like to save only values in the forms to some text file so that another code will read it as input parameter and run. I thought to use json. However, is there any other simpler way to save only the values in those edit fields?

By the by, you are perfect to be a good TEACHER. I am grateful to you for answering an weak student like me.

Best
Abhijit

[Updated on: Sun, 31 January 2016 15:38]

Report message to a moderator

Re: Problem in example code [message #45960 is a reply to message #45957] Sun, 31 January 2016 20:09 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Sun, 31 January 2016 15:09
***** Actually, I have a card Layout and I want to fill different forms like EditField, EditInt etc and like to save only values in the forms to some text file so that another code will read it as input parameter and run. I thought to use json. However, is there any other simpler way to save only the values in those edit fields?
Simpler way is to add Jsonize(JsonIO& json) method to whatever you want to save. Then you can simply call StoreAsJsonFile(object, filename), which will automatically use the Jsonize method to store all the data. The good thing about Jsonize is, that when implemented correctly, it can be used both ways. So you can load previously saved data without writing more code, simply just by calling LoadFromJsonFile(object, filename). See reference/Jsonize and Jsonize docs.

vegaonline wrote on Sun, 31 January 2016 15:09
By the by, you are perfect to be a good TEACHER. I am grateful to you for answering an weak student like me.
I'm happy to help. The learning curve for U++ is quite steep, so beginners sometimes need few hints, or they would leave before they find out the beauty of this powerful framework Wink

Honza
Re: Problem in example code [message #45964 is a reply to message #45960] Mon, 01 February 2016 05:40 Go to previous messageGo to next message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

Lot of Thanks.

I am again requesting for two issues. Very Happy

(i) I have a 4 column data file for ArrayCtrl. I want to click say col_1 and click option X. Then I want click say col_3 and click option y. Then I may plot 2D graph. However, my issue is that I am unable to choose particlular column of ArrayCtrl. I tried to use "doPlot.aArray.GetClickColumn();" which did not work. I tried to click header of ArrayCtrl.

(ii) I want to write a small code for generating geometrical primitives like sphere, cylinder, plate etc. Is there any example? In the bazar I saw one example related to OCE which reqd. oce.h etc. and I did not have OCE installed.

Best Regards
Abhijit
Re: Problem in example code [message #45973 is a reply to message #45964] Tue, 02 February 2016 21:16 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Mon, 01 February 2016 05:40
(i) I have a 4 column data file for ArrayCtrl. I want to click say col_1 and click option X. Then I want click say col_3 and click option y. Then I may plot 2D graph. However, my issue is that I am unable to choose particlular column of ArrayCtrl. I tried to use "doPlot.aArray.GetClickColumn();" which did not work. I tried to click header of ArrayCtrl.
Sorry, I don't know ArrayCtrl well enough to advise you on this. Maybe someone else will know the answer. My best hint is to use a different way to do this, e.g. context menu with "set as X" and "set as Y" options, or simply create droplist for each axis listing the possible columns.

vegaonline wrote on Mon, 01 February 2016 05:40
(ii) I want to write a small code for generating geometrical primitives like sphere, cylinder, plate etc. Is there any example? In the bazar I saw one example related to OCE which reqd. oce.h etc. and I did not have OCE installed.
Depends what you actually want... Simple drawings should be quite easy using Draw or Painter. For some better quality pictures there is the OCE based package you mentioned or GLCtrl which lets you draw anything using OpenGL primitives. Either way, don't expect a DrawCylinder function, there is AFAIK no package that would let you do this on such a high level.

Honza
Re: Problem in example code [message #45975 is a reply to message #45973] Fri, 05 February 2016 05:40 Go to previous message
vegaonline is currently offline  vegaonline
Messages: 35
Registered: December 2015
Location: Mumbai, India
Member

dolik.rce wrote on Wed, 03 February 2016 01:46
vegaonline wrote on Mon, 01 February 2016 05:40
(i) I have a 4 column data file for ArrayCtrl. I want to click say col_1 and click option X. Then I want click say col_3 and click option y. Then I may plot 2D graph. However, my issue is that I am unable to choose particlular column of ArrayCtrl. I tried to use "doPlot.aArray.GetClickColumn();" which did not work. I tried to click header of ArrayCtrl.
Sorry, I don't know ArrayCtrl well enough to advise you on this. Maybe someone else will know the answer. My best hint is to use a different way to do this, e.g. context menu with "set as X" and "set as Y" options, or simply create droplist for each axis listing the possible columns.

vegaonline wrote on Mon, 01 February 2016 05:40
(ii) I want to write a small code for generating geometrical primitives like sphere, cylinder, plate etc. Is there any example? In the bazar I saw one example related to OCE which reqd. oce.h etc. and I did not have OCE installed.
Depends what you actually want... Simple drawings should be quite easy using Draw or Painter. For some better quality pictures there is the OCE based package you mentioned or GLCtrl which lets you draw anything using OpenGL primitives. Either way, don't expect a DrawCylinder function, there is AFAIK no package that would let you do this on such a high level.

Honza


Thanks a lot for your ideas. I am using Droplist for the plot.

I feel some modifications are required like VectorMap for n dim Vectors. This may be required for modification of Plotting of 2D using error bars etc.
For that I see Pointf3 definition defined at "uppsrc/Geom/fp3.h". I wanted to use it by "#include<Geom/fp3.h>" which shows error. Also I want to
define Vector<Pointf3> so that I may modify ScatterDraw.




Best Regards
Abhi

[Updated on: Fri, 05 February 2016 13:08]

Report message to a moderator

Previous Topic: Issues using 2015.2 version
Next Topic: How to build FREBSD *.so in Windows?
Goto Forum:
  


Current Time: Fri Mar 29 09:54:52 CET 2024

Total time taken to generate the page: 0.01196 seconds