complexnumbersmodule.cpp 2.79 KB
Newer Older
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
/*
This file is generated, but you can safely change it
until you run "gen_actor_source.py" with "--project" flag.

Generated file is just a skeleton for module contents. 
You should change it corresponding to functionality.
*/

#include <QtCore>
#include <QtGui>
#include "complexnumbersmodule.h"

namespace ActorComplexNumbers {

ComplexNumbersModule::ComplexNumbersModule(ExtensionSystem::KPlugin * parent)
    : ComplexNumbersModuleBase(parent)
{
    /* TODO 
    implement class Constructor
    */
}

void ComplexNumbersModule::reset()
{
    /* TODO
    This method is called when actor resets its state before program starts.
    */
}

void ComplexNumbersModule::setAnimationEnabled(bool enabled)
{
    /* TODO
    Set internal flag for animation
    */
}

Victor Yacovlev's avatar
Victor Yacovlev committed
37

Victor Yacovlev's avatar
Victor Yacovlev committed
38 39 40 41 42
qreal ComplexNumbersModule::runRe(const Complex& x)
{
    /* TODO implement me */
    return 0.0;
}
Victor Yacovlev's avatar
Victor Yacovlev committed
43

44

Victor Yacovlev's avatar
Victor Yacovlev committed
45
qreal ComplexNumbersModule::runIm(const Complex& x)
46 47 48 49 50 51
{
    /* TODO implement me */
    return 0.0;
}


Victor Yacovlev's avatar
Victor Yacovlev committed
52
Complex ComplexNumbersModule::runOperatorPLUS(const Complex& x, const Complex& y)
53 54
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
55
    return Complex();
56 57 58
}


Victor Yacovlev's avatar
Victor Yacovlev committed
59
Complex ComplexNumbersModule::runOperatorMINUS(const Complex& x, const Complex& y)
60 61
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
62
    return Complex();
63 64 65
}


Victor Yacovlev's avatar
Victor Yacovlev committed
66
Complex ComplexNumbersModule::runOperatorASTERISK(const Complex& x, const Complex& y)
67 68
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
69
    return Complex();
70 71 72
}


Victor Yacovlev's avatar
Victor Yacovlev committed
73
Complex ComplexNumbersModule::runOperatorSLASH(const Complex& x, const Complex& y)
74 75
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
76
    return Complex();
77 78 79
}


Victor Yacovlev's avatar
Victor Yacovlev committed
80
Complex ComplexNumbersModule::runOperatorASSIGN(const int x)
81 82
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
83
    return Complex();
84 85
}

Victor Yacovlev's avatar
Victor Yacovlev committed
86

Victor Yacovlev's avatar
Victor Yacovlev committed
87
Complex ComplexNumbersModule::runOperatorASSIGN(const qreal x)
Victor Yacovlev's avatar
Victor Yacovlev committed
88 89
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
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
    return Complex();
}


Complex ComplexNumbersModule::runOperatorINPUT(const QString& x, bool& ok)
{
    static const QRegExp rxPlusMinus("[+-]");
    int p = x.indexOf(rxPlusMinus);
    QString re = "0.0", im = "0.0";
    if (p==-1) {
        if (x.trimmed().endsWith(QChar('i'), Qt::CaseInsensitive))
            im = x.trimmed();
        else
            re = x.trimmed();
    }
    else {
        QString a = x.left(p).trimmed();
        QString b = x.mid(p+1).trimmed();
        if (a.endsWith(QChar('i'), Qt::CaseInsensitive)) {
            im = a;
            re = x[p]+b;
        }
        else {
            im = x[p]+b;
            re = a;
        }
    }
    bool ok1, ok2;
    Complex result;
    im.remove(QChar('i'), Qt::CaseInsensitive);
    im = im.trimmed();
    if (im.endsWith("*")) {
        im = im.left(im.length()-1);
        im = im.trimmed();
    }
    result.re = re.toDouble(&ok1);
    result.im = im.toDouble(&ok2);
    ok = ok1 && ok2;
    return result;
Victor Yacovlev's avatar
Victor Yacovlev committed
129 130 131
}


Victor Yacovlev's avatar
Victor Yacovlev committed
132
QString ComplexNumbersModule::runOperatorOUTPUT(const Complex& x)
Victor Yacovlev's avatar
Victor Yacovlev committed
133 134
{
    /* TODO implement me */
Victor Yacovlev's avatar
Victor Yacovlev committed
135
    return "";
Victor Yacovlev's avatar
Victor Yacovlev committed
136 137
}

138 139
    
} // $namespace