U++ Forum - RDF feed
type: channel
description: Main place for discussions about U++ cross platform development framework.
items: Problem in example code
items: Re: Problem in example code

Problem in example code
type: item
description: I tried to run SplitterFrame demo code as shown in URL http://www.ultimatepp.org/reference$SplitterFrame1$en-us.htm l. I see place to put GUI widgets while I may need to see the code. How can I see layout code? Thanks and Regards Abhijt
creator: vegaonline
date: 2015-12-29T14:53:23-00:00

Re: Problem in example code
type: item
description: Hello one more time , From the last stable version (9251 and up) we introduce new buttons that change the file view/edit mode. You can find them on TheIDE menu bar (Edit as text, Edit using designer, View as hex). Probably more information you will find on screen-shot posted below: I strongly believe that we need to describe menu bar functionality in our documentation. Sincerely, Klugier
creator: Klugier
date: 2015-12-29T15:06:46-00:00

Re: Problem in example code
type: item
description: Also, there is Ctrl+T shortcut. But the idea is that you shouldn't really need this. You can either compose your GUI using the editor (with *.lay file), or do it in your code (in *.cpp). But you should never edit *.lay files "manualy" in their text form.
creator: dolik.rce
date: 2015-12-29T15:13:01-00:00

Re: Problem in example code
type: item
description: @Klugier Hi! Thanks a lot for the prompt and perfect help. Now I can see layout text. @dolik.rce Hi! Thanks for the remark. However, I am confused with your statement. If I can edit .lay file why can't I edit it in their text form? For example I want to put a StaticText or label specifying foreground and background color. GUI editor shows only foreground color or INK COLOR. How can I do this? Wish all of you Happy New Year Best, Abhijit
creator: vegaonline
date: 2015-12-29T16:25:30-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Tue, 29 December 2015 17:25 Thanks for the remark. However, I am confused with your statement. If I can edit .lay file why can't I edit it in their text form? Well, that you can do something doesn't really mean you should If you modify the file in such a way that the editor in TheIDE will not understand it anymore, you might loose some information. I never actually tried that, so maybe the editor is clever enough to prevent this, but I wouldn't rely on it... The only reasonable situation where I would consider editing .lay file in its text form is when I wanted to do some Find&Replace to rename a bunch of widgets or some similar task that would be too tedious to do in the editor. vegaonline wrote on Tue, 29 December 2015 17:25 For example I want to put a StaticText or label specifying foreground and background color. GUI editor shows only foreground color or INK COLOR. How can I do this? Things that can't be done in GUI editor are usually done in code. It is actually quite simple, e.g. to change the text of StaticText programatically: #include <CtrlLib/CtrlLib.h> using namespace Upp; #define LAYOUTFILE <MyApp/MyApp.lay> #include <CtrlCore/lay.h> class MyWindow : public WithMyLayout<TopWindow> { typedef MyWindow CLASSNAME; public: MyWindow(){ CtrlLayout(*this, ""); MyStaticText.SetText("MyText"); } }; The exact case you ask for, changing background color, is actually kind of tricky There is nothing like SetBackgroundColor method, but it is possible to change the background of the text itself. StaticText and many other widgets support QTF. It might look scary, but there is a nice editor in TheIDE (press Alt+Q). So to set The background of your text to blue, you'd do this: MyStaticText.SetText(t_("\1[$(0.0.255) Test]") The "\1" at the beginning denotes that the string should be treated as QTF, see the documentation here. Honza
creator: dolik.rce
date: 2015-12-29T18:31:25-00:00

