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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
/* TRANSLATOR BALL::QSAR
Necessary for lupdate.
*/
/* inputDataItem.C
*
* Copyright (C) 2009 Marcel Schumann
*
* This file is part of QuEasy -- A Toolbox for Automated QSAR Model
* Construction and Validation.
* QuEasy 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.
*
* QuEasy 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 this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <inputDataItem.h>
#include <mainWindow.h>
#include <BALL/QSAR/exception.h>
#include <exception.h>
#include <inputPlotter.h>
#include <QtGui/QDialog>
#include <QtGui/QDrag>
#include <QtCore/QMimeData>
#include <QtGui/QApplication>
#include <QtGui/QMessageBox>
using namespace BALL::QSAR;
using namespace BALL::Exception;
using namespace BALL::QSAR::Exception;
namespace BALL
{
namespace VIEW
{
InputDataItem::InputDataItem(QString filename, bool center_data, bool center_y, DataItemView* view):
DataItem(view),
filename_(filename),
center_data_(center_data),
center_y_(center_y)
{
data_ = new QSARData;
input_plotter_ = NULL;
append_ = 0;
checked_for_discrete_y_ = 0;
discrete_y_ = 0;
partitioner_IDs_.clear();
createActions();
}
InputDataItem::InputDataItem(QString filename, DataItemView* view):
DataItem(view),
data_(NULL),
filename_(filename)
{
input_plotter_ = NULL;
append_ = 0;
checked_for_discrete_y_ = 0;
discrete_y_ = 0;
partitioner_IDs_.clear();
createActions();
}
InputDataItem::InputDataItem():
DataItem(NULL),
data_(NULL),
filename_(""),
center_data_(false),
center_y_(false)
{
input_plotter_ = NULL;
append_ = 0;
checked_for_discrete_y_ = 0;
discrete_y_ = 0;
partitioner_IDs_.clear();
createActions();
}
InputDataItem::~InputDataItem()
{
if(!append_) delete data_;
delete input_plotter_;
}
InputDataItem::InputDataItem(InputDataItem& item):
DataItem(item.view_)
{
data_ = new QSARData(*item.data_) ;
filename_ = item.filename_;
center_data_ = item.center_data_;
center_y_ = item.center_data_;
name_ = item.name_;
setPixmap(item.pixmap());
center_data_ = item.center_data_;
center_y_ = item.center_data_;
input_plotter_ = item.input_plotter_;
append_ = item.append_;
checked_for_discrete_y_ = item.checked_for_discrete_y_;
discrete_y_ = item.discrete_y_;
partitioner_IDs_ = item.partitioner_IDs_;
createActions();
}
QSARData* InputDataItem::data()
{
return data_;
}
QString InputDataItem::filename()
{
return filename_;
}
bool InputDataItem::centerData()
{
return center_data_;
}
bool InputDataItem::centerY()
{
return center_y_;
}
void InputDataItem::setCenterDataFlag(bool cd)
{
center_data_ = cd;
}
void InputDataItem::setCenterResponseFlag(bool cr)
{
center_y_ = cr;
}
void InputDataItem::setData(QSARData* data)
{
data_ = data;
}
void InputDataItem::loadFromFile(String file)
{
try
{
if(data_==NULL)
{
//throw BALL::Exception::GeneralException(__FILE__,__LINE__,"InputDataItem error","InputDataItem not connected to a QSARData object!!");
data_ = new QSARData;
}
data_->readFromFile(file);
}
catch(WrongDataType e)
{
QMessageBox::warning(view_,"Error",e.getMessage());
return;
}
done_ = 1;
}
void InputDataItem::showPlotter()
{
if(data_==0 || data_->getNoSubstances()==0)
{
QMessageBox::information(view_,"No data","Data must be read before it can be plotted!\nTherefore, click \"Execute Pipeline\" first.");
return;
}
if(data_->getNoResponseVariables()==0)
{
QMessageBox::information(view_,"No response variable", "This input data does not contain a response variable, so that plotting of the response values is not possible.");
return;
}
if(input_plotter_ == NULL)
{
input_plotter_=new InputPlotter(this);
}
input_plotter_->show();
}
void InputDataItem::setAppend(bool append)
{
append_ = append;
}
bool InputDataItem::append()
{
return append_;
}
BALL::String InputDataItem::getMouseOverText()
{
String s="";
if(data_!=NULL)
{
if(data_->getNoSubstances()>0)
{
s=String(data_->getNoSubstances())+" compounds\n";
s+=String(data_->getNoDescriptors())+" features\n";
int no_y=data_->getNoResponseVariables();
s+=String(no_y)+" response variable";
if(no_y!=1) s+="s";
}
}
return s;
}
void InputDataItem::createActions()
{
QAction* plot_action = new QAction(QIcon(""),tr("Plot data"), this);
connect(plot_action, SIGNAL(triggered()), this, SLOT(showPlotter()));
context_menu_actions_.push_back(plot_action);
}
}
}
|