File: dialog_functions.h

package info (click to toggle)
evolvotron 0.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,420 kB
  • ctags: 1,367
  • sloc: cpp: 10,462; python: 162; sh: 147; makefile: 9
file content (138 lines) | stat: -rw-r--r-- 4,308 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**************************************************************************/
/*  Copyright 2012 Tim Day                                                */
/*                                                                        */
/*  This file is part of Evolvotron                                       */
/*                                                                        */
/*  Evolvotron is free software: you can redistribute it and/or modify    */
/*  it under the terms of the GNU General Public License as published by  */
/*  the Free Software Foundation, either version 3 of the License, or     */
/*  (at your option) any later version.                                   */
/*                                                                        */
/*  Evolvotron is distributed in the hope that it will be useful,         */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
/*  GNU General Public License for more details.                          */
/*                                                                        */
/*  You should have received a copy of the GNU General Public License     */
/*  along with Evolvotron.  If not, see <http://www.gnu.org/licenses/>.   */
/**************************************************************************/

/*! \file 
  \brief Interface for class DialogFunctions.
*/

#ifndef _dialog_functions_h_
#define _dialog_functions_h_

#include "mutation_parameters_qobject.h"

class EvolvotronMain;

//! Utility class for DialogFunctions.  Expands changed(int) to changed(src,int)
/*! Would ideally live in dialog_functions.cpp, but that causes (moc-related?) problems with linking;
  seems to need wider visibility.  \todo Move to own file and only include in dialog_functions.cpp
 */
class SignalExpanderValueChangedQSlider : public QObject
{
private:
  Q_OBJECT
  
  QSlider*const _src;
public:
  SignalExpanderValueChangedQSlider(QObject* parent,QSlider* src)
    :QObject(parent)
    ,_src(src)
  {}
public slots:
  void valueChanged(int v)
  {
    emit valueChanged(_src,v);
  }

signals:
  void valueChanged(QSlider*,int);
};

//! Similar to SignalExpanderQSlider except attaches an integer argument to the clicked signal
class SignalExpanderClickedUint : public QObject
{
 private:
  Q_OBJECT

  uint _arg;
 public:
  SignalExpanderClickedUint(QObject* parent,uint arg)
    :QObject(parent)
    ,_arg(arg)
    {}
 public slots:
  void clicked()
    {
      emit clicked(_arg);
    }
 signals:
 void clicked(uint);
};

//! Provides a dialog for controlling which functions are available.
class DialogFunctions : public QDialog
{
 private:
  Q_OBJECT

 protected:
  //! Owner of dialog
  EvolvotronMain*const _parent;

  //! Instance of MutationParameters under dialog control.
  /*! \warning Careful of modifying things which might make DialogMutationParameters get out of sync
   */
  MutationParametersQObject*const _mutation_parameters;

  //! Top level holder of all the dialog content.
  QWidget* _dialog_content;

  //! Notification of undiluted branching ratio.
  QLabel* _branching_ratio;

  //! Required branching ratio after dilution
  QSlider* _slider_target_branching_ratio;

  //! Proportion of diluting nodes which are pure constants
  QSlider* _slider_proportion_constant;

  //! Proportion of non-constant nodes which are 12-parameter transforms
  QSlider* _slider_identity_supression;
  
  //! Lookup from each slider in the weighting controls area to corresponding function.
  std::map<QSlider*,const FunctionRegistration*> _slider_to_function;

 public:
  //! Constructor.
  DialogFunctions(EvolvotronMain* parent,MutationParametersQObject* mp);

  //! Destructor.
  ~DialogFunctions();

  //! Reload from _mutation_parameters
  void setup_from_mutation_parameters();

 protected slots:
   
   //@{
   //! Signalled by sliders.
   void changed_target_branching_ratio(int v);
   void changed_proportion_constant(int v);
   void changed_identity_supression(int v);
   void changed_function_weighting(QSlider*,int v);
   //@}

   //! Signalled by randomization methods
   void clicked_button_rand(uint mask);

 public slots:
  //! Signalled by mutation parameters
  void mutation_parameters_changed();
};

#endif