Re: Problem in example code
type: item
description: Thanks for the explanation. I am sorry asking too many and silly questions. Please consider me as a learner who likes to clear confusion. Although the concept and implement of U++ is superb, "theide" is also great! I am surprised to see why I did not find this tool before! 1. I find that upp.out directory contains all the upp related staff and ~/MyApps/Testing contains all .cpp, .lay and .h files. If I want to build an application and like to run on some other machine not having Upp or other staffs installed, how can I do it? I found that in my machine, I can run executable file Testing built at ~/upp.out/MyApps/GCC.Debug.Debug_Full.Gui.Shared/. 2. Can I plot mathematical graphs etc.? Can I use codes with matplotlib in python or U++ has own widgets? I am making a GUI for my App which is a small scientific application for my experimental device which needs a menu while one menu item shall open a small panel in same window to input text and data, while the other panel in the same window shall erase earlier panel and may plot some files in 2D, 3D, contour etc. Best, Abhijit
creator: vegaonline
date: 2015-12-31T06:14:32-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Thu, 31 December 2015 07:14 Thanks for the explanation. I am sorry asking too many and silly questions. Please consider me as a learner who likes to clear confusion. Although the concept and implement of U++ is superb, "theide" is also great! I am surprised to see why I did not find this tool before! You are welcome. Everyone on this forum knows that U++ has pretty steep learning curve and that the documentation doesn't always make everything clear. So the newbies are expected to ask many questions, and there is also many people willing to answer. vegaonline wrote on Thu, 31 December 2015 07:14 1. I find that upp.out directory contains all the upp related staff and ~/MyApps/Testing contains all .cpp, .lay and .h files. If I want to build an application and like to run on some other machine not having Upp or other staffs installed, how can I do it? I found that in my machine, I can run executable file Testing built at ~/upp.out/MyApps/GCC.Debug.Debug_Full.Gui.Shared/. Yes, all the intermediate files (object files and libraries) are stored in upp.out (or whatever path you configure). The resulting binary is by default stored there to, but this can be easily changed. Just go to Build -> Output mode and there is a field labeled "Target file override" (actually there is two of them, one for debug mode and for release). If you check the checkbox there, TheIDE will create the binary with the path and name specified in the corresponding input field. All you need to do to run any U++ program on other machine is to copy this single binary. Often it works out of the box, but sometimes there might be some libraries that are not installed on the other machine, but that is usually pretty easy to figure out and fix just by installing them using distribution packages. It might also happen that the other machine contains some of those libraries in version incompatible with those on the machine used to build your app, in which case it is bit harder to fix and it m…
creator: dolik.rce
date: 2015-12-31T12:58:55-00:00

Re: Problem in example code
type: item
description: Thanks a lot. I have seen GU Tut 6. I want a menu at the top. Depending on the menu item, panels need to be opened in the same window in stead of separate windows erasing contents of earlier items. Best, Abhijit
creator: vegaonline
date: 2015-12-31T17:31:34-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Thu, 31 December 2015 18:31 I have seen GU Tut 6. I want a menu at the top. Depending on the menu item, panels need to be opened in the same window in stead of separate windows erasing contents of earlier items. Oh, ok. That is actually even simpler You can represent each panel using ParentCtrl (or WithMyLayout<ParentCtrl>, when using .lay file). This way you can Add and Remove multiple widgets (that is your 'panel') at once easily. For more customizable interface, you can also use Splitter Honza
creator: dolik.rce
date: 2016-01-01T19:07:16-00:00

Re: Problem in example code
type: item
description: @HONZA, Thanks for kindly guiding me. I am trying to use ParentCtrl, while I am facing problem. I am attaching required files. The initial screen is OK. When I press "Configure", I want "CardLayout1" is to be shown which is not coming. By the by, please ignore many commented lines as I am learner. Please guide me.
creator: vegaonline
date: 2016-01-02T21:39:35-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Sat, 02 January 2016 22:39 @HONZA, Thanks for kindly guiding me. I am trying to use ParentCtrl, while I am facing problem. I am attaching required files. The initial screen is OK. When I press "Configure", I want "CardLayout1" is to be shown which is not coming. By the by, please ignore many commented lines as I am learner. Please guide me. Hi Abhijit, The only part you were missing is adding and removing the ParentCtrl as necessary. The two functions called from menu should do something like this: void Testing::doConfig() { doPlot.Remove(); Add(doCard); } void Testing::doGeom() { doCard.Remove(); Add(doPlot); } Also, the menu should be added using AddFrame, which you probably already tried, I've seen it in one of the comments It makes things much easier when switching the layouts, sinco you don't have to care about it's position. I have modified the sources and attach them for your reference.
creator: dolik.rce
date: 2016-01-03T11:57:00-00:00

