modify clr btn 16 plugins, add regdmp for sigtraps, rework mask_engine, mask rotate...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / wave / wave.C
index 03f537f083e5af841d65753eb366ea737166cba4..c5f0c3f39b87ed66f85fe83e3be85e416b46e689 100644 (file)
  *
  */
 
  *
  */
 
-#include "bcdisplayinfo.h"
-#include "clip.h"
-#include "bchash.h"
-#include "filexml.h"
-#include "guicast.h"
-#include "keyframe.h"
-#include "language.h"
-#include "loadbalance.h"
-#include "pluginvclient.h"
-#include "vframe.h"
+#include "wave.h"
 
 
-#include <math.h>
-#include <stdint.h>
-#include <string.h>
 
 
 
 
 
 
 
 
-#define SMEAR 0
-#define BLACKEN 1
 
 
 
 
 
 
-class WaveEffect;
-class WaveWindow;
-
-
-class WaveConfig
-{
-public:
-       WaveConfig();
-       void copy_from(WaveConfig &src);
-       int equivalent(WaveConfig &src);
-       void interpolate(WaveConfig &prev,
-               WaveConfig &next,
-               long prev_frame,
-               long next_frame,
-               long current_frame);
-       int mode;
-       int reflective;
-       float amplitude;
-       float phase;
-       float wavelength;
-};
-
-class WaveSmear : public BC_Radial
-{
-public:
-       WaveSmear(WaveEffect *plugin, WaveWindow *window, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-       WaveWindow *window;
-};
-
-class WaveBlacken : public BC_Radial
-{
-public:
-       WaveBlacken(WaveEffect *plugin, WaveWindow *window, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-       WaveWindow *window;
-};
-
-
-class WaveReflective : public BC_CheckBox
-{
-public:
-       WaveReflective(WaveEffect *plugin, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-};
-
-class WaveAmplitude : public BC_FSlider
-{
-public:
-       WaveAmplitude(WaveEffect *plugin, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-};
-
-class WavePhase : public BC_FSlider
-{
-public:
-       WavePhase(WaveEffect *plugin, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-};
-
-class WaveLength : public BC_FSlider
-{
-public:
-       WaveLength(WaveEffect *plugin, int x, int y);
-       int handle_event();
-       WaveEffect *plugin;
-};
-
-
-
-
-
-
-
-
-
-class WaveWindow : public PluginClientWindow
-{
-public:
-       WaveWindow(WaveEffect *plugin);
-       ~WaveWindow();
-       void create_objects();
-       void update_mode();
-       WaveEffect *plugin;
-//     WaveSmear *smear;
-//     WaveBlacken *blacken;
-//     WaveReflective *reflective;
-       WaveAmplitude *amplitude;
-       WavePhase *phase;
-       WaveLength *wavelength;
-};
-
-
-
-
-
-
-
-class WaveServer : public LoadServer
-{
-public:
-       WaveServer(WaveEffect *plugin, int cpus);
-       void init_packages();
-       LoadClient* new_client();
-       LoadPackage* new_package();
-       WaveEffect *plugin;
-};
-
-class WavePackage : public LoadPackage
-{
-public:
-       WavePackage();
-       int row1, row2;
-};
-
-class WaveUnit : public LoadClient
-{
-public:
-       WaveUnit(WaveEffect *plugin, WaveServer *server);
-       void process_package(LoadPackage *package);
-       WaveEffect *plugin;
-};
-
-
-
-
-
-
-
-
-
-class WaveEffect : public PluginVClient
+WaveConfig::WaveConfig()
 {
 {
-public:
-       WaveEffect(PluginServer *server);
-       ~WaveEffect();
-
-       PLUGIN_CLASS_MEMBERS(WaveConfig)
-       int process_realtime(VFrame *input, VFrame *output);
-       int is_realtime();
-       void save_data(KeyFrame *keyframe);
-       void read_data(KeyFrame *keyframe);
-       void update_gui();
-
-       VFrame *temp_frame;
-       VFrame *input, *output;
-       WaveServer *engine;
-};
-
-
-
-
-
-
-
-
-
-
-
+       reset(RESET_ALL);
+}
 
 
 
 
-WaveConfig::WaveConfig()
+void WaveConfig::reset(int clear)
 {
 {
-       mode = SMEAR;
-       reflective = 0;
-       amplitude = 10;
-       phase = 0;
-       wavelength = 10;
+       switch(clear) {
+               case RESET_ALL :
+                       mode = SMEAR;
+                       reflective = 0;
+                       amplitude = 0;
+                       phase = 0;
+                       wavelength = 0;
+                       break;
+               case RESET_AMPLITUDE : amplitude = 0;
+                       break;
+               case RESET_PHASE : phase = 0;
+                       break;
+               case RESET_WAVELENGTH : wavelength = 0;
+                       break;
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       mode = SMEAR;
+                       reflective = 0;
+                       amplitude = 10;
+                       phase = 0;
+                       wavelength = 10;
+                       break;
+       }
 }
 
 void WaveConfig::copy_from(WaveConfig &src)
 }
 
 void WaveConfig::copy_from(WaveConfig &src)
@@ -367,16 +211,66 @@ int WaveLength::handle_event()
        return 1;
 }
 
        return 1;
 }
 
+WaveReset::WaveReset(WaveEffect *plugin, WaveWindow *gui, int x, int y)
+ : BC_GenericButton(x, y, _("Reset"))
+{
+       this->plugin = plugin;
+       this->gui = gui;
+}
+WaveReset::~WaveReset()
+{
+}
+int WaveReset::handle_event()
+{
+       plugin->config.reset(RESET_ALL);
+       gui->update_gui(RESET_ALL);
+       plugin->send_configure_change();
+       return 1;
+}
 
 
+WaveDefaultSettings::WaveDefaultSettings(WaveEffect *plugin, WaveWindow *gui, int x, int y, int w)
+ : BC_GenericButton(x, y, w, _("Default"))
+{
+       this->plugin = plugin;
+       this->gui = gui;
+}
+WaveDefaultSettings::~WaveDefaultSettings()
+{
+}
+int WaveDefaultSettings::handle_event()
+{
+       plugin->config.reset(RESET_DEFAULT_SETTINGS);
+       gui->update_gui(RESET_DEFAULT_SETTINGS);
+       plugin->send_configure_change();
+       return 1;
+}
 
 
-
-
+WaveSliderClr::WaveSliderClr(WaveEffect *plugin, WaveWindow *gui, int x, int y, int w, int clear)
+ : BC_Button(x, y, w, plugin->get_theme()->get_image_set("reset_button"))
+{
+       this->plugin = plugin;
+       this->gui = gui;
+       this->clear = clear;
+}
+WaveSliderClr::~WaveSliderClr()
+{
+}
+int WaveSliderClr::handle_event()
+{
+       // clear==1 ==> Amplitude slider
+       // clear==2 ==> Phase slider
+       // clear==3 ==> Steps slider
+       plugin->config.reset(clear);
+       gui->update_gui(clear);
+       plugin->send_configure_change();
+       return 1;
+}
 
 
 
 
 WaveWindow::WaveWindow(WaveEffect *plugin)
 
 
 
 
 WaveWindow::WaveWindow(WaveEffect *plugin)
- : PluginClientWindow(plugin, 335, 150, 335, 150, 0)
+ : PluginClientWindow(plugin, 385, 140, 385, 140, 0)
 {
        this->plugin = plugin;
 }
 {
        this->plugin = plugin;
 }
@@ -388,6 +282,8 @@ WaveWindow::~WaveWindow()
 void WaveWindow::create_objects()
 {
        int x = 10, y = 10, x1 = 115;
 void WaveWindow::create_objects()
 {
        int x = 10, y = 10, x1 = 115;
+       int x2 = 0; int clrBtn_w = 50;
+       int defaultBtn_w = 100;
 
 //     add_subwindow(new BC_Title(x, y, _("Mode:")));
 //     add_subwindow(smear = new WaveSmear(plugin, this, x1, y));
 
 //     add_subwindow(new BC_Title(x, y, _("Mode:")));
 //     add_subwindow(smear = new WaveSmear(plugin, this, x1, y));
@@ -398,12 +294,23 @@ void WaveWindow::create_objects()
 //     y += 30;
        add_subwindow(new BC_Title(x, y, _("Amplitude:")));
        add_subwindow(amplitude = new WaveAmplitude(plugin, x1, y));
 //     y += 30;
        add_subwindow(new BC_Title(x, y, _("Amplitude:")));
        add_subwindow(amplitude = new WaveAmplitude(plugin, x1, y));
+       x2 = x1 + amplitude->get_w() + 10;
+       add_subwindow(amplitudeClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_AMPLITUDE));
+
        y += 30;
        add_subwindow(new BC_Title(x, y, _("Phase:")));
        add_subwindow(phase = new WavePhase(plugin, x1, y));
        y += 30;
        add_subwindow(new BC_Title(x, y, _("Phase:")));
        add_subwindow(phase = new WavePhase(plugin, x1, y));
+       add_subwindow(phaseClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_PHASE));
+
        y += 30;
        add_subwindow(new BC_Title(x, y, _("Wavelength:")));
        add_subwindow(wavelength = new WaveLength(plugin, x1, y));
        y += 30;
        add_subwindow(new BC_Title(x, y, _("Wavelength:")));
        add_subwindow(wavelength = new WaveLength(plugin, x1, y));
+       add_subwindow(wavelengthClr = new WaveSliderClr(plugin, this, x2, y, clrBtn_w, RESET_WAVELENGTH));
+
+       y += 40;
+       add_subwindow(reset = new WaveReset(plugin, this, x, y));
+       add_subwindow(default_settings = new WaveDefaultSettings(plugin, this,
+               (385 - 10 - defaultBtn_w), y, defaultBtn_w));
 
        show_window();
        flush();
 
        show_window();
        flush();
@@ -415,6 +322,28 @@ void WaveWindow::update_mode()
 //     blacken->update(plugin->config.mode == BLACKEN);
 }
 
 //     blacken->update(plugin->config.mode == BLACKEN);
 }
 
+// for Reset button
+void WaveWindow::update_gui(int clear)
+{
+       switch(clear) {
+               case RESET_AMPLITUDE : amplitude->update(plugin->config.amplitude);
+                       break;
+               case RESET_PHASE : phase->update(plugin->config.phase);
+                       break;
+               case RESET_WAVELENGTH : wavelength->update(plugin->config.wavelength);
+                       break;
+               case RESET_ALL :
+               case RESET_DEFAULT_SETTINGS :
+               default:
+                       amplitude->update(plugin->config.amplitude);
+                       phase->update(plugin->config.phase);
+                       wavelength->update(plugin->config.wavelength);
+                       break;
+       }
+}
+
+
+