Esempio n. 1
0
/*!
    Returns a deep-copied clone of the QUmlDurationConstraint.
*/
QModelingElement *QUmlDurationConstraint::clone() const
{
    QUmlDurationConstraint *c = new QUmlDurationConstraint;
    c->asQModelingObject()->setObjectName(this->asQModelingObject()->objectName());
    c->asQModelingObject()->setProperty("role", this->asQModelingObject()->property("role"));
    foreach (QUmlComment *element, ownedComments())
        c->addOwnedComment(dynamic_cast<QUmlComment *>(element->clone()));
    c->setName(name());
    if (nameExpression())
        c->setNameExpression(dynamic_cast<QUmlStringExpression *>(nameExpression()->clone()));
    c->setVisibility(visibility());
    c->setFirstEvent(firstEvent());
    if (specification())
        c->setSpecification(dynamic_cast<QUmlDurationInterval *>(specification()->clone()));
    return c;
}
		//---------
		Specification VideoInput::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
			auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);

			this->device = make_shared<::videoInput>();
			this->deviceIndex = settings->deviceID;

			this->device->setComMultiThreaded(true);
			this->device->setIdealFramerate(this->deviceIndex, (int) settings->idealFrameRate);
			this->device->setRequestedMediaSubType(VI_MEDIASUBTYPE_MJPG);
			this->device->setupDevice(this->deviceIndex, settings->width, settings->height);
			this->device->setVideoSettingFilter(this->deviceIndex, this->device->propSharpness, 0);
			this->resetTimestamp();

			Specification specification(CaptureSequenceType::Continuous
				, settings->width
				, settings->height
				, "videoInput"
				, this->device->getDeviceName(this->deviceIndex));
			
			specification.addPixelMode(PixelMode::RGB8);

			this->setupFloatParameter("Exposure", this->device->propExposure);
			this->setupFloatParameter("Gain", this->device->propGain);
			this->setupFloatParameter("Focus", this->device->propFocus);
			this->setupFloatParameter("Sharpness", this->device->propSharpness);

			this->frameIndex = 0;

			return specification;
		}
Esempio n. 3
0
		//---------
		Specification VideoInput::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
			auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);

			if (!this->device) {
				this->device = make_shared<::videoInput>();
			}
			this->deviceIndex = settings->deviceID;

			this->device->setComMultiThreaded(true);
			this->device->setIdealFramerate(this->deviceIndex, (int) settings->idealFrameRate);
			this->device->setRequestedMediaSubType(VI_MEDIASUBTYPE_MJPG);
			this->device->setupDevice(this->deviceIndex, settings->width, settings->height);
			this->device->setVideoSettingFilter(this->deviceIndex, this->device->propSharpness, 0);
			this->resetTimestamp();

			Specification specification(settings->width, settings->height, "videoInput", this->device->getDeviceName(this->deviceIndex));
			
			specification.addFeature(Feature::Feature_DeviceID);
			specification.addFeature(Feature::Feature_Exposure);
			specification.addFeature(Feature::Feature_FreeRun);
			specification.addFeature(Feature::Feature_Gain);
			specification.addFeature(Feature::Feature_Focus);
			specification.addFeature(Feature::Feature_Sharpness);
			
			specification.addPixelMode(PixelMode::Pixel_RGB8);

			this->frameIndex = 0;

			OFXMV_WARNING << "VideoInput. implements Exposure as a normalised range 0...1000. I.e. ignoring the unit us.";
			return specification;
		}
Esempio n. 4
0
		//----------
		Specification NullDevice::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
			auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);

			this->settings = * settings;
			Specification specification(this->settings.width, this->settings.height, "NullDevice", "NullDevice");
			specification.addFeature(Feature::Feature_FreeRun);
			specification.addPixelMode(PixelMode::Pixel_L8);
			return specification;
		}
		//----------
		Specification NullDevice::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
			auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);

			this->settings = * settings;
			Specification specification(CaptureSequenceType::Continuous
				, this->settings.width
				, this->settings.height
				, "NullDevice"
				, "NullDevice");
			specification.addPixelMode(PixelMode::L8);
			return specification;
		}
