Pairing MLAPP (AppDesigner) Apps With Other Classes

13 ビュー (過去 30 日間)
Alexander Cochran
Alexander Cochran 2018 年 6 月 15 日
コメント済み: Noah Griffiths 2021 年 7 月 27 日
I'm currently building an object-oriented system that groups medical imaging data together for processing. I wish to make the system very easy to use, so GUIs are an attractive next step.
What's the best way that I can pair GUIs (MLAPPs designed in AppDesigner, specifically) with my existing class structure to allow the GUI objects to call different member functions?
Example:
Class1 (top-level grouping class, where an array of Class2 objects is stored)
Class2 (second-level grouping class, where an array of Class3 objects is stored)
Class3 (lower-level data class, containing actual medical imaging data)
I would want to initialize all objects (starting with a Class1) and then be able to use the GUI to select a Class2 (a group of Class3 objects) or an individual Class3 object, and then perform processing functions on it (e.g., select a dataset, hit some buttons, do processing). I understand how callbacks work, but I'm curious what the best way to go about sharing data between GUI objects instantiated in my Class1 and other objects would be.
  1 件のコメント
Guillaume
Guillaume 2018 年 6 月 15 日
So if I understood correctly you'd have something like:
classdef Class1
properties %what access restrictions?
Class2 child;
end
end
classdef Class2
properties %what access restrictions?
Class3 child;
end
end
classdef Class3
end
That is Class1 has a member that is of type Class2 and Class2 has a member that is of type Class3. After that I'm not sure what's your question nor why it would involve callbacks.

サインインしてコメントする。

回答 (1 件)

Chris Portal
Chris Portal 2018 年 6 月 17 日
This is how I’d approach it:
  1. Use the app window’s StartupFcn callback to initialize all your Class1, Class2, and Class3 objects.
  2. Save the Class1 instance as a property of your app, called something like “MyMedicalData”.
  3. Also in this callback, populate whatever UI components (dropdown, tree, etc.) you’re going to use for presenting and selecting the individual Class2 and Class3 objects.
  4. Configure the callbacks for the UI components you use to access the appropriate class objects you need via the app property you created. Something like app.MyMedicalData.GetArrayOfClass2Objects.
(Note, I’m assuming your Class1 definition has some kind of GetArrayOfClass2Objects property or method to navigate your internal data structures.)
  3 件のコメント
Aditya Mahesh
Aditya Mahesh 2020 年 2 月 3 日
Where is the class 1, class2 and class 3 definition created within the appdesigner?
Noah Griffiths
Noah Griffiths 2021 年 7 月 27 日
@Alexander Cochran as far as I'm aware, having anything but the class created in the constructor is bad quality code i.e. doing so creates tight coupling and poor cohesion. Even constructors can be dangerous in certain situations.
Here is a really useful resource for creating quality code:
https://refactoring.guru/refactoring/smells

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by