Re: Problem in example code
type: item
description: Great ! I understand. Thanks a lot. However, I may reach Plot menu from any other menu item having separate layout except card menu. Should I use ".Remove() for all other different layout or there is any single Remove command to remove all other layout which may be present there? Best, Abhijit
creator: vegaonline
date: 2016-01-03T13:41:41-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Sun, 03 January 2016 14:41 However, I may reach Plot menu from any other menu item having separate layout except card menu. Should I use ".Remove() for all other different layout or there is any single Remove command to remove all other layout which may be present there? There are ways to access the all the children of given Ctrls and to iterate through them. See GetFirstChild(), GetNext(), GetChildIndex(), GetIndexChild(), GetChildCount() and related functions in Ctrl documentation. In your particular case it would probably be ok just to call GetLasChild()->Remove(). But I never actually needed to use such a low level approach in my apps and it feels kind of error prone to me. There is actually much simpler way: You can just remember your last state For example, you can add Ctrl* active to your class (don't forget to initialize it to NULL in constructor, otherwise you'll get crashes ), and then use a method like this for the switching: void Testing::SetLayout(Ctrl* ctrl) { if (active) active->Remove(); Add(*ctrl); active = ctrl; } Your menu code could then be as simple as this: menu.Add("Configure", THISBACK1(SetLayout, &doCard)).Help("Edit Simulation Setup"); menu.Add("Geometry", THISBACK1(SetLayout, &doPlot)).Help("Edit Experimental Geometry"); That is of course assuming there is no special initialization for each layout needed on each switch, in which case you would have to still call doConfig() and doGeom() from menu and they would in turn call the common switching code in SetLayout. Honza
creator: dolik.rce
date: 2016-01-03T20:08:28-00:00

Re: Problem in example code
type: item
description: [quote title=dolik.rce wrote on Mon, 04 January 2016 01:38]vegaonline wrote on Sun, 03 January 2016 14:41 menu.Add("Configure", THISBACK1(SetLayout, &doCard)).Help("Edit Simulation Setup"); menu.Add("Geometry", THISBACK1(SetLayout, &doPlot)).Help("Edit Experimental Geometry"); That is of course assuming there is no special initialization for each layout needed on each switch, in which case you would have to still call doConfig() and doGeom() from menu and they would in turn call the common switching code in SetLayout. Honza Hi the idea is superb. However, I am getting the following error for the above code: Pl. advise. Thanks and Regards Abhijit
creator: vegaonline
date: 2016-01-04T12:59:10-00:00

Re: Problem in example code
type: item
description: You are passing the functions (doConfig, doGeom) instead of the ParentCtrls (doCard, doPlot) Honza
creator: dolik.rce
date: 2016-01-04T13:47:39-00:00

Re: Problem in example code
type: item
description: dolik.rce wrote on Mon, 04 January 2016 19:17 You are passing the functions (doConfig, doGeom) instead of the ParentCtrls (doCard, doPlot) Honza You are Great! Thanks a lot. Sorry for the silly mistake.
creator: vegaonline
date: 2016-01-04T16:21:25-00:00

