Salome HOME
Merge from agy/feedbackads140304
[modules/paravis.git] / src / Plugins / TableReader / ParaViewPlugin / pqCustomChartDisplayPanelImplementation.cxx
1 // Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "pqCustomChartDisplayPanelImplementation.h"
21 #include "pqCustomXYChartDisplayPanel.h"
22
23 #include "vtkSMProxy.h"
24
25 #include "pqDataRepresentation.h"
26 #include "pqPipelineSource.h"
27
28
29 pqCustomChartDisplayPanelImplementation::pqCustomChartDisplayPanelImplementation(QObject* p):
30 QObject(p)
31 {
32 }
33
34 bool pqCustomChartDisplayPanelImplementation::canCreatePanel(pqRepresentation* repr) const
35 {
36   if(!repr || !repr->getProxy() || 
37       (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
38   {
39     return false;
40   }
41
42   pqDataRepresentation* dataRepr = qobject_cast<pqDataRepresentation*>(repr);
43   if(dataRepr)
44   {
45     pqPipelineSource* input = dataRepr->getInput();
46     QString name = input->getProxy()->GetXMLName();
47     if (name == "TableReader")
48     {
49       return true;
50     }
51   }
52
53   return false;
54 }
55
56 pqDisplayPanel* pqCustomChartDisplayPanelImplementation::createPanel(pqRepresentation* repr, QWidget* p)
57 {
58   if(!repr || !repr->getProxy() ||
59       (repr->getProxy()->GetXMLName() != QString("XYChartRepresentation")))
60   {
61     return NULL;
62   }
63
64   pqDataRepresentation* dataRepr = qobject_cast<pqDataRepresentation*>(repr);
65   if(dataRepr)
66   {
67     pqPipelineSource* input = dataRepr->getInput();
68     QString name=input->getProxy()->GetXMLName();
69
70     if (name == "TableReader")
71     {
72       return new pqCustomXYChartDisplayPanel(repr, p);
73     }
74   }
75
76   return NULL;
77 }
78
79