Esempio n. 6
0
		//----------
		Specification DeckLink::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
			auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);

			auto devices = ofxBlackmagic::Iterator::getDeviceList();
			if (devices.empty()) {
				throw(ofxMachineVision::Exception("No DeckLink devices available"));
			}
			if (devices.size() <= (unsigned int)settings->deviceID) {
				string str = "deviceID [" + ofToString(settings->deviceID) + "] out of range. [" + ofToString(devices.size()) + "] devices available";
				throw(ofxMachineVision::Exception(str));
			}
			this->device = devices[settings->deviceID];
			int width, height;

			this->displayMode = static_cast<_BMDDisplayMode>(settings->displayMode.get());

			try {
				CHECK_ERRORS(device.device->QueryInterface(IID_IDeckLinkInput, (void**)&this->input), "Failed to query interface");
				CHECK_ERRORS(this->input->SetCallback(this), "Failed to set input callback");

				//find the current display mode
				IDeckLinkDisplayModeIterator * displayModeIterator = 0;
				CHECK_ERRORS(input->GetDisplayModeIterator(&displayModeIterator), "Couldn't get DisplayModeIterator");
				IDeckLinkDisplayMode * displayModeTest = nullptr;
				IDeckLinkDisplayMode * displayModeFound = nullptr;
				while (displayModeIterator->Next(&displayModeTest) == S_OK) {
					if (displayModeTest->GetDisplayMode() == this->displayMode) {
						displayModeFound = displayModeTest;
					}
				}

				if (!displayModeFound) {
					CHECK_ERRORS(S_FALSE, "Cannot find displayMode");
				}
				width = displayModeFound->GetWidth();
				height = displayModeFound->GetHeight();
			}
			catch (std::exception e) {
				throw(ofxMachineVision::Exception(e.what()));
			}
			
			this->openTime = ofGetElapsedTimeMicros();
			this->frameIndex = 0;

			Specification specification(width, height, "BlackMagic", device.modelName);
			specification.addFeature(ofxMachineVision::Feature::Feature_DeviceID);
			specification.addFeature(ofxMachineVision::Feature::Feature_FreeRun);

			return specification;
		}