Re: Problem in example code
type: item
description: HI! I have another very peculiar problem. I wanted to make a simple layout like before by adding a new layout. While build is performed, I get an error In file included from /home/vega/MyApps/honza/Testing/main.cpp:1:0: /home/vega/MyApps/honza/Testing/Testing.h:15:2: error: 'WithPltLayout1' does not name a type WithPltLayout1<ParentCtrl>doGeo; ^ I cleaned and tried to re-build, while getting the same error. Thanks and Regards Abhiit
creator: vegaonline
date: 2016-01-04T20:10:10-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Mon, 04 January 2016 21:10 I wanted to make a simple layout like before by adding a new layout. While build is performed, I get an error In file included from /home/vega/MyApps/honza/Testing/main.cpp:1:0: /home/vega/MyApps/honza/Testing/Testing.h:15:2: error: 'WithPltLayout1' does not name a type WithPltLayout1<ParentCtrl>doGeo; ^ Hard to say without seeing the actual code. Few thigns to check: Is there really layout called PltLayout1? Check for typos... Is it in the .lay file that is properly included in Testing.h (using #define LAYOUTFILE <Testing/xyz.ly> with #include CtrlCore/lay.h following)? Is there some syntax error preceding this line, that would make your compiler report this as an error, while it is actually correct? Honza
creator: dolik.rce
date: 2016-01-04T20:23:59-00:00

Re: Problem in example code
type: item
description: Hi! I have two very silly problems which I could not fix as per my satisfaction. In my code I have menus and one of them is plot. In this plot menu I have a layout in which there is a droplist entry with name "pltType". I tried many ways yet I could not put any option there. Next, how can I read a data file and use for plotting using scatterCtrl? I find that LoadFromFile reads in string. How can I put Serialize? Thanks and Regards Abhijit
creator: vegaonline
date: 2016-01-12T11:04:31-00:00

Re: Problem in example code
type: item
description: Hello Abhijit For the ScatterCtrl the best for you would be to open ScatterCtrl_demo and reading for example tab1_Basic.cpp. For example you can declare a Vector<Pointf> data in a safe place (as a class member, for example), fill it with the data from your file and do this: void Tab1_Basic::Init() { CtrlLayout(*this); SizePos(); data << Pointf(10, 26) << Pointf(20, 37) << Pointf(30, 31) << Pointf(40, 33) << Pointf(50, 28); scatter.AddSeries(data).Legend("Series 1").Fill().MarkBorderColor(); scatter.SetRange(60, 50).SetMajorUnits(10, 10); scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().SetPopText("h", "v", "v2").SetMouseHandling(true, true); scatter.SetLegendPos(Point(20, 20)); }
creator: koldo
date: 2016-01-12T12:57:08-00:00

Re: Problem in example code
type: item
description: koldo wrote on Tue, 12 January 2016 18:27 Hello Abhijit For the ScatterCtrl the best for you would be to open ScatterCtrl_demo and reading for example tab1_Basic.cpp. For example you can declare a Vector<Pointf> data in a safe place (as a class member, for example), fill it with the data from your file and do this: void Tab1_Basic::Init() { CtrlLayout(*this); SizePos(); data << Pointf(10, 26) << Pointf(20, 37) << Pointf(30, 31) << Pointf(40, 33) << Pointf(50, 28); scatter.AddSeries(data).Legend("Series 1").Fill().MarkBorderColor(); scatter.SetRange(60, 50).SetMajorUnits(10, 10); scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().SetPopText("h", "v", "v2").SetMouseHandling(true, true); scatter.SetLegendPos(Point(20, 20)); } Dear Koldo, Thanks a lot for the reply. I have already seen the scattercontrol example. However, my problem is that if filename="......" known then how can I load data and place in Pointf vector? I did not see cin type of function. At the same time, if I use LoadFromFile(filename) then string will be loaded. Actually I am confused and can't formulate exact code. Best regards, Abhijit
creator: vegaonline
date: 2016-01-12T16:00:54-00:00

Re: Problem in example code
type: item
description: Beside this I find that I am unable to put items in the droplist or in the array (arrayCtrl). I tried to refer by doPlot.array which did not report any error while nothing was printed in the droplist.
creator: vegaonline
date: 2016-01-13T08:17:40-00:00

Re: Problem in example code
type: item
description: UP
creator: vegaonline
date: 2016-01-19T06:55:33-00:00

Re: Problem in example code
type: item
description: Hello vegaonline I understand that your issue is that you do not know how to get data from a text file, lets say a .csv file, and fill with it a C++ vector or an U++ Vector, isn't it?
creator: koldo
date: 2016-01-19T09:19:18-00:00

Re: Problem in example code
type: item
description: koldo wrote on Tue, 19 January 2016 14:49 Hello vegaonline I understand that your issue is that you do not know how to get data from a text file, lets say a .csv file, and fill with it a C++ vector or an U++ Vector, isn't it? Two points. (i) I want to read a csv data file and take into U++ vector. Can I do like C++ vectors which is easy? (ii) When I try to put items in droplist associated to a layout, I see nothing. Pl. see last attachment.
creator: vegaonline
date: 2016-01-19T09:27:08-00:00

Re: Problem in example code
type: item
description: Hello Vegaonline You can load text files in many ways. In Bazaar/Functions4U there are two functions: - ReadCSVFile(): Simpler to use - ReadCSVFileByLine(): It can read huge text files For example: Vector<Vector <Value> > ReadCSVFile( const String fileName, // File name char separator = ',', // Separator between data bool bycols = true, // Data is in columns, not in rows bool removeRepeated = true, // Remove repeated rows char decimalSign = '.', // Decimal sign (it may be ',' instead bool onlyStrings = false // if false, it tries to use the appropriate number type, if not it consider everything as strings );
creator: koldo
date: 2016-01-19T14:44:38-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Tue, 19 January 2016 10:27 (i) I want to read a csv data file and take into U++ vector. Can I do like C++ vectors which is easy? As Koldo already said, there is many ways. I like this one: FileIn f("/path/to/my.file"); String ln = f.GetLine(); String val1, val2; Vector<double> x, y; while( !f.IsEof()) { SplitTo(ln, '\t', val1, val2); // for tab delimited values, change delimiter as needed x.Add(StrDbl(TrimBoth(val1))); y << StrDbl(TrimBoth(val2)); // this is same as y.Add, just bit easier to read in some cases ln = f.GetLine(); } vegaonline wrote on Tue, 19 January 2016 10:27 (ii) When I try to put items in droplist associated to a layout, I see nothing. Pl. see last attachment. You are actually doing it right in your code: doPlot.pltType.Add(0,"2D"); doPlot.pltType.Add(1,"3D"); doPlot.pltType.Add(2,"Contour"); The problem is, that this pice of code is in function doPlt, that is never called, so all the initialization it should perform never happens. move the DropList initialization to the constructor of your class and it will work as expected. Best regards, Honza PS: I'm sorry it took me so long to answer. Those two questions required me to look in to the code and test it, so it took longer than simple questions that I can answer from top of my head.
creator: dolik.rce
date: 2016-01-19T20:16:16-00:00

Re: Problem in example code
type: item
description: Dear Kolbo and Honza, Thanks a lot for the reply and kind help. @Honza I am grateful to you for illustrating so lucidly in spite of your busy schedule. Adding initialization in constructor solved DropList problem. However, for plotting say scatter plot, one needs Vector<Pointf> V type of data. Here I am reading Vector<double> x, y; I tried : Vector<double> x, y; VectorMap<double, double> P1; while (!inF.IsEof()) { SplitTo(ln, ',', val1, val2); // for tab delimited values, change delimiter as needed x.Add(StrDbl(TrimBoth(val1))); y << StrDbl(TrimBoth(val2)); // this is same as y.Add, just bit easier to read in some cases P1<<(x,y); //<--------------------------------- CHECK ln = inF.GetLine(); doPlot.array.Add(val1); doPlot.array.Add(val2); } Here, I wanted to put val1 and val2 to P1 as (val1, val2) so that I may take P1 to scatter. However, it is not successfull. Also I am unable to show data in arrayCtrl array. Best Regards Abhijit
creator: vegaonline
date: 2016-01-20T09:12:01-00:00

Re: Problem in example code
type: item
description: Hi, You can simply construct Pointf from two doubles: Pointf(x, y). So the code would be: Vector<Pointf> data; while (!inF.IsEof()) { SplitTo(ln, ',', val1, val2); double x = StrDbl(TrimBoth(val1)); double y = StrDbl(TrimBoth(val2)); data.Add(Pointf(x,y)); ln = inF.GetLine(); } Honza
creator: dolik.rce
date: 2016-01-20T09:57:46-00:00

Re: Problem in example code
type: item
description: dolik.rce wrote on Wed, 20 January 2016 15:27 Hi, You can simply construct Pointf from two doubles: Pointf(x, y). So the code would be: Vector<Pointf> data; while (!inF.IsEof()) { SplitTo(ln, ',', val1, val2); double x = StrDbl(TrimBoth(val1)); double y = StrDbl(TrimBoth(val2)); data.Add(Pointf(x,y)); ln = inF.GetLine(); } Honza Thanks a lot. What would happen for 3D data having (x, y, z) for contour plot? Best, Abhijit
creator: vegaonline
date: 2016-01-20T10:24:35-00:00

Re: Problem in example code
type: item
description: As far as I know we cannot plot 3D data yet.
creator: koldo
date: 2016-01-20T12:50:05-00:00

Re: Problem in example code
type: item
description: koldo wrote on Wed, 20 January 2016 18:20 As far as I know we cannot plot 3D data yet. Hi Koldo, Thanks for the insight. However, then can I use Python here like embedding? The reason is that I need to plot 2D and 3D with contour plotting and I used matplotlib.pyplot for 3D plotting using Anaconda. Best Regards Abhijit
creator: vegaonline
date: 2016-01-20T15:56:42-00:00

Re: Problem in example code
type: item
description: Sorry, I do not have any idea about python.
creator: koldo
date: 2016-01-22T09:12:37-00:00

Re: Problem in example code
type: item
description: Dear Koldo, Thanks. I have a confusion. Suppose I have a class Testing which is declared as TopWindow. Now let there be another class Plotting as ParentCtrl. I can declare "Plotting plt" in the construction of class Testing so that I may access methods of Plotting from Testing by using "plt.funcInPlotting". Is there any way by which I can also refer a variable/methods of Testing from a function of Plotting? Best Regards Abhijit
creator: vegaonline
date: 2016-01-22T09:39:15-00:00

Re: Problem in example code
type: item
description: vegaonline wrote on Fri, 22 January 2016 10:39 I have a confusion. Suppose I have a class Testing which is declared as TopWindow. Now let there be another class Plotting as ParentCtrl. I can declare "Plotting plt" in the construction of class Testing so that I may access methods of Plotting from Testing by using "plt.funcInPlotting". Is there any way by which I can also refer a variable/methods of Testing from a function of Plotting? Short answer: You can pass reference or pointer to Testing when constructing the Plotting instance, or when calling its function. Slightly longer answer: There is many ways to do that, some better and some worse. But all of them are actually not connected to U++ in any way. This is a matter of general C++ application design. If you want to write complex applications in C++ you should already know this. Honza
creator: dolik.rce
date: 2016-01-22T13:06:47-00:00

Re: Problem in example code
type: item
description: Thanks a lot. I have another problem. I have a layout containing lots of EditField and DropList etc. I want to store in a file. I though to save in JSON file. I am using the following snippets. filename1 = ""; PWDir="/home/vega/MyApps/Flasher/DAT/"; fs1.PreSelect(PWDir); fs1.Types("*.inp"); if (fs1.ExecuteSaveAs(NULL)) filename1 = ~fs1; for (Ctrl *q = GetFirstChild(); q; q=q->GetNext()) if (dynamic_cast<EditField *> (q)) { String id = q->GetLayoutId(); PromptOK(id); if (id.GetCount()) json(id, ~*q); } SaveFile(ConfigFile(filename1), json); I find that SaveAs window comes and after entering filename to store, the file is not stored. How can I solve the issue? Best Regards Abhijit
creator: vegaonline
date: 2016-01-29T12:05:28-00:00

Re: Problem in example code
type: item
description: Hi Abhijit, I don't immediately see any problem with your code, without actually running it... If I were you, I'd try to add some logging into key places of the code, to figure out where exactly is the problem. Use LOG and DUMP macros, which produce a log when the application is compiled in debug mode. To see the log, just press Alt+L or go to Debug > View the logfile. I'd start with adding DUMP(json) after the loop. Also, I guess you already tried inspecting the values of id, by adding PromptOK. Does it show the names of fields you are expecting? Also, the code seems little over-complicated. Have a look at examples in reference/Jsonize. It displays exactly what you want, saving large structures into json file (just not as dynamically as you try to do it). Also reference/SelectFile might be of some help. Best regards, Honza
creator: dolik.rce
date: 2016-01-29T19:43:59-00:00

Re: Problem in example code
type: item
description: dolik.rce wrote on Sat, 30 January 2016 01:13 Hi Abhijit, I don't immediately see any problem with your code, without actually running it... If I were you, I'd try to add some logging into key places of the code, to figure out where exactly is the problem. Use LOG and DUMP macros, which produce a log when the application is compiled in debug mode. To see the log, just press Alt+L or go to Debug > View the logfile. I'd start with adding DUMP(json) after the loop. Also, I guess you already tried inspecting the values of id, by adding PromptOK. Does it show the names of fields you are expecting? Also, the code seems little over-complicated. Have a look at examples in reference/Jsonize. It displays exactly what you want, saving large structures into json file (just not as dynamically as you try to do it). Also reference/SelectFile might be of some help. Best regards, Honza Hi Honza, Thanks. Earlier I tried to see the DUMP file and now again I checked. It reports " json = {}". Also PromptOK did not show as the code did not go through that "IF" loop " if (dynamic_cast<EditField *> (q)) ". Best, Abhi
creator: vegaonline
date: 2016-01-30T05:37:34-00:00

Re: Problem in example code
type: item
description: Hi, I'm still not sure it is really good idea to this dynamically, but here is a working method: void StoreToJson() { Json json; for (Ctrl *q = GetFirstChild(); q; q=q->GetNext()) { if (dynamic_cast<EditField *> (q)) { String id = q->GetLayoutId(); if (id.GetCount()) json(id, ~*q); } } SelectFileOut out("*.*"); if (out.IsOpen()) out << json << "\n"; } It is actually almost the same as the code you posted. Full code is in the attached archive. Just click anywhere in the window to trigger the save as dialog. I'm not sure why it didn't work for you. Only thing I can think of is that you didn't assign names to the editfields in the layout. Honza
creator: dolik.rce
date: 2016-01-30T08:33:46-00:00

Re: Problem in example code
type: item
description: dolik.rce wrote on Sat, 30 January 2016 14:03 Hi, I'm still not sure it is really good idea to this dynamically, but here is a working method: void StoreToJson() { Json json; for (Ctrl *q = GetFirstChild(); q; q=q->GetNext()) { if (dynamic_cast<EditField *> (q)) { String id = q->GetLayoutId(); if (id.GetCount()) json(id, ~*q); } } SelectFileOut out("*.*"); if (out.IsOpen()) out << json << "\n"; } It is actually almost the same as the code you posted. Full code is in the attached archive. Just click anywhere in the window to trigger the save as dialog. I'm not sure why it didn't work for you. Only thing I can think of is that you didn't assign names to the editfields in the layout. Honza Dear Honza, Thanks a lot. Your technique for SelectFileOut is working and one file is created while the content is "{}". It means json content was not made. Probably you are right that dynamic_cast is not working. EditFields have dedicated names. Here "if (dynamic_cast<EditField *> (q)) { " is not true. Is there any other way to bypass dynamic_cast? best Abhi
creator: vegaonline
date: 2016-01-30T15:37:35-00:00

Re: Problem in example code
type: item
description: 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
creator: dolik.rce
date: 2016-01-30T16:09:10-00:00

Re: Problem in example code
type: item
description: 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 ty…
creator: vegaonline
date: 2016-01-31T14:09:42-00:00

Re: Problem in example code
type: item
description: 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 Honza
creator: dolik.rce
date: 2016-01-31T19:09:39-00:00

Re: Problem in example code
type: item
description: Lot of Thanks. I am again requesting for two issues. (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
creator: vegaonline
date: 2016-02-01T04:40:49-00:00

Re: Problem in example code
type: item
description: 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
creator: dolik.rce
date: 2016-02-02T20:16:20-00:00

Re: Problem in example code
type: item
description: 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
creator: vegaonline
date: 2016-02-05T04:40:20-00:00