123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- /*=========================================================================
- Library: CTK
- Copyright (c) Kitware Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.commontk.org/LICENSE
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =========================================================================*/
- // Qt includes
- #include <QApplication>
- #include <QDebug>
- #include <QTimer>
- // CTK includes
- #include "ctkVTKSurfaceMaterialPropertyWidget.h"
- // VTK includes
- #include <vtkProperty.h>
- // STD includes
- #include <iostream>
- //-----------------------------------------------------------------------------
- int ctkVTKSurfaceMaterialPropertyWidgetTest1(int argc, char * argv [] )
- {
- QApplication app(argc, argv);
- ctkVTKSurfaceMaterialPropertyWidget propertyWidget(0);
-
- if (propertyWidget.isEnabled())
- {
- std::cerr << "No vtkProperty provided, should be disabled."
- << std::endl;
- return EXIT_FAILURE;
- }
-
- vtkProperty* property = vtkProperty::New();
-
- double ambient = property->GetAmbient();
- double diffuse = property->GetDiffuse();
- double specular = property->GetSpecular();
- double specularPower = property->GetSpecularPower();
-
- propertyWidget.setProperty(property);
- property->Delete();
-
- if (propertyWidget.property() != property)
- {
- std::cerr << "ctkVTKSurfaceMaterialPropertyWidget::setProperty() failed."
- << propertyWidget.property() << std::endl;
- return EXIT_FAILURE;
- }
-
- if (propertyWidget.ambient() != ambient)
- {
- std::cerr << "Wrong ambient: " << propertyWidget.ambient() << std::endl;
- return EXIT_FAILURE;
- }
- if (propertyWidget.diffuse() != diffuse)
- {
- std::cerr << "Wrong diffuse: " << propertyWidget.diffuse() << std::endl;
- return EXIT_FAILURE;
- }
- if (propertyWidget.specular() != specular)
- {
- std::cerr << "Wrong specular: " << propertyWidget.specular() << std::endl;
- return EXIT_FAILURE;
- }
- if (propertyWidget.specularPower() != specularPower)
- {
- std::cerr << "Wrong specularPower: " << propertyWidget.specularPower() << std::endl;
- return EXIT_FAILURE;
- }
- property->SetAmbient(0.5);
- if (propertyWidget.ambient() != 0.5)
- {
- std::cerr << "vtkProperty::SetAmbient() failed: " << propertyWidget.ambient() << std::endl;
- return EXIT_FAILURE;
- }
- // QColor handles floating points on 16bit integers
- propertyWidget.setAmbient(0.8);
-
- if (property->GetAmbient() != 0.8)
- {
- std::cerr << "ctkVTKSurfaceMaterialPropertyWidget::setAmbient() failed: "
- << property->GetAmbient() << std::endl;
- return EXIT_FAILURE;
- }
- property->SetDiffuse(1.2);
- if (propertyWidget.diffuse() != 1.)
- {
- std::cerr << "vtkProperty::SetDiffuse() failed: " << propertyWidget.diffuse() << std::endl;
- return EXIT_FAILURE;
- }
- // QColor handles floating points on 16bit integers
- propertyWidget.setDiffuse(0.3);
-
- if (property->GetDiffuse() != 0.3)
- {
- std::cerr << "ctkVTKSurfaceMaterialPropertyWidget::setDiffuse() failed: "
- << property->GetDiffuse() << std::endl;
- return EXIT_FAILURE;
- }
- property->SetSpecular(0.99);
- if (propertyWidget.specular() != 0.99)
- {
- std::cerr << "vtkProperty::SetSpecular() failed: " << propertyWidget.specular() << std::endl;
- return EXIT_FAILURE;
- }
- // QColor handles floating points on 16bit integers
- propertyWidget.setSpecular(0.01);
-
- if (property->GetSpecular() != 0.01)
- {
- std::cerr << "ctkVTKSurfaceMaterialPropertyWidget::setSpecular() failed: "
- << property->GetSpecular() << std::endl;
- return EXIT_FAILURE;
- }
- property->SetSpecularPower(45);
- if (propertyWidget.specularPower() != 45)
- {
- std::cerr << "vtkProperty::SetSpecularPower() failed: " << propertyWidget.specularPower() << std::endl;
- return EXIT_FAILURE;
- }
- // QColor handles floating points on 16bit integers
- propertyWidget.setSpecularPower(60);
-
- if (property->GetSpecularPower() != 50)
- {
- std::cerr << "ctkVTKSurfaceMaterialPropertyWidget::setSpecularPower() failed: "
- << property->GetSpecularPower() << std::endl;
- return EXIT_FAILURE;
- }
- propertyWidget.show();
- if (argc < 2 || QString(argv[1]) != "-I" )
- {
- QTimer::singleShot(200, &app, SLOT(quit()));
- }
- return app.exec();
- }
|