void ArticulatedModel::preprocess(const Array<Instruction>& program) {

    for (int i = 0; i < program.size(); ++i) {
        const Instruction& instruction = program[i];

        Part* partPtr = NULL;

        switch (instruction.type) {
        case Instruction::SCALE:
            {
                // Scale every pivot translation and every vertex position by the scale factor
                float scaleFactor = instruction.arg;
                scaleWholeModel(scaleFactor);
            }
            break;

        case Instruction::MOVE_CENTER_TO_ORIGIN:
            moveToOrigin(true);
            break;

        case Instruction::MOVE_BASE_TO_ORIGIN:
            moveToOrigin(false);
            break;

        case Instruction::SET_MATERIAL:
            {
                bool keepLightMaps = true;
                if (instruction.source.size() == 3) {
                    keepLightMaps = instruction.source[2];
                }
                UniversalMaterial::Specification specification(instruction.arg);
                setMaterial(instruction.mesh, specification, keepLightMaps, instruction.source);
            }                              
            break;

        case Instruction::SET_TWO_SIDED:
            {
                SetTwoSidedCallback callback(instruction.arg);
                forEachMesh(instruction.mesh, callback, instruction.source);
            }
            break;

        case Instruction::SET_CFRAME:
            {
                const CFrame cframe = instruction.arg;
                if (instruction.part.isRoot()) {
                    for (int p = 0; p < m_rootArray.size(); ++p) {
                        m_rootArray[p]->cframe = cframe;
                    }
                } else if (instruction.part.isAll()) {
                    for (int p = 0; p < m_partArray.size(); ++p) {
                        m_partArray[p]->cframe = cframe;
                    }
                } else {
                    partPtr = part(instruction.part);
                    instruction.source.verify(partPtr != NULL, "Part not found.");
                    partPtr->cframe = cframe;
                }        
            }
            break;

        case Instruction::TRANSFORM_CFRAME:
            {
                const CFrame cframe = instruction.arg;
                if (instruction.part.isRoot()) {
                    for (int p = 0; p < m_rootArray.size(); ++p) {
                        m_rootArray[p]->cframe = cframe * m_rootArray[p]->cframe;
                    }
                } else if (instruction.part.isAll()) {
                    for (int p = 0; p < m_partArray.size(); ++p) {
                        m_partArray[p]->cframe = cframe * m_partArray[p]->cframe;
                    }
                } else {
                    partPtr = part(instruction.part);
                    instruction.source.verify(partPtr != NULL, "Part not found.");
                    partPtr->cframe = cframe * partPtr->cframe;
                }        
            }
            break;

        case Instruction::TRANSFORM_GEOMETRY:
            {
                const Matrix4 transform(instruction.arg);
                if (instruction.part.isRoot()) {
                    for (int p = 0; p < m_rootArray.size(); ++p) {
                        m_rootArray[p]->transformGeometry(dynamic_pointer_cast<ArticulatedModel>(shared_from_this()), transform);
                    }
                } else if (instruction.part.isAll()) {
                    for (int p = 0; p < m_partArray.size(); ++p) {
                        m_partArray[p]->transformGeometry(dynamic_pointer_cast<ArticulatedModel>(shared_from_this()), transform);
                    }
                } else {
                    partPtr = part(instruction.part);
                    instruction.source.verify(partPtr != NULL, "Part not found.");
                    partPtr->transformGeometry(dynamic_pointer_cast<ArticulatedModel>(shared_from_this()), transform);
                }        
            }
            break;


        case Instruction::RENAME_PART:
            instruction.source.verify(! instruction.part.isAll() && ! instruction.part.isRoot(), 
                "The argument to renamePart() cannot be all() or root()");
            partPtr = part(instruction.part);
            instruction.source.verify(partPtr != NULL, "Could not find part");
            partPtr->name = instruction.arg.string(); 
            break;


        case Instruction::RENAME_MESH:
            {
                // Copy the array, since it may be modified by the callback
                Array<Mesh*> meshArray;
                getIdentifiedMeshes(instruction.mesh, meshArray);
                instruction.source.verify(meshArray.size() == 1, "Must rename only one mesh");
                instruction.source.verify(meshArray[0] != NULL, "Could not find mesh");
                meshArray[0]->name = instruction.arg.string(); 
            }
            break;

        case Instruction::ADD:
            alwaysAssertM(false, "not implemented");
            /*
            partPtr = NULL;
            if (! instruction.part.isNone()) {
                partPtr = part(instruction.part);
                instruction.source.verify(partPtr != NULL, "Unrecognized parent part");
            }
            {
                // Load the child part
                shared_ptr<ArticulatedModel> m2 = ArticulatedModel::create(Specification(instruction.arg));

                // Update part table and mesh table, and overwrite IDs
                for (int p = 0; p < m2->m_partArray.size(); ++p) {

                    Part* part = m2->m_partArray[p];
                    const_cast<ID&>(part->id) = createID();
                    m_partTable.set(part->id, part);

                    for (int m = 0; m < part->m_meshArray.size(); ++m) {
                        Mesh* mesh = part->m_meshArray[m];
                        const_cast<ID&>(mesh->id) = createID();
                        m_meshTable.set(mesh->id, mesh);
                    }
                }

                // Steal all elements of the child and add them to this
                if (partPtr == NULL) {
                    // Add as roots
                    m_rootArray.append(m2->m_rootArray);
                } else {
                    // Reparent
                    partPtr->m_child.append(m2->m_rootArray);
                    for (int p = 0; p < m2->m_partArray.size(); ++p) {
                        if (m2->m_partArray[p]->isRoot()) {
                            m2->m_partArray[p]->m_parent = partPtr;
                        }
                    }
                }
                m_partArray.append(m2->m_partArray);

                // Allow m2 to be garbage collected
            }
            */
            break;

        case Instruction::REMOVE_MESH:
            {
                RemoveMeshCallback callback;
                forEachMesh(instruction.mesh, callback, instruction.source);
            }
            break;

        case Instruction::REVERSE_WINDING:
            {
                ReverseWindingCallback callback;
                forEachMesh(instruction.mesh, callback, instruction.source);
            }
            break;
        case Instruction::COPY_TEXCOORD0_TO_TEXCOORD1:
            {
                if (instruction.part.isRoot()) {
                    //TODO: implement
                    alwaysAssertM(false, "COPY_TEXCOORD0_TO_TEXCOORD1 currently implemented only for entire model");
                    /*for (int p = 0; p < m_rootArray.size(); ++p) {
                        m_rootArray[p]->cpuVertexArray.copyTexCoord0ToTexCoord1();
                    }*/
                } else if (instruction.part.isAll()) {
                    for (int g = 0; g < m_geometryArray.size(); ++g) {
                        m_geometryArray[g]->cpuVertexArray.copyTexCoord0ToTexCoord1();
                    }
                } else {
                    //TODO: implement
                    alwaysAssertM(false, "COPY_TEXCOORD0_TO_TEXCOORD1 currently implemented only for entire model");
                    /*partPtr = part(instruction.part);
                    instruction.source.verify(partPtr != NULL, "Part not found.");
                    partPtr->cpuVertexArray.copyTexCoord0ToTexCoord1();*/
                } 
            }
            break;

        case Instruction::OFFSET_AND_SCALE_TEXCOORD1:
            {
         
                const Point2& offset = instruction.arg;
                const Point2& scale = instruction.source[2];
                if (instruction.part.isRoot()) {
                    //TODO: implement
                    alwaysAssertM(false, "OFFSET_AND_SCALE_TEXCOORD1 currently implemented only for entire model");
                    /*for (int p = 0; p < m_rootArray.size(); ++p) {
                        m_rootArray[p]->cpuVertexArray.offsetAndScaleTexCoord1(offset, scale);
                    }*/
                } else if (instruction.part.isAll()) {
                    for (int g = 0; g < m_geometryArray.size(); ++g) {
                        m_geometryArray[g]->cpuVertexArray.offsetAndScaleTexCoord1(offset, scale);
                    }
                } else {
                    //TODO: implement
                    alwaysAssertM(false, "OFFSET_AND_SCALE_TEXCOORD1 currently implemented only for entire model");
                    /*partPtr = part(instruction.part);
                    instruction.source.verify(partPtr != NULL, "Part not found.");
                    partPtr->cpuVertexArray.offsetAndScaleTexCoord1(offset, scale);*/
                } 
            }
            break;

        case Instruction::MERGE_ALL:
             {
                 MeshMergeCallback merge(MeshMergeCriterion(instruction.arg));
                 forEachPart(merge);
             }
             break;
 
        default:
            alwaysAssertM(false, "Instruction not implemented");
        }
    }

}
Esempio n. 8
0
void UmlState::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  define();

  chapter((parent()->kind() == aClassView)
	  ? "StateMachine" : "State",
	  pfix, rank, "state", level);

  Q3CString s = description();
  
  if (!s.isEmpty()) {
    fw.write("<p>");
    writeq(description());
    fw.write("<br /></p>");
  }

  UmlState * ref = reference();
  
  if (ref != 0) {
    fw.write("<p>References ");
    ref->write();
    fw.write("</p>");
  }
  else {
    if (isActive())
      fw.write("<p>Active state</p>\n");
    
    UmlOperation * beh = specification();
    
    if (beh != 0) {
      fw.write("<p>Implements ");
      beh->write();
      fw.write("</p>");
    }
    
    Q3CString scpp, sjava;
    
    s = entryBehavior();
    scpp = cppEntryBehavior();
    sjava = javaEntryBehavior();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Entry Behavior :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
    
    s = exitBehavior();
    scpp = cppExitBehavior();
    sjava = javaExitBehavior();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Exit Behavior :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
    
    s = doActivity();
    scpp = cppDoActivity();
    sjava = javaDoActivity();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Do activity :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
  }
  
  UmlStateDiagram * d = associatedDiagram();
  
  if (d != 0) {
    fw.write("<p>Diagram : ");
    d->write();
    fw.write("</p>");
  }

  write_properties();

  write_children(pfix, rank, level);

  unload(FALSE, FALSE);
}
Esempio n. 9
0
void UmlState::write(FileOut & out) {
  anItemKind pkind = parent()->kind();
  bool mach = (pkind != aState) && (pkind != aRegion);
  UmlState * ref = reference();
  const char * k;
  
  if (mach) {
    k = (_uml_20) ? "ownedMember" : "packagedElement";
    memo_incoming_trans();
  }
  else
    k = "subvertex";
  
  out.indent(); 
  out << "<" << k << " xmi:type=\"uml:"
    << ((mach || (stereotype() == "machine")) ? "StateMachine" : "State")
    << '"';
  out.id(this); 
  out << " name=\"";
  out.quote(name());
  out << '"';
  if (ref != 0)
    out.ref(ref, "submachine");
  else {
    if (specification() != 0)
      out.ref(specification(), "specification");
    if (isActive())
      out << " isActive=\"true\"";
  }
  out << ">\n";
  out.indent(+1); 
  
  write_description_properties(out); 
  
  if (ref == 0) {
    QCString doentry;
    QCString doactivity;
    QCString doexit;
    
    switch (_lang) {
    case Uml:
      doentry = entryBehavior();
      doactivity = doActivity();
      doexit = exitBehavior();
      break;
    case Cpp:
      doentry = cppEntryBehavior();
      doactivity = cppDoActivity();
      doexit = cppExitBehavior();
      break;
    default: // Java
      doentry = javaEntryBehavior();
      doactivity = javaDoActivity();
      doexit = javaExitBehavior();
      break;
    }
    
    if (! doentry.isEmpty()) {
      out.indent();
      out << "<entry xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "ENTRY_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doentry);
      out << "</body>\n";
      out.indent();
      out << "</entry>\n";
    }
    
    if (! doactivity.isEmpty()) {
      out.indent();
      out << "<doActivity xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "DOACTIVITY_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doactivity);
      out << "</body>\n";
      out.indent();
      out << "</doActivity>\n";
    }
    
    if (! doexit.isEmpty()) {
      out.indent();
      out << "<exit xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "EXIT_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doexit);
      out << "</body>\n";
      out.indent();
      out << "</exit>\n";
    }
  }
  
  while (! _incoming_trans.isEmpty())
    _incoming_trans.take(0)->write_in(out);
  
  const QVector<UmlItem> ch = children(); 
  unsigned n = ch.size();
  unsigned i;
  bool need_region = FALSE;
     
  for (i = 0; i != n; i += 1) {
    if (ch[i]->kind() != aRegion) {
      need_region = TRUE;
      break;
    }
  }

  if (need_region) {
    if (ref == 0) {
      out.indent();
      out << "<region xmi:type=\"uml:Region\"";
      out.id_prefix(this, "IMPLICIT_REGION_");
      out << " name=\"Bouml_Implicit_Region\">\n";
      out.indent(+1);
    }
    
    for (i = 0; i != n; i += 1)
      if (ch[i]->kind() != aRegion)
	ch[i]->write(out);
    
#if 0
    // to bypass Eclipse's bug
    while (! _trans.isEmpty())
      _trans.take(0)->write_it(out);
#endif
    
    if (ref == 0) {
      out.indent(-1);
      out.indent();
      out << "</region>\n";
    }
  }

  if (ref == 0) {
    for (i = 0; i != n; i += 1)
      if (ch[i]->kind() == aRegion)
	ch[i]->write(out);
  }
       
#if 1
    // to bypass Eclipse's bug
    while (! _trans.isEmpty())
      _trans.take(0)->write_it(out);
#endif
    
  out.indent(-1); 
  out.indent(); 
  out << "</" << k << ">\n"; 
    
  unload(); 
}
int main( int argc, char * argv[] )
{
    return lest::run( specification(), argc, argv /*, std::cout */